public void ExecuteStoredProcedure(object sender, EventArgs e) { try { var fields = AddListBoxFields.Select(a => a.Text).Concat(AddListBoxCombo.Select(a => a.TableFieldName)); var values = AddListBoxFields.Select(a => a.Input).Concat(AddListBoxCombo.Select(a => a.GetId())); if (AddListBoxFields.Any(a => a.Input == null) || AddListBoxCombo.Any(a => a.Selected == null)) { Notification("Все поля должны быть заполнены"); return; } else { var data = context.ExecuteStoredProcedure(SelectedStoredProcedures, fields, values); RefreshSelectedTable(data); SelectedTableName = SelectedStoredProcedures; UpdateStoredProcedures(); } UpdateTables(); } catch (Exception ex) { Notification(ex.Message); } }
public void Save(object sender, RoutedEventArgs e) { try { var columns = AddListBoxFields.Select(a => a.Text).Concat(AddListBoxCombo.Select(a => a.TableFieldName)); var values = AddListBoxFields.Select(a => a.Input).Concat(AddListBoxCombo.Select(a => a.GetId())); if (AddListBoxFields.Any(a => a.Input == null) || AddListBoxCombo.Any(a => a.Selected == null)) { Notification("Все поля должны быть заполнены"); return; } else if (InsertOrUpdate) { context.Update(SelectedTableName, Convert.ToInt32(values.First()), columns.Skip(1), values.Skip(1)); } else { context.Insert(SelectedTableName, columns, values); } RefreshSelectedTable(); } catch (Exception ex) { Notification(ex.Message); } }
private void RowDataEntryField(IEnumerable <string> columns) { AddListBoxCombo = context.GetForeignKeys(SelectedTableName)?.GroupBy(a => a.Text).Select(a => a.First()).ToList() ?? new List <TableField>(); AddListBoxFields = columns.Except(AddListBoxCombo.Select(a => a.TableFieldName)).Select(a => new PairTableField() { Text = a }).ToList(); }