public SavingResult SaveSettingL0(string SettingName, object SettingValue) { SavingResult res = new SavingResult(); //-- using (dbVisionEntities db = new dbVisionEntities()) { tblSettingL0 SaveModel = SaveSettingL0(SettingName, SettingValue, db, res); if (res.ExecutionResult == eExecutionResult.ValidationError) { return(res); } //-- try { db.SaveChanges(); res.PrimeKeyValue = SaveModel.SettingL0ID; res.ExecutionResult = eExecutionResult.CommitedSucessfuly; } catch (Exception ex) { CommonFunctions.GetFinalError(res, ex); } } return(res); }
public SavingResult SaveMinimumWageCategoryRate(List <MinimumWageCategoryRateChangeListModel> Rates, DateTime?WEFDate) { DateTime? PreviousDate = null; SavingResult res = new SavingResult(); using (dbVisionEntities db = new dbVisionEntities()) { if (WEFDate == null) { db.tblMinimumWageRates.RemoveRange( from r in db.tblMinimumWageRates join mc in db.tblMinimumWageCategories on r.MinimumWageCategoryID equals mc.MinimumWageCategoryID where mc.CompanyID == CommonProperties.LoginInfo.LoggedInCompany.CompanyID select r); } else { PreviousDate = WEFDate.Value.AddDays(-1); foreach (var rate in Rates) { var PreviousRates = db.tblMinimumWageRates.Where(r => r.MinimumWageCategoryID == rate.MinimumWageCategoryID && (r.WEDateTo == null || r.WEDateTo >= WEFDate)); foreach (var prate in PreviousRates) { prate.WEDateTo = PreviousDate; db.tblMinimumWageRates.Attach(prate); db.Entry(prate).State = System.Data.Entity.EntityState.Modified; } db.tblMinimumWageRates.RemoveRange(db.tblMinimumWageRates.Where(r => r.MinimumWageCategoryID == rate.MinimumWageCategoryID && r.WEDateFrom >= WEFDate)); } } db.tblMinimumWageRates.AddRange(Rates.Where(r => r.RuralRate != 0 || r.UrbanRate != 0).Select(r => new tblMinimumWageRate() { MinimumWageCategoryID = r.MinimumWageCategoryID, MinimumWageCategoryRuralRate = r.RuralRate, MinimumWageCategoryUrbanRate = r.UrbanRate, WEDateFrom = WEFDate, rcdt = DateTime.Now, rcuid = CommonProperties.LoginInfo.LoggedinUser.UserID, })); try { db.SaveChanges(); res.ExecutionResult = eExecutionResult.CommitedSucessfuly; } catch (Exception ex) { CommonFunctions.GetFinalError(res, ex); } } return(res); }
public SavingResult UpdateTACode(int EmployeeID, int TACode) { SavingResult res = new SavingResult(); using (dbVisionEntities db = new dbVisionEntities()) { var SaveModel = db.tblEmployees.FirstOrDefault(r => r.EmployeeID == EmployeeID); if (SaveModel == null) { res.ExecutionResult = eExecutionResult.ValidationError; res.ValidationError = "Employee not found."; return(res); } SaveModel.TACode = TACode; db.tblEmployees.Attach(SaveModel); db.Entry(SaveModel).State = System.Data.Entity.EntityState.Modified; try { db.SaveChanges(); res.ExecutionResult = eExecutionResult.CommitedSucessfuly; } catch (Exception ex) { CommonFunctions.GetFinalError(res, ex); } } //-- return(res); }
public SavingResult SaveNewRecord(tblPayrollMonth SaveModel) { SavingResult res = new SavingResult(); using (dbVisionEntities db = new dbVisionEntities()) { SaveModel.rcuid = (Model.CommonProperties.LoginInfo.LoggedinUser != null ? (int?)Model.CommonProperties.LoginInfo.LoggedinUser.UserID : null); SaveModel.rcdt = DateTime.Now; db.tblPayrollMonths.Add(SaveModel); db.Entry(SaveModel).State = System.Data.Entity.EntityState.Added; //-- try { db.SaveChanges(); res.PrimeKeyValue = SaveModel.PayrollMonthID; res.ExecutionResult = eExecutionResult.CommitedSucessfuly; } catch (Exception ex) { CommonFunctions.GetFinalError(res, ex); return(res); } } return(res); }
public SavingResult SaveLogoFileName(int CompanyID, string FileName) { SavingResult res = new SavingResult(); using (dbVisionEntities db = new dbVisionEntities()) { var SaveModel = db.tblCompanies.Find(CompanyID); if (SaveModel == null) { res.ExecutionResult = eExecutionResult.ValidationError; res.ValidationError = "Selected company not found. It may be deleted over network. Please check again or contact your administrator."; return(res); } SaveModel.CompanyLogoFileName = FileName; db.tblCompanies.Attach(SaveModel); db.Entry(SaveModel).State = System.Data.Entity.EntityState.Modified; //-- try { db.SaveChanges(); res.PrimeKeyValue = SaveModel.CompanyID; res.ExecutionResult = eExecutionResult.CommitedSucessfuly; } catch (Exception ex) { CommonFunctions.GetFinalError(res, ex); } return(res); } }
public SavingResult SaveDataReceiverErrorLog(string Message, string Error) { SavingResult res = new SavingResult(); using (dbVisionEntities db = new dbVisionEntities()) { db.tblDataReceiverErrorLogs.Add(new tblDataReceiverErrorLog() { Message = Message, Error = Error, rcdt = DateTime.Now }); try { db.SaveChanges(); res.ExecutionResult = eExecutionResult.CommitedSucessfuly; } catch (Exception ex) { CommonFunctions.GetFinalError(res, ex); } } return(res); }
public SavingResult SaveEmployeeProfileImageFileName(int EmployeeID, string ImageFileName) { SavingResult res = new SavingResult(); using (dbVisionEntities db = new dbVisionEntities()) { var SaveModel = db.tblEmployees.Find(EmployeeID); if (SaveModel == null) { res.ExecutionResult = eExecutionResult.ValidationError; res.ValidationError = "Selected record is not found."; return(res); } SaveModel.EmployeeImageFileName = ImageFileName; try { db.SaveChanges(); res.ExecutionResult = eExecutionResult.CommitedSucessfuly; } catch (Exception ex) { CommonFunctions.GetFinalError(res, ex); } } return(res); }
public SavingResult SaveNewRecord(tblTAApproval SaveModel) { SavingResult res = new SavingResult(); //-- Perform Validation //res.ExecutionResult = eExecutionResult.ValidationError; //res.ValidationError = "Validation error message"; //return res; //-- using (dbVisionEntities db = new dbVisionEntities()) { SaveNewRecord(SaveModel, db); //-- try { db.SaveChanges(); res.PrimeKeyValue = SaveModel.TAApprovalID; res.ExecutionResult = eExecutionResult.CommitedSucessfuly; } catch (Exception ex) { CommonFunctions.GetFinalError(res, ex); } } return(res); }
public SavingResult ChangePassworD(int UserID, string NewPassword) { SavingResult res = new SavingResult(); using (dbVisionEntities db = new dbVisionEntities()) { var user = db.tblUsers.Find(UserID); if (user == null) { return(null); } user.Password = NewPassword; db.tblUsers.Attach(user); db.Entry(user).State = System.Data.Entity.EntityState.Modified; //-- try { db.SaveChanges(); res.ExecutionResult = eExecutionResult.CommitedSucessfuly; } catch (Exception ex) { CommonFunctions.GetFinalError(res, ex); } } return(res); }
public SavingResult SaveNewRecord(tblEmployeeDepartment SaveModel) { SavingResult res = new SavingResult(); //-- Perform Validation //res.ExecutionResult = eExecutionResult.ValidationError; //res.ValidationError = "Validation error message"; //return res; //-- using (dbVisionEntities db = new dbVisionEntities()) { //tblEmployeeDepartment SaveModel; if (String.IsNullOrWhiteSpace(SaveModel.EmployeeDepartmentName)) { res.ValidationError = "Can not accept blank value. Please enter Employee Department Name."; res.ExecutionResult = eExecutionResult.ValidationError; return(res); } else if (IsDuplicateRecord(SaveModel.EmployeeDepartmentName, SaveModel.EmployeeDepartmentID, db)) { res.ValidationError = "Can not accept duplicate value. The Employee Department Name is already exists."; res.ExecutionResult = eExecutionResult.ValidationError; return(res); } if (SaveModel.EmployeeDepartmentID == 0) // New Entry { SaveModel.rstate = (byte)eRecordState.Active; SaveModel.CompanyID = CommonProperties.LoginInfo.LoggedInCompany.CompanyID; SaveModel.rcuid = CommonProperties.LoginInfo.LoggedinUser.UserID; SaveModel.rcdt = DateTime.Now; db.tblEmployeeDepartments.Add(SaveModel); } else { SaveModel.reuid = CommonProperties.LoginInfo.LoggedinUser.UserID; SaveModel.redt = DateTime.Now; db.tblEmployeeDepartments.Attach(SaveModel); db.Entry(SaveModel).State = System.Data.Entity.EntityState.Modified; } //-- //-- try { db.SaveChanges(); res.PrimeKeyValue = SaveModel.EmployeeDepartmentID; res.ExecutionResult = eExecutionResult.CommitedSucessfuly; } catch (Exception ex) { CommonFunctions.GetFinalError(res, ex); } } return(res); }
public SavingResult SaveNewRecord(tblLeaveEncashment SaveModel) { SavingResult res = new SavingResult(); //-- Perform Validation //res.ExecutionResult = eExecutionResult.ValidationError; //res.ValidationError = "Validation error message"; //return res; //-- using (dbVisionEntities db = new dbVisionEntities()) { //tblLeaveEncashment SaveModel; if (SaveModel.LeaveEncashmentNo == 0) { res.ValidationError = "Please enter Leave Application No.."; res.ExecutionResult = eExecutionResult.ValidationError; return(res); } else if (IsDuplicateRecord(SaveModel.LeaveEncashmentNoPrefixID, SaveModel.LeaveEncashmentNo, SaveModel.LeaveEncashmentID, db)) { res.ValidationError = "Can not accept duplicate value. The Leave Application No. is already exists."; res.ExecutionResult = eExecutionResult.ValidationError; return(res); } if (SaveModel.LeaveEncashmentID == 0) // New Entry { SaveModel.rcuid = Model.CommonProperties.LoginInfo.LoggedinUser.UserID; SaveModel.rcdt = DateTime.Now; SaveModel.CompanyID = Model.CommonProperties.LoginInfo.LoggedInCompany.CompanyID; SaveModel.FinPeriodID = Model.CommonProperties.LoginInfo.LoggedInFinPeriod.FinPeriodID; db.tblLeaveEncashments.Add(SaveModel); } else { SaveModel.reuid = Model.CommonProperties.LoginInfo.LoggedinUser.UserID; SaveModel.redt = DateTime.Now; db.tblLeaveEncashments.Attach(SaveModel); db.Entry(SaveModel).State = System.Data.Entity.EntityState.Modified; } //-- try { db.SaveChanges(); res.PrimeKeyValue = SaveModel.LeaveEncashmentID; res.ExecutionResult = eExecutionResult.CommitedSucessfuly; } catch (Exception ex) { CommonFunctions.GetFinalError(res, ex); } } return(res); }
public SavingResult SaveNewRecord(tblCity SaveModel) { SavingResult res = new SavingResult(); //-- Perform Validation //res.ExecutionResult = eExecutionResult.ValidationError; //res.ValidationError = "Validation error message"; //return res; //-- using (dbVisionEntities db = new dbVisionEntities()) { //tblCity SaveModel; if (SaveModel.CityName == "") { res.ValidationError = "Can not accept blank value. Please enter City Name."; res.ExecutionResult = eExecutionResult.ValidationError; return(res); } else if (IsDuplicateRecord(SaveModel.CityName, SaveModel.CityID, SaveModel.StateID, db)) { res.ValidationError = "Can not accept duplicate value. The City Name is already exists."; res.ExecutionResult = eExecutionResult.ValidationError; return(res); } SaveModel.CountryID = db.tblStates.FirstOrDefault(r => r.StateID == SaveModel.StateID).CountryID; if (SaveModel.CityID == 0) // New Entry { SaveModel.rcuid = Model.CommonProperties.LoginInfo.LoggedinUser.UserID; SaveModel.rcdt = DateTime.Now; db.tblCities.Add(SaveModel); } else { SaveModel.reuid = Model.CommonProperties.LoginInfo.LoggedinUser.UserID; SaveModel.redt = DateTime.Now; db.tblCities.Attach(SaveModel); db.Entry(SaveModel).State = System.Data.Entity.EntityState.Modified; } //-- try { db.SaveChanges(); res.PrimeKeyValue = SaveModel.CityID; res.ExecutionResult = eExecutionResult.CommitedSucessfuly; } catch (Exception ex) { CommonFunctions.GetFinalError(res, ex); } } return(res); }
public SavingResult SaveNewRecord(DateTime DateFrom, DateTime DateTo, List <EmployeeRestDayViewModel> dsEmployee) { SavingResult res = new SavingResult(); using (dbVisionEntities db = new dbVisionEntities()) { db.tblEmployeeRestDays.RemoveRange(db.tblEmployeeRestDays.Where(r => r.CompanyID == Model.CommonProperties.LoginInfo.LoggedInCompany.CompanyID && r.FinPeriodID == Model.CommonProperties.LoginInfo.LoggedInFinPeriod.FinPeriodID && r.RestDate >= DateFrom && r.RestDate < DateTo)); foreach (var Employee in dsEmployee) { for (int ri = 0; ri < Employee.RestDayDetailDataSource.Count(); ri++) { if (Employee.RestDayDetailDataSource[ri].RestDay) { DateTime date = DateFrom;//.AddDays(ri); while (date.DayOfWeek != Employee.RestDayDetailDataSource[ri].Day) { date = date.AddDays(1); } do { tblEmployeeRestDay SaveModel = new tblEmployeeRestDay() { EmployeeID = Employee.EmployeeID, RestDate = date, CompanyID = CommonProperties.LoginInfo.LoggedInCompany.CompanyID, FinPeriodID = CommonProperties.LoginInfo.LoggedInFinPeriod.FinPeriodID, rcdt = DateTime.Now, rcuid = CommonProperties.LoginInfo.LoggedinUser.UserID, }; db.tblEmployeeRestDays.Add(SaveModel); date = date.AddDays(7); } while (date <= DateTo); } } } try { db.SaveChanges(); res.ExecutionResult = eExecutionResult.CommitedSucessfuly; } catch (Exception ex) { CommonFunctions.GetFinalError(res, ex); } } return(res); }
public SavingResult SaveNewRecord(tblUser SaveModel) { SavingResult res = new SavingResult(); //-- using (dbVisionEntities db = new dbVisionEntities()) { if (SaveModel.UserName == "") { res.ValidationError = "Can not accept blank value. The User Name is required."; res.ExecutionResult = eExecutionResult.ValidationError; return(res); } else if (IsDuplicateRecord(SaveModel.UserName, SaveModel.UserID, db)) { res.ValidationError = "Can not accept duplicate value. The user Name is already exists."; res.ExecutionResult = eExecutionResult.ValidationError; return(res); } else if (SaveModel.SuperAdmin) { res.ValidationError = "Can not accept add/edit a super user."; res.ExecutionResult = eExecutionResult.ValidationError; return(res); } if (SaveModel.UserID == 0) // New Entry { SaveModel.rcuid = Model.CommonProperties.LoginInfo.LoggedinUser.UserID; SaveModel.rcdt = DateTime.Now; db.tblUsers.Add(SaveModel); } else { SaveModel.reuid = Model.CommonProperties.LoginInfo.LoggedinUser.UserID; SaveModel.redt = DateTime.Now; db.tblUsers.Attach(SaveModel); db.Entry(SaveModel).State = System.Data.Entity.EntityState.Modified; } //-- try { db.SaveChanges(); res.PrimeKeyValue = SaveModel.UserID; res.ExecutionResult = eExecutionResult.CommitedSucessfuly; } catch (Exception ex) { CommonFunctions.GetFinalError(res, ex); } } return(res); }
public SavingResult ReInstate(int EmployeeID, string Reason, EmployeeServiceDetailViewModel ServiceDetail) { SavingResult res = new SavingResult(); using (dbVisionEntities db = new dbVisionEntities()) { var SaveModel = db.tblEmployees.Find(EmployeeID); if (SaveModel == null) { res.ValidationError = "Selected employee not found."; res.ExecutionResult = eExecutionResult.ValidationError; return(res); } tblEmployeeServiceDetail EmployeeServiceDetail = new tblEmployeeServiceDetail() { tblEmployee = SaveModel, EmploymentEffectiveDate = ServiceDetail.EmploymentEffectiveDate, ContractExpiryDate = ServiceDetail.ContractExpiryDate, EmploymentType = ServiceDetail.EmploymentType, EmployeeDesignationID = ServiceDetail.EmployeeDesignationID, EmployeeDepartmentID = ServiceDetail.EmployeeDepartmentID, EmployeeWIBAClassID = ServiceDetail.EmployeeWIBAClassID, LocationID = ServiceDetail.LocationID, MinimumWageCategoryID = ServiceDetail.MinimumWageCategoryID, DailyRate = ServiceDetail.DailyRate, BasicSalary = ServiceDetail.BasicSalary, HousingAllowance = ServiceDetail.HousingAllowance, WeekendAllowance = ServiceDetail.WeekendAllowance, EmployeeShiftType = ServiceDetail.EmployeeShiftTypeID, EmployeeShiftID = ServiceDetail.EmployeeShiftID, ReinstatementReason = Reason, }; db.tblEmployeeServiceDetails.Add(EmployeeServiceDetail); SaveModel.tblEmployeeServiceDetail = EmployeeServiceDetail; try { db.SaveChanges(); res.ExecutionResult = eExecutionResult.CommitedSucessfuly; } catch (Exception ex) { CommonFunctions.GetFinalError(res, ex); } } return(res); }
public SavingResult Save(int ShiftID, DateTime?WEFDateFrom, int[] SelectedEmployeeIDs) { SavingResult res = new SavingResult(); using (dbVisionEntities db = new dbVisionEntities()) { if (SelectedEmployeeIDs.Count() == 0) { res.ExecutionResult = eExecutionResult.ErrorWhileExecuting; res.ValidationError = "No employee was selected."; return(res); } if (WEFDateFrom != null) { db.tblEmployeeShiftAllocations.RemoveRange(db.tblEmployeeShiftAllocations.Where(r => SelectedEmployeeIDs.Contains(r.EmployeeID) && r.WEDateFrom >= WEFDateFrom.Value && r.CompanyID == CommonProperties.LoginInfo.LoggedInCompany.CompanyID)); } else { db.tblEmployeeShiftAllocations.RemoveRange(db.tblEmployeeShiftAllocations.Where(r => SelectedEmployeeIDs.Contains(r.EmployeeID) && r.CompanyID == CommonProperties.LoginInfo.LoggedInCompany.CompanyID)); } db.tblEmployeeShiftAllocations.AddRange( from e in SelectedEmployeeIDs select new tblEmployeeShiftAllocation() { EmployeeID = e, EmployeeShiftID = ShiftID, WEDateFrom = WEFDateFrom, CompanyID = CommonProperties.LoginInfo.LoggedInCompany.CompanyID, FinPeriodID = CommonProperties.LoginInfo.LoggedInFinPeriod.FinPeriodID, rcdt = DateTime.Now, rcuid = CommonProperties.LoginInfo.LoggedinUser.UserID, }); try { db.SaveChanges(); res.ExecutionResult = eExecutionResult.CommitedSucessfuly; } catch (Exception ex) { CommonFunctions.GetFinalError(res, ex); } } return(res); }
public SavingResult SaveLayout(eGridControlIDs GridID, string Layout, string PrintOptions, string PageSettings, long CompanyID, long FinPerID) { SavingResult res = new SavingResult(); //-- using (dbVisionEntities db = new dbVisionEntities()) { int intGrid = (int)GridID; tblGridLayout SaveModel = db.tblGridLayouts.FirstOrDefault(r => r.GridID == intGrid && r.CompanyID == CompanyID && r.FinPerID == FinPerID); if (SaveModel == null) // New Entry { SaveModel = new tblGridLayout(); SaveModel.rcuid = Model.CommonProperties.LoginInfo.LoggedinUser.UserID; SaveModel.rcdt = DateTime.Now; db.tblGridLayouts.Add(SaveModel); } else { SaveModel.reuid = Model.CommonProperties.LoginInfo.LoggedinUser.UserID; SaveModel.redt = DateTime.Now; db.tblGridLayouts.Attach(SaveModel); db.Entry(SaveModel).State = System.Data.Entity.EntityState.Modified; } SaveModel.GridID = (int)GridID; SaveModel.Descr = GridID.ToString(); SaveModel.Layout = Layout; SaveModel.PrintOptions = PrintOptions; SaveModel.PageSettings = PageSettings; SaveModel.CompanyID = Model.CommonProperties.LoginInfo.LoggedInCompany.CompanyID; SaveModel.FinPerID = Model.CommonProperties.LoginInfo.LoggedInFinPeriod.FinPeriodID; try { db.SaveChanges(); res.PrimeKeyValue = SaveModel.GridLayoutID; res.ExecutionResult = eExecutionResult.CommitedSucessfuly; } catch (Exception ex) { CommonFunctions.GetFinalError(res, ex); } } return(res); }
public SavingResult SaveFormat(int FormatID, string FormatName, string GridFormat) { SavingResult res = new SavingResult(); using (dbVisionEntities db = new dbVisionEntities()) { tblEmployeeListFormat SaveModel = null; if (FormatID > 0) { SaveModel = db.tblEmployeeListFormats.Find(FormatID); } if (SaveModel == null) { SaveModel = new tblEmployeeListFormat() { rcdt = DateTime.Now, rcuid = Model.CommonProperties.LoginInfo.LoggedinUser.UserID, }; db.tblEmployeeListFormats.Add(SaveModel); } else { SaveModel.redt = DateTime.Now; SaveModel.reuid = Model.CommonProperties.LoginInfo.LoggedinUser.UserID; db.tblEmployeeListFormats.Attach(SaveModel); db.Entry(SaveModel).State = System.Data.Entity.EntityState.Modified; } SaveModel.EmployeeListFormatName = FormatName; SaveModel.GridFromat = GridFormat; try { db.SaveChanges(); res.ExecutionResult = eExecutionResult.CommitedSucessfuly; res.PrimeKeyValue = SaveModel.EmployeeListFormatID; } catch (Exception ex) { CommonFunctions.GetFinalError(res, ex); } } return(res); }
public SavingResult UpdateWIBAClassRate(DateTime?WEDate, List <EmployeeWIBAClassRateViewModel> Rate) { SavingResult res = new SavingResult(); //-- using (dbVisionEntities db = new dbVisionEntities()) { var SelectedRates = Rate.Where(r => r.Selected); int[] SelectedWIBAClassIDs = SelectedRates.Select(r => r.EmployeeWIBClassID).ToArray(); if (WEDate == null) { db.tblEmployeeWIBAClassRates.RemoveRange(db.tblEmployeeWIBAClassRates.Where(r => SelectedWIBAClassIDs.Contains(r.EmployeeWIBAClassID))); } else { db.tblEmployeeWIBAClassRates.RemoveRange(db.tblEmployeeWIBAClassRates.Where(r => SelectedWIBAClassIDs.Contains(r.EmployeeWIBAClassID) && r.WEDate >= WEDate)); } foreach (var rate in SelectedRates) { tblEmployeeWIBAClassRate SaveModel = new tblEmployeeWIBAClassRate() { EmployeeWIBAClassID = rate.EmployeeWIBClassID, WEDate = WEDate, EmployeeWIBAClassRate = rate.Rate, CompanyID = CommonProperties.LoginInfo.LoggedInCompany.CompanyID, rcdt = DateTime.Now, rcuid = CommonProperties.LoginInfo.LoggedinUser.UserID, }; db.tblEmployeeWIBAClassRates.Add(SaveModel); } try { db.SaveChanges(); res.ExecutionResult = eExecutionResult.CommitedSucessfuly; } catch (Exception ex) { CommonFunctions.GetFinalError(res, ex); } } //-- return(res); }
public SavingResult Termination(int EmployeeID, eTerminationType Type, DateTime TerminationDate, string Reason) { SavingResult res = new SavingResult(); using (dbVisionEntities db = new dbVisionEntities()) { var SaveModel = db.tblEmployees.Find(EmployeeID); if (SaveModel == null) { res.ValidationError = "Selected employee not found."; res.ExecutionResult = eExecutionResult.ValidationError; return(res); } tblEmployeeServiceDetail ServiceSaveModel = null; if (SaveModel.EmployeeLastServiceDetailID != null) { ServiceSaveModel = db.tblEmployeeServiceDetails.Find(SaveModel.EmployeeLastServiceDetailID); } if (ServiceSaveModel == null) { res.ValidationError = "No service detail found."; res.ExecutionResult = eExecutionResult.ValidationError; return(res); } ServiceSaveModel.EmployeementStatus = (byte)(Type == eTerminationType.Resignation ? eEmployementStatus.Resigned : eEmployementStatus.Terminated); ServiceSaveModel.TerminationTypeID = (byte)Type; ServiceSaveModel.TerminationDate = TerminationDate; ServiceSaveModel.TerminationReason = Reason; db.tblEmployeeServiceDetails.Attach(ServiceSaveModel); db.Entry(ServiceSaveModel).State = System.Data.Entity.EntityState.Modified; try { db.SaveChanges(); res.ExecutionResult = eExecutionResult.CommitedSucessfuly; } catch (Exception ex) { CommonFunctions.GetFinalError(res, ex); } } return(res); }
public SavingResult SaveNewRecord(tblEmployeeSalaryIncrement SaveModel) { SavingResult res = new SavingResult(); using (dbVisionEntities db = new dbVisionEntities()) { if (SaveModel.EmployeeSalaryIncrementID == 0) { SaveModel.rcuid = Model.CommonProperties.LoginInfo.LoggedinUser.UserID; SaveModel.rcdt = DateTime.Now; SaveModel.CompanyID = Model.CommonProperties.LoginInfo.LoggedInCompany.CompanyID; SaveModel.FinPeriodID = CommonProperties.LoginInfo.LoggedInFinPeriod.FinPeriodID; db.tblEmployeeSalaryIncrements.Add(SaveModel); } else { SaveModel.reuid = Model.CommonProperties.LoginInfo.LoggedinUser.UserID; SaveModel.redt = DateTime.Now; db.tblEmployeeSalaryIncrements.Attach(SaveModel); db.Entry(SaveModel).State = System.Data.Entity.EntityState.Modified; } var tblService = db.tblEmployeeServiceDetails.Where(p => p.EmployeeID == SaveModel.EmployeeID).FirstOrDefault(); if (tblService != null) { tblService.BasicSalary = SaveModel.NewBasicSalary; } try { db.SaveChanges(); res.PrimeKeyValue = SaveModel.EmployeeSalaryIncrementID; res.ExecutionResult = eExecutionResult.CommitedSucessfuly; } catch (Exception ex) { CommonFunctions.GetFinalError(res, ex); } } return(res); }
public SavingResult DeleteRecord(long DeleteID) { SavingResult res = new SavingResult(); using (dbVisionEntities db = new dbVisionEntities()) { if (DeleteID != 0) { tblUserGroup RecordToDelete = db.tblUserGroups.FirstOrDefault(r => r.UserGroupID == DeleteID); if (RecordToDelete == null) { res.ValidationError = "Selected record not found. May be it has been deleted by another User over network."; res.ExecutionResult = eExecutionResult.ValidationError; return(res); } else { //db.tblUserGroupPerimissions.RemoveRange(db.tblUserGroupPerimissions.Where(r => r.UserGroupID == RecordToDelete.UserGroupID)); //db.tblUserGroups.Remove(RecordToDelete); byte RecordState_Deleted = (byte)eRecordState.Deleted; RecordToDelete.rstate = RecordState_Deleted; db.tblUserGroups.Attach(RecordToDelete); db.Entry(RecordToDelete).State = System.Data.Entity.EntityState.Modified; } try { db.SaveChanges(); res.ExecutionResult = eExecutionResult.CommitedSucessfuly; } catch (Exception ex) { CommonFunctions.GetFinalError(res, ex); } } } return(res); }
public SavingResult UnAuthorize(long ID) { SavingResult res = new SavingResult(); using (dbVisionEntities db = new dbVisionEntities()) { var rec = db.tblEmployeeSalaryIncrements.FirstOrDefault(r => r.EmployeeSalaryIncrementID == ID); rec.rState = (byte)eRecordState.Active; db.tblEmployeeSalaryIncrements.Attach(rec); db.Entry(rec).State = System.Data.Entity.EntityState.Modified; try { db.SaveChanges(); res.ExecutionResult = eExecutionResult.CommitedSucessfuly; } catch (Exception ex) { CommonFunctions.GetFinalError(res, ex); } } return(res); }
public SavingResult DeleteRecord(int DeleteID) { SavingResult res = new SavingResult(); using (dbVisionEntities db = new dbVisionEntities()) { if (DeleteID != 0) { tblEmployeeDesignation RecordToDelete = db.tblEmployeeDesignations.Find(DeleteID); if (RecordToDelete == null) { res.ValidationError = "Selected record not found. May be it has been deleted by another user over network."; res.ExecutionResult = eExecutionResult.ValidationError; return(res); } else { byte RecordState_Deleted = (byte)eRecordState.Deleted; //db.tblEmployeeDesignations.Remove(RecordToDelete); RecordToDelete.rstate = RecordState_Deleted; db.tblEmployeeDesignations.Attach(RecordToDelete); db.Entry(RecordToDelete).State = System.Data.Entity.EntityState.Modified; } try { db.SaveChanges(); res.ExecutionResult = eExecutionResult.CommitedSucessfuly; } catch (Exception ex) { CommonFunctions.GetFinalError(res, ex); } } } return(res); }
public SavingResult DeleteRecord(long DeleteID) { SavingResult res = null; using (dbVisionEntities db = new dbVisionEntities()) { res = DeleteRecord(DeleteID, db); if (res.ExecutionResult == eExecutionResult.ValidationError) { return(res); } try { db.SaveChanges(); res.ExecutionResult = eExecutionResult.CommitedSucessfuly; } catch (Exception ex) { CommonFunctions.GetFinalError(res, ex); } } return(res); }
public void SaveNewRecord(IEnumerable <TAApprovalImportViewModel> ImportViewModels) { using (dbVisionEntities db = new dbVisionEntities()) { foreach (var viewModel in ImportViewModels) { tblTAApproval SaveModel = new tblTAApproval() { ApprovedDate = viewModel.ApprovedDate.Value, TAApprovalNoPrefixID = viewModel.ApprovalNoPrefixID.Value, TAApprovalNo = viewModel.ApprovalNo.Value, EmployeeID = viewModel.EmployeeID.Value, TAApprovalDate = viewModel.ApprovalDate.Value, ApprovalTypeID = (byte)viewModel.ApprovalTypeID.Value, ApprovedHours = viewModel.ApprovedHours.Value, Remarks = viewModel.Remark, }; SavingResult res = SaveNewRecord(SaveModel, db); if (res.ExecutionResult != eExecutionResult.ErrorWhileExecuting && res.ExecutionResult != eExecutionResult.ValidationError) { try { db.SaveChanges(); res.PrimeKeyValue = SaveModel.TAApprovalID; viewModel.TAApprovalID = SaveModel.TAApprovalID; res.ExecutionResult = eExecutionResult.CommitedSucessfuly; } catch (Exception ex) { CommonFunctions.GetFinalError(res, ex); } } viewModel.SavingResult = res; } } }
public SavingResult Authorize(int ID) { SavingResult res = new SavingResult(); using (dbVisionEntities db = new dbVisionEntities()) { var rec = db.tblEmployeeDesignations.Find(ID); rec.rstate = (byte)eRecordState.Authorized; db.tblEmployeeDesignations.Attach(rec); db.Entry(rec).State = System.Data.Entity.EntityState.Modified; //-- try { db.SaveChanges(); res.ExecutionResult = eExecutionResult.CommitedSucessfuly; } catch (Exception ex) { CommonFunctions.GetFinalError(res, ex); } } return(res); }
public SavingResult Authorize(long ID) { SavingResult res = new SavingResult(); using (dbVisionEntities db = new dbVisionEntities()) { var rec = db.tblTAApprovalNoPrefixes.FirstOrDefault(r => r.TAApprovalNoPrefixID == ID); rec.rstate = (byte)eRecordState.Authorized; db.tblTAApprovalNoPrefixes.Attach(rec); db.Entry(rec).State = System.Data.Entity.EntityState.Modified; //-- try { db.SaveChanges(); res.ExecutionResult = eExecutionResult.CommitedSucessfuly; } catch (Exception ex) { CommonFunctions.GetFinalError(res, ex); } } return(res); }
public SavingResult SaveNewRecord(tblLocation SaveModel, LocationWeekendSettingViewModel WeekendSetting) { SavingResult res = new SavingResult(); //-- Perform Validation //res.ExecutionResult = eExecutionResult.ValidationError; //res.ValidationError = "Validation error message"; //return res; //-- using (dbVisionEntities db = new dbVisionEntities()) { //tblLocation SaveModel; if (SaveModel.LocationName == "") { res.ValidationError = "Can not accept blank value. Please enter Location Name."; res.ExecutionResult = eExecutionResult.ValidationError; return(res); } else if (IsDuplicateRecord(SaveModel.LocationName, SaveModel.LocationID, db)) { res.ValidationError = "Can not accept duplicate value. The Location Name is already exists."; res.ExecutionResult = eExecutionResult.ValidationError; return(res); } if (SaveModel.LocationID == 0) // New Entry { SaveModel.CompanyID = CommonProperties.LoginInfo.LoggedInCompany.CompanyID; SaveModel.rcuid = Model.CommonProperties.LoginInfo.LoggedinUser.UserID; SaveModel.rcdt = DateTime.Now; db.tblLocations.Add(SaveModel); } else { SaveModel.reuid = Model.CommonProperties.LoginInfo.LoggedinUser.UserID; SaveModel.redt = DateTime.Now; db.tblLocations.Attach(SaveModel); db.Entry(SaveModel).State = System.Data.Entity.EntityState.Modified; if (WeekendSetting.WEDateFrom != null) { DateTime LastUptoDate = WeekendSetting.WEDateFrom.Value.Date.AddDays(-1); foreach (var weekendRows in db.tblLocationWeekendSettings.Where(r => r.LocationID == SaveModel.LocationID && r.WEDateFrom < WeekendSetting.WEDateFrom && (r.WEDateTo == null || r.WEDateTo >= WeekendSetting.WEDateFrom))) { weekendRows.WEDateTo = LastUptoDate; db.tblLocationWeekendSettings.Attach(weekendRows); db.Entry(weekendRows).State = System.Data.Entity.EntityState.Modified; } db.tblLocationWeekendSettings.RemoveRange(db.tblLocationWeekendSettings.Where(r => r.LocationID == SaveModel.LocationID && r.WEDateFrom >= WeekendSetting.WEDateFrom)); } else { db.tblLocationWeekendSettings.RemoveRange(db.tblLocationWeekendSettings.Where(r => r.LocationID == SaveModel.LocationID)); } } db.tblLocationWeekendSettings.Add(new tblLocationWeekendSetting() { tblLocation = SaveModel, WEDateFrom = WeekendSetting.WEDateFrom, Monday = (byte)WeekendSetting.Monday, Tuesday = (byte)WeekendSetting.Tuesday, Wednesday = (byte)WeekendSetting.Wednesday, Thursday = (byte)WeekendSetting.Thursday, Friday = (byte)WeekendSetting.Friday, Saturday = (byte)WeekendSetting.Saturday, Sunday = (byte)WeekendSetting.Sunday }); //-- try { db.SaveChanges(); res.PrimeKeyValue = SaveModel.LocationID; res.ExecutionResult = eExecutionResult.CommitedSucessfuly; } catch (Exception ex) { CommonFunctions.GetFinalError(res, ex); } } return(res); }
public SavingResult SaveNewRecord(tblFinPeriod SaveModel, FinPeriodDetailModel PrevFinPeriod, FinPeriodDetailModel NextFinPeriod, List <AccountClosingBalanceViewModel> COBalances, List <ProductOpeningStockViewModel> POStocks) { SavingResult res = new SavingResult(); //-- using (dbVisionEntities db = new dbVisionEntities()) { //tblFinPeriod SaveModel; if (SaveModel.FinPeriodName == "") { res.ValidationError = "Can not accept blank value. Please enter Financial Period Name."; res.ExecutionResult = eExecutionResult.ValidationError; return(res); } else if (IsDuplicateRecord(SaveModel.FinPeriodName, SaveModel.FinPeriodID, db)) { res.ValidationError = "Can not accept duplicate value. The Financial Period Name is already exists."; res.ExecutionResult = eExecutionResult.ValidationError; return(res); } bool IsNewFinPeriodAdded = (SaveModel.FinPeriodID == 0); if (SaveModel.FinPeriodID == 0) // New Entry { SaveModel.rcuid = Model.CommonProperties.LoginInfo.LoggedinUser.UserID; SaveModel.rcdt = DateTime.Now; SaveModel.CompanyID = CommonProperties.LoginInfo.LoggedInCompany.CompanyID; db.tblFinPeriods.Add(SaveModel); if (PrevFinPeriod != null) { tblFinPeriod PrevFinPerSaveModel = db.tblFinPeriods.Find(PrevFinPeriod.FinPeriodID); if (PrevFinPerSaveModel != null) { if (PrevFinPerSaveModel.FinPeriodTo == null) { PrevFinPerSaveModel.FinPeriodTo = SaveModel.FinPeriodFrom.Date.AddDays(-1); //if (PrevFinPerSaveModel.FinPeriodName == PrevFinPerSaveModel.FinPeriodFrom.Year.ToString() + " - *") //{ PrevFinPerSaveModel.FinPeriodName = PrevFinPerSaveModel.FinPeriodFrom.Year.ToString() + " - " + PrevFinPerSaveModel.FinPeriodTo.Value.Year.ToString(); //} PrevFinPerSaveModel.redt = DateTime.Now; db.tblFinPeriods.Attach(PrevFinPerSaveModel); db.Entry(PrevFinPerSaveModel).State = System.Data.Entity.EntityState.Modified; } } } } else { SaveModel.reuid = Model.CommonProperties.LoginInfo.LoggedinUser.UserID; SaveModel.redt = DateTime.Now; db.tblFinPeriods.Attach(SaveModel); db.Entry(SaveModel).State = System.Data.Entity.EntityState.Modified; } //-- try { db.SaveChanges(); res.PrimeKeyValue = SaveModel.FinPeriodID; res.ExecutionResult = eExecutionResult.CommitedSucessfuly; } catch (Exception ex) { CommonFunctions.GetFinalError(res, ex); } if (IsNewFinPeriodAdded && PrevFinPeriod != null) { // /// Transfer Stock and Balances // DAL.Account.AccountOpeningBalanceDAL COPBDALObj = new Account.AccountOpeningBalanceDAL(); // ///--- Save Account Balances // foreach (var copb in COBalances) // { // if (copb.OpeningBalance != 0) // { // COPBDALObj.SaveNewRecord(new tblAccountOpeningBalance() // { // OpeningBalanceDate = SaveModel.FinPeriodFrom.Date, // OpeningBalanceAmt = copb.OpeningBalance, // Narration = "Opening Balance T/F", // AccountID = copb.AccountID, // CompanyID = CommonProperties.LoginInfo.LoggedInCompany.CompanyID, // tblFinPeriod = SaveModel, // rcdt = DateTime.Now, // rcuid = CommonProperties.LoginInfo.LoggedinUser.UserID // }, SaveModel.CompanyID, SaveModel.FinPeriodID, db, res); // } // } // /// // /// Save Product Stock // DAL.Inventory.ProductOpeningStockDAL POStockDALObj = new Inventory.ProductOpeningStockDAL(); // int OpeningStockVoucherTypeID = (int)Model.Inventory.eStockVoucherType.OpeningStock; // foreach (var stock in POStocks) // { // if (stock.Stock != 0) // { // POStockDALObj.SaveNewRecord( // new tblStock() // { // StockVoucherTypeID = OpeningStockVoucherTypeID, // VDate = SaveModel.FinPeriodFrom.Date, // Narration = "Opening Stock T/F", // CompanyID = CommonProperties.LoginInfo.LoggedInCompany.CompanyID, // tblFinPeriod = SaveModel, // rcdt = DateTime.Now, // rcuid = CommonProperties.LoginInfo.LoggedinUser.UserID // }, // new List<tblStockPDetail>() { new tblStockPDetail() // { // ProductID = stock.ProductID, // Rate = stock.Rate, // Qty = stock.Stock // } }, // SaveModel.CompanyID, SaveModel.FinPeriodID, db, res); // } // } /// //-- try { db.SaveChanges(); res.PrimeKeyValue = SaveModel.FinPeriodID; res.ExecutionResult = eExecutionResult.CommitedSucessfuly; } catch (Exception ex) { CommonFunctions.GetFinalError(res, ex); } } } return(res); }