public void SaveOldRow(TblPositionRouteHeaderViewModel oldRow) { if (oldRow != null) { var valiationCollection = new List <ValidationResult>(); var isvalid = Validator.TryValidateObject(oldRow, new ValidationContext(oldRow, null, null), valiationCollection, true); if (isvalid) { var save = oldRow.Iserial == 0; if (AllowUpdate != true && !save) { MessageBox.Show(strings.AllowUpdateMsg); return; } var saveRow = new TblPositionRouteHeader(); saveRow.InjectFrom(oldRow); if (Loading == false) { Loading = true; Glclient.UpdateOrInsertTblPositionRouteHeaderAsync(saveRow, save, MainRowList.IndexOf(oldRow), LoggedUserInfo.DatabasEname); } } } }
private int DeleteTblPositionRouteHeader(TblPositionRouteHeader row, int index, string company) { using (var entityGroup = new ccnewEntities(GetSqlConnectionString(company))) { var query = (from e in entityGroup.TblPositionRouteHeaders where e.Iserial == row.Iserial select e).SingleOrDefault(); if (query != null) { entityGroup.DeleteObject(query); } entityGroup.SaveChanges(); } return(row.Iserial); }
private TblPositionRouteHeader UpdateOrInsertTblPositionRouteHeader(TblPositionRouteHeader newRow, bool save, int index, out int outindex, string company) { outindex = index; using (var entityGroup = new ccnewEntities(GetSqlConnectionString(company))) { if (save) { entityGroup.TblPositionRouteHeaders.AddObject(newRow); } else { var oldRow = (from e in entityGroup.TblPositionRouteHeaders where e.Iserial == newRow.Iserial select e).SingleOrDefault(); if (oldRow != null) { GenericUpdate(oldRow, newRow, entityGroup); } } entityGroup.SaveChanges(); return(newRow); } }