12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- 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 UpdateLogistician : Form
- {
- SqlCommand query = null;
- SqlDataReader reader = null;
- public UpdateLogistician()
- {
- InitializeComponent();
- }
- private void UpdateBTN_Click(object sender, EventArgs e)
- {
- query = new SqlCommand($"update Logisticians set surname_logistician = @surname_logistician, name_logistician = @name_logistician, midname_logistician = @midname_logistician, number_passport_logistician = @number_passport_logistician, place_passport_logistician = @place_passport_logistician, date_passport_logistician = @date_passport_logistician, code_passport_logistician = @code_passport_logistician, telephone_logistician = @telephone_logistician where code_logistician like '{MainMenu.logisticianIndex}'", dbhelper.sqlConnection);
- query.Parameters.AddWithValue("surname_logistician", SurnameLogisticianTB.Text);
- query.Parameters.AddWithValue("name_logistician", NameLogisticianTB.Text);
- query.Parameters.AddWithValue("midname_logistician", MidnameLogisticianTB.Text);
- query.Parameters.AddWithValue("number_passport_logistician", NumberPassportLogisticianMTB.Text);
- query.Parameters.AddWithValue("place_passport_logistician", PlacePassportLogisticianRTB.Text);
- query.Parameters.AddWithValue("date_passport_logistician", DatePassportLogisticianDTP.Value);
- query.Parameters.AddWithValue("code_passport_logistician", CodePassportLogisticianMTB.Text);
- query.Parameters.AddWithValue("telephone_logistician", TelephoneLogisticianMTB.Text);
- if (query.ExecuteNonQuery().ToString().Equals("1"))
- {
- MessageBox.Show("Изменение прошло успешно!", "Уведомление", MessageBoxButtons.OK, MessageBoxIcon.Information);
- this.Close();
- }
- }
- private void UpdateLogistician_Load(object sender, EventArgs e)
- {
- query = new SqlCommand($"select surname_logistician, name_logistician, midname_logistician, number_passport_logistician, place_passport_logistician, date_passport_logistician, code_passport_logistician, telephone_logistician from Logisticians where code_logistician like '{MainMenu.logisticianIndex}'", dbhelper.sqlConnection);
- reader = query.ExecuteReader();
- reader.Read();
- SurnameLogisticianTB.Text = reader.GetString(0);
- NameLogisticianTB.Text = reader.GetString(1);
- MidnameLogisticianTB.Text = reader.GetString(2);
- NumberPassportLogisticianMTB.Text = reader.GetString(3);
- PlacePassportLogisticianRTB.Text = reader.GetString(4);
- DatePassportLogisticianDTP.Value = reader.GetDateTime(5);
- CodePassportLogisticianMTB.Text = reader.GetString(6);
- TelephoneLogisticianMTB.Text = reader.GetString(7);
- reader.Close();
- }
- }
- }
|