public void getEmpOTSettings() { string message; try { string record = this.Request["record"]; Hashtable ht = JavaScriptConvert.DeserializeObject <Hashtable>(record); otaplctnBll bll = new otaplctnBll(); LvSettingInfo lstSettings = bll.GetEmpOTSettings(ht["emno"].ToString(), ht["otcd"].ToString(), Convert.ToDateTime(ht["fromdate"].ToString())); string json = JavaScriptConvert.SerializeObject(lstSettings); message = "{status:'success',msg:'" + json + "'}"; Response.Write(message); } catch (Exception ex) { message = "{status:'failure',msg:'" + ExceptionPaser.Parse(HRMSRes.Public_Message_QueryFail, ex, true) + "'}"; Response.Output.Write(message); } }
public double TransferToLeave(totdetail _otdetail, tottype _ottype, ref int lvdefseq) { otanaovtBll bll = new otanaovtBll(); LvSettingInfo settingInfo = bll.GetEmpOTSettings(_otdetail.emno, _otdetail.otcd, _otdetail.sttm); double hoursToTTLV = 0; double hoursForTTLV = (((_otdetail.othm == 0)) ? _otdetail.othr : _otdetail.othm).Value; if (settingInfo.MinBalance >= hoursForTTLV) { hoursToTTLV = hoursForTTLV; } else { hoursToTTLV = settingInfo.MinBalance; } if (hoursToTTLV > 0) { tlvdfbyem lvemp = new tlvdfbyem(); //problem here,转换成天数后怎么统计 lvemp.days = hoursToTTLV; lvemp.emno = _otdetail.emno; lvemp.exdt = _otdetail.sttm.AddYears(1); //default 1 year later lvemp.lmtm = DateTime.Now; lvemp.lmur = Constant.SYSTEM_USER_ID; lvemp.ltcd = _ottype.ttlv; lvemp.remk = "Transfer from overtime[" + "frtm:" + UtilDatetime.FormateDateTime1(_otdetail.sttm) + ",totm:" + UtilDatetime.FormateDateTime1(_otdetail.edtm) + "]"; int?maxsqno = GetMaxsqno("tlvdfbyem", _otdetail.emno); maxsqno = maxsqno.HasValue == false ? 0 : maxsqno.Value; lvemp.sqno = maxsqno.Value + 1; DoInsert <tlvdfbyem>(lvemp); lvdefseq = lvemp.sqno; } return(hoursToTTLV); }
public double TransferToLeave(totaplctn _overtimeApp, tottype _ottype, ref int lvdefseq) { //自动转换成休假,会检查limit otanaovtBll bll = new otanaovtBll(); LvSettingInfo settingInfo = bll.GetEmpOTSettings(_overtimeApp.emno, _overtimeApp.otcd, _overtimeApp.frtm); double hoursToTTLV = 0; double hoursForTTLV = (((_overtimeApp.othm == 0) || (_overtimeApp.othm.HasValue == false)) ? _overtimeApp.othr : _overtimeApp.othm).Value; if (settingInfo.MinBalance >= hoursForTTLV) { hoursToTTLV = hoursForTTLV; } else { hoursToTTLV = settingInfo.MinBalance; } if (hoursToTTLV > 0) { tlvdfbyem lvemp = new tlvdfbyem(); //problem here,转换成天数后怎么统计 lvemp.days = settingInfo.MinBalance; lvemp.emno = _overtimeApp.emno; lvemp.exdt = _overtimeApp.frtm.AddYears(1); //default 1 year later lvemp.lmtm = DateTime.Now; lvemp.lmur = Constant.SYSTEM_USER_ID; lvemp.ltcd = _ottype.ttlv; lvemp.remk = "Transfer from overtime[appno:" + _overtimeApp.apno + ",frtm:" + UtilDatetime.FormateDateTime1(_overtimeApp.frtm) + ",totm:" + UtilDatetime.FormateDateTime1(_overtimeApp.totm) + "]"; lvemp.sqno = GetMaxsqno("tlvdfbyem", _overtimeApp.emno).Value; DoInsert <tlvdfbyem>(lvemp); lvdefseq = lvemp.sqno; } return(hoursToTTLV); }
public LvSettingInfo GetEmpLeaveSettings(string _emno, string _ltcd, DateTime _leavedate) { LvSettingInfo settingInfo = new LvSettingInfo(); double leaveBalance = 0; settingInfo.emp = GetSelectedObject <vw_employment>(new List <ColumnInfo>() { new ColumnInfo() { ColumnName = "emno", ColumnValue = _emno } }); //根据员工个人设定 lvdfbyempDal empDal = new lvdfbyempDal(); settingInfo.dfbyEmployment = empDal.getLeaveSettingsByEmp(_emno, _ltcd, DateTime.Now); leaveBalance = settingInfo.dfbyEmployment; if (settingInfo.dfbyEmployment > 0) { settingInfo.SummaryText.Add("By Employment: " + settingInfo.dfbyEmployment.ToString()); } //根据服务年数设定 lvdfbyyearsDal yearDal = new lvdfbyyearsDal(); settingInfo.dfbyYear = yearDal.getLeaveSettingsByYear(_ltcd, Convert.ToDouble(DateTime.Now.Year)); leaveBalance += settingInfo.dfbyYear; if (settingInfo.dfbyYear > 0) { settingInfo.SummaryText.Add("By Year: " + settingInfo.dfbyYear.ToString()); } //根据其他设定 lvdfbyotDal otherDay = new lvdfbyotDal(); List <tlvdfbyod> lstSettingByOther = otherDay.getLeaveSettingsByOther(settingInfo.emp, _ltcd); var q1 = (from p in lstSettingByOther where p.tlvdfbyot.dfva == settingInfo.emp.GetType().GetProperty(p.tlvdfbyot.tstdefcfg.finm).GetValue(settingInfo.emp, null).ToString().Trim() where p.fryr <= settingInfo.emp.yearservice && p.toyr >= (settingInfo.emp.yearservice - 1) select p).ToList(); for (int i = 0; i < q1.Count; i++) { settingInfo.dfbyOthers += lstSettingByOther[i].days; leaveBalance += lstSettingByOther[i].days; if (lstSettingByOther[i].days > 0) { settingInfo.SummaryText.Add("By " + lstSettingByOther[i].tlvdfbyot.dftx + ": " + lstSettingByOther[i].days.ToString()); } } //取得上年结转 lvcryfwdDal carryDal = new lvcryfwdDal(); settingInfo.DaysCarry = carryDal.getCarryDaysByEmp(settingInfo.emp, _ltcd, Convert.ToDouble(DateTime.Now.Year)); leaveBalance += settingInfo.DaysCarry; if (settingInfo.DaysCarry > 0) { settingInfo.SummaryText.Add("From Carryforward: " + settingInfo.DaysCarry.ToString()); } //取得最大限制 lvlealmtDal limitDal = new lvlealmtDal(); settingInfo.WeekLimit = limitDal.GetWeeklmbyEmp(settingInfo.emp, _ltcd, HRMS_Limit_Type.LeaveHours); settingInfo.MonthLimit = limitDal.GetMonthlmbyEmp(settingInfo.emp, _ltcd, HRMS_Limit_Type.LeaveHours); settingInfo.YearLimit = limitDal.GetYearlmbyEmp(settingInfo.emp, _ltcd, HRMS_Limit_Type.LeaveHours); if (settingInfo.WeekLimit != -1) { settingInfo.SummaryText.Add("Limit in Week: " + settingInfo.WeekLimit.ToString()); } if (settingInfo.MonthLimit != -1) { settingInfo.SummaryText.Add("Limit in Month: " + settingInfo.MonthLimit.ToString()); } if (settingInfo.YearLimit != -1) { settingInfo.SummaryText.Add("Limit in Year: " + settingInfo.YearLimit.ToString()); } //取得已经休假天数 lvleaappDal appDal = new lvleaappDal(); settingInfo.WeekConsume = appDal.getWeekConsumedByEmp(settingInfo.emp, _ltcd, _leavedate); settingInfo.MonthConsume = appDal.getMonthConsumedByEmp(settingInfo.emp, _ltcd, _leavedate); settingInfo.YearConsume = appDal.getYearConsumedByEmp(settingInfo.emp, _ltcd, _leavedate); if (settingInfo.WeekLimit != -1) { settingInfo.SummaryText.Add("Consume in Week: " + (Math.Round(settingInfo.WeekConsume, 2)).ToString()); } if (settingInfo.MonthLimit != -1) { settingInfo.SummaryText.Add("Consume in Month: " + (Math.Round(settingInfo.MonthConsume, 2)).ToString()); } if (settingInfo.YearLimit != -1) { settingInfo.SummaryText.Add("Consume in Year: " + (Math.Round(settingInfo.YearConsume, 2)).ToString()); } if (settingInfo.WeekLimit != -1) { settingInfo.WeekBalance = Math.Round(settingInfo.WeekLimit - settingInfo.WeekConsume, 2); settingInfo.SummaryText.Add("Balance in Week: " + settingInfo.WeekBalance.ToString()); } if (settingInfo.MonthLimit != -1) { settingInfo.MonthBalance = Math.Round(settingInfo.MonthLimit - settingInfo.MonthConsume, 2); settingInfo.SummaryText.Add("Balance in Month: " + settingInfo.MonthBalance.ToString()); } if (settingInfo.YearLimit != -1) { settingInfo.YearBalance = Math.Round(settingInfo.YearLimit - settingInfo.YearConsume, 2); settingInfo.SummaryText.Add("Balance in Year: " + settingInfo.YearBalance.ToString()); } return(settingInfo); }
public LvSettingInfo GetEmpTTLVSettings(string _emno, string _otcd, DateTime _otdt) { LvSettingInfo settingInfo = new LvSettingInfo(); settingInfo.emp = GetSelectedObject <vw_employment>(new List <ColumnInfo>() { new ColumnInfo() { ColumnName = "emno", ColumnValue = _emno } }); //取得最大限制 otlimitDal limitDal = new otlimitDal(); settingInfo.WeekLimit = limitDal.GetWeeklmbyEmp(settingInfo.emp, _otcd, HRMS_Limit_Type.OvertimeTTLVHours); settingInfo.MonthLimit = limitDal.GetMonthlmbyEmp(settingInfo.emp, _otcd, HRMS_Limit_Type.OvertimeTTLVHours); settingInfo.YearLimit = limitDal.GetYearlmbyEmp(settingInfo.emp, _otcd, HRMS_Limit_Type.OvertimeTTLVHours); //if (settingInfo.WeekLimit != -1) // settingInfo.SummaryText.Add("Limit in Week: " + settingInfo.WeekLimit.ToString()); //if (settingInfo.MonthLimit != -1) // settingInfo.SummaryText.Add("Limit in Month: " + settingInfo.MonthLimit.ToString()); //if (settingInfo.YearLimit != -1) // settingInfo.SummaryText.Add("Limit in Year: " + settingInfo.YearLimit.ToString()); //取得已经加班小时数 otaplctnDal appDal = new otaplctnDal(); settingInfo.WeekConsume = appDal.getWeekTTLVHoursByEmp(settingInfo.emp, _otcd, _otdt); settingInfo.MonthConsume = appDal.getMonthTTLVHoursByEmp(settingInfo.emp, _otcd, _otdt); settingInfo.YearConsume = appDal.getYearTTLVHoursByEmp(settingInfo.emp, _otcd, _otdt); //if (settingInfo.WeekLimit != -1) // settingInfo.SummaryText.Add("Consume in Week: " + (Math.Round(settingInfo.WeekConsume, 2)).ToString()); //if (settingInfo.MonthLimit != -1) // settingInfo.SummaryText.Add("Consume in Month: " + (Math.Round(settingInfo.MonthConsume, 2)).ToString()); //if (settingInfo.YearLimit != -1) // settingInfo.SummaryText.Add("Consume in Year: " + (Math.Round(settingInfo.YearConsume, 2)).ToString()); if (settingInfo.WeekLimit != -1) { settingInfo.WeekBalance = Math.Round(settingInfo.WeekLimit - settingInfo.WeekConsume, 2); //settingInfo.SummaryText.Add("Balance in Week: " + settingInfo.WeekBalance.ToString()); } if (settingInfo.MonthLimit != -1) { settingInfo.MonthBalance = Math.Round(settingInfo.MonthLimit - settingInfo.MonthConsume, 2); //settingInfo.SummaryText.Add("Balance in Month: " + settingInfo.MonthBalance.ToString()); } if (settingInfo.YearLimit != -1) { settingInfo.YearBalance = Math.Round(settingInfo.YearLimit - settingInfo.YearConsume, 2); //settingInfo.SummaryText.Add("Balance in Year: " + settingInfo.YearBalance.ToString()); } settingInfo.MinBalance = Math.Min((settingInfo.WeekBalance == -1 ? 10000 : settingInfo.WeekBalance), (settingInfo.MonthBalance == -1 ? 10000 : settingInfo.MonthBalance)); settingInfo.MinBalance = Math.Min(settingInfo.MinBalance, (settingInfo.YearBalance == -1 ? 10000 : settingInfo.YearBalance)); return(settingInfo); }
public void DoCarryforward(vw_employment _emp, string _ltcd, int _yearToCarry) { try { #region get Standard Work Hours double stdWorkHours = 0; string strStdWorkHours = ((StSystemConfig)Parameter.CURRENT_SYSTEM_CONFIG).PrSWHPD; try { if (strStdWorkHours == string.Empty) { stdWorkHours = 8; } else { stdWorkHours = Convert.ToDouble(strStdWorkHours); } } catch { stdWorkHours = 8; } #endregion double leaveEntitlement = 0; double hoursToCarry = 0; LvSettingInfo settingInfo = new LvSettingInfo(); settingInfo.emp = _emp; DateTime startDate = new DateTime(_yearToCarry, 1, 1); DateTime endDate = new DateTime(_yearToCarry, 12, 31); //根据员工个人设定 lvdfbyempDal empDal = new lvdfbyempDal(); settingInfo.dfbyEmployment = empDal.getLeaveSettingsByEmp(_emp.emno, _ltcd, endDate); leaveEntitlement = settingInfo.dfbyEmployment; //根据服务年数设定 double yearDiff = DateTime.Now.Year - _yearToCarry; lvdfbyyearsDal yearDal = new lvdfbyyearsDal(); settingInfo.dfbyYear = yearDal.getLeaveSettingsByYear(_ltcd, (settingInfo.emp.yearservice.Value - yearDiff) < 0 ? 0 : (settingInfo.emp.yearservice.Value - yearDiff)); leaveEntitlement += settingInfo.dfbyYear; //根据其他设定 lvdfbyotDal otherDay = new lvdfbyotDal(); List <tlvdfbyod> lstSettingByOther = otherDay.getLeaveSettingsByOther(settingInfo.emp, _ltcd); var q1 = (from p in lstSettingByOther where p.tlvdfbyot.dfva == settingInfo.emp.GetType().GetProperty(p.tlvdfbyot.tstdefcfg.finm).GetValue(settingInfo.emp, null).ToString().Trim() where p.fryr <= ((settingInfo.emp.yearservice - yearDiff) < 0 ? 0 : (settingInfo.emp.yearservice - yearDiff)) && p.toyr >= (((settingInfo.emp.yearservice - yearDiff) - 1) < 0 ? 0 : ((settingInfo.emp.yearservice - yearDiff) - 1)) && p.tlvdfbyot.ltcd == _ltcd select p).ToList(); for (int i = 0; i < q1.Count; i++) { settingInfo.dfbyOthers += lstSettingByOther[i].days; leaveEntitlement += lstSettingByOther[i].days; } //取得上年结转 lvcryfwdDal carryDal = new lvcryfwdDal(); settingInfo.DaysCarry = carryDal.getCarryDaysByEmp(settingInfo.emp, _ltcd, startDate.Year); leaveEntitlement += settingInfo.DaysCarry; //取得最大限制 lvlealmtDal limitDal = new lvlealmtDal(); settingInfo.YearLimit = limitDal.GetYearlmbyEmp(settingInfo.emp, _ltcd, HRMS_Limit_Type.LeaveCarryforwardHours); //取得已经休假小时数 lvleaappDal appDal = new lvleaappDal(); settingInfo.YearConsume = appDal.getYearConsumedByEmp(settingInfo.emp, _ltcd, startDate); if ((settingInfo.YearLimit != -1) && (Math.Round(settingInfo.YearLimit / stdWorkHours, 2) <= (leaveEntitlement - Math.Round(settingInfo.YearConsume / stdWorkHours, 2)))) { //settingInfo.YearBalance = Math.Round(settingInfo.YearLimit - settingInfo.YearConsume, 2); hoursToCarry = settingInfo.YearLimit; } else { hoursToCarry = leaveEntitlement * stdWorkHours - settingInfo.YearConsume; } #region 保存 bool isNeedToSave = true; if (((StSystemConfig)Parameter.CURRENT_SYSTEM_CONFIG).LvINCV == "Y") { if (hoursToCarry <= 0) { hoursToCarry = 0; } } if (isNeedToSave && (settingInfo.YearConsume != 0 || leaveEntitlement != 0 || settingInfo.YearLimit != -1 || hoursToCarry != 0)) { tlvcryfwd carryForward = new tlvcryfwd(); carryForward.daro = null; carryForward.days = Math.Round(hoursToCarry / stdWorkHours, 2); carryForward.hrcs = 0; carryForward.emno = _emp.emno; carryForward.hors = hoursToCarry; carryForward.ltcd = _ltcd; carryForward.year = _yearToCarry.ToString(); carryForward.lmur = Function.GetCurrentUser(); carryForward.lmtm = DateTime.Now; carryForward.cnsu = settingInfo.YearConsume; carryForward.enti = leaveEntitlement; carryForward.limt = settingInfo.YearLimit; DoInsert <tlvcryfwd>(carryForward); } #endregion } catch (UtilException ex) { throw ex; } catch (Exception ex) { throw new UtilException(ex.Message, ex); } }