F_PC_0401_1.cs 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  1. /*******************************************************************************
  2. * Copyright(c) 2015 dongke All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_PC_0401_1.cs
  5. * 2.功能描述:班次配置一览
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 袁新成 2015/04/22 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Data;
  12. using System.Reflection;
  13. using System.Windows.Forms;
  14. using Dongke.IBOSS.PRD.Basics.BaseControls;
  15. using Dongke.IBOSS.PRD.Basics.BaseResources;
  16. using Dongke.IBOSS.PRD.Client.CommonModule;
  17. using Dongke.IBOSS.PRD.Client.Controls;
  18. using Dongke.IBOSS.PRD.Client.DataModels;
  19. using Dongke.IBOSS.PRD.WCF.DataModels;
  20. using Dongke.IBOSS.PRD.WCF.Proxys;
  21. namespace Dongke.IBOSS.PRD.Client.PCModule
  22. {
  23. /// <summary>
  24. /// 班次配置一览
  25. /// </summary>
  26. public partial class F_PC_0401_1 : DKDockPanelBase
  27. {
  28. #region 成员变量
  29. // 窗体的单例模式
  30. private static F_PC_0401_1 _instance;
  31. // 正在查询
  32. private bool _isSearching = false;
  33. #endregion
  34. #region 构造函数
  35. /// <summary>
  36. /// 构造函数
  37. /// </summary>
  38. public F_PC_0401_1()
  39. {
  40. this.InitializeComponent();
  41. // 为各个控件文本赋值
  42. this.InitializeControls();
  43. }
  44. #endregion
  45. #region 单例模式
  46. /// <summary>
  47. /// 单例模式,防止重复创建窗体
  48. /// </summary>
  49. public static F_PC_0401_1 Instance
  50. {
  51. get
  52. {
  53. if (_instance == null)
  54. {
  55. _instance = new F_PC_0401_1();
  56. }
  57. return _instance;
  58. }
  59. }
  60. #endregion
  61. #region 事件
  62. /// <summary>
  63. /// 页面加载事件
  64. /// </summary>
  65. /// <param name="sender"></param>
  66. /// <param name="e"></param>
  67. private void F_PC_0401_Load(object sender, EventArgs e)
  68. {
  69. try
  70. {
  71. // 加载权限
  72. FormPermissionManager.FormPermissionControl(this.Name, this,
  73. LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData,
  74. LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  75. }
  76. catch (Exception ex)
  77. {
  78. // 对异常进行共通处理
  79. ExceptionManager.HandleEventException(this.ToString(),
  80. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  81. }
  82. }
  83. /// <summary>
  84. /// 窗体关闭事件
  85. /// </summary>
  86. /// <param name="sender"></param>
  87. /// <param name="e"></param>
  88. private void F_PC_0401_FormClosed(object sender, FormClosedEventArgs e)
  89. {
  90. _instance = null;
  91. }
  92. /// <summary>
  93. /// 关闭按钮事件
  94. /// </summary>
  95. /// <param name="sender"></param>
  96. /// <param name="e"></param>
  97. private void tsbtnClose_Click(object sender, EventArgs e)
  98. {
  99. this.Close();
  100. }
  101. /// <summary>
  102. /// 自动适应列宽
  103. /// </summary>
  104. /// <param name="sender"></param>
  105. /// <param name="e"></param>
  106. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  107. {
  108. this.dgvClassesSet.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  109. this.dgvClassesDetail.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  110. }
  111. /// <summary>
  112. /// 查询按钮
  113. /// </summary>
  114. /// <param name="sender"></param>
  115. /// <param name="e"></param>
  116. private void btnSearch_Click(object sender, EventArgs e)
  117. {
  118. try
  119. {
  120. this._isSearching = true;
  121. this.dgvClassesSet.DataSource = null;
  122. this.dgvClassesDetail.DataSource = null;
  123. this.DataSource = this.GetSearchData();
  124. if (this.DataSource != null)
  125. {
  126. this.dgvClassesSet.DataSource = this.DataSource.Tables[0];
  127. if (this.DataSource.Tables.Count > 1)
  128. {
  129. this.dgvClassesDetail.DataSource = this.DataSource.Tables[1];
  130. }
  131. }
  132. this._isSearching = false;
  133. }
  134. catch (Exception ex)
  135. {
  136. this._isSearching = false;
  137. // 对异常进行共通处理
  138. ExceptionManager.HandleEventException(this.ToString(),
  139. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  140. }
  141. }
  142. /// <summary>
  143. /// 新建按钮
  144. /// </summary>
  145. /// <param name="sender"></param>
  146. /// <param name="e"></param>
  147. private void tsbtnAdd_Click(object sender, EventArgs e)
  148. {
  149. try
  150. {
  151. F_PC_0402_1 frmPC0402 = new F_PC_0402_1(Constant.FormMode.Add);
  152. DialogResult dialogresult = frmPC0402.ShowDialog();
  153. if (dialogresult == DialogResult.OK)
  154. {
  155. // todo
  156. this.btnSearch_Click(sender, e);
  157. }
  158. }
  159. catch (Exception ex)
  160. {
  161. // 对异常进行共通处理
  162. ExceptionManager.HandleEventException(this.ToString(),
  163. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  164. }
  165. }
  166. /// <summary>
  167. /// 逻辑按钮
  168. /// </summary>
  169. /// <param name="sender"></param>
  170. /// <param name="e"></param>
  171. private void tsbtnEdit_Click(object sender, EventArgs e)
  172. {
  173. try
  174. {
  175. DataGridViewRow currentRow = this.dgvClassesSet.CurrentRow;
  176. if (currentRow != null)
  177. {
  178. int classesSettingID = Convert.ToInt32(this.dgvClassesSet.CurrentRow.Cells["ClassesSettingID"].Value.ToString());
  179. int userId = Convert.ToInt32(this.dgvClassesSet.CurrentRow.Cells["userId"].Value.ToString());
  180. F_PC_0402_1 frmPC0402 = new F_PC_0402_1(Constant.FormMode.Edit);
  181. frmPC0402.ClassesSettingID = classesSettingID;
  182. frmPC0402.UserId = userId;
  183. frmPC0402.UserCode = this.dgvClassesSet.CurrentRow.Cells["CSUserCode"].Value.ToString();
  184. frmPC0402.UserName1 = this.dgvClassesSet.CurrentRow.Cells["CSUserName"].Value.ToString();
  185. frmPC0402.Remark = this.dgvClassesSet.CurrentRow.Cells["Remarks"].Value.ToString();
  186. frmPC0402.AccountDate = DateTime.Parse(this.dgvClassesSet.CurrentRow.Cells["AccountDate"].Value.ToString());
  187. DialogResult dialogresult = frmPC0402.ShowDialog();
  188. if (dialogresult == DialogResult.OK)
  189. {
  190. this.btnSearch_Click(sender, e);
  191. }
  192. }
  193. }
  194. catch (Exception ex)
  195. {
  196. // 对异常进行共通处理
  197. ExceptionManager.HandleEventException(this.ToString(),
  198. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  199. }
  200. }
  201. /// <summary>
  202. /// 单元格鼠标双击事件
  203. /// </summary>
  204. /// <param name="sender"></param>
  205. /// <param name="e"></param>
  206. private void dgvClassesSet_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
  207. {
  208. if (e.RowIndex < 0 || e.ColumnIndex < 0)
  209. {
  210. return;
  211. }
  212. this.tsbtnEdit_Click(sender, e);
  213. }
  214. /// <summary>
  215. /// 行选中事件
  216. /// </summary>
  217. /// <param name="sender"></param>
  218. /// <param name="e"></param>
  219. private void dgvClassesSet_SelectionChanged(object sender, EventArgs e)
  220. {
  221. if (this._isSearching)
  222. {
  223. return;
  224. }
  225. try
  226. {
  227. DataGridViewRow currentRow = this.dgvClassesSet.CurrentRow;
  228. if (currentRow != null)
  229. {
  230. int id = Convert.ToInt32(currentRow.Cells["ClassesSettingID"].Value);
  231. this.dgvClassesDetail.DataSource = null;
  232. // 调用服务器端获取数据集
  233. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  234. {
  235. return PCModuleProxyNew.Service.GetFPC0401SDData(id);
  236. }
  237. );
  238. if (sre.Status == Constant.ServiceResultStatus.Success)
  239. {
  240. this.dgvClassesDetail.DataSource = sre.Data.Tables[0];
  241. }
  242. }
  243. else
  244. {
  245. DKMessageBox.ShowDialog(this, DKMessageCode.W_CMN_C_001);
  246. }
  247. }
  248. catch (Exception ex)
  249. {
  250. // 对异常进行共通处理
  251. ExceptionManager.HandleEventException(this.ToString(),
  252. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  253. }
  254. }
  255. /// <summary>
  256. /// 清空条件按钮
  257. /// </summary>
  258. /// <param name="sender"></param>
  259. /// <param name="e"></param>
  260. private void btnClearCondition_Click(object sender, EventArgs e)
  261. {
  262. this.txtUserCode.Clear();
  263. this.txtRemarks.Clear();
  264. this.dtpDateBegin.Value = DateTime.Now.Date;
  265. this.dtpDateEnd.Value = DateTime.Now.Date;
  266. }
  267. #endregion
  268. #region 私有方法/函数
  269. /// <summary>
  270. /// 初始化控件
  271. /// </summary>
  272. private void InitializeControls()
  273. {
  274. this.Text = FormTitles.F_PC_0401;
  275. this.tsbtnAdd.Text = ButtonText.TSBTN_ADD;
  276. this.tsbtnEdit.Text = ButtonText.TSBTN_EDIT;
  277. this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
  278. this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
  279. this.btnSearch.Text = ButtonText.BTN_SEARCH;
  280. this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
  281. this.gbxCondition.Text = Constant.LABEL_QUERY_CONDITIONS;
  282. // 取客户端当天日期
  283. this.dtpDateBegin.Value = DateTime.Now.Date;
  284. this.dtpDateEnd.Value = DateTime.Now.Date;
  285. this.dgvClassesSet.AutoGenerateColumns = false;
  286. this.dgvClassesSet.ReadOnly = true;
  287. this.dgvClassesDetail.AutoGenerateColumns = false;
  288. this.dgvClassesDetail.ReadOnly = true;
  289. }
  290. /// <summary>
  291. /// 根据界面查询条件获取数据集
  292. /// </summary>
  293. private DataSet GetSearchData()
  294. {
  295. try
  296. {
  297. FPC0401_SE se = new FPC0401_SE();
  298. se.UserCode = this.txtUserCode.Text;
  299. se.DateBegin = this.dtpDateBegin.Value.Date;
  300. se.DateEnd = this.dtpDateEnd.Value.Date;
  301. se.Remarks = this.txtRemarks.Text;
  302. // 调用服务器端获取数据集
  303. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  304. {
  305. return PCModuleProxyNew.Service.GetFPC0401SData(se);
  306. }
  307. );
  308. if (sre.Data == null || sre.Data.Tables[0]==null || sre.Data.Tables[0].Rows.Count == 0)
  309. {
  310. // 提示未查找到数据
  311. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  312. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  313. //清空数据
  314. return null;
  315. }
  316. if (sre.Status == Constant.ServiceResultStatus.Success)
  317. {
  318. return sre.Data;
  319. }
  320. return null;
  321. }
  322. catch (Exception ex)
  323. {
  324. throw ex;
  325. }
  326. }
  327. #endregion
  328. }
  329. }