F_PAM_0301.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  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_0301 : DockPanelBase
  23. {
  24. #region 成员变量
  25. //单例模式
  26. private static F_PAM_0301 _instance;
  27. // 最后选择行
  28. private int _selecedRow;
  29. #endregion
  30. #region 构造函数
  31. public F_PAM_0301()
  32. {
  33. InitializeComponent();
  34. this.Text = FormTitles.F_PAM_0301;
  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_0301 Instance
  49. {
  50. get
  51. {
  52. if (_instance == null)
  53. {
  54. _instance = new F_PAM_0301();
  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. PieceworkEntity pieceworkEndit = new PieceworkEntity();
  97. pieceworkEndit.PayPlanName = this.txtName.Text.Trim();
  98. if(cmbPayPlan.Text!="")
  99. {
  100. pieceworkEndit.PayPlanID = Convert.ToInt32(cmbPayPlan.SelectedValue);
  101. }
  102. DataSet dsProductionData = (DataSet)DoAsync(new AsyncMethod(() =>
  103. {
  104. return PAMModuleProxy.Service.GetPieceworkData(pieceworkEndit);
  105. }));
  106. this.btnSearch.Enabled = true;
  107. this.btnClearCondition.Enabled = true;
  108. if (dsProductionData != null)
  109. {
  110. base.DataSource = dsProductionData;
  111. if (this.DataSource != null && this.DataSource.Tables.Count > Constant.INT_IS_ZERO)
  112. {
  113. this.dgvJobsPayPlan.DataSource = this.DataSource.Tables[0];
  114. if (this.DataSource.Tables[0].Rows.Count <= Constant.INT_IS_ZERO)
  115. {
  116. // 提示未查找到数据
  117. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  118. MessageBoxButtons.OK, MessageBoxIcon.Information);
  119. }
  120. else
  121. {
  122. if (selectRowIndex >= Constant.INT_IS_ZERO)
  123. {
  124. if (selectRowIndex >= dsProductionData.Tables[0].Rows.Count)
  125. {
  126. this.dgvJobsPayPlan.Rows[this.dgvJobsPayPlan.Rows.Count - 1].Selected = true;
  127. this.dgvJobsPayPlan.CurrentCell = this.dgvJobsPayPlan.Rows[this.dgvJobsPayPlan.Rows.Count - 1].Cells["PayPlanName"];
  128. }
  129. else
  130. {
  131. this.dgvJobsPayPlan.Rows[selectRowIndex].Selected = true;
  132. this.dgvJobsPayPlan.CurrentCell = this.dgvJobsPayPlan.Rows[selectRowIndex].Cells["PayPlanName"];
  133. }
  134. }
  135. }
  136. }
  137. }
  138. }
  139. catch (Exception ex)
  140. {
  141. this.btnSearch.Enabled = true;
  142. this.btnClearCondition.Enabled = true;
  143. // 对异常进行共通处理
  144. ExceptionManager.HandleEventException(this.ToString(),
  145. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  146. }
  147. }
  148. /// <summary>
  149. /// 清空事件
  150. /// </summary>
  151. private void btnClearCondition_Click(object sender, EventArgs e)
  152. {
  153. //this.dkProcedureSearchBox.ClearControl();
  154. //this.radAll.Checked = true;
  155. this.txtName.Text = "";
  156. this.cmbPayPlan.SelectedValue = -1;
  157. }
  158. /// <summary>
  159. /// 关闭窗体事件
  160. /// </summary>
  161. private void tsbtnClose_Click(object sender, EventArgs e)
  162. {
  163. this.Close();
  164. }
  165. /// <summary>
  166. /// 自适应事件
  167. /// </summary>
  168. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  169. {
  170. this.dgvJobsPayPlan.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells); ;
  171. }
  172. /// <summary>
  173. /// 窗体关闭事件
  174. /// </summary>
  175. private void F_PAM_0201_FormClosed(object sender, FormClosedEventArgs e)
  176. {
  177. _instance = null;
  178. }
  179. /// <summary>
  180. /// 添加事件
  181. /// </summary>
  182. private void tsbtnAdd_Click(object sender, EventArgs e)
  183. {
  184. try
  185. {
  186. //以新建模式打开信息窗体
  187. F_PAM_0302 frmPAM0302 = new F_PAM_0302(Constant.FormMode.Add, null);
  188. DialogResult dialogResult = frmPAM0302.ShowDialog();
  189. if (dialogResult == DialogResult.OK)
  190. {
  191. btnSearch_Click(sender, e);
  192. }
  193. }
  194. catch (Exception ex)
  195. {
  196. // 对异常进行共通处理
  197. ExceptionManager.HandleEventException(this.ToString(),
  198. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  199. }
  200. }
  201. /// <summary>
  202. ///编辑事件
  203. /// </summary>
  204. private void tsbtnEdit_Click(object sender, EventArgs e)
  205. {
  206. try
  207. {
  208. DataGridViewRow currentRow = this.dgvJobsPayPlan.CurrentRow;
  209. if (currentRow != null)
  210. {
  211. //获取需要的信息ID
  212. int entityId = Convert.ToInt32(currentRow.Cells["PayPlanID"].Value);
  213. //以复制模式打开信息窗体
  214. F_PAM_0103 frmPAM0103 = new F_PAM_0103(Constant.FormMode.Edit, entityId);
  215. DialogResult dialogResult = frmPAM0103.ShowDialog();
  216. //操作成功后刷新数据源
  217. if (dialogResult == DialogResult.OK)
  218. {
  219. btnSearch_Click(sender, e);
  220. }
  221. }
  222. }
  223. catch (Exception ex)
  224. {
  225. // 对异常进行共通处理
  226. ExceptionManager.HandleEventException(this.ToString(),
  227. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  228. }
  229. }
  230. #endregion
  231. /// <summary>
  232. /// 编辑按钮事件
  233. /// </summary>
  234. /// <param name="sender"></param>
  235. /// <param name="e"></param>
  236. private void tsbtnEdit_Click_1(object sender, EventArgs e)
  237. {
  238. try
  239. {
  240. if (this.dgvJobsPayPlan.CurrentRow != null)
  241. {
  242. F_PAM_0302 frmPAM0302 = new F_PAM_0302(Constant.FormMode.Edit, Convert.ToInt32(this.dgvJobsPayPlan.CurrentRow.Cells["PieceTacticsID"].Value));
  243. DialogResult dialogResult = frmPAM0302.ShowDialog();
  244. if (dialogResult.Equals(DialogResult.OK))
  245. {
  246. btnSearch_Click(sender, e);
  247. }
  248. }
  249. }
  250. catch (Exception ex)
  251. {
  252. // 对异常进行共通处理
  253. ExceptionManager.HandleEventException(this.ToString(),
  254. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  255. }
  256. }
  257. }
  258. }