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); } }
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 lvcryfwdBll() { dal = new lvcryfwdDal(); baseDal = dal; }