VidNomenklatury_add.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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.Data.SqlClient;
  10. using System.Windows.Forms;
  11. namespace proba
  12. {
  13. public partial class VidNomenklatury_add : Form
  14. {
  15. DataBase dataBase = new DataBase();
  16. public VidNomenklatury_add()
  17. {
  18. InitializeComponent();
  19. }
  20. private void button_back_Click(object sender, EventArgs e)
  21. {
  22. this.Hide();
  23. VidNomenkatury vidNomenkatury = new VidNomenkatury();
  24. vidNomenkatury.ShowDialog();
  25. }
  26. private void button_save_Click(object sender, EventArgs e)
  27. {
  28. dataBase.openConnection();
  29. var view_tools = text_description.Text;
  30. var addQuery = $"insert into [View_tools] (view_tools) values (N'{view_tools}')";
  31. var command = new SqlCommand(addQuery, dataBase.GetConnection());
  32. command.ExecuteNonQuery();
  33. MessageBox.Show("Запись успешно добавлена в таблицу");
  34. dataBase.closeConnection();
  35. }
  36. private void VidNomenklatury_add_FormClosing(object sender, FormClosingEventArgs e)
  37. {
  38. Application.Exit();
  39. }
  40. }
  41. }