private int DeleteTblGlobalRetailBusinessBudget(TblGlobalRetailBusinessBudget row) { using (var context = new WorkFlowManagerDBEntities()) { var oldRow = (from e in context.TblGlobalRetailBusinessBudgets where e.Iserial == row.Iserial select e).SingleOrDefault(); if (oldRow != null) { context.DeleteObject(oldRow); context.SaveChanges(); } return(row.Iserial); } }
public void SaveMainRow() { var valiationCollection = new List <ValidationResult>(); bool isvalid = Validator.TryValidateObject(TransactionHeader, new ValidationContext(TransactionHeader, null, null), valiationCollection, true); if (isvalid) { var data = new TblGlobalRetailBusinessBudget(); data.InjectFrom(TransactionHeader); bool save = TransactionHeader.Iserial == 0; data.TransactionType = TransactionType; if (save) { if (AllowAdd) { Loading = true; Client.UpdateOrInsertTblGlobalRetailBusinessBudgetAsync(data, LoggedUserInfo.Iserial); } else { MessageBox.Show("You are Not Allowed to Add"); } } else { if (AllowUpdate) { Loading = true; Client.UpdateOrInsertTblGlobalRetailBusinessBudgetAsync(data, LoggedUserInfo.Iserial); } else { MessageBox.Show("You are Not Allowed to Update"); } } } }
private TblGlobalRetailBusinessBudget UpdateOrInsertTblGlobalRetailBusinessBudget(TblGlobalRetailBusinessBudget newRow, int userIserial) { using (var context = new WorkFlowManagerDBEntities()) { var oldRow = (from e in context.TblGlobalRetailBusinessBudgets where e.Iserial == newRow.Iserial select e).SingleOrDefault(); if (oldRow != null) { GenericUpdate(oldRow, newRow, context); } else { context.TblGlobalRetailBusinessBudgets.AddObject(newRow); } context.SaveChanges(); return(newRow); } }