using MySql.Data.MySqlClient; 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; namespace ekz_lednev { public partial class Form3 : Form { public Form3() { InitializeComponent(); } private void Form3_Load(object sender, EventArgs e) { } // Функция Редактирования private void button1_Click(object sender, EventArgs e) { } //Обновление датагридвью и закрытие формочки добавления private void button2_Click(object sender, EventArgs e) { Application.Restart(); this.Close(); } private void button1_Click_1(object sender, EventArgs e) { DB dB = DB.GetInstance(); MySqlCommand cmd = new MySqlCommand($@"UPDATE `pozorisp_lednev_ekz`.`Material` SET `name` = '{textBox1.Text}', `material_type_id` = '{textBox2.Text}', `price_one` = '{textBox3.Text}', `quantity_real` = '{textBox4.Text}', `quantity_plan` = '{textBox5.Text}', `quantity_pack` = '{textBox6.Text}', `unit_id` = '{textBox7.Text}' WHERE (`id` = '{textBox8.Text}');", dB.GetConnection()); cmd.ExecuteNonQuery(); MessageBox.Show("Изменено!"); Application.Restart(); } private void button2_Click_1(object sender, EventArgs e) { Application.Restart(); this.Close(); } private void button3_Click(object sender, EventArgs e) { MessageBox.Show($"Заполните все поля и нажмите кнопку редактировать, готово!" + "" + " Если вы не хотите изменять данные в поле, просто введите то же значение, что и было до этого"); } } }