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 DeleteRecord(int ID) { SavingResult res = new SavingResult(); using (dbUltraCoralEntities db = new dbUltraCoralEntities()) { var RecordToDelete = db.tblProducts.Find(ID); if (RecordToDelete == null) { res.ExecutionResult = eExecutionResult.ValidationError; res.ValidationError = "Selected record is already deleted or changed over network. Record not found."; return(res); } db.tblProducts.Remove(RecordToDelete); //-- try { db.SaveChanges(); res.ExecutionResult = eExecutionResult.CommitedSucessfuly; } catch (Exception ex) { ex = Common.Functions.FindFinalError(ex); res.ExecutionResult = eExecutionResult.ErrorWhileExecuting; res.Exception = 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 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 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 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); }
private void btnSaveFormat_Click(object sender, EventArgs e) { if (lookupFormat.EditValue == null) { MessageBox.Show("Please select format or type a new format name", "Format Saving", MessageBoxButtons.OK, MessageBoxIcon.Warning); lookupFormat.Focus(); return; } string LayoutXML = null; using (MemoryStream stream = new MemoryStream()) { advBandedGridView1.SaveLayoutToStream(stream, DevExpress.Utils.OptionsLayoutBase.FullLayout); stream.Seek(0, SeekOrigin.Begin); using (StreamReader reader = new StreamReader(stream)) { LayoutXML = reader.ReadToEnd(); } } SavingResult res = ReportDALObj.SaveFormat((int)lookupFormat.EditValue, lookupFormat.Text, LayoutXML); SavingParemeter paras = new SavingParemeter() { SavingResult = res }; AfterSaving(paras); if (res.ExecutionResult == eExecutionResult.CommitedSucessfuly && ((int?)lookupFormat.EditValue ?? 0) == -1) { LoadFormatLookup(); AssignFormatLookup(); } }
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 static void GetFinalError(SavingResult res, Exception ex) { res.ExecutionResult = eExecutionResult.ErrorWhileExecuting; res.Exception = ex; while (res.Exception != null && res.Exception.Message == "An error occurred while updating the entries. See the inner exception for details.") { res.Exception = res.Exception.InnerException; } if (ex.GetType() == typeof(System.Data.Entity.Validation.DbEntityValidationException)) { res.ValidationError = "dbEntity Validation Errors : \r\n\r\n"; System.Data.Entity.Validation.DbEntityValidationException ValidationException = (System.Data.Entity.Validation.DbEntityValidationException)ex; foreach (System.Data.Entity.Validation.DbEntityValidationResult ValidRes in ValidationException.EntityValidationErrors) { foreach (System.Data.Entity.Validation.DbValidationError ValidError in ValidRes.ValidationErrors) { res.ValidationError += ValidError.PropertyName + " = " + ValidError.ErrorMessage + "\r\n"; } res.ValidationError += "\r\n"; } res.Exception = new Exception(res.ValidationError); } }
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 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 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 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 UpdateRateUplift(int ProductID, decimal RateUplift) { SavingResult res = new SavingResult(); using (dbUltraCoralEntities db = new dbUltraCoralEntities()) { tblProduct SaveModel = db.tblProducts.Find(ProductID); if (SaveModel == null) { res.ExecutionResult = eExecutionResult.ValidationError; res.ValidationError = "Product not found"; return(res); } SaveModel = db.tblProducts.FirstOrDefault(r => r.ProductID == ProductID); if (SaveModel == null) { res.ExecutionResult = eExecutionResult.ValidationError; res.ValidationError = "Selected user has been deleted over network. Can not find product details. Please retry."; return(res); } if (SaveModel.RateUpliftPerc == RateUplift) // if quantity has not changed then don't update quantity. { return(new SavingResult() { ExecutionResult = eExecutionResult.NotExecutedYet }); } SaveModel.RateUpliftPerc = RateUplift; SaveModel.redt = DateTime.Now; //SaveModel.reuid = Common.Props.LoginUser.UserID; db.tblProducts.Attach(SaveModel); db.Entry(SaveModel).State = System.Data.Entity.EntityState.Modified; //-- try { db.SaveChanges(); res.PrimeKeyValue = SaveModel.ProductID; res.ExecutionResult = eExecutionResult.CommitedSucessfuly; } catch (Exception ex) { ex = Common.Functions.FindFinalError(ex); res.ExecutionResult = eExecutionResult.ErrorWhileExecuting; res.Exception = 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); }
private void gvPAYERelief_RowUpdated(object sender, DevExpress.XtraGrid.Views.Base.RowObjectEventArgs e) { if (e.Row == null) { return; } SavingResult res = null; PAYEReliefeViewModel Row = (PAYEReliefeViewModel)e.Row; if (dePAYEReliefWED.EditValue == null) { res = new SavingResult(); res.ExecutionResult = eExecutionResult.ValidationError; res.ValidationError = "Please enter Effective date."; } else { res = PAYEReliefDALObj.SaveNewRecord(Row, (DateTime)dePAYEReliefWED.EditValue); } Row.SavingError = null; if (res.ExecutionResult == eExecutionResult.CommitedSucessfuly) { var newRow = PAYEReliefDALObj.GetViewModelByID((int)res.PrimeKeyValue); if (newRow != null) { int newRowIndex = PAYEReliefeViewModelBindingSource.IndexOf(Row); //Row = newRow; PAYEReliefeViewModelBindingSource[newRowIndex] = newRow; } else { PAYEReliefeViewModelBindingSource.RemoveAt(gvPAYERelief.GetFocusedDataSourceRowIndex()); } } else if (res.ExecutionResult == eExecutionResult.ErrorWhileExecuting) { Row.SavingError = "Error while saving.\r\n" + res.Exception.Message; } else if (res.ExecutionResult == eExecutionResult.ValidationError) { Row.SavingError = "Validation Errors.\r\n" + res.ValidationError; } else if (!String.IsNullOrWhiteSpace(res.MessageAfterSave)) { Row.SavingError = "Please note:\r\n" + res.MessageAfterSave; } }
public SavingResult DeleteRecord(long DeleteID, dbVisionEntities db) { SavingResult res = null; if (DeleteID != 0) { tblFinPeriod RecordToDelete = db.tblFinPeriods.FirstOrDefault(r => r.FinPeriodID == DeleteID); res = DeleteRecord(RecordToDelete, db); } else { res = new SavingResult(); } 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 ActionResult ApproveCustomer(int id, bool Approved) { SavingResult SavingRes = DALObj.ApproveUser(id, Approved); CustomerViewModel ViewModel = DALObj.FindByID(id); if (Common.Functions.SetAfterSaveResult(ModelState, SavingRes)) { CustomerViewModel Customer = DALObj.FindByID(id); string SendTo = null; string Subject = null; string Body = null; if (Approved) { SendTo = Customer.EMailID; Subject = "You account has been approved."; Body = string.Format(@"Dear sir, Your account on {0} has been approved. Now you can place order on {0}. Please login by clicking on the link below. {1} If the above link is not working then please copy and paste the above link in address bar. If you have any issue, please contact support on {0} ", Common.Props.CurrentDomainName, Common.Props.CurrentDomainName + @"/Users/Login"); Common.Functions.SendEmailFromNoReply(SendTo, Subject, Body); } else { SendTo = Customer.EMailID; Subject = "You account has been rejected by admin."; Body = string.Format(@"Dear customer, Your account on {0} has been disapproved and rejected by admin. Please contact support on {0} for more details.", Common.Props.CurrentDomainName); Common.Functions.SendEmailFromNoReply(SendTo, Subject, Body); } return(RedirectToAction("ApproveCustomerConfirm", new { id = id })); } return(View(ViewModel)); }
public static bool SetAfterSaveResult(ModelStateDictionary ModelState, SavingResult res) { switch (res.ExecutionResult) { case eExecutionResult.CommitedSucessfuly: return(true); case eExecutionResult.ErrorWhileExecuting: ModelState.AddModelError("", res.Exception.Message); break; case eExecutionResult.ValidationError: ModelState.AddModelError("", res.ValidationError); break; } return(false); }
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); }
/// <summary> /// Processes the after delete record event. /// </summary> /// <param name="parameters">Parameters</param> /// <returns></returns> public async Task <SavingResult> ProcessAfterDeleteRecordAsync(SaveParameters parameters) { SavingResult result; try { await this.ExecuteActionsAsync(parameters, ETableDbEventType.BeforeCreate); result = new SavingResult() { Result = parameters.AdditionalParameters }; } catch (ALexException ex) { result = base.GetResultFromException <SavingResult>(ex, 4006); } return(result); }
public SavingResult ApproveUser(int UserID) { SavingResult res = new SavingResult(); using (dbUltraCoralEntities db = new dbUltraCoralEntities()) { tblUser SaveModel = null; SaveModel = db.tblUsers.FirstOrDefault(r => r.UserID == UserID); if (SaveModel == null) { res.ExecutionResult = eExecutionResult.ValidationError; res.ValidationError = "Selected user has been deleted over network. Can not find user's details. Please retry."; return(res); } SaveModel.IsApproved = true; 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) { while (ex.Message == "An error occurred while updating the entries. See the inner exception for details.") { ex = ex.InnerException; } res.ExecutionResult = eExecutionResult.ErrorWhileExecuting; res.Exception = ex; } } return(res); }