FormStorekeeper.cs 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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 FormStorekeeper : Form
  14. {
  15. public FormStorekeeper()
  16. {
  17. InitializeComponent();
  18. }
  19. private void FormStorekeeper_Load(object sender, EventArgs e)
  20. {
  21. // TODO: This line of code loads data into the 'fabrikaLDADataSet.Furnitura' table. You can move, or remove it, as needed.
  22. this.furnituraTableAdapter.Fill(this.fabrikaLDADataSet.Furnitura);
  23. // TODO: This line of code loads data into the 'fabrikaLDADataSet.Cloth' table. You can move, or remove it, as needed.
  24. this.clothTableAdapter.Fill(this.fabrikaLDADataSet.Cloth);
  25. SqlConnection con = new SqlConnection(FormAuthorization.StrCon);
  26. con.Open();
  27. SqlCommand cmd = new SqlCommand($@"select Fam,Name,Otch from Users where IdUser = {FormAuthorization.IdUser}", con);
  28. SqlDataReader res = cmd.ExecuteReader();
  29. res.Read();
  30. lblFIO.Text = $"{res["Fam"]} {res["Name"]} {res["Otch"]}";
  31. res.Close();
  32. con.Close();
  33. GetOrdersFromDB();
  34. }
  35. private void btnEdit_Click(object sender, EventArgs e)
  36. {
  37. FormEditUser frm = new FormEditUser();
  38. this.Hide();
  39. frm.ShowDialog();
  40. this.Show();
  41. }
  42. void GetOrdersFromDB()
  43. {
  44. SqlConnection con = new SqlConnection(FormAuthorization.StrCon);
  45. con.Open();
  46. SqlCommand cmd = new SqlCommand($@"Select Orders.IdOrder,Products.TitleProduct,Products.Lenght,Products.Width,Orders.IdClient,Cloth.Title as ClothTitle, Colors.Title as
  47. ColorTitle,
  48. Furnitura.namefur,Orders.CountFurnitura,
  49. Orders.CountProduct
  50. from Orders join Users on Users.IdUser = Orders.IdClient join Products on
  51. Products.IdProduct = Orders.IdProduct join Cloth on Cloth.IdCloth = Orders.IdCloth join Furnitura on
  52. Furnitura.idfur = Orders.IdFur join Colors on Cloth.IdColor = Colors.IdColor", con);
  53. SqlDataReader res = cmd.ExecuteReader();
  54. while (res.Read())
  55. {
  56. // dgvOrders.Rows.Add(res["Products.TitleProduct"], res["Orders.CountProduct"], res["Cloth.Title"], res["Furnitura.namefur"], res["Orders.CountFurnitura"]);
  57. }
  58. res.Close();
  59. con.Close();
  60. }
  61. void GetClothFromDB()
  62. {
  63. SqlConnection con = new SqlConnection(FormAuthorization.StrCon); // Возможны ошибки с названием цвета
  64. SqlCommand cmd = new SqlCommand(@"SELECT Cloth.IdCloth, Cloth.Title, Cloth.IdColor, Cloth.Weight, Cloth.Height, Cloth.Note, Cloth.Photo,
  65. Colors.IdColor AS Expr1, Colors.Title AS ColorTitle
  66. FROM Cloth INNER JOIN
  67. Colors ON Cloth.IdColor = Colors.IdColor", con);
  68. con.Open();
  69. SqlDataReader res = cmd.ExecuteReader();
  70. while (res.Read())
  71. {
  72. ListViewItem lv = new ListViewItem();
  73. // lvCloth.Items.Add(lv);
  74. }
  75. res.Close();
  76. con.Close();
  77. }
  78. private void btnDoc_Click(object sender, EventArgs e)
  79. {
  80. FormAddTovar frm = new FormAddTovar();
  81. this.Hide();
  82. frm.ShowDialog();
  83. this.Show();
  84. }
  85. }
  86. }