using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Data.SqlClient; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace СУБД_Фабрика { public partial class FormZak : Form { public FormZak() { InitializeComponent(); } SqlConnection Con = new SqlConnection(FormMain.txtCon); public class ClothPanel : Panel { public System.Windows.Forms.Label LblComment; public System.Windows.Forms.Label LblLenght; public System.Windows.Forms.Label LblTitle; public System.Windows.Forms.Label LblWidth; public System.Windows.Forms.Label LblColor; public System.Windows.Forms.PictureBox PbxPhoto; public ClothPanel() { this.LblColor = new System.Windows.Forms.Label(); this.LblWidth = new System.Windows.Forms.Label(); this.LblTitle = new System.Windows.Forms.Label(); this.LblLenght = new System.Windows.Forms.Label(); this.LblComment = new System.Windows.Forms.Label(); this.PbxPhoto = new System.Windows.Forms.PictureBox(); this.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.PbxPhoto)).BeginInit(); this.SuspendLayout(); // // panel1 // this.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.BackColor = System.Drawing.Color.WhiteSmoke; this.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.Controls.Add(this.LblComment); this.Controls.Add(this.LblLenght); this.Controls.Add(this.LblTitle); this.Controls.Add(this.LblWidth); this.Controls.Add(this.LblColor); this.Controls.Add(this.PbxPhoto); this.Font = new System.Drawing.Font("Arial Narrow", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204))); this.Location = new System.Drawing.Point(38, 53); this.Name = "panel1"; this.Size = new System.Drawing.Size(391, 132); this.TabIndex = 0; // // LblColor // this.LblColor.AutoSize = true; this.LblColor.Location = new System.Drawing.Point(141, 38); this.LblColor.Name = "LblColor"; this.LblColor.Size = new System.Drawing.Size(35, 16); this.LblColor.TabIndex = 1; this.LblColor.Text = "label1"; // // LblWidth // this.LblWidth.AutoSize = true; this.LblWidth.Location = new System.Drawing.Point(141, 64); this.LblWidth.Name = "LblWidth"; this.LblWidth.Size = new System.Drawing.Size(35, 16); this.LblWidth.TabIndex = 2; this.LblWidth.Text = "label2"; // // LblTitle // this.LblTitle.AutoSize = true; this.LblTitle.Location = new System.Drawing.Point(141, 13); this.LblTitle.Name = "LblTitle"; this.LblTitle.Size = new System.Drawing.Size(35, 16); this.LblTitle.TabIndex = 3; this.LblTitle.Text = "label3"; // // LblLenght // this.LblLenght.AutoSize = true; this.LblLenght.Location = new System.Drawing.Point(141, 80); this.LblLenght.Name = "LblLenght"; this.LblLenght.Size = new System.Drawing.Size(35, 16); this.LblLenght.TabIndex = 4; this.LblLenght.Text = "label4"; // // LblComment // this.LblComment.AutoSize = true; this.LblComment.Location = new System.Drawing.Point(141, 102); this.LblComment.Name = "LblComment"; this.LblComment.Size = new System.Drawing.Size(35, 16); this.LblComment.TabIndex = 5; this.LblComment.Text = "label5"; // // PbxPhoto // this.PbxPhoto.Location = new System.Drawing.Point(12, 13); this.PbxPhoto.Name = "PbxPhoto"; this.PbxPhoto.Size = new System.Drawing.Size(123, 105); this.PbxPhoto.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; this.PbxPhoto.TabIndex = 0; this.PbxPhoto.TabStop = false; } } public class FurnPanel : Panel { public System.Windows.Forms.PictureBox PbxPhoto; public System.Windows.Forms.Label LblCount; public System.Windows.Forms.Label LblTitle; public FurnPanel() { this.PbxPhoto = new System.Windows.Forms.PictureBox(); this.LblCount = new System.Windows.Forms.Label(); this.LblTitle = new System.Windows.Forms.Label(); ((System.ComponentModel.ISupportInitialize)(this.PbxPhoto)).BeginInit(); this.SuspendLayout(); this.SuspendLayout(); // // PbxPhoto // this.PbxPhoto.Location = new System.Drawing.Point(29, 3); this.PbxPhoto.Name = "PbxPhoto"; this.PbxPhoto.Size = new System.Drawing.Size(123, 105); this.PbxPhoto.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; this.PbxPhoto.TabIndex = 0; this.PbxPhoto.TabStop = false; // // LblCount // this.LblCount.AutoSize = true; this.LblCount.Location = new System.Drawing.Point(13, 150); this.LblCount.Name = "LblCount"; this.LblCount.Size = new System.Drawing.Size(35, 16); this.LblCount.TabIndex = 1; this.LblCount.Text = "label1"; // // LblTitle // this.LblTitle.AutoSize = true; this.LblTitle.Location = new System.Drawing.Point(13, 122); this.LblTitle.Name = "LblTitle"; this.LblTitle.Size = new System.Drawing.Size(35, 16); this.LblTitle.TabIndex = 3; this.LblTitle.Text = "label3"; // // panel1 // this.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.BackColor = System.Drawing.Color.WhiteSmoke; this.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.Controls.Add(this.PbxPhoto); this.Controls.Add(this.LblTitle); this.Controls.Add(this.LblCount); this.Font = new System.Drawing.Font("Arial Narrow", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204))); this.Location = new System.Drawing.Point(69, 53); this.Name = "panel1"; this.Size = new System.Drawing.Size(451, 185); this.TabIndex = 0; } } void FillClothes() { string txtQuery = "SELECT Title, Color, Width, Length, Comment, Photo FROM Cloth"; Con.Open(); SqlCommand query = new SqlCommand(txtQuery, Con); SqlDataReader res = query.ExecuteReader(); while (res.Read()) { ClothPanel cp = new ClothPanel(); cp.LblTitle.Text = "Название " + res["Title"].ToString(); cp.LblColor.Text = "Цвет: " + res["Color"].ToString(); cp.LblLenght.Text = "Длина: " + res["Length"].ToString(); cp.LblWidth.Text = "Ширина: " + res["Width"].ToString(); cp.LblComment.Text = "Описание: " + res["Comment"].ToString(); try { cp.PbxPhoto.Image = Image.FromFile(Application.StartupPath + "\\Clothes\\" + res["Photo"]); } catch { cp.PbxPhoto.Image = Image.FromFile(Application.StartupPath + "\\Picture.png"); } PanelClothes.Controls.Add(cp); } Con.Close(); } void FillFur() { string txtQuery = "SELECT namefur, photo, countfur FROM Furnitura"; Con.Open(); SqlCommand query = new SqlCommand(txtQuery, Con); SqlDataReader res = query.ExecuteReader(); while (res.Read()) { FurnPanel fp = new FurnPanel(); fp.LblTitle.Text = "Название " + res["namefur"].ToString(); fp.LblCount.Text = "Кол-во на складе: " + res["countfur"].ToString(); try { fp.PbxPhoto.Image = Image.FromFile(Application.StartupPath + "\\Furn\\" + res["Photo"]); } catch { fp.PbxPhoto.Image = Image.FromFile(Application.StartupPath + "\\Picture.png"); } PanelFurn.Controls.Add(fp); } Con.Close(); } void FillOrders() { string txtQuery = $@"SELECT Izdelia.Title as Izd, Users.Fam, Cloth.Title AS Cloth, Furnitura.namefur, Orders.CountFur, Orders.CountIzd FROM Cloth INNER JOIN Orders ON Cloth.IDCloth = Orders.IDCloth INNER JOIN Furnitura ON Orders.IDFur = Furnitura.idfur INNER JOIN Izdelia ON Orders.IDIzd = Izdelia.IDIzd INNER JOIN Users ON Orders.IDMen = Users.IDUser where Users.Role = 2 and Orders.IDZak = {FormMain.IDUser}"; Con.Open(); SqlCommand query = new SqlCommand(txtQuery, Con); SqlDataReader res = query.ExecuteReader(); int i = 0; while (res.Read()) { DgvOrders.Rows.Add(); DgvOrders.Rows[i].Cells[0].Value = res["Izd"].ToString(); DgvOrders.Rows[i].Cells[1].Value = (res["Fam"].ToString()); DgvOrders.Rows[i].Cells[2].Value = (res["Cloth"].ToString()); DgvOrders.Rows[i].Cells[3].Value = (res["namefur"].ToString()); DgvOrders.Rows[i].Cells[4].Value = (res["CountFur"].ToString()); DgvOrders.Rows[i].Cells[5].Value = (res["CountIzd"].ToString()); i++; } Con.Close(); } private void FormZak_Load(object sender, EventArgs e) { // TODO: This line of code loads data into the 'sewingFactoryMURDataSet1.Izdelia' table. You can move, or remove it, as needed. this.izdeliaTableAdapter.Fill(this.sewingFactoryMURDataSet1.Izdelia); // TODO: This line of code loads data into the 'sewingFactoryMURDataSet1.Users' table. You can move, or remove it, as needed. this.usersTableAdapter.Fill(this.sewingFactoryMURDataSet1.Users); BsUsers.Filter = $"IDUser = {FormMain.IDUser}"; FillFur(); FillClothes(); FillOrders(); } private void BtnProfile_Click(object sender, EventArgs e) { FormProfile FrmProf = new FormProfile(); if(FrmProf.ShowDialog() == DialogResult.OK) { this.usersTableAdapter.Fill(this.sewingFactoryMURDataSet1.Users); } } private void BtnAddZak_Click(object sender, EventArgs e) { } } }