| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205 |
- /*******************************************************************************
- * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
- * 类的信息:
- * 1.程序名称:F_PAM_0602.cs
- * 2.功能描述:工资结算
- * 编辑履历:
- * 作者 日期 版本 修改内容
- * 王鑫 2015/08/28 1.00 新建
- *******************************************************************************/
- using System;
- using System.Windows.Forms;
- using Dongke.IBOSS.PRD.Client.CommonModule;
- using Dongke.IBOSS.PRD.Basics.BaseResources;
- using Dongke.IBOSS.PRD.WCF.Proxys;
- using Dongke.IBOSS.PRD.Basics.BaseControls;
- using System.Data;
- using Dongke.IBOSS.PRD.Basics.Library;
- namespace Dongke.IBOSS.PRD.Client.PAMModule
- {
- /// <summary>
- /// 工资结算
- /// </summary>
- public partial class F_PAM_0602 : FormBase
- {
- #region 成员变量
- //单例模式
- private static F_PAM_0602 _instance;
- // 最后选择行
- private int _selecedRow;
- // 合算年月
- private DateTime? _payrollAccountYYYYMM = null;
- #endregion
- #region 构造函数
- public F_PAM_0602()
- {
- InitializeComponent();
- this.Text = FormTitles.F_PAM_0602;
- }
- #endregion
- #region 单例模式
- /// <summary>
- /// 单例模式,防止重复创建窗体
- /// </summary>
- public static F_PAM_0602 Instance
- {
- get
- {
- if (_instance == null)
- {
- _instance = new F_PAM_0602();
- }
- return _instance;
- }
- }
- #endregion
- #region 事件
- /// <summary>
- /// 窗体加载
- /// </summary>
- private void F_PAM_0201_Load(object sender, EventArgs e)
- {
- dtpStartTime.Value = DateTime.Now;
- DataSet dsSystemDate = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- {
- return SystemModuleProxy.Service.GetSettlementTime();
- }));
- if (dsSystemDate != null && dsSystemDate.Tables[0].Rows.Count > 0)
- {
- DateTime time = Convert.ToDateTime(dsSystemDate.Tables[0].Rows[0]["datevalue"]);
- lblDescription.Text = string.Format("最近工资结算的会计账务日期{0}", time.Year.ToString() + (time.Month.ToString().Length < 2 ? "0" + time.Month.ToString() : time.Month.ToString()));
- this._payrollAccountYYYYMM = time;
- }
- }
- /// <summary>
- /// 窗体关闭事件
- /// </summary>
- private void F_PAM_0201_FormClosed(object sender, FormClosedEventArgs e)
- {
- _instance = null;
- }
- /// <summary>
- /// 结算按钮事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void c_Button1_Click(object sender, EventArgs e)
- {
- try
- {
- int year = dtpStartTime.Value.Year;
- int month = dtpStartTime.Value.Month;
- DateTime time = new DateTime(year, month, 1);
- if (time < this._payrollAccountYYYYMM)
- {
- MessageBox.Show("结算必须大于已结算的月");
- return;
- }
- DateTime startTime = DateTime.Now;
- this.dtpStartTime.Enabled = false;
- int returnRow = (int)DoAsync(new BaseAsyncMethod(() =>
- {
- return PAMModuleProxy.Service.SavePayPiecework(month, year);
- }));
- this.dtpStartTime.Enabled = true;
- if (returnRow > 0)
- {
- DateTime endTime = DateTime.Now;
- TimeSpan ts = endTime - startTime;
- System.Text.StringBuilder mes = new System.Text.StringBuilder();
- mes.AppendLine("结 算 月:" + time.ToString("yyyy-MM"));
- mes.AppendLine("结算日期:" + dateTimePicker1.Value.ToString("yyyy-MM-dd") + "~" + dtpEndTime.Value.ToString("yyyy-MM-dd"));
- mes.AppendLine("操作时间:" + startTime.ToString("yyyy-MM-dd HH:mm:ss") + "~" + endTime.ToString("yyyy-MM-dd HH:mm:ss"));
- mes.Append("耗 时:" + ts.TotalHours.ToString("##0.00") + "小时");
- // 写日志
- OutputLog.Trace(LogPriority.Information, this.Text, "工资结算", mes.ToString());
- MessageBox.Show("结算成功");
- this.DialogResult = DialogResult.OK;
- }
- else if (returnRow == -99)
- {
- MessageBox.Show("此月已经结算");
- return;
- }
- else
- {
- MessageBox.Show("结算失败");
- this.DialogResult = DialogResult.No;
- }
- //DateTime endTime = DateTime.Now;
- //TimeSpan ts = endTime - startTime;
- //MessageBox.Show(ts.Days+"天"+ts.Hours+"小时"+ts.Minutes+"分钟"+ts.Seconds+"秒");
- this.Close();
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- #endregion
- private void dtpStartTime_ValueChanged(object sender, EventArgs e)
- {
- DataSet dsSystemSettings = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- {
- return SystemModuleProxy.Service.GetSystemData();
- }));
- if (dsSystemSettings != null && dsSystemSettings.Tables[0].Rows.Count > 0)
- {
- // 算出此月一共多少天,防止设置的值,大于当月的天数
- int daysCount = DateTime.DaysInMonth(dtpStartTime.Value.Year, dtpStartTime.Value.Month);
- DataRow[] dr = dsSystemSettings.Tables[0].Select("SettingCode='S_CMN_0003'");
- DateTime? dateStartTime = null;
- DateTime? dateEndTime = null;
- if (dr.Length > 0)
- {
- if (dr[0]["SettingValue"].ToString() == "月末")
- {
- dateStartTime = new DateTime(dtpStartTime.Value.Year, dtpStartTime.Value.Month, 1);
- dateEndTime = new DateTime(dtpStartTime.Value.Year, dtpStartTime.Value.Month, daysCount, 23, 59, 59);
- }
- else
- {
- // 选择的值,大于当月的天数
- if (Convert.ToInt32(dr[0]["SettingValue"]) > daysCount)
- {
- dateEndTime = new DateTime(dtpStartTime.Value.Year, dtpStartTime.Value.Month, daysCount, 23, 59, 59);
- dateStartTime = dateEndTime.Value.AddMonths(-1).AddDays(1);
- }
- else
- {
- dateEndTime = new DateTime(dtpStartTime.Value.Year, dtpStartTime.Value.Month, Convert.ToInt32(dr[0]["SettingValue"].ToString()), 23, 59, 59);
- dateStartTime = dateEndTime.Value.AddMonths(-1).AddDays(1);
- }
- }
- dateTimePicker1.Value = Convert.ToDateTime(dateStartTime);
- dtpEndTime.Value = Convert.ToDateTime(dateEndTime);
- }
- }
- }
- }
- }
|