private int DeleteTblPurchaseBudgetHeader(TblPurchaseBudgetHeader row) { using (var context = new WorkFlowManagerDBEntities()) { var oldRow = (from e in context.TblPurchaseBudgetHeaders where e.Iserial == row.Iserial select e).SingleOrDefault(); if (oldRow != null) { context.DeleteObject(oldRow); } context.SaveChanges(); } return(row.Iserial); }
public void SaveMainRow() { if (SelectedMainRow != null) { var valiationCollection = new List <ValidationResult>(); var isvalid = Validator.TryValidateObject(SelectedMainRow, new ValidationContext(SelectedMainRow, null, null), valiationCollection, true); if (isvalid) { var saveRow = new TblPurchaseBudgetHeader(); saveRow.InjectFrom(SelectedMainRow); Client.UpdateOrInsertTblPurchaseBudgetHeaderAsync(saveRow, MainRowList.IndexOf(SelectedMainRow)); } } }
private TblPurchaseBudgetHeader UpdateOrInsertTblPurchaseBudgetHeader(TblPurchaseBudgetHeader newRow, int index, out int outindex) { outindex = index; using (var context = new WorkFlowManagerDBEntities()) { var oldRow = (from e in context.TblPurchaseBudgetHeaders where e.Iserial == newRow.Iserial select e).SingleOrDefault(); if (oldRow != null) { GenericUpdate(oldRow, newRow, context); } else { context.TblPurchaseBudgetHeaders.AddObject(newRow); } context.SaveChanges(); return(newRow); } }