AddLogistician.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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 AddLogistician : Form
  14. {
  15. SqlCommand query = null;
  16. SqlDataReader reader = null;
  17. public AddLogistician()
  18. {
  19. InitializeComponent();
  20. }
  21. private void AddLogistician_Load(object sender, EventArgs e)
  22. {
  23. }
  24. private void AddBTN_Click(object sender, EventArgs e)
  25. {
  26. query = new SqlCommand("insert into logisticians (surname_logistician, name_logistician, midname_logistician, number_passport_logistician, place_passport_logistician, date_passport_logistician, code_passport_logistician, telephone_logistician) values (@surname_logistician, @name_logistician, @midname_logistician, @number_passport_logistician, @place_passport_logistician, @date_passport_logistician, @code_passport_logistician, @telephone_logistician)", dbhelper.sqlConnection);
  27. query.Parameters.AddWithValue("surname_logistician", SurnameLogisticianTB.Text);
  28. query.Parameters.AddWithValue("name_logistician", NameLogisticianTB.Text);
  29. query.Parameters.AddWithValue("midname_logistician", MidnameLogisticianTB.Text);
  30. query.Parameters.AddWithValue("number_passport_logistician", NumberPassportLogisticianMTB.Text);
  31. query.Parameters.AddWithValue("place_passport_logistician", PlacePassportLogisticianRTB.Text);
  32. query.Parameters.AddWithValue("date_passport_logistician", DatePassportLogisticianDTP.Value);
  33. query.Parameters.AddWithValue("code_passport_logistician", CodePassportLogisticianMTB.Text);
  34. query.Parameters.AddWithValue("telephone_logistician", TelephoneLogisticianMTB.Text);
  35. if (query.ExecuteNonQuery().ToString().Equals("1"))
  36. {
  37. MessageBox.Show("Добавление прошло успешно!", "Уведомление", MessageBoxButtons.OK, MessageBoxIcon.Information);
  38. this.Close();
  39. }
  40. }
  41. }
  42. }