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