123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288 |
- 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)
- {
- FormAddOrder FrmAddOrd = new FormAddOrder();
- FrmAddOrd.ShowDialog();
- FillOrders();
- }
- private void BtnLevin_Click(object sender, EventArgs e)
- {
- FormLevin FrmLev = new FormLevin();
- FrmLev.ShowDialog();
- }
- }
- }
|