RedactorProfile.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using System.Data.SqlClient;
  11. namespace project
  12. {
  13. public partial class RedactorProfile : Form
  14. {
  15. DataBase dataBase = new DataBase();
  16. public RedactorProfile()
  17. {
  18. InitializeComponent();
  19. }
  20. private void RedactorProfile_Load(object sender, EventArgs e)
  21. {
  22. // При загрузке формы в поля вставляются данные пользователя
  23. comboBox1.Text = Convert.ToString(comboBox1.Items[0]);
  24. textBox1.Text = Login.name;
  25. textBox2.Text = Login.surname;
  26. textBox3.Text = Login.number;
  27. }
  28. private void button1_Click(object sender, EventArgs e)
  29. {
  30. dataBase.openConnection();
  31. var addQuery = $"update Employee set name = '{Convert.ToString(textBox1.Text)}', surname = '{Convert.ToString(textBox2.Text)}', number = '{Convert.ToString(textBox3.Text)}', pol = '{Convert.ToString(comboBox1.Text)}' where login = '{Login.login}'";
  32. var command = new SqlCommand(addQuery, dataBase.GetConnection());
  33. command.ExecuteNonQuery();
  34. dataBase.closeConnection();
  35. this.Hide();
  36. Profile profile = new Profile();
  37. profile.Show();
  38. }
  39. }
  40. }