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 Transportation { public partial class UpdateExecutor : Form { SqlCommand query = null; SqlDataReader reader = null; public UpdateExecutor() { InitializeComponent(); } private void UpdateExecutor_Load(object sender, EventArgs e) { query = new SqlCommand($"select surname_executor as 'Фамилия исполнителя', name_executor as 'Имя исполнителя', midname_executor as 'Отчество исполнителя' from Executors where code_executor like '{MainMenu.executorIndex}'", dbhelper.sqlConnection); reader = query.ExecuteReader(); reader.Read(); SurnameExecutorTB.Text = reader.GetString(0); NameExecutorTB.Text = reader.GetString(1); MidnameExecutorTB.Text = reader.GetString(2); reader.Close(); } private void UpdateBTN_Click(object sender, EventArgs e) { query = new SqlCommand($"update executors set surname_executor = @surname_executor, name_executor = @name_executor, midname_executor = @midname_executor where code_executor like '{MainMenu.executorIndex}'", dbhelper.sqlConnection); query.Parameters.AddWithValue("surname_executor", SurnameExecutorTB.Text); query.Parameters.AddWithValue("name_executor", NameExecutorTB.Text); query.Parameters.AddWithValue("midname_executor", MidnameExecutorTB.Text); if (query.ExecuteNonQuery().ToString().Equals("1")) { MessageBox.Show("Изменение прошло успешно!", "Уведомление", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } } } }