F_PAM_0401..cs 9.0 KB

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