///<summary> /// 合并同年调休 ///</summary> public static List <AdjustRest> InitUpdateAdjustRestList(List <AdjustRest> adjustRestList) { List <AdjustRest> UpdateadjustRestList = new List <AdjustRest>(); foreach (AdjustRest rest in adjustRestList) { AdjustRest findrest = Contain(rest.AdjustYear, UpdateadjustRestList); if (findrest != null) { findrest.SurplusHours += rest.SurplusHours; } else { //判断是不是12月21号以后 if (rest.AdjustYear.Month == AdjustRestUtility.StartTime.Month && rest.AdjustYear.Day >= AdjustRestUtility.StartTime.Day) { AdjustRest r = new AdjustRest(); r.AdjustYear = rest.AdjustYear.AddYears(1); r.SurplusHours = rest.SurplusHours; UpdateadjustRestList.Add(r); } else { UpdateadjustRestList.Add(rest); } } } return(UpdateadjustRestList); }
/// <summary> /// 通过时间查询某个员工有效的调休值,没有则返回0 /// </summary> public AdjustRest GetAdjustRestByAccountIDAndTime(int accountid, DateTime dt) { AdjustRest retAdjustRest; //判断是不是12月21号以后 if (dt.Month == AdjustRestUtility.StartTime.Month && dt.Day >= AdjustRestUtility.StartTime.Day) { dt = dt.AddYears(1); } retAdjustRest = _IAdjustRestDal.GetAdjustRestByAccountIDAndYear(accountid, dt); if (retAdjustRest == null) { retAdjustRest = new AdjustRest(0, 0, null, dt); } if (dt.Date <= new DateTime(dt.Year, AdjustRestUtility.AvailableTime.Month, AdjustRestUtility.AvailableTime.Day) || (dt.Month == AdjustRestUtility.StartTime.Month && dt.Day >= AdjustRestUtility.StartTime.Day)) { retAdjustRest.SurplusHours += _IAdjustRestDal.GetAdjustRestByAccountIDAndYear(accountid, dt.AddYears(-1)).SurplusHours; } return(retAdjustRest); }
/// <summary> /// /// </summary> public void Excute() { if (!string.IsNullOrEmpty(_LeaveRequestItem.UseList)) { string[] detail = _LeaveRequestItem.UseList.Split('/'); if (detail != null) { foreach (string s in detail) { string[] use = s.Split(','); if (use != null && use.Length == 2) { int adjustid = Convert.ToInt32(use[0]); decimal deletehour = Convert.ToDecimal(use[1]); AdjustRest adjustrest = _IAdjustRest.GetAdjustRestByPKID(adjustid); if (adjustrest != null) { adjustrest.SurplusHours += deletehour; _IAdjustRest.UpdateAdjustRest(adjustrest); } } } CreateHistory(); } } }
/// <summary> /// 根据员工ID获得调休信息,不包括历史信息 /// </summary> /// <param name="accountID"></param> /// <returns></returns> public AdjustRest GetAdjustRestBasicInfoByAccountID(int accountID) { AdjustRest retAdjustRest = GetNowAdjustRestByAccountID(accountID); retAdjustRest.Employee = new Employee(accountID, EmployeeTypeEnum.All); retAdjustRest.Employee = _GetEmployee.GetEmployeeBasicInfoByAccountID(accountID); return(retAdjustRest); }
private void SaveEvent() { try { if (_View.CheckValidResult) { int failCount = 0; int successCount = 0; int outofdateCount = 0; string outofdateMsg = string.Empty; List <AdjustRest> adjustRestList = _View.AdjustRestChangeValueSource; foreach (AdjustRest adjustRest in adjustRestList) { try { AdjustRest currAdjustRest = _IEmployeeAttendanceFacade.GetAdjustRestByPKID(adjustRest.AdjustRestID); if (currAdjustRest.SurplusHours != _View.GetOldSurplusHours(adjustRest.AdjustRestID)) { _View.OperationResultColorSet(adjustRest.AdjustRestID, OperationResult.OutOfDate, currAdjustRest.SurplusHours); outofdateCount++; outofdateMsg += "<br>" + currAdjustRest.Employee.Account.Name + "的剩余调休已被更新为" + currAdjustRest.SurplusHours; failCount++; continue; } _IEmployeeAttendanceFacade.UpdateAdjustRest(adjustRest.AdjustRestID, adjustRest.SurplusHours, adjustRest.AdjustRestHistoryList[0].Remark, _Operator.Id); _View.OperationResultColorSet(adjustRest.AdjustRestID, OperationResult.Success, 0); successCount++; } catch { failCount++; _View.OperationResultColorSet(adjustRest.AdjustRestID, OperationResult.Fail, 0); } } _View.ResultMsg = successCount + " 条记录修改成功," + failCount + " 条记录修改失败。"; if (outofdateCount > 0) { _View.ResultMsg += "其中有" + outofdateCount + " 条记录已被他人修改。具体情况如下,请查实后保存更新:" + outofdateMsg; } } else { _View.ResultMsg = "保存失败,数据格式不正确,或者没有填写修改原因"; } } catch (Exception ex) { _View.ResultMsg = ex.Message; } }
/// <summary> /// 初始化调休,将加班信息变成一条条调休记录 /// </summary> /// <returns></returns> private List <AdjustRest> InitAdjustRestList() { List <AdjustRest> adjustRestList = new List <AdjustRest>(); AdjustRest ar = new AdjustRest(); ar.AdjustYear = _OverWorkItem.FromDate; ar.SurplusHours = _OverWorkItem.AdjustHour;//_OverWorkItem.CostTime*GetMagnification(_OverWorkItem, _AdjustRule); adjustRestList.Add(ar); return(adjustRestList); }
private static int Update(AdjustRest adjustrest) { SqlCommand cmd = new SqlCommand(); cmd.Parameters.Add(_PKID, SqlDbType.Int).Value = adjustrest.AdjustRestID; cmd.Parameters.Add(_AccountID, SqlDbType.Int).Value = adjustrest.Employee.Account.Id; cmd.Parameters.Add(_Hours, SqlDbType.Decimal).Value = adjustrest.SurplusHours; cmd.Parameters.Add(_AdjustYear, SqlDbType.DateTime).Value = new DateTime(adjustrest.AdjustYear.Year, 1, 1); return(SqlHelper.ExecuteNonQuery("UpdateAdjustRestByAdjustID", cmd)); }
/// <summary> /// /// </summary> /// <param name="pkid"></param> /// <returns></returns> public AdjustRest GetAdjustRestByPKID(int pkid) { AdjustRest retAdjustRest = _IAdjustRestDal.GetAdjustRestByPKID(pkid); retAdjustRest.Employee = new Employee(retAdjustRest.Employee.Account.Id, EmployeeTypeEnum.All); retAdjustRest.Employee = _GetEmployee.GetEmployeeBasicInfoByAccountID(retAdjustRest.Employee.Account.Id); retAdjustRest.AdjustRestHistoryList = _GetAdjustRestHistory.GetAdjustRestHistoryByAccountID(retAdjustRest.Employee.Account.Id); return(retAdjustRest); }
private List <AdjustRest> InitAdjustRestListIner() { List <AdjustRest> adjustRestList = new List <AdjustRest>(); AdjustRest ar = new AdjustRest(); ar.AdjustYear = _OutApplicationItem.ToDate; ar.SurplusHours = _OutApplicationItem.AdjustHour; adjustRestList.Add(ar); return(adjustRestList); }
public void DataBind(string accountID) { AdjustRest theDataToBind = _IEmployeeAttendanceFacade.GetAdjustRestByAccountID(Convert.ToInt32(accountID)); if (theDataToBind != null) { _ItsView.SurplusHours = theDataToBind.SurplusHours.ToString(); _ItsView.EmployeeName = theDataToBind.Employee.Account.Name; _ItsView.AdjustRestHistorySource = theDataToBind.AdjustRestHistoryList; _ItsView.AccountID = theDataToBind.Employee.Account.Id; } }
/// <summary> /// /// </summary> public int InsertAdjustRest(AdjustRest adjustRest) { int pkid; SqlCommand cmd = new SqlCommand(); cmd.Parameters.Add(_PKID, SqlDbType.Int).Direction = ParameterDirection.Output; cmd.Parameters.Add(_AccountID, SqlDbType.Int).Value = adjustRest.Employee.Account.Id; cmd.Parameters.Add(_Hours, SqlDbType.Decimal).Value = adjustRest.SurplusHours; cmd.Parameters.Add(_AdjustYear, SqlDbType.DateTime).Value = new DateTime(adjustRest.AdjustYear.Year, 1, 1); SqlHelper.ExecuteNonQueryReturnPKID("AdjustRestInsert", cmd, out pkid); return(pkid); }
public AdjustRest GetAdjustRestByAccountIDAndYear(int accountid, DateTime adjustYear) { bool hasValue; AdjustRest adjustrest = Get(accountid, adjustYear, out hasValue); if (!hasValue) { adjustrest = new AdjustRest(0, 0, new Employee(accountid, EmployeeTypeEnum.All), adjustYear); adjustrest.AdjustRestID = InsertAdjustRest(adjustrest); } return(adjustrest); }
public AdjustRest GetAdjustRestByPKID(int adjustID) { AdjustRest adjustRest = null; SqlCommand cmd = new SqlCommand(); cmd.Parameters.Add(_PKID, SqlDbType.Int).Value = adjustID; using (SqlDataReader sdr = SqlHelper.ExecuteReader("GetAdjustRestByPKID", cmd)) { if (sdr.Read()) { adjustRest = GetFieldFromParm(sdr); } } return(adjustRest); }
/// <summary> /// 更新调休 /// </summary> public int UpdateAdjustRest(AdjustRest adjustRest) { int count = 1; bool hasValue; Get(adjustRest.Employee.Account.Id, adjustRest.AdjustYear, out hasValue); if (hasValue) { count = Update(adjustRest); } else { InsertAdjustRest(adjustRest); } return(count); }
private List <AdjustRest> InitDayAttendanceList(LeaveRequestItem item) { List <AdjustRest> adjustRestList = new List <AdjustRest>(); CalculateCostHour cal = new CalculateCostHour(item.FromDate, item.ToDate, _AccountID, Convert.ToInt32(LeaveRequestTypeEnum.AdjustRest)); cal.Excute(); foreach (DayAttendance attendance in cal.DayAttendanceList) { AdjustRest ar = new AdjustRest(); ar.AdjustYear = attendance.Date; ar.SurplusHours = attendance.Hours; adjustRestList.Add(ar); } return(adjustRestList); }
/// <summary> /// 所有GET数据绑定 /// </summary> private static AdjustRest GetFieldFromParm(IDataRecord sdr) { AdjustRest adjustRest = new AdjustRest(); for (int i = 0; i < sdr.FieldCount; i++) { int tryIntParse; switch (sdr.GetName(i)) { case _DBPKID: if (sdr[_DBPKID] != null && int.TryParse(sdr[_DBPKID].ToString(), out tryIntParse)) { adjustRest.AdjustRestID = (int)sdr[_DBPKID]; } break; case _DBAccountID: if (sdr[_DBAccountID] != null && int.TryParse(sdr[_DBAccountID].ToString(), out tryIntParse)) { adjustRest.Employee = adjustRest.Employee ?? new Employee((int)sdr[_DBAccountID], EmployeeTypeEnum.All); } break; case _DbHours: decimal tryDecimalParse; if (sdr[_DbHours] != null && decimal.TryParse(sdr[_DbHours].ToString(), out tryDecimalParse)) { adjustRest.SurplusHours = (decimal)sdr[_DbHours]; } break; case _DBAdjustYear: if (sdr[_DBAdjustYear] != null) { adjustRest.AdjustYear = Convert.ToDateTime(sdr[_DBAdjustYear]); } break; default: break; } } return(adjustRest); }
/// <summary> /// 更新调休 /// </summary> /// <param name="operatorType"></param> /// <param name="UpdateadjustRestList"></param> private void UpdateAdjustRestDB(OperatorType operatorType, IEnumerable <AdjustRest> UpdateadjustRestList) { foreach (AdjustRest rest in UpdateadjustRestList) { AdjustRest adjustRest = _IAdjustRest.GetAdjustRestByAccountIDAndYear(_AccountID, rest.AdjustYear); if (operatorType == OperatorType.add) { adjustRest.SurplusHours = adjustRest.SurplusHours + rest.SurplusHours; //获得调休 _ChangeHour += rest.SurplusHours; } else if (operatorType == OperatorType.delete) { adjustRest.SurplusHours = adjustRest.SurplusHours - rest.SurplusHours; //返还调休 _ChangeHour += rest.SurplusHours; } _IAdjustRest.UpdateAdjustRest(adjustRest); } }
///<summary> /// 初始化有多少个要更改的adjustrest ///</summary> public static List <AdjustRest> InitUpdateAdjustRestList(List <AdjustRest> adjustRestList) { List <AdjustRest> UpdateadjustRestList = new List <AdjustRest>(); foreach (AdjustRest rest in adjustRestList) { AdjustRest findrest = ContainByYear(rest.AdjustYear, UpdateadjustRestList); if (findrest == null) { //判断是不是12月21号以后 if (rest.AdjustYear.Month == AdjustRestUtility.StartTime.Month && rest.AdjustYear.Day >= AdjustRestUtility.StartTime.Day) { AdjustRest r = new AdjustRest(); r.AdjustYear = rest.AdjustYear.AddYears(1); r.SurplusHours = rest.SurplusHours; UpdateadjustRestList.Add(r); } else { UpdateadjustRestList.Add(rest); } } if (rest.AdjustYear.Date <= new DateTime(WhichYear(rest.AdjustYear), AdjustRestUtility.AvailableTime.Month, AdjustRestUtility.AvailableTime.Day) && rest.AdjustYear.Date >= new DateTime(WhichYear(rest.AdjustYear) - 1, AdjustRestUtility.StartTime.Month, AdjustRestUtility.StartTime.Day)) { if ( ContainByYear( new DateTime(WhichYear(rest.AdjustYear) - 1, 1, 1), UpdateadjustRestList) == null) { UpdateadjustRestList.Add( new AdjustRest(0, rest.SurplusHours, rest.Employee, new DateTime(WhichYear(rest.AdjustYear) - 1, 1, 1))); } } } return(UpdateadjustRestList); }
private static AdjustRest Get(int accountID, DateTime adjustYear, out bool hasvalue) { AdjustRest adjustRest = null; SqlCommand cmd = new SqlCommand(); cmd.Parameters.Add(_AccountID, SqlDbType.Int).Value = accountID; cmd.Parameters.Add(_AdjustYear, SqlDbType.DateTime).Value = adjustYear; using (SqlDataReader sdr = SqlHelper.ExecuteReader("GetAdjustRestByAccountIDAndYear", cmd)) { if (sdr.Read()) { adjustRest = GetFieldFromParm(sdr); hasvalue = true; } else { hasvalue = false; } } return(adjustRest); }
private List <AdjustRest> GetChangeValueFromGridView() { List <AdjustRest> _retAdjustRestList = new List <AdjustRest>(); for (int i = 0; i < gvEmployeeAdjustRest.Rows.Count; i++) { AdjustRest itemAdjustRest = new AdjustRest(); HiddenField hfAccountID = (HiddenField)gvEmployeeAdjustRest.Rows[i].FindControl("hfAccountID"); HiddenField hfAdjustRestID = (HiddenField)gvEmployeeAdjustRest.Rows[i].FindControl("hfAdjustRestID"); HiddenField hfOldSurplusHours = (HiddenField)gvEmployeeAdjustRest.Rows[i].FindControl("hfOldSurplusHours"); TextBox txtSurplusHours = (TextBox)gvEmployeeAdjustRest.Rows[i].FindControl("txtSurplusHours"); TextBox txtReason = (TextBox)gvEmployeeAdjustRest.Rows[i].FindControl("txtReason"); if (Convert.ToDecimal(txtSurplusHours.Text.Trim()) == Convert.ToDecimal(hfOldSurplusHours.Value) && string.IsNullOrEmpty(txtReason.Text.Trim())) { continue; } itemAdjustRest.Employee = new HRMISModel.Employee(Convert.ToInt32(hfAccountID.Value), EmployeeTypeEnum.All); itemAdjustRest.AdjustRestID = Convert.ToInt32(hfAdjustRestID.Value); decimal decimalAdjustRest; if (!decimal.TryParse(txtSurplusHours.Text.Trim(), out decimalAdjustRest)) { txtSurplusHours.CssClass = "inputred1"; throw new Exception("格式错误"); } itemAdjustRest.SurplusHours = decimalAdjustRest; itemAdjustRest.AdjustRestHistoryList = new List <AdjustRestHistory>(); itemAdjustRest.AdjustRestHistoryList.Add(new AdjustRestHistory()); itemAdjustRest.AdjustRestHistoryList[0].Remark = txtReason.Text.Trim(); _retAdjustRestList.Add(itemAdjustRest); } return(_retAdjustRestList); }
/// <summary> /// 初始化调休,将出差信息变成一条条调休记录 /// </summary> /// <returns></returns> private List <AdjustRest> InitAdjustRestList() { List <AdjustRest> adjustRestList = new List <AdjustRest>(); DateTime from = _OutApplicationItem.FromDate; DateTime to = _OutApplicationItem.ToDate; CalculateDays _CalculateDays = new CalculateDays(BllInstance.SpecialDateBllInstance.GetAllSpecialDate(null)); List <PlanDutyDetail> _PlanDutyDetailList = new PlanDutyDal().GetPlanDutyDetailByAccount(_AccountID, from, to); CalculateOutCityHour calculateOutCityHour = new CalculateOutCityHour(from, to, _AccountID); calculateOutCityHour.Excute(); foreach (DayAttendance attendance in calculateOutCityHour.DayAttendanceList) { PlanDutyDetail planDutyDetail = PlanDutyDetail.GetPlanDutyDetailByDate(_PlanDutyDetailList, attendance.Date); AdjustRest ar = new AdjustRest(); ar.AdjustYear = attendance.Date; if (_CalculateDays.IsNationalHoliday(attendance.Date)) { //节日 ar.SurplusHours = attendance.Hours * _AdjustRule.OutCityJieRiRate; } else if (planDutyDetail.PlanDutyClass.IsWeek) { //双休 ar.SurplusHours = attendance.Hours * _AdjustRule.OutCityShuangXiuRate; } else { //普通 ar.SurplusHours = 0; //attendance.Hours*_AdjustRule.OutCityPuTongRate; } adjustRestList.Add(ar); } return(adjustRestList); }
public List <AdjustRest> GetAdjustRestByAccountID(int accountID) { List <AdjustRest> iRet = new List <AdjustRest>(); SqlCommand cmd = new SqlCommand(); cmd.Parameters.Add(_AccountID, SqlDbType.Int).Value = accountID; try { using (SqlDataReader sdr = SqlHelper.ExecuteReader("GetAdjustRestByAccountID", cmd)) { while (sdr.Read()) { AdjustRest adjustRest = GetFieldFromParm(sdr); iRet.Add(adjustRest); } } return(iRet); } catch { throw new ApplicationException(_DBError); } }
private void InitAdjustRest() { _AdjustRest = _IAdjustRest.GetAdjustRestByPKID(_AdjustRestID); }
/// <summary> /// 更新调休 /// </summary> private void UpdateAdjustRestDB(IEnumerable <AdjustRest> UpdateadjustRestList, bool isupdate) { _LeaveRequestItem.UseList = ""; //初始化要扣除的调休 List <AdjustRest> adjustRestList = new List <AdjustRest>(); foreach (AdjustRest rest in UpdateadjustRestList) { AdjustRest adjustRest = _IAdjustRest.GetAdjustRestByAccountIDAndYear(_AccountID, rest.AdjustYear); adjustRestList.Add(adjustRest); } if (adjustRestList.Count > 0) { foreach (AdjustRest rest in _AdjustRestDay) { AdjustRest adjustFirst = ContainByYear(rest.AdjustYear, adjustRestList); AdjustRest adjustSecond = Contain(rest.AdjustYear, adjustRestList); //同年说明只扣一条记录 if (adjustFirst.AdjustYear.Year == adjustSecond.AdjustYear.Year) { adjustFirst.SurplusHours -= rest.SurplusHours; adjustFirst.ChangeHours += rest.SurplusHours; } else { //不同年则扣第二年的记录,如果扣不了,则还是扣第一年的记录 decimal chagehour = adjustSecond.SurplusHours - rest.SurplusHours; if (chagehour < 0) { if (adjustSecond.SurplusHours > 0) { adjustFirst.SurplusHours += chagehour; adjustFirst.ChangeHours += (-chagehour); adjustSecond.ChangeHours += adjustSecond.SurplusHours; adjustSecond.SurplusHours = 0; } else { adjustFirst.SurplusHours -= rest.SurplusHours; adjustFirst.ChangeHours += rest.SurplusHours; } } else { adjustSecond.ChangeHours += rest.SurplusHours; adjustSecond.SurplusHours = chagehour; } } } foreach (AdjustRest rest in adjustRestList) { if (rest.SurplusHours < 0) { HrmisUtility.ThrowException("剩余调休不足"); } if (isupdate) { _IAdjustRest.UpdateAdjustRest(rest); _LeaveRequestItem.UseList = string.Format("{0},{1}/{2}", rest.AdjustRestID, rest.ChangeHours, _LeaveRequestItem.UseList); } } if (isupdate) { //记录下使用情况 _LeaveRequestDal.UpdateLeaveRequestItemUseDetail(_LeaveRequestItem); } } else { HrmisUtility.ThrowException("剩余调休不足"); } }