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 save = SelectedDetailRow.Iserial == 0; if (SelectedDetailRow.TblAccount == 0) { SelectedDetailRow.TblAccount = SelectedMainRow.Iserial; } if (AllowUpdate != true && !save) { MessageBox.Show(strings.AllowUpdateMsg); return; } var rowToSave = new TblAccountInterval(); rowToSave.InjectFrom(SelectedDetailRow); Glclient.UpdateOrInsertTblAccountIntervalsAsync(rowToSave, save, SelectedMainRow.DetailsList.IndexOf(SelectedDetailRow), LoggedUserInfo.DatabasEname); } } }
private int DeleteTblAccountInterval(TblAccountInterval row, int index, string company) { using (var entity = new ccnewEntities(GetSqlConnectionString(company))) { var query = (from e in entity.TblAccountIntervals where e.Iserial == row.Iserial select e).SingleOrDefault(); if (query != null) { entity.DeleteObject(query); } entity.SaveChanges(); } return(row.Iserial); }
private TblAccountInterval UpdateOrInsertTblAccountIntervals(TblAccountInterval newRow, bool save, int index, out int outindex, string company) { outindex = index; using (var entity = new ccnewEntities(GetSqlConnectionString(company))) { if (save) { entity.TblAccountIntervals.AddObject(newRow); } else { var oldRow = (from e in entity.TblAccountIntervals where e.Iserial == newRow.Iserial select e).SingleOrDefault(); if (oldRow != null) { GenericUpdate(oldRow, newRow, entity); } } entity.SaveChanges(); return(newRow); } }