F_PAM_0102.cs 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_PAM_0102.cs
  5. * 2.功能描述:工种工资方案
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 王鑫 2015/08/17 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Data;
  12. using System.Windows.Forms;
  13. using Dongke.IBOSS.PRD.Client.CommonModule;
  14. using Dongke.IBOSS.PRD.Basics.BaseResources;
  15. using Dongke.IBOSS.PRD.Basics.DockPanel;
  16. using Dongke.IBOSS.PRD.WCF.DataModels;
  17. using Dongke.IBOSS.PRD.WCF.Proxys;
  18. using Dongke.IBOSS.PRD.WCF.Proxys.SystemModuleService;
  19. namespace Dongke.IBOSS.PRD.Client.PAMModule
  20. {
  21. /// <summary>
  22. /// 工种工资方案
  23. /// </summary>
  24. public partial class F_PAM_0102 : DockPanelBase
  25. {
  26. #region 成员变量
  27. //单例模式
  28. private static F_PAM_0102 _instance;
  29. // 最后选择行
  30. private int _selecedRow;
  31. #endregion
  32. #region 构造函数
  33. public F_PAM_0102()
  34. {
  35. InitializeComponent();
  36. this.Text = FormTitles.F_PAM_0102;
  37. this.btnSearch.Text = ButtonText.BTN_SEARCH;
  38. this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
  39. this.tsbtnAdd.Text = ButtonText.TSBTN_ADD;
  40. this.tsbtnEdit.Text = ButtonText.TSBTN_EDIT;
  41. this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
  42. this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
  43. this.gbxCondition.Text = Constant.LABEL_QUERY_CONDITIONS;
  44. }
  45. #endregion
  46. #region 单例模式
  47. /// <summary>
  48. /// 单例模式,防止重复创建窗体
  49. /// </summary>
  50. public static F_PAM_0102 Instance
  51. {
  52. get
  53. {
  54. if (_instance == null)
  55. {
  56. _instance = new F_PAM_0102();
  57. }
  58. return _instance;
  59. }
  60. }
  61. #endregion
  62. #region 事件
  63. /// <summary>
  64. /// 窗体加载
  65. /// </summary>
  66. private void F_PAM_0102_Load(object sender, EventArgs e)
  67. {
  68. this.dgvJobsPayPlan.AutoGenerateColumns = false;
  69. }
  70. /// <summary>
  71. /// 查询事件
  72. /// </summary>
  73. private void btnSearch_Click(object sender, EventArgs e)
  74. {
  75. try
  76. {
  77. // 记录当前选中行
  78. int selectRowIndex = this._selecedRow;
  79. // 异步处理
  80. this.btnSearch.Enabled = false;
  81. this.btnClearCondition.Enabled = false;
  82. DataSet dsProductionData = (DataSet)DoAsync(new AsyncMethod(() =>
  83. {
  84. return PAMModuleProxy.Service.GetJobsPayPlanList(this.txtJobsCode.Text.Trim(), this.txtPayPlanName.Text.Trim(), this.txtJobsName.Text.Trim());
  85. }));
  86. this.btnSearch.Enabled = true;
  87. this.btnClearCondition.Enabled = true;
  88. if (dsProductionData != null)
  89. {
  90. base.DataSource = dsProductionData;
  91. if (this.DataSource != null && this.DataSource.Tables.Count > Constant.INT_IS_ZERO)
  92. {
  93. this.dgvJobsPayPlan.DataSource = this.DataSource.Tables[0];
  94. if (this.DataSource.Tables[0].Rows.Count <= Constant.INT_IS_ZERO)
  95. {
  96. // 提示未查找到数据
  97. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  98. MessageBoxButtons.OK, MessageBoxIcon.Information);
  99. }
  100. else
  101. {
  102. if (selectRowIndex >= Constant.INT_IS_ZERO)
  103. {
  104. if (selectRowIndex >= dsProductionData.Tables[0].Rows.Count)
  105. {
  106. this.dgvJobsPayPlan.Rows[this.dgvJobsPayPlan.Rows.Count - 1].Selected = true;
  107. this.dgvJobsPayPlan.CurrentCell = this.dgvJobsPayPlan.Rows[this.dgvJobsPayPlan.Rows.Count - 1].Cells["JobsName"];
  108. }
  109. else
  110. {
  111. this.dgvJobsPayPlan.Rows[selectRowIndex].Selected = true;
  112. this.dgvJobsPayPlan.CurrentCell = this.dgvJobsPayPlan.Rows[selectRowIndex].Cells["JobsName"];
  113. }
  114. }
  115. }
  116. }
  117. }
  118. }
  119. catch (Exception ex)
  120. {
  121. this.btnSearch.Enabled = true;
  122. this.btnClearCondition.Enabled = true;
  123. // 对异常进行共通处理
  124. ExceptionManager.HandleEventException(this.ToString(),
  125. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  126. }
  127. }
  128. /// <summary>
  129. /// 清空事件
  130. /// </summary>
  131. private void btnClearCondition_Click(object sender, EventArgs e)
  132. {
  133. this.txtJobsCode.Text = string.Empty;
  134. this.txtPayPlanName.Text = string.Empty;
  135. this.txtJobsName.Text = string.Empty;
  136. }
  137. /// <summary>
  138. /// 关闭窗体事件
  139. /// </summary>
  140. private void tsbtnClose_Click(object sender, EventArgs e)
  141. {
  142. this.Close();
  143. }
  144. /// <summary>
  145. /// 自适应事件
  146. /// </summary>
  147. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  148. {
  149. this.dgvJobsPayPlan.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);;
  150. }
  151. /// <summary>
  152. /// 窗体关闭事件
  153. /// </summary>
  154. private void F_PAM_0102_FormClosed(object sender, FormClosedEventArgs e)
  155. {
  156. _instance = null;
  157. }
  158. /// <summary>
  159. /// 添加事件
  160. /// </summary>
  161. private void tsbtnAdd_Click(object sender, EventArgs e)
  162. {
  163. try
  164. {
  165. //以新建模式打开信息窗体
  166. F_PAM_0103 frmPAM0103 = new F_PAM_0103(Constant.FormMode.Add, Constant.INT_IS_ZERO);
  167. DialogResult dialogResult = frmPAM0103.ShowDialog();
  168. if (dialogResult == DialogResult.OK)
  169. {
  170. btnSearch_Click(sender, e);
  171. }
  172. }
  173. catch (Exception ex)
  174. {
  175. // 对异常进行共通处理
  176. ExceptionManager.HandleEventException(this.ToString(),
  177. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  178. }
  179. }
  180. /// <summary>
  181. ///编辑事件
  182. /// </summary>
  183. private void tsbtnEdit_Click(object sender, EventArgs e)
  184. {
  185. try
  186. {
  187. DataGridViewRow currentRow = this.dgvJobsPayPlan.CurrentRow;
  188. if (currentRow != null)
  189. {
  190. //获取需要的信息ID
  191. int entityId = Convert.ToInt32(currentRow.Cells["PayPlanID"].Value);
  192. //以复制模式打开信息窗体
  193. F_PAM_0103 frmPAM0103= new F_PAM_0103(Constant.FormMode.Edit, entityId);
  194. DialogResult dialogResult = frmPAM0103.ShowDialog();
  195. //操作成功后刷新数据源
  196. if (dialogResult == DialogResult.OK)
  197. {
  198. btnSearch_Click(sender, e);
  199. }
  200. }
  201. }
  202. catch (Exception ex)
  203. {
  204. // 对异常进行共通处理
  205. ExceptionManager.HandleEventException(this.ToString(),
  206. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  207. }
  208. }
  209. #endregion
  210. }
  211. }