public Hr_EmpBorrow_Settings GetBorrowSettingDataByBranchandCompany(string strCompany_Id, string strBranch_Id) { StackFrame stackFrame = new StackFrame(); MethodBase methodBase = stackFrame.GetMethod(); try { OpenEntityConnection(); Hr_EmpBorrow_Settings ObjEmpBorrow_Settings = (from objLinq in objPharmaEntities.Hr_EmpBorrow_Settings where objLinq.Company_Id == strCompany_Id && objLinq.Branch_Id == strBranch_Id select objLinq).FirstOrDefault(); if (ObjEmpBorrow_Settings != null) { Hr_EmpBorrow_Settings objEmpBorrow_SettingsDL = new Hr_EmpBorrow_Settings(); { objEmpBorrow_SettingsDL.Branch_Id = ObjEmpBorrow_Settings.Branch_Id; objEmpBorrow_SettingsDL.Company_Id = ObjEmpBorrow_Settings.Company_Id; objEmpBorrow_SettingsDL.AllowedValueNotExceedTo = ObjEmpBorrow_Settings.AllowedValueNotExceedTo; objEmpBorrow_SettingsDL.AllowExceedMaxValue = ObjEmpBorrow_Settings.AllowExceedMaxValue; } return(objEmpBorrow_SettingsDL); } else { return(null); } } 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(null); } finally { CloseEntityConnection(); } }
public bool SaveBorrowSettingData(Hr_EmpBorrow_Settings objList) { StackFrame stackFrame = new StackFrame(); MethodBase methodBase = stackFrame.GetMethod(); try { OpenEntityConnection(); int Result = 0; // string emSerialNo = (objList.EmpSerialForDocNotify == null ? 0 : objList.EmpSerialForDocNotify).ToString(); Hr_EmpBorrow_Settings ObjForUpdate = (from objLinq in objPharmaEntities.Hr_EmpBorrow_Settings where objLinq.Company_Id == objList.Company_Id && objLinq.Branch_Id == objList.Branch_Id select objLinq).FirstOrDefault(); if (ObjForUpdate != null) { ObjForUpdate.AllowedValueNotExceedTo = objList.AllowedValueNotExceedTo; ObjForUpdate.AllowExceedMaxValue = objList.AllowExceedMaxValue; Result = objPharmaEntities.SaveChanges(); return(Result > 0); } else { if (objList != null) { Hr_EmpBorrow_Settings loclDtls = new Hr_EmpBorrow_Settings { Branch_Id = objList.Branch_Id, Company_Id = objList.Company_Id, AllowedValueNotExceedTo = objList.AllowedValueNotExceedTo, AllowExceedMaxValue = objList.AllowExceedMaxValue, }; objPharmaEntities.Hr_EmpBorrow_Settings.Add(loclDtls); //saves all above operations within one transaction Result = objPharmaEntities.SaveChanges(); return(Result > 0); } else { return(false); } } } 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(); } }