GLavn.cs 2.5 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 Дол_Восток
  12. {
  13. public partial class GLavn : Form
  14. {
  15. string queryText = null;
  16. SqlCommand query = null;
  17. public GLavn()
  18. {
  19. InitializeComponent();
  20. }
  21. private void GLavn_Load(object sender, EventArgs e)
  22. {
  23. switch (tabControl1.SelectedIndex)
  24. {
  25. case 0:
  26. queryText = $"select kod_sotrudnic as '№', surname as 'Фамилия', name as 'Имя', patronymic as 'Отчество', dolgnost as 'Должность' from Sotrudnic join dolgnost on dolgnost.kod_dolgnost = sotrudnic.kod_dolgnost";
  27. break;
  28. case 1:
  29. break;
  30. }
  31. SqlDataAdapter dataAdapter = new SqlDataAdapter($"select kod_sotrudnic as '№', surname as 'Фамилия', name as 'Имя', patronymic as 'Отчество', dolgnost as 'Должность' from Sotrudnic join dolgnost on dolgnost.kod_dolgnost = sotrudnic.kod_dolgnost", db_helper.sqlConnection);
  32. DataSet dataSet = new DataSet();
  33. dataAdapter.Fill(dataSet);
  34. Sotrudnici.DataSource = dataSet.Tables[0];
  35. }
  36. private void GLavn_FormClosing(object sender, FormClosingEventArgs e)
  37. {
  38. Application.Exit();
  39. }
  40. private void splitContainer1_Panel2_Paint(object sender, PaintEventArgs e)
  41. {
  42. }
  43. private void bt_add_Click(object sender, EventArgs e)
  44. {
  45. }
  46. private void bt_delete_Click(object sender, EventArgs e)
  47. {
  48. string row = Sotrudnici.Rows[Sotrudnici.CurrentCell.RowIndex].Cells[0].Value.ToString();
  49. query = new SqlCommand($"select kod_passport from sotrudnic where kod_sotrudnic like '{row}'", db_helper.sqlConnection);
  50. string kodPassport = query.ExecuteScalar().ToString();
  51. query = new SqlCommand($"select kod_experience from sotrudnic where kod_sotrudnic like '{row}'", db_helper.sqlConnection);
  52. string kodExperience = query.ExecuteScalar().ToString();
  53. MessageBox.Show($"kod_sotrudnic = {row}\nkod_passport = {kodPassport}\nkod_experience = {kodExperience}");
  54. }
  55. private void bt_change_Click(object sender, EventArgs e)
  56. {
  57. }
  58. }
  59. }