F_PAM_0601.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_PAM_0601.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.Basics.DockPanel;
  16. using Dongke.IBOSS.PRD.WCF.Proxys;
  17. namespace Dongke.IBOSS.PRD.Client.PAMModule
  18. {
  19. /// <summary>
  20. /// 工资结算一览
  21. /// </summary>
  22. public partial class F_PAM_0601 : DockPanelBase
  23. {
  24. #region 成员变量
  25. //单例模式
  26. private static F_PAM_0601 _instance;
  27. // 最后选择行
  28. private int _selecedRow;
  29. #endregion
  30. #region 构造函数
  31. public F_PAM_0601()
  32. {
  33. InitializeComponent();
  34. this.Text = FormTitles.F_PAM_0601;
  35. this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
  36. this.tsbtnPay.Text = ButtonText.TSBTN_PAY;
  37. this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
  38. this.gbxCondition.Text = Constant.LABEL_QUERY_CONDITIONS;
  39. }
  40. #endregion
  41. #region 单例模式
  42. /// <summary>
  43. /// 单例模式,防止重复创建窗体
  44. /// </summary>
  45. public static F_PAM_0601 Instance
  46. {
  47. get
  48. {
  49. if (_instance == null)
  50. {
  51. _instance = new F_PAM_0601();
  52. }
  53. return _instance;
  54. }
  55. }
  56. #endregion
  57. #region 事件
  58. /// <summary>
  59. /// 窗体加载
  60. /// </summary>
  61. private void F_PAM_0201_Load(object sender, EventArgs e)
  62. {
  63. this.dgvPayroll.AutoGenerateColumns = false;
  64. this.dgvPiecework.AutoGenerateColumns = false;
  65. this.dgvDamageSubsidy.AutoGenerateColumns = false;
  66. this.dgvRepairSubsidy.AutoGenerateColumns = false;
  67. this.dgvQualityASS.AutoGenerateColumns = false;
  68. DateTime dt = DateTime.Now.Date;
  69. dtpStartTime.Value = new DateTime(dt.Year, dt.Month, 1);
  70. tsbtnPay.Size = new System.Drawing.Size(60, 25);
  71. tsbtnChangePay.Size = new System.Drawing.Size(65, 25);
  72. }
  73. /// <summary>
  74. /// 关闭窗体事件
  75. /// </summary>
  76. private void tsbtnClose_Click(object sender, EventArgs e)
  77. {
  78. this.Close();
  79. }
  80. /// <summary>
  81. /// 自适应事件
  82. /// </summary>
  83. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  84. {
  85. this.dgvPayroll.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  86. this.dgvPiecework.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  87. this.dgvDamageSubsidy.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  88. this.dgvRepairSubsidy.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  89. this.dgvQualityASS.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  90. }
  91. /// <summary>
  92. /// 窗体关闭事件
  93. /// </summary>
  94. private void F_PAM_0201_FormClosed(object sender, FormClosedEventArgs e)
  95. {
  96. _instance = null;
  97. }
  98. /// <summary>
  99. /// 搜索按钮事件
  100. /// </summary>
  101. /// <param name="sender"></param>
  102. /// <param name="e"></param>
  103. private void btnSearch_Click_1(object sender, EventArgs e)
  104. {
  105. try
  106. {
  107. // 记录当前选中行
  108. int selectRowIndex = this._selecedRow;
  109. // 异步处理
  110. this.btnSearch.Enabled = false;
  111. string year = dtpStartTime.Value.Year.ToString();
  112. string month = dtpStartTime.Value.Month.ToString().Length < 2 ? "0" + dtpStartTime.Value.Month.ToString() : dtpStartTime.Value.Month.ToString();
  113. this.dgvPayroll.DataSource = null;
  114. this.dgvPiecework.DataSource = null;
  115. this.dgvDamageSubsidy.DataSource = null;
  116. this.dgvRepairSubsidy.DataSource = null;
  117. this.dgvQualityASS.DataSource = null;
  118. DataSet dsProductionData = (DataSet)DoAsync(new AsyncMethod(() =>
  119. {
  120. return PAMModuleProxy.Service.GetPayroll(year + month);
  121. }));
  122. this.btnSearch.Enabled = true;
  123. if (dsProductionData != null)
  124. {
  125. base.DataSource = dsProductionData;
  126. if (this.DataSource != null && this.DataSource.Tables.Count > Constant.INT_IS_ZERO)
  127. {
  128. this.dgvPayroll.DataSource = this.DataSource.Tables[0];
  129. if (this.DataSource.Tables[0].Rows.Count <= Constant.INT_IS_ZERO)
  130. {
  131. // 提示未查找到数据
  132. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  133. MessageBoxButtons.OK, MessageBoxIcon.Information);
  134. }
  135. else
  136. {
  137. if (selectRowIndex >= Constant.INT_IS_ZERO)
  138. {
  139. if (selectRowIndex >= dsProductionData.Tables[0].Rows.Count)
  140. {
  141. this.dgvPayroll.Rows[this.dgvPayroll.Rows.Count - 1].Selected = true;
  142. this.dgvPayroll.CurrentCell = this.dgvPayroll.Rows[this.dgvPayroll.Rows.Count - 1].Cells["YYYYMM"];
  143. }
  144. else
  145. {
  146. this.dgvPayroll.Rows[selectRowIndex].Selected = true;
  147. this.dgvPayroll.CurrentCell = this.dgvPayroll.Rows[selectRowIndex].Cells["YYYYMM"];
  148. }
  149. }
  150. }
  151. }
  152. //this.tabControl1.SelectTab(0);
  153. this.tabControl1.Controls[0].Text = year + "-" + month + "工资单";
  154. }
  155. }
  156. catch (Exception ex)
  157. {
  158. this.btnSearch.Enabled = true;
  159. // 对异常进行共通处理
  160. ExceptionManager.HandleEventException(this.ToString(),
  161. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  162. }
  163. }
  164. /// <summary>
  165. /// 单元格选定事件
  166. /// </summary>
  167. /// <param name="sender"></param>
  168. /// <param name="e"></param>
  169. private void dgvPayroll_SelectionChanged(object sender, EventArgs e)
  170. {
  171. }
  172. /// <summary>
  173. /// 结算按钮事件
  174. /// </summary>
  175. /// <param name="sender"></param>
  176. /// <param name="e"></param>
  177. private void tsbtnPay_Click(object sender, EventArgs e)
  178. {
  179. try
  180. {
  181. F_PAM_0602 fpam0602 = new F_PAM_0602();
  182. fpam0602.ShowDialog();
  183. if (fpam0602.DialogResult == DialogResult.OK)
  184. {
  185. btnSearch_Click_1(sender, e);
  186. }
  187. }
  188. catch (Exception ex)
  189. {
  190. // 对异常进行共通处理
  191. ExceptionManager.HandleEventException(this.ToString(),
  192. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  193. }
  194. }
  195. /// <summary>
  196. /// 工资调整按钮事件
  197. /// </summary>
  198. /// <param name="sender"></param>
  199. /// <param name="e"></param>
  200. private void tsbtnChange_Click(object sender, EventArgs e)
  201. {
  202. try
  203. {
  204. F_PAM_0603 fpam0603 = new F_PAM_0603();
  205. fpam0603.ShowDialog();
  206. if (fpam0603.DialogResult == DialogResult.OK)
  207. {
  208. btnSearch_Click_1(sender, e);
  209. }
  210. }
  211. catch (Exception ex)
  212. {
  213. // 对异常进行共通处理
  214. ExceptionManager.HandleEventException(this.ToString(),
  215. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  216. }
  217. }
  218. /// <summary>
  219. /// 审核按钮事件
  220. /// </summary>
  221. /// <param name="sender"></param>
  222. /// <param name="e"></param>
  223. private void tsbtnApproval_Click(object sender, EventArgs e)
  224. {
  225. try
  226. {
  227. F_PAM_0604 fpam0604 = new F_PAM_0604();
  228. fpam0604.ShowDialog();
  229. if (fpam0604.DialogResult == DialogResult.OK)
  230. {
  231. btnSearch_Click_1(sender, e);
  232. }
  233. }
  234. catch (Exception ex)
  235. {
  236. // 对异常进行共通处理
  237. ExceptionManager.HandleEventException(this.ToString(),
  238. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  239. }
  240. }
  241. #endregion
  242. /// <summary>
  243. /// 单元格双击事件
  244. /// </summary>
  245. /// <param name="sender"></param>
  246. /// <param name="e"></param>
  247. private void dgvPayroll_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
  248. {
  249. try
  250. {
  251. if (this.dgvPayroll.CurrentCell != null)
  252. {
  253. //if (!this.tsbtnClose.ReadOnly)
  254. //{
  255. if (e.RowIndex < 0)
  256. {
  257. return;
  258. }
  259. DataGridViewColumn columnItem = this.dgvPayroll.Columns[e.ColumnIndex];
  260. this._selecedRow = this.dgvPayroll.CurrentCell.RowIndex;
  261. //this.dgvDefect.DataSource = null;
  262. int staffid = Convert.ToInt32(this.dgvPayroll.Rows[_selecedRow].Cells["staffid"].Value.ToString());
  263. string yyyymm = this.dgvPayroll.Rows[_selecedRow].Cells["YYYYMM"].Value.ToString();
  264. DataSet ds = (DataSet)DoAsync(new AsyncMethod(() =>
  265. {
  266. return PAMModuleProxy.Service.GetPayrollInfo(yyyymm, staffid);
  267. }));
  268. if (ds != null)
  269. {
  270. //if (columnItem.Name == "Piecework")
  271. //{
  272. // this.tabControl1.SelectTab(1);
  273. //}
  274. //else if (columnItem.Name == "DamageSubsidy")
  275. //{
  276. // this.tabControl1.SelectTab(2);
  277. //}
  278. //else if (columnItem.Name == "RepairSubsidy")
  279. //{
  280. // this.tabControl1.SelectTab(3);
  281. //}
  282. //else if (columnItem.Name == "QualityEXA")
  283. //{
  284. // this.tabControl1.SelectTab(4);
  285. //}
  286. // this.tabPage2.Select();
  287. this.tabControl1.SelectTab(1);
  288. this.dgvPiecework.DataSource = ds.Tables[0];
  289. this.dgvDamageSubsidy.DataSource = ds.Tables[1];
  290. this.dgvRepairSubsidy.DataSource = ds.Tables[2];
  291. this.dgvQualityASS.DataSource = ds.Tables[3];
  292. }
  293. //}
  294. }
  295. }
  296. catch (Exception ex)
  297. {
  298. // 对异常进行共通处理
  299. ExceptionManager.HandleEventException(this.ToString(),
  300. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  301. }
  302. }
  303. /// <summary>
  304. /// 反结算按钮事件
  305. /// </summary>
  306. /// <param name="sender"></param>
  307. /// <param name="e"></param>
  308. private void tsbtnChangePay_Click(object sender, EventArgs e)
  309. {
  310. //try
  311. //{
  312. // if (this.dgvPayroll.CurrentCell != null)
  313. // {
  314. // DialogResult msgBoxResult = MessageBox.Show(
  315. // string.Format(Messages.MSG_CMN_Q002, "工资", "反结算"), this.Text,
  316. // MessageBoxButtons.YesNo, MessageBoxIcon.Question);
  317. // if (msgBoxResult == DialogResult.Yes)
  318. // {
  319. // this._selecedRow = this.dgvPayroll.CurrentCell.RowIndex;
  320. // int staffid = Convert.ToInt32(this.dgvPayroll.Rows[_selecedRow].Cells["staffid"].Value.ToString());
  321. // string yyyymm = this.dgvPayroll.Rows[_selecedRow].Cells["YYYYMM"].Value.ToString();
  322. // int resultvalue = (int)DoAsync(() =>
  323. // {
  324. // return PAMModuleProxy.Service.ChangePayPiecework(yyyymm);
  325. // }
  326. // );
  327. // this.dgvPayroll.ReadOnly = true;
  328. // // 修改成功
  329. // if (resultvalue > Constant.INT_IS_ZERO)
  330. // {
  331. // MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "工资", "反结算"),
  332. // this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  333. // this.btnSearch_Click_1(sender, e);
  334. // }
  335. // else
  336. // {
  337. // MessageBox.Show(string.Format(Messages.MSG_CMN_W001, "工资", "反结算"),
  338. // this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  339. // }
  340. // }
  341. // }
  342. //}
  343. //catch (Exception ex)
  344. //{
  345. // // 对异常进行共通处理
  346. // ExceptionManager.HandleEventException(this.ToString(),
  347. // System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  348. //}
  349. try
  350. {
  351. F_PAM_0605 fpam0605 = new F_PAM_0605();
  352. fpam0605.ShowDialog();
  353. if (fpam0605.DialogResult == DialogResult.OK)
  354. {
  355. btnSearch_Click_1(sender, e);
  356. }
  357. }
  358. catch (Exception ex)
  359. {
  360. // 对异常进行共通处理
  361. ExceptionManager.HandleEventException(this.ToString(),
  362. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  363. }
  364. }
  365. private void tsbtnAdd_Click(object sender, EventArgs e)
  366. {
  367. }
  368. private void tsbtnEdit_Click_1(object sender, EventArgs e)
  369. {
  370. }
  371. }
  372. }