F_PAM_0604.cs 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_PAM_0604.cs
  5. * 2.功能描述:工资审核
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 王鑫 2015/08/28 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.WCF.Proxys;
  16. using Dongke.IBOSS.PRD.Basics.BaseControls;
  17. using Dongke.IBOSS.PRD.Basics.DockPanel;
  18. namespace Dongke.IBOSS.PRD.Client.PAMModule
  19. {
  20. /// <summary>
  21. /// 工资审核
  22. /// </summary>
  23. public partial class F_PAM_0604 : DockPanelBase
  24. {
  25. #region 成员变量
  26. //单例模式
  27. private static F_PAM_0604 _instance;
  28. // 最后选择行
  29. private int _selecedRow;
  30. #endregion
  31. #region 构造函数
  32. public F_PAM_0604()
  33. {
  34. InitializeComponent();
  35. this.Text = FormTitles.F_PAM_0604;
  36. this.gbxCondition.Text = Constant.LABEL_QUERY_CONDITIONS;
  37. }
  38. #endregion
  39. #region 单例模式
  40. /// <summary>
  41. /// 单例模式,防止重复创建窗体
  42. /// </summary>
  43. public static F_PAM_0604 Instance
  44. {
  45. get
  46. {
  47. if (_instance == null)
  48. {
  49. _instance = new F_PAM_0604();
  50. }
  51. return _instance;
  52. }
  53. }
  54. #endregion
  55. #region 事件
  56. /// <summary>
  57. /// 窗体加载
  58. /// </summary>
  59. private void F_PAM_0201_Load(object sender, EventArgs e)
  60. {
  61. this.dgvPayroll.AutoGenerateColumns = false;
  62. DateTime dt = DateTime.Now.Date;
  63. dtpStartTime.Value = new DateTime(dt.Year, dt.Month, 1);
  64. }
  65. /// <summary>
  66. /// 关闭窗体事件
  67. /// </summary>
  68. private void tsbtnClose_Click(object sender, EventArgs e)
  69. {
  70. this.Close();
  71. }
  72. /// <summary>
  73. /// 自适应事件
  74. /// </summary>
  75. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  76. {
  77. //this.dgvJobsPayPlan.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells); ;
  78. }
  79. /// <summary>
  80. /// 窗体关闭事件
  81. /// </summary>
  82. private void F_PAM_0201_FormClosed(object sender, FormClosedEventArgs e)
  83. {
  84. _instance = null;
  85. }
  86. /// <summary>
  87. /// 搜索按钮事件
  88. /// </summary>
  89. /// <param name="sender"></param>
  90. /// <param name="e"></param>
  91. private void btnSearch_Click_1(object sender, EventArgs e)
  92. {
  93. try
  94. {
  95. DataTable dt = dgvPayroll.DataSource as DataTable;
  96. if (dt == null || dt.Rows.Count == 0)
  97. {
  98. return;
  99. }
  100. int returnValue = (int)DoAsync(new AsyncMethod(() =>
  101. {
  102. return PAMModuleProxy.Service.SavePayrollAuditStatus(dt);
  103. }));
  104. if (returnValue > 0) //等于O,表示未修改数据,影响行为0
  105. {
  106. // 提示信息
  107. MessageBox.Show(string.Format(Messages.MSG_CMN_I001, this.Text, "保存"),
  108. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  109. }
  110. btnSearch_Click(sender, e);
  111. }
  112. catch (Exception ex)
  113. {
  114. // 对异常进行共通处理
  115. ExceptionManager.HandleEventException(this.ToString(),
  116. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  117. }
  118. }
  119. /// <summary>
  120. /// 结算按钮事件
  121. /// </summary>
  122. /// <param name="sender"></param>
  123. /// <param name="e"></param>
  124. private void tsbtnPay_Click(object sender, EventArgs e)
  125. {
  126. try
  127. {
  128. F_PAM_0602 fpam0602 = new F_PAM_0602();
  129. fpam0602.ShowDialog();
  130. if (fpam0602.DialogResult == DialogResult.OK)
  131. {
  132. btnSearch_Click_1(sender, e);
  133. }
  134. }
  135. catch (Exception ex)
  136. {
  137. // 对异常进行共通处理
  138. ExceptionManager.HandleEventException(this.ToString(),
  139. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  140. }
  141. }
  142. private void dgvPayroll_CurrentCellDirtyStateChanged(object sender, EventArgs e)
  143. {
  144. try
  145. {
  146. if (this.dgvPayroll.CurrentRow != null && this.dgvPayroll.IsCurrentCellDirty)
  147. {
  148. if ("Sel".Equals(this.dgvPayroll.Columns
  149. [this.dgvPayroll.CurrentCell.ColumnIndex].Name))
  150. {
  151. this.dgvPayroll.CommitEdit(DataGridViewDataErrorContexts.Commit);
  152. }
  153. }
  154. }
  155. catch (Exception ex)
  156. {
  157. // 对异常进行共通处理
  158. ExceptionManager.HandleEventException(this.ToString(),
  159. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  160. }
  161. }
  162. /// <summary>
  163. ///
  164. /// </summary>
  165. /// <param name="sender"></param>
  166. /// <param name="e"></param>
  167. private void btnSearch_Click(object sender, EventArgs e)
  168. {
  169. try
  170. {
  171. // 记录当前选中行
  172. int selectRowIndex = this._selecedRow;
  173. // 异步处理
  174. this.btnSearch.Enabled = false;
  175. string year = dtpStartTime.Value.Year.ToString();
  176. string month = dtpStartTime.Value.Month.ToString().Length < 2 ? "0" + dtpStartTime.Value.Month.ToString() : dtpStartTime.Value.Month.ToString();
  177. DataSet dsProductionData = (DataSet)DoAsync(new AsyncMethod(() =>
  178. {
  179. return PAMModuleProxy.Service.GetPayroll(year+month);
  180. }));
  181. this.btnSearch.Enabled = true;
  182. if (dsProductionData != null)
  183. {
  184. //base.DataSource = dsProductionData;
  185. DataView dv = dsProductionData.Tables[0].DefaultView;
  186. dv.RowFilter = "AuditStatus=0";
  187. DataSet ds = new DataSet();
  188. ds.Tables.Add(dv.ToTable());
  189. base.DataSource = ds;
  190. if (this.DataSource != null && this.DataSource.Tables.Count > Constant.INT_IS_ZERO)
  191. {
  192. this.dgvPayroll.DataSource = this.DataSource.Tables[0];
  193. if (this.DataSource.Tables[0].Rows.Count <= Constant.INT_IS_ZERO)
  194. {
  195. // 提示未查找到数据
  196. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  197. MessageBoxButtons.OK, MessageBoxIcon.Information);
  198. }
  199. else
  200. {
  201. if (selectRowIndex >= Constant.INT_IS_ZERO)
  202. {
  203. if (selectRowIndex >= dsProductionData.Tables[0].Rows.Count)
  204. {
  205. //this.dgvPayroll.Rows[this.dgvPayroll.Rows.Count - 1].Selected = true;
  206. this.dgvPayroll.CurrentCell = this.dgvPayroll.Rows[this.dgvPayroll.Rows.Count - 1].Cells["YYYYMM"];
  207. }
  208. else
  209. {
  210. //this.dgvPayroll.Rows[selectRowIndex].Selected = true;
  211. this.dgvPayroll.CurrentCell = this.dgvPayroll.Rows[selectRowIndex].Cells["YYYYMM"];
  212. }
  213. }
  214. }
  215. }
  216. foreach (DataGridViewRow row in this.dgvPayroll.Rows)
  217. {
  218. // 未注浆的,不能编辑
  219. object groutingFlag = row.Cells["AuditStatus"].Value;
  220. if (groutingFlag.ToString() == "1")
  221. {
  222. row.Cells["Sel"].ReadOnly = true;
  223. row.Cells["Remarks"].ReadOnly = true;
  224. }
  225. }
  226. this.dgvPayroll.IsSetInputColumnsColor = true;
  227. }
  228. }
  229. catch (Exception ex)
  230. {
  231. this.btnSearch.Enabled = true;
  232. // 对异常进行共通处理
  233. ExceptionManager.HandleEventException(this.ToString(),
  234. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  235. }
  236. }
  237. #endregion
  238. private void tsbtnClose_Click_1(object sender, EventArgs e)
  239. {
  240. this.Close();
  241. }
  242. private void tsbtnAdaptive_Click_1(object sender, EventArgs e)
  243. {
  244. this.dgvPayroll.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  245. }
  246. }
  247. }