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 static System.Windows.Forms.VisualStyles.VisualStyleElement; namespace WindowsFormsApp19 { public partial class Form2 : Form { public Form2() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { { if ((textBox1.Text == "") || (textBox2.Text == "") || (textBox3.Text == "") || (textBox4.Text == "") || (textBox5.Text == "")) { MessageBox.Show("Заполните ВСЕ поля"); } else { DataTable data = DbConnection.select(@"INSERT INTO Products (`Name`, `Article`,`Type`, `Min_cost`,`Type_coefficient`) VALUES ('" + textBox1.Text + "', '" + textBox2.Text + "', '" + textBox3.Text + ",'" + textBox4.Text + "','" + textBox5.Text + "');"); data = DbConnection.select(@"SELECT * FROM Products"); textBox1.Clear(); textBox2.Clear(); textBox3.Clear(); textBox4.Clear(); textBox5.Clear(); dataGridView1.DataSource = data; } } } private void Form2_Load(object sender, EventArgs e) { DataTable data = DbConnection.select("SELECT * FROM `Products`"); dataGridView1.DataSource = data; } } }