public void SaveOldRow(TblGlGenEntityGroupViewModel 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 TblGlGenEntityGroup(); saveRow.InjectFrom(oldRow); Glclient.UpdateOrInsertTblGlGenEntityGroupAsync(saveRow, save, MainRowList.IndexOf(oldRow), LoggedUserInfo.DatabasEname); } } }
private int DeleteTblGlGenEntityGroup(TblGlGenEntityGroup row, int index, string company) { using (var entityGroup = new ccnewEntities(GetSqlConnectionString(company))) { var query = (from e in entityGroup.TblGlGenEntityGroups where e.Iserial == row.Iserial select e).SingleOrDefault(); if (query != null) { var Ledger = entityGroup.TblLedgerMainDetails.Where(w => w.EntityAccount == query.Iserial); if (Ledger.Any()) { throw new System.Exception("Cannot delete Because There is a transaction Exisit"); } entityGroup.DeleteObject(query); } entityGroup.SaveChanges(); } return(row.Iserial); }
private TblGlGenEntityGroup UpdateOrInsertTblGlGenEntityGroup(TblGlGenEntityGroup newRow, bool save, int index, out int outindex, string company) { outindex = index; using (var entityGroup = new ccnewEntities(GetSqlConnectionString(company))) { if (save) { entityGroup.TblGlGenEntityGroups.AddObject(newRow); } else { var oldRow = (from e in entityGroup.TblGlGenEntityGroups where e.Iserial == newRow.Iserial select e).SingleOrDefault(); if (oldRow != null) { GenericUpdate(oldRow, newRow, entityGroup); } } entityGroup.SaveChanges(); return(newRow); } }