Guest User

Untitled

a guest
Jan 8th, 2021
19
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. NameColumn.TextChanged += (sender, e) =>
  2. {
  3. db.Close();
  4. db.Open();
  5. if (NameColumn.Text.Trim() != string.Empty)
  6. {
  7. try
  8. {
  9. db.Query($"EXEC sp_rename N'{TableName + "_COPY"}.[{ColumnName}]', N'{NameColumn.Text}', 'COLUMN';");
  10. db.Query($"UPDATE [{"USUMODEL" + TableName + "_COPY"}] SET [Имя столбца] = N'{NameColumn.Text}' WHERE [Имя столбца] = N'{ColumnName}'");
  11. ColumnName = NameColumn.Text;
  12. NameColumn.SetValue(HintAssist.HelperTextProperty, "");
  13. }
  14. catch
  15. {
  16. NameColumn.SetValue(HintAssist.HelperTextProperty, "Столбец с таким названием уже есть");
  17. }
  18. }
  19. else
  20. {
  21. NameColumn.SetValue(HintAssist.HelperTextProperty, "Введите название столбца");
  22. }
  23. OK.IsEnabled = true;
  24. foreach (TextBox text in scrollStack.Children.Cast<Grid>().Select(b => b.Children[1]))
  25. {
  26. if (!(text.GetValue(HintAssist.HelperTextProperty) == "" || text.GetValue(HintAssist.HelperTextProperty) == null))
  27. {
  28. OK.IsEnabled = false;
  29. break;
  30. }
  31. }
  32. db.Close();
  33. };
Advertisement
Add Comment
Please, Sign In to add comment