public bool SaveVacationRecordData(List <VcationRecordDL> objList) { StackFrame stackFrame = new StackFrame(); MethodBase methodBase = stackFrame.GetMethod(); try { OpenEntityConnection(); int Result = 0; if (objList != null) { foreach (var obj in objList) { // data base bind if (obj.RowStatus == 0) { } //Add else if (obj.RowStatus == 1) { Hr_EmpVactionRecord newobj = new Hr_EmpVactionRecord(); newobj.Rec_Hdr_Id = GetNewHeaderId(); newobj.Company_Id = obj.Company_Id; newobj.Branch_Id = obj.Branch_Id; newobj.Emp_Serial_No = obj.Emp_Serial_No; newobj.Rec_Order_HdrId = GetNewHeaderId(); newobj.Rec_Order_No = "0"; newobj.Request_Id = obj.Request_Id; newobj.TransDate = DateTime.Now.ToString("yyyyMMdd"); newobj.FromDate = obj.FromDate; newobj.ToDate = obj.ToDate; newobj.BackDate = Convert.ToString(obj.BackDate); newobj.Vaction_Period = obj.Vaction_Period; newobj.PlaceOfResidence = obj.PlaceOfResidence; newobj.Commissioner_Serial_no = obj.Emp_Serial_No; newobj.Reason = obj.Reason; newobj.InsUser = UserNameProperty; newobj.InsDate = DateTime.Now; newobj.DocumentPath = null; newobj.Reason = obj.Reason; newobj.MessageNotesForEmp = obj.MessageNotesForEmpeason; newobj.HireItem_Id = obj.HireItem_Id; newobj.FreeBalancRequest = obj.FreeBalancRequest; newobj.ChargeBalancRequest = obj.ChargeBalancRequest; newobj.AcuallBackDate = obj.AcuallBackDate; newobj.AcuallVaction_Peiod = obj.AcuallVaction_Peiod; newobj.Contract_Id = obj.Contract_Id; newobj.ContractPeriod_Id = obj.ContractPeriod_Id; newobj.Tot_Transferd_Period = obj.Tot_Transferd_Period; newobj.Curr_DiscVac_Period = obj.Curr_DiscVac_Period; newobj.Curr_DiscTransferd_Period = obj.Curr_DiscTransferd_Period; newobj.Prev_Vaction_Period = obj.Prev_Vaction_Period; newobj.CurrAllowedVacTillDate = obj.CurrAllowedVacTillDate; newobj.Vac_Place_Type = null; newobj.Offical_Vaction_Period = obj.Offical_Vaction_Period; newobj.VactionFromPrmEffec = obj.VactionFromPrmEffec; newobj.Confirmed = 0; objPharmaEntities.Hr_EmpVactionRecord.Add(newobj); Result = objPharmaEntities.SaveChanges(); } //Edit else if (obj.RowStatus == 2) { if (obj.Rec_Hdr_Id != Guid.Empty) { Hr_EmpVactionRecord ObjForUpdate = (from objLinq in objPharmaEntities.Hr_EmpVactionRecord where objLinq.Rec_Hdr_Id == obj.Rec_Hdr_Id select objLinq).FirstOrDefault(); if (ObjForUpdate != null) { ObjForUpdate.Emp_Serial_No = obj.Emp_Serial_No; ObjForUpdate.FromDate = obj.FromDate; ObjForUpdate.ToDate = obj.ToDate; ObjForUpdate.PlaceOfResidence = obj.PlaceOfResidence; ObjForUpdate.Reason = obj.Reason; ObjForUpdate.UpdateUser = UserNameProperty; ObjForUpdate.UpdateDate = DateTime.Now; Result = objPharmaEntities.SaveChanges(); } } else { Hr_EmpVactionRecord newobj = new Hr_EmpVactionRecord(); newobj.Rec_Hdr_Id = GetNewHeaderId(); newobj.Company_Id = obj.Company_Id; newobj.Branch_Id = obj.Branch_Id; newobj.Emp_Serial_No = obj.Emp_Serial_No; newobj.Rec_Order_HdrId = GetNewHeaderId(); newobj.Rec_Order_No = "0"; newobj.Request_Id = obj.Request_Id; newobj.TransDate = DateTime.Now.ToString("yyyyMMdd"); newobj.FromDate = obj.FromDate; newobj.ToDate = obj.ToDate; newobj.BackDate = Convert.ToString(obj.BackDate); newobj.Vaction_Period = obj.Vaction_Period; newobj.PlaceOfResidence = obj.PlaceOfResidence; newobj.Commissioner_Serial_no = obj.Emp_Serial_No; newobj.Reason = obj.Reason; newobj.InsUser = UserNameProperty; newobj.InsDate = DateTime.Now; newobj.DocumentPath = null; newobj.Reason = obj.Reason; newobj.MessageNotesForEmp = obj.MessageNotesForEmpeason; newobj.HireItem_Id = obj.HireItem_Id; newobj.FreeBalancRequest = obj.FreeBalancRequest; newobj.ChargeBalancRequest = obj.ChargeBalancRequest; newobj.AcuallBackDate = obj.AcuallBackDate; newobj.AcuallVaction_Peiod = obj.AcuallVaction_Peiod; newobj.Contract_Id = obj.Contract_Id; newobj.ContractPeriod_Id = obj.ContractPeriod_Id; newobj.Tot_Transferd_Period = obj.Tot_Transferd_Period; newobj.Curr_DiscVac_Period = obj.Curr_DiscVac_Period; newobj.Curr_DiscTransferd_Period = obj.Curr_DiscTransferd_Period; newobj.Prev_Vaction_Period = obj.Prev_Vaction_Period; newobj.CurrAllowedVacTillDate = obj.CurrAllowedVacTillDate; newobj.Vac_Place_Type = null; newobj.Offical_Vaction_Period = obj.Offical_Vaction_Period; newobj.VactionFromPrmEffec = obj.VactionFromPrmEffec; newobj.Confirmed = 0; objPharmaEntities.Hr_EmpVactionRecord.Add(newobj); Result = objPharmaEntities.SaveChanges(); } } //Delete else if (obj.RowStatus == 3) { if (obj.Rec_Hdr_Id != Guid.Empty) { Hr_EmpVactionRecord ObjForDelete = (from objLinq in objPharmaEntities.Hr_EmpVactionRecord where objLinq.Rec_Hdr_Id == obj.Rec_Hdr_Id select objLinq).FirstOrDefault(); if (ObjForDelete != null) { objPharmaEntities.Hr_EmpVactionRecord.Remove(ObjForDelete); objPharmaEntities.SaveChanges(); } } else { } } else { } } return(Result > 0); } else { return(Result < 0); } } catch (Exception ex) { catchEntityvalidation((System.Data.Entity.Validation.DbEntityValidationException)ex, System.Runtime.InteropServices.Marshal.GetExceptionCode().ToString(), this.UserNameProperty.ToString(), this.GetType().Name.ToString(), methodBase.Name.ToString()); ex.InnerException.Message.ToString(); return(false); } finally { CloseEntityConnection(); } }
public bool SaveRecordData(List <RecordsConfirmationDL> objList) { StackFrame stackFrame = new StackFrame(); MethodBase methodBase = stackFrame.GetMethod(); try { OpenEntityConnection(); int Result = 0; if (objList != null) { foreach (var obj in objList) { if (obj.Record_ID == 0) { if (obj.Rec_Hdr_Id != Guid.Empty) { Hr_EmpOverTimeRecord ObjForUpdate = (from objLinq in objPharmaEntities.Hr_EmpOverTimeRecord where objLinq.Rec_Hdr_Id == obj.Rec_Hdr_Id select objLinq).FirstOrDefault(); if (ObjForUpdate != null) { ObjForUpdate.Confirmed = 1; Result = objPharmaEntities.SaveChanges(); } } } else if (obj.Record_ID == 1) { if (obj.Rec_Hdr_Id != Guid.Empty) { Hr_EmpPermissionRecord ObjForUpdate = (from objLinq in objPharmaEntities.Hr_EmpPermissionRecord where objLinq.Rec_Hdr_Id == obj.Rec_Hdr_Id select objLinq).FirstOrDefault(); if (ObjForUpdate != null) { ObjForUpdate.Confirmed = 1; Result = objPharmaEntities.SaveChanges(); } } } else if (obj.Record_ID == 2) { if (obj.Rec_Hdr_Id != Guid.Empty) { Hr_EmpDelayRecord ObjForUpdate = (from objLinq in objPharmaEntities.Hr_EmpDelayRecord where objLinq.Rec_Hdr_Id == obj.Rec_Hdr_Id select objLinq).FirstOrDefault(); if (ObjForUpdate != null) { ObjForUpdate.Confirmed = 1; Result = objPharmaEntities.SaveChanges(); } } } else if (obj.Record_ID == 3) { if (obj.Rec_Hdr_Id != Guid.Empty) { Hr_EmpVactionRecord ObjForUpdate = (from objLinq in objPharmaEntities.Hr_EmpVactionRecord where objLinq.Rec_Hdr_Id == obj.Rec_Hdr_Id select objLinq).FirstOrDefault(); if (ObjForUpdate != null) { ObjForUpdate.Confirmed = 1; Result = objPharmaEntities.SaveChanges(); } } } else if (obj.Record_ID == 4) { if (obj.Rec_Hdr_Id != Guid.Empty) { Hr_EmpAbsenceRecord ObjForUpdate = (from objLinq in objPharmaEntities.Hr_EmpAbsenceRecord where objLinq.Rec_Hdr_Id == obj.Rec_Hdr_Id select objLinq).FirstOrDefault(); if (ObjForUpdate != null) { ObjForUpdate.Confirmed = 1; Result = objPharmaEntities.SaveChanges(); } } } else { } } return(Result > 0); } else { return(Result < 0); } } catch (Exception ex) { catchEntityvalidation((System.Data.Entity.Validation.DbEntityValidationException)ex, System.Runtime.InteropServices.Marshal.GetExceptionCode().ToString(), this.UserNameProperty.ToString(), this.GetType().Name.ToString(), methodBase.Name.ToString()); ex.InnerException.Message.ToString(); return(false); } finally { CloseEntityConnection(); } }