F_PAM_0605.cs 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_PAM_0602.cs
  5. * 2.功能描述:工资结算
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 王鑫 2015/08/28 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Windows.Forms;
  12. using Dongke.IBOSS.PRD.Client.CommonModule;
  13. using Dongke.IBOSS.PRD.Basics.BaseResources;
  14. using Dongke.IBOSS.PRD.WCF.Proxys;
  15. using Dongke.IBOSS.PRD.Basics.BaseControls;
  16. using System.Data;
  17. namespace Dongke.IBOSS.PRD.Client.PAMModule
  18. {
  19. public partial class F_PAM_0605 : FormBase
  20. {
  21. #region 成员变量
  22. //单例模式
  23. private static F_PAM_0605 _instance;
  24. // 最后选择行
  25. //private int _selecedRow;
  26. // 合算年月
  27. private DateTime? _payrollAccountYYYYMM = null;
  28. #endregion
  29. #region 构造函数
  30. public F_PAM_0605()
  31. {
  32. InitializeComponent();
  33. this.Text = FormTitles.F_PAM_0605;
  34. }
  35. #endregion
  36. #region 单例模式
  37. /// <summary>
  38. /// 单例模式,防止重复创建窗体
  39. /// </summary>
  40. public static F_PAM_0605 Instance
  41. {
  42. get
  43. {
  44. if (_instance == null)
  45. {
  46. _instance = new F_PAM_0605();
  47. }
  48. return _instance;
  49. }
  50. }
  51. #endregion
  52. #region 事件
  53. /// <summary>
  54. /// 窗体加载
  55. /// </summary>
  56. private void F_PAM_0201_Load(object sender, EventArgs e)
  57. {
  58. dtpStartTime.Value = DateTime.Now;
  59. DataSet dsSystemDate = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  60. {
  61. return SystemModuleProxy.Service.GetSettlementTime();
  62. }));
  63. if (dsSystemDate != null && dsSystemDate.Tables[0].Rows.Count > 0)
  64. {
  65. DateTime time = Convert.ToDateTime(dsSystemDate.Tables[0].Rows[0]["datevalue"]);
  66. lblDescription.Text = string.Format("最近工资结算的会计账务日期{0}", time.Year.ToString() + (time.Month.ToString().Length < 2 ? "0" + time.Month.ToString() : time.Month.ToString()));
  67. dtpStartTime.Value = time;
  68. this._payrollAccountYYYYMM = time;
  69. }
  70. }
  71. /// <summary>
  72. /// 窗体关闭事件
  73. /// </summary>
  74. private void F_PAM_0201_FormClosed(object sender, FormClosedEventArgs e)
  75. {
  76. _instance = null;
  77. }
  78. /// <summary>
  79. /// 结算按钮事件
  80. /// </summary>
  81. /// <param name="sender"></param>
  82. /// <param name="e"></param>
  83. private void c_Button1_Click(object sender, EventArgs e)
  84. {
  85. try
  86. {
  87. int year = dtpStartTime.Value.Year;
  88. int month = dtpStartTime.Value.Month;
  89. string yyyymm = year.ToString() + (month.ToString().Length < 2 ? "0" + month.ToString() : month.ToString());
  90. int returnRow = (int)DoAsync(new BaseAsyncMethod(() =>
  91. {
  92. return PAMModuleProxy.Service.ChangePayPiecework(yyyymm);
  93. }));
  94. if (returnRow > 0)
  95. {
  96. MessageBox.Show("反结算成功");
  97. this.DialogResult = DialogResult.OK;
  98. }
  99. else
  100. {
  101. MessageBox.Show("反结算失败");
  102. this.DialogResult = DialogResult.No;
  103. }
  104. this.Close();
  105. }
  106. catch (Exception ex)
  107. {
  108. // 对异常进行共通处理
  109. ExceptionManager.HandleEventException(this.ToString(),
  110. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  111. }
  112. }
  113. #endregion
  114. private void dtpStartTime_ValueChanged(object sender, EventArgs e)
  115. {
  116. DataSet dsSystemSettings = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  117. {
  118. return SystemModuleProxy.Service.GetSystemData();
  119. }));
  120. if (dsSystemSettings != null && dsSystemSettings.Tables[0].Rows.Count > 0)
  121. {
  122. // 算出此月一共多少天,防止设置的值,大于当月的天数
  123. int daysCount = DateTime.DaysInMonth(dtpStartTime.Value.Year, dtpStartTime.Value.Month);
  124. DataRow[] dr = dsSystemSettings.Tables[0].Select("SettingCode='S_CMN_0003'");
  125. DateTime? dateStartTime = null;
  126. DateTime? dateEndTime = null;
  127. if (dr.Length > 0)
  128. {
  129. if (dr[0]["SettingValue"].ToString() == "月末")
  130. {
  131. dateStartTime = new DateTime(dtpStartTime.Value.Year, dtpStartTime.Value.Month, 1);
  132. dateEndTime = new DateTime(dtpStartTime.Value.Year, dtpStartTime.Value.Month, daysCount, 23, 59, 59);
  133. }
  134. else
  135. {
  136. // 选择的值,大于当月的天数
  137. if (Convert.ToInt32(dr[0]["SettingValue"]) > daysCount)
  138. {
  139. dateEndTime = new DateTime(dtpStartTime.Value.Year, dtpStartTime.Value.Month, daysCount, 23, 59, 59);
  140. dateStartTime = dateEndTime.Value.AddMonths(-1).AddDays(1);
  141. }
  142. else
  143. {
  144. dateEndTime = new DateTime(dtpStartTime.Value.Year, dtpStartTime.Value.Month, Convert.ToInt32(dsSystemSettings.Tables[0].Rows[0]["SettingValue"]), 23, 59, 59);
  145. dateStartTime = dateEndTime.Value.AddMonths(-1).AddDays(1);
  146. }
  147. }
  148. dateTimePicker1.Value = Convert.ToDateTime(dateStartTime);
  149. dtpEndTime.Value = Convert.ToDateTime(dateEndTime);
  150. }
  151. }
  152. }
  153. }
  154. }