DannyeAdd.cs 1.4 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 project
  12. {
  13. public partial class DannyeAdd : Form
  14. {
  15. DataBase dataBase = new DataBase();
  16. public DannyeAdd()
  17. {
  18. InitializeComponent();
  19. }
  20. private void button4_Click(object sender, EventArgs e)
  21. {
  22. dataBase.openConnection();
  23. var addQuery = $"insert into Student (name, surname, patronymic, number, group_type, codeCard) values ('{textBox1.Text}','{textBox2.Text}','{textBox3.Text}','{textBox4.Text}','{textBox5.Text}','{textBox6.Text}')";
  24. var command = new SqlCommand(addQuery, dataBase.GetConnection());
  25. command.ExecuteNonQuery();
  26. MessageBox.Show("Запись успешно добавлена в таблицу");
  27. dataBase.closeConnection();
  28. this.Hide();
  29. Main MAIN = new Main();
  30. MAIN.Show();
  31. }
  32. private void DannyeAdd_FormClosed(object sender, FormClosedEventArgs e)
  33. {
  34. Application.Exit();
  35. }
  36. private void button1_Click(object sender, EventArgs e)
  37. {
  38. this.Hide();
  39. Main main = new Main();
  40. main.Show();
  41. }
  42. }
  43. }