12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using System.Data.SqlClient;
- namespace proba
- {
- public partial class CountryAdd : Form
- {
- public int razmer = 0;
- public static string[] add_country = new string[1];
- DataBase dataBase = new DataBase();
- public CountryAdd()
- {
- InitializeComponent();
- }
- private void button_save_Click(object sender, EventArgs e)
- {
- if (textBox1.Text.Replace(" ", "") == "") MessageBox.Show("Поле страна не может быть пустым");
- else
- {
- dataBase.openConnection();
- var country = textBox1.Text;
- var addQuery = $"insert into [Country] (country) values (N'{country}')";
- var command = new SqlCommand(addQuery, dataBase.GetConnection());
- command.ExecuteNonQuery();
- MessageBox.Show("Запись успешно добавлена в таблицу");
- add_country[razmer] = textBox1.Text;
- Array.Resize(ref add_country, add_country.Length + 1);
- razmer++;
- dataBase.closeConnection();
- }
- }
- public void global_FormClosed(object sender, EventArgs e)
- {
- Application.Exit();
- }
- private void button_back_Click(object sender, EventArgs e)
- {
- this.Hide();
- Country nomenklatura = new Country();
- nomenklatura.ShowDialog();
- }
- }
- }
|