AddExecutor.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using System.Data.SqlClient;
  11. namespace Transportation
  12. {
  13. public partial class AddExecutor : Form
  14. {
  15. SqlCommand query = null;
  16. public AddExecutor()
  17. {
  18. InitializeComponent();
  19. }
  20. private void AddBTN_Click(object sender, EventArgs e)
  21. {
  22. query = new SqlCommand("insert into executors (surname_executor, name_executor, midname_executor) values (@surname_executor, @name_executor, @midname_executor)", dbhelper.sqlConnection);
  23. query.Parameters.AddWithValue("surname_executor", SurnameExecutorTB.Text);
  24. query.Parameters.AddWithValue("name_executor", NameExecutorTB.Text);
  25. query.Parameters.AddWithValue("midname_executor", MidnameExecutorTB.Text);
  26. if (query.ExecuteNonQuery().ToString().Equals("1"))
  27. {
  28. MessageBox.Show("Добавление прошло успешно!", "Уведомление", MessageBoxButtons.OK, MessageBoxIcon.Information);
  29. this.Close();
  30. }
  31. }
  32. }
  33. }