public SavingResult SaveNewRecord(tblLeaveEncashmentNoPrefix SaveModel) { SavingResult res = new SavingResult(); //-- Perform Validation //res.ExecutionResult = eExecutionResult.ValidationError; //res.ValidationError = "Validation error message"; //return res; //-- using (dbVisionEntities db = new dbVisionEntities()) { //tblLeaveEncashmentNoPrefix SaveModel; if (SaveModel.LeaveEncashmentNoPrefixName == "") { res.ValidationError = "Can not accept blank value. Please enter Prefix Name."; res.ExecutionResult = eExecutionResult.ValidationError; return(res); } else if (IsDuplicateRecord(SaveModel.LeaveEncashmentNoPrefixName, SaveModel.LeaveEncashmentNoPrefixID, db)) { res.ValidationError = "Can not accept duplicate value. The Prefix Name is already exists."; res.ExecutionResult = eExecutionResult.ValidationError; return(res); } if (SaveModel.LeaveEncashmentNoPrefixID == 0) // New Entry { SaveModel.rcuid = Model.CommonProperties.LoginInfo.LoggedinUser.UserID; SaveModel.rcdt = DateTime.Now; SaveModel.CompanyID = Model.CommonProperties.LoginInfo.LoggedInCompany.CompanyID; db.tblLeaveEncashmentNoPrefixes.Add(SaveModel); } else { SaveModel.reuid = Model.CommonProperties.LoginInfo.LoggedinUser.UserID; SaveModel.redt = DateTime.Now; db.tblLeaveEncashmentNoPrefixes.Attach(SaveModel); db.Entry(SaveModel).State = System.Data.Entity.EntityState.Modified; } //-- try { db.SaveChanges(); res.PrimeKeyValue = SaveModel.LeaveEncashmentNoPrefixID; res.ExecutionResult = eExecutionResult.CommitedSucessfuly; } catch (Exception ex) { CommonFunctions.GetFinalError(res, ex); } } return(res); }
public override void FillSelectedRecordInContent(object RecordToFill) { tblLeaveEncashmentNoPrefix EditingRecord = DALObject.FindSaveModelByPrimeKey(((LeaveEncashmentNoPrefixEditListModel)RecordToFill).LeaveEncashmentNoPrefixID); if (EditingRecord == null) { return; } txtLeaveEncashmentNoPrefixName.Text = EditingRecord.LeaveEncashmentNoPrefixName; }
public SavingResult DeleteRecord(long DeleteID) { SavingResult res = new SavingResult(); using (dbVisionEntities db = new dbVisionEntities()) { if (DeleteID != 0) { tblLeaveEncashmentNoPrefix RecordToDelete = db.tblLeaveEncashmentNoPrefixes.FirstOrDefault(r => r.LeaveEncashmentNoPrefixID == 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.tblLeaveEncashmentNoPrefixes.Remove(RecordToDelete); byte RecordState_Deleted = (byte)eRecordState.Deleted; RecordToDelete.rstate = RecordState_Deleted; db.tblLeaveEncashmentNoPrefixes.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); }