public void SaveOldRow(TblCostCenterViewModel 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 TblCostCenter(); saveRow.InjectFrom(oldRow); if (!Loading) { Loading = true; Glclient.UpdateOrInsertTblCostCentersAsync(saveRow, save, MainRowList.IndexOf(oldRow), LoggedUserInfo.DatabasEname); } } } }
private int DeleteTblCostCenter(TblCostCenter row, int index, string company) { using (var entity = new ccnewEntities(GetSqlConnectionString(company))) { var query = (from e in entity.TblCostCenters where e.Iserial == row.Iserial select e).SingleOrDefault(); if (query != null) { entity.DeleteObject(query); } entity.SaveChanges(); } return(row.Iserial); }
public SearchCostCenterViewModel() { if (!IsDesignTime) { Glclient = new GlServiceClient(); MainRowList = new SortableCollectionView <TblCostCenter>(); SelectedMainRow = new TblCostCenter(); Glclient.GetTblCostCenterCompleted += (s, sv) => { foreach (var row in sv.Result) { MainRowList.Add(row); } Loading = false; FullCount = sv.fullCount; }; } }
private TblCostCenter UpdateOrInsertTblCostCenters(TblCostCenter newRow, bool save, int index, out int outindex, string company) { outindex = index; using (var entity = new ccnewEntities(GetSqlConnectionString(company))) { if (save) { entity.TblCostCenters.AddObject(newRow); } else { var oldRow = (from e in entity.TblCostCenters where e.Iserial == newRow.Iserial select e).SingleOrDefault(); if (oldRow != null) { GenericUpdate(oldRow, newRow, entity); } } entity.SaveChanges(); return(newRow); } }