public void SaveDetailRow() { if (SelectedDetailRow != null) { var valiationCollection = new List <ValidationResult>(); var isvalid = Validator.TryValidateObject(SelectedDetailRow, new ValidationContext(SelectedDetailRow, null, null), valiationCollection, true); if (isvalid) { var rowToSave = new TblPurchaseBudgetDetail(); rowToSave.InjectFrom(SelectedDetailRow); Client.UpdateOrInsertTblPurchaseBudgetDetailAsync(rowToSave, SelectedMainRow.DetailsList.IndexOf(SelectedDetailRow)); } } }
private TblPurchaseBudgetDetail DeleteTblPurchaseBudgetDetail(TblPurchaseBudgetDetail row) { using (var context = new WorkFlowManagerDBEntities()) { var oldRow = (from e in context.TblPurchaseBudgetDetails where e.Iserial == row.Iserial select e).SingleOrDefault(); if (oldRow != null) { context.DeleteObject(oldRow); } context.SaveChanges(); } return(row); }
private TblPurchaseBudgetDetail UpdateOrInsertTblPurchaseBudgetDetail(TblPurchaseBudgetDetail newRow, int index, out int outindex) { outindex = index; using (var context = new WorkFlowManagerDBEntities()) { var oldRow = (from e in context.TblPurchaseBudgetDetails where e.Iserial == newRow.Iserial select e).SingleOrDefault(); if (oldRow != null) { GenericUpdate(oldRow, newRow, context); } else { context.TblPurchaseBudgetDetails.AddObject(newRow); } context.SaveChanges(); return(newRow); } }