Profile.cs 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 Profile : Form
  14. {
  15. public static string login;
  16. DataBase dataBase = new DataBase();
  17. public Profile()
  18. {
  19. InitializeComponent();
  20. }
  21. private void Profile_Load(object sender, EventArgs e)
  22. {
  23. string proverkaLogin = Login.login;
  24. dataBase.openConnection();
  25. SqlCommand sqlCommand2 = new SqlCommand($"SELECT name From Employee WHERE login = '{proverkaLogin}'", dataBase.GetConnection());
  26. string namePolzovatel = sqlCommand2.ExecuteScalar().ToString();
  27. if (namePolzovatel == "")
  28. label1.Text = label1.Text + " Отсутствует";
  29. else
  30. label1.Text = label1.Text + " " + namePolzovatel;
  31. Login.name = namePolzovatel;
  32. sqlCommand2 = new SqlCommand($"SELECT surname From Employee WHERE login = '{proverkaLogin}'", dataBase.GetConnection());
  33. string surnamePolzovatel = sqlCommand2.ExecuteScalar().ToString();
  34. if (surnamePolzovatel == "")
  35. label2.Text = label2.Text + " Отсутствует";
  36. else
  37. label2.Text = label2.Text + " " + surnamePolzovatel;
  38. Login.surname = surnamePolzovatel;
  39. sqlCommand2 = new SqlCommand($"SELECT number From Employee WHERE login = '{proverkaLogin}'", dataBase.GetConnection());
  40. string numberPolzovatel = sqlCommand2.ExecuteScalar().ToString();
  41. if (numberPolzovatel == "")
  42. label3.Text = label3.Text + " Отсутствует";
  43. else
  44. label3.Text = label3.Text + " " + numberPolzovatel;
  45. Login.number = numberPolzovatel;
  46. sqlCommand2 = new SqlCommand($"SELECT pol From Employee WHERE login = '{proverkaLogin}'", dataBase.GetConnection());
  47. string polPolzovatel = sqlCommand2.ExecuteScalar().ToString();
  48. if (polPolzovatel == "")
  49. label4.Text = label4.Text + " Не указан";
  50. else
  51. label4.Text = label4.Text + " " + polPolzovatel;
  52. sqlCommand2 = new SqlCommand($"SELECT id From Employee WHERE login = '{proverkaLogin}'", dataBase.GetConnection());
  53. string idPolzovatel = sqlCommand2.ExecuteScalar().ToString();
  54. label5.Text = label5.Text + " " + idPolzovatel;
  55. sqlCommand2 = new SqlCommand($"SELECT administrator From Employee WHERE login = '{proverkaLogin}'", dataBase.GetConnection());
  56. string admPolzovatel = sqlCommand2.ExecuteScalar().ToString();
  57. if (admPolzovatel.Trim() == "true")
  58. label6.Visible = true;
  59. }
  60. private void button1_Click(object sender, EventArgs e)
  61. {
  62. RedactorProfile redactorProfile = new RedactorProfile();
  63. this.Hide();
  64. redactorProfile.Show();
  65. }
  66. }
  67. }