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