public int UpEmployeeAnnualDays(EmployeeAnnualLeave data, AnnualDaysOffset offsetData) { using (var trans = _DbContext.Database.BeginTransaction()){ var count = 0; try { if (offsetData.reason == "" || offsetData.reason == null) { return(0); } _DbContext.annualdaysoffset.Add(offsetData); count = _DbContext.SaveChanges(); if (count == 0) { return(0); } var oDic = new Dictionary <string, string> { }; var nDic = new Dictionary <string, string> { }; var opLog = new OperateLog() { operateID = data.lastOperaAccID, active = "更新", category = "特休", createTime = definePara.dtNow() }; var context = _DbContext.employeeannualleaves.FirstOrDefault(b => b.ID == data.ID); if (context != null) { toNameFn.AddUpEmployeeAnnualDays_convertToDic(ref oDic, context); opLog.employeeID = context.employeeID; context.remainHours = data.remainHours; context.deadLine = data.deadLine; context.lastOperaAccID = data.lastOperaAccID; context.updateTime = data.updateTime; count = _DbContext.SaveChanges(); } if (count == 1) { toNameFn.AddUpEmployeeAnnualDays_convertToDic(ref nDic, context); opLog.content = toNameFn.AddUpEmployeeAnnualDays_convertToText(nDic, oDic); opLog.content += $",原因:{offsetData.reason}"; //主管調整員工餘額 saveOperateLog(opLog); //紀錄操作紀錄 } trans.Commit(); } catch (Exception ex) { count = catchErrorProcess(ex, count); } return(count); }//using }
public int addUpAnnualStatus(EmployeeAnnualLeave annualData, AnnualDaysOffset offsetData) { offsetData.createTime = annualData.updateTime = definePara.dtNow(); offsetData.lastOperaAccID = annualData.lastOperaAccID = (int)loginID; var isLegal = aRepository.chkDeadLineLength(annualData); var res = 0; if (isLegal) { res = aRepository.UpEmployeeAnnualDays(annualData, offsetData); } return(res); }