FormWorkPlace.cs 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Data.SqlClient;
  6. using System.Drawing;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows.Forms;
  11. namespace СУБД_Техносервис
  12. {
  13. public partial class FormWorkPlace : Form
  14. {
  15. public FormWorkPlace()
  16. {
  17. InitializeComponent();
  18. }
  19. string TxtCon = "Data Source=213.155.192.79,3002;Initial Catalog=TechServiceBAU;Persist Security Info=True;User ID=u21baranov;Password=au5p";
  20. /// <summary>
  21. /// вывод данных в виде плиточного интерфейса
  22. /// </summary>
  23. void OutputRequest()
  24. {
  25. SqlConnection con = new SqlConnection(TxtCon);
  26. con.Open();
  27. string TxtQuery = @"SELECT Request.IdRequest, Manager.Photo, (Manager.Surname + ' ' + Manager.Name + ' ' + Manager.Patronymic) as FIOManager, (Client.Surname + ' ' + Client.Name + ' ' + Client.Patronymic) as FIOClient, Request.EquipmentDefect, Request.DateAccepting, TypeDefect.Title as TypeDefect,
  28. Status.Title AS Statys, (SELECT String_AGG(Master.Surname + ' ' + Master.Name + ' ' + Master.Patronymic, ', ')
  29. FROM Employee AS Master INNER JOIN
  30. ExecutionRequest ON Master.IdEmployee = ExecutionRequest.IdMaster
  31. where ExecutionRequest.IdRequest = Request.IdRequest) as FIOMasters
  32. FROM Client INNER JOIN
  33. Request ON Client.IdClient = Request.IdClient INNER JOIN
  34. Employee AS Manager ON Request.IdManager = Manager.IdEmployee INNER JOIN
  35. TypeDefect ON Request.IdTypeDefect = TypeDefect.IdTypeDefect INNER JOIN
  36. Status ON Request.IdStatus = Status.IdStatus";
  37. SqlCommand cmd = new SqlCommand(TxtQuery, con);
  38. SqlDataReader Rez = cmd.ExecuteReader();
  39. DgvRequest.Rows.Clear();
  40. while (Rez.Read())
  41. {
  42. string TxtInfo = $@"Менеджер: {Rez["FIOManager"]}
  43. Клиент: {Rez["FIOClient"]}
  44. Оборудование: {Rez["EquipmentDefect"]}
  45. Заявка добавлена: {Rez["DateAccepting"]}
  46. Тип неисправности: {Rez["TypeDefect"]}
  47. Статус заявки {Rez["Statys"]}";
  48. try
  49. {
  50. DgvRequest.Rows.Add(Rez["IdRequest"], Image.FromFile(Application.StartupPath + "\\Photo\\" + Rez["Photo"]), TxtInfo, $"Исполнители: {Rez["FIOMasters"]}");
  51. }
  52. catch
  53. {
  54. DgvRequest.Rows.Add(Rez["IdRequest"], Image.FromFile(Application.StartupPath + "\\Photo\\Picture.png"), TxtInfo, $"Исполнители: {Rez["FIOMasters"]}");
  55. }
  56. }
  57. con.Close();
  58. }
  59. private void FormWorkPlace_Load(object sender, EventArgs e)
  60. {
  61. OutputRequest();
  62. }
  63. }
  64. }