diff --git a/demo25052026.sln b/demo25052026.sln new file mode 100644 index 0000000..35016e1 --- /dev/null +++ b/demo25052026.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.37027.11 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "demo25052026", "demo25052026\demo25052026.csproj", "{F5E8BDB8-DEBC-4BC0-AFD9-499110BC8FA7}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {F5E8BDB8-DEBC-4BC0-AFD9-499110BC8FA7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F5E8BDB8-DEBC-4BC0-AFD9-499110BC8FA7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F5E8BDB8-DEBC-4BC0-AFD9-499110BC8FA7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F5E8BDB8-DEBC-4BC0-AFD9-499110BC8FA7}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {3456BF3B-02F1-4EE3-A1AF-2B26850E5679} + EndGlobalSection +EndGlobal diff --git a/demo25052026/1.jpg b/demo25052026/1.jpg new file mode 100644 index 0000000..238c32b Binary files /dev/null and b/demo25052026/1.jpg differ diff --git a/demo25052026/10.jpg b/demo25052026/10.jpg new file mode 100644 index 0000000..a6e4c3d Binary files /dev/null and b/demo25052026/10.jpg differ diff --git a/demo25052026/2.jpg b/demo25052026/2.jpg new file mode 100644 index 0000000..8b38894 Binary files /dev/null and b/demo25052026/2.jpg differ diff --git a/demo25052026/3.jpg b/demo25052026/3.jpg new file mode 100644 index 0000000..39443e0 Binary files /dev/null and b/demo25052026/3.jpg differ diff --git a/demo25052026/4.jpg b/demo25052026/4.jpg new file mode 100644 index 0000000..d375624 Binary files /dev/null and b/demo25052026/4.jpg differ diff --git a/demo25052026/5.jpg b/demo25052026/5.jpg new file mode 100644 index 0000000..f7af58a Binary files /dev/null and b/demo25052026/5.jpg differ diff --git a/demo25052026/6.jpg b/demo25052026/6.jpg new file mode 100644 index 0000000..e20b800 Binary files /dev/null and b/demo25052026/6.jpg differ diff --git a/demo25052026/7.jpg b/demo25052026/7.jpg new file mode 100644 index 0000000..a268000 Binary files /dev/null and b/demo25052026/7.jpg differ diff --git a/demo25052026/8.jpg b/demo25052026/8.jpg new file mode 100644 index 0000000..b94c062 Binary files /dev/null and b/demo25052026/8.jpg differ diff --git a/demo25052026/9.jpg b/demo25052026/9.jpg new file mode 100644 index 0000000..abe73b4 Binary files /dev/null and b/demo25052026/9.jpg differ diff --git a/demo25052026/Form1.Designer.cs b/demo25052026/Form1.Designer.cs new file mode 100644 index 0000000..8f33deb --- /dev/null +++ b/demo25052026/Form1.Designer.cs @@ -0,0 +1,129 @@ + +namespace demo25052026 +{ + partial class Form1 + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel(); + this.comboBox1 = new System.Windows.Forms.ComboBox(); + this.comboBox2 = new System.Windows.Forms.ComboBox(); + this.textBox1 = new System.Windows.Forms.TextBox(); + this.button1 = new System.Windows.Forms.Button(); + this.button2 = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // flowLayoutPanel1 + // + this.flowLayoutPanel1.AutoScroll = true; + this.flowLayoutPanel1.Location = new System.Drawing.Point(12, 51); + this.flowLayoutPanel1.Name = "flowLayoutPanel1"; + this.flowLayoutPanel1.Size = new System.Drawing.Size(1054, 387); + this.flowLayoutPanel1.TabIndex = 0; + // + // comboBox1 + // + this.comboBox1.FormattingEnabled = true; + this.comboBox1.Items.AddRange(new object[] { + "Все поставщики", + "Kari", + "Обувь для вас"}); + this.comboBox1.Location = new System.Drawing.Point(12, 13); + this.comboBox1.Name = "comboBox1"; + this.comboBox1.Size = new System.Drawing.Size(192, 28); + this.comboBox1.TabIndex = 1; + this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged); + // + // comboBox2 + // + this.comboBox2.FormattingEnabled = true; + this.comboBox2.Items.AddRange(new object[] { + "По возврастанию количества", + "По убыванию количества"}); + this.comboBox2.Location = new System.Drawing.Point(225, 17); + this.comboBox2.Name = "comboBox2"; + this.comboBox2.Size = new System.Drawing.Size(183, 28); + this.comboBox2.TabIndex = 2; + this.comboBox2.SelectedIndexChanged += new System.EventHandler(this.comboBox2_SelectedIndexChanged); + // + // textBox1 + // + this.textBox1.Location = new System.Drawing.Point(440, 13); + this.textBox1.Name = "textBox1"; + this.textBox1.Size = new System.Drawing.Size(320, 27); + this.textBox1.TabIndex = 3; + this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged); + // + // button1 + // + this.button1.Location = new System.Drawing.Point(806, 11); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(137, 29); + this.button1.TabIndex = 4; + this.button1.Text = "Добавить"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // button2 + // + this.button2.Location = new System.Drawing.Point(963, 13); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(94, 29); + this.button2.TabIndex = 5; + this.button2.Text = "Заказы"; + this.button2.UseVisualStyleBackColor = true; + this.button2.Click += new System.EventHandler(this.button2_Click); + // + // Form1 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(1078, 450); + this.Controls.Add(this.button2); + this.Controls.Add(this.button1); + this.Controls.Add(this.textBox1); + this.Controls.Add(this.comboBox2); + this.Controls.Add(this.comboBox1); + this.Controls.Add(this.flowLayoutPanel1); + this.Name = "Form1"; + this.Text = "Form1"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1; + private System.Windows.Forms.ComboBox comboBox1; + private System.Windows.Forms.ComboBox comboBox2; + private System.Windows.Forms.TextBox textBox1; + private System.Windows.Forms.Button button1; + private System.Windows.Forms.Button button2; + } +} + diff --git a/demo25052026/Form1.cs b/demo25052026/Form1.cs new file mode 100644 index 0000000..1c464cb --- /dev/null +++ b/demo25052026/Form1.cs @@ -0,0 +1,141 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using Npgsql; + +namespace demo25052026 +{ + public partial class Form1 : Form + { + static string connS = "Server=localhost;Port=5432;Database=newdemo26;Username=postgres;Password=Swa2sWA13;"; + public Form1() + { + InitializeComponent(); + + NpgsqlConnection npgsqlConnection = new NpgsqlConnection(connS); + npgsqlConnection.Open(); + NpgsqlCommand command = new NpgsqlCommand(@$"SELECT (SELECT ""Imia"" FROM public.""Naimenov"" WHERE ""Naimenov"".""ID_Naimenov"" = ""Tovar"".""Naimenov_ID""), (SELECT ""Imia"" FROM public.""Tip"" WHERE ""Tip"".""ID_Tip"" = ""Tovar"".""Tip_ID""), ""Ed_izm"", ""Cena"", (SELECT ""Imia"" FROM public.""Postav"" WHERE ""Postav"".""ID_Postav"" = ""Tovar"".""Postav_ID""), (SELECT ""Imia"" FROM public.""Proizv"" WHERE ""Proizv"".""ID_Proizv"" = ""Proizv_ID""), ""Skidka"", ""Kolichestvo"", ""Opisanie"", ""Photo"", ""ID_Tovar"" FROM public.""Tovar"";", npgsqlConnection); + DataTable data = new DataTable(); + data.Load(command.ExecuteReader()); + + for (int i = 0; i < data.Rows.Count; i++) + { + UCTovar uCTovar = new UCTovar(this); + uCTovar.textBox1.Text = data.Rows[i].ItemArray[0].ToString(); + uCTovar.textBox1.Text = uCTovar.textBox1.Text + " | " + data.Rows[i].ItemArray[1].ToString(); + + uCTovar.textBox2.Text = data.Rows[i].ItemArray[8].ToString(); + uCTovar.textBox3.Text = data.Rows[i].ItemArray[4].ToString(); + uCTovar.textBox4.Text = data.Rows[i].ItemArray[5].ToString(); + uCTovar.textBox5.Text = data.Rows[i].ItemArray[3].ToString(); + uCTovar.textBox6.Text = data.Rows[i].ItemArray[2].ToString(); + uCTovar.textBox7.Text = data.Rows[i].ItemArray[7].ToString(); + + uCTovar.Skidka.Text = data.Rows[i].ItemArray[6].ToString(); + if (data.Rows[i].ItemArray[9].ToString() != "") uCTovar.Photo.Image = Image.FromFile(data.Rows[i].ItemArray[9].ToString()); + else uCTovar.Photo.Image = Image.FromFile("picture.png"); + uCTovar.Name = data.Rows[i].ItemArray[10].ToString(); + flowLayoutPanel1.Controls.Add(uCTovar); + } + + npgsqlConnection.Close(); + + } + + private void textBox1_TextChanged(object sender, EventArgs e) + { + AllPoisk(comboBox2.SelectedIndex, comboBox1.SelectedIndex); + } + + public void AllPoisk(int sort, int filtr) + { + flowLayoutPanel1.Controls.Clear(); + + NpgsqlConnection npgsqlConnection = new NpgsqlConnection(connS); + npgsqlConnection.Open(); + string dob = ""; + if(sort == 0) + { + dob = $@"ORDER BY ""Skidka"" ASC"; + } + else if (sort == 1) + { + dob = $@"ORDER BY ""Skidka"" DESC"; + } + + string dob2 = ""; + if(filtr == 1) + { + dob2 = $@" AND (SELECT ""Imia"" FROM public.""Postav"" WHERE ""Postav"".""ID_Postav"" = ""Tovar"".""Postav_ID"") = 'Kari'"; + + } + else if (filtr == 2) + { + dob2 = $@" AND (SELECT ""Imia"" FROM public.""Postav"" WHERE ""Postav"".""ID_Postav"" = ""Tovar"".""Postav_ID"") = 'Обувь для вас'"; + } + + NpgsqlCommand command = new NpgsqlCommand(@$"SELECT (SELECT ""Imia"" FROM public.""Naimenov"" WHERE ""Naimenov"".""ID_Naimenov"" = ""Tovar"".""Naimenov_ID""), (SELECT ""Imia"" FROM public.""Tip"" WHERE ""Tip"".""ID_Tip"" = ""Tovar"".""Tip_ID""), ""Ed_izm"", ""Cena"", (SELECT ""Imia"" FROM public.""Postav"" WHERE ""Postav"".""ID_Postav"" = ""Tovar"".""Postav_ID""), (SELECT ""Imia"" FROM public.""Proizv"" WHERE ""Proizv"".""ID_Proizv"" = ""Proizv_ID""), ""Skidka"", ""Kolichestvo"", ""Opisanie"", ""Photo"", ""ID_Tovar"" FROM public.""Tovar"" WHERE (SELECT ""Imia"" FROM public.""Naimenov"" WHERE ""Naimenov"".""ID_Naimenov"" = ""Tovar"".""Naimenov_ID"") || (SELECT ""Imia"" FROM public.""Tip"" WHERE ""Tip"".""ID_Tip"" = ""Tovar"".""Tip_ID"") || ""Ed_izm"" || ""Cena"" || (SELECT ""Imia"" FROM public.""Postav"" WHERE ""Postav"".""ID_Postav"" = ""Tovar"".""Postav_ID"") || (SELECT ""Imia"" FROM public.""Proizv"" WHERE ""Proizv"".""ID_Proizv"" = ""Proizv_ID"") || ""Skidka"" ||""Kolichestvo"" || ""Opisanie"" || ""Photo"" ILIKE '%{textBox1.Text}%' " + dob2 + dob, npgsqlConnection); + DataTable data = new DataTable(); + data.Load(command.ExecuteReader()); + + for (int i = 0; i < data.Rows.Count; i++) + { + UCTovar uCTovar = new UCTovar(this); + uCTovar.textBox1.Text = data.Rows[i].ItemArray[0].ToString(); + uCTovar.textBox1.Text = uCTovar.textBox1.Text + " | " + data.Rows[i].ItemArray[1].ToString(); + + uCTovar.textBox2.Text = data.Rows[i].ItemArray[8].ToString(); + uCTovar.textBox3.Text = data.Rows[i].ItemArray[4].ToString(); + uCTovar.textBox4.Text = data.Rows[i].ItemArray[5].ToString(); + uCTovar.textBox5.Text = data.Rows[i].ItemArray[3].ToString(); + uCTovar.textBox6.Text = data.Rows[i].ItemArray[2].ToString(); + uCTovar.textBox7.Text = data.Rows[i].ItemArray[7].ToString(); + + uCTovar.Skidka.Text = data.Rows[i].ItemArray[6].ToString(); + if (data.Rows[i].ItemArray[9].ToString() != "") uCTovar.Photo.Image = Image.FromFile(data.Rows[i].ItemArray[9].ToString()); + else uCTovar.Photo.Image = Image.FromFile("picture.png"); + uCTovar.Name = data.Rows[i].ItemArray[10].ToString(); + flowLayoutPanel1.Controls.Add(uCTovar); + } + + npgsqlConnection.Close(); + } + + private void comboBox2_SelectedIndexChanged(object sender, EventArgs e) + { + + AllPoisk(comboBox2.SelectedIndex, comboBox1.SelectedIndex); + + + + } + + private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) + { + + AllPoisk(comboBox2.SelectedIndex, comboBox1.SelectedIndex); + + + } + + private void button1_Click(object sender, EventArgs e) + { + this.Hide(); + Form2 form2 = new Form2(0); + form2.ShowDialog(); + } + + private void button2_Click(object sender, EventArgs e) + { + this.Hide(); + Form3 form = new Form3(); + form.ShowDialog(); + } + } +} diff --git a/demo25052026/Form1.resx b/demo25052026/Form1.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/demo25052026/Form1.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/demo25052026/Form2.Designer.cs b/demo25052026/Form2.Designer.cs new file mode 100644 index 0000000..f3162ba --- /dev/null +++ b/demo25052026/Form2.Designer.cs @@ -0,0 +1,235 @@ + +namespace demo25052026 +{ + partial class Form2 + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.textBox7 = new System.Windows.Forms.TextBox(); + this.textBox5 = new System.Windows.Forms.TextBox(); + this.textBox2 = new System.Windows.Forms.TextBox(); + this.Skidka = new System.Windows.Forms.TextBox(); + this.Photo = new System.Windows.Forms.PictureBox(); + this.button1 = new System.Windows.Forms.Button(); + this.button2 = new System.Windows.Forms.Button(); + this.button4 = new System.Windows.Forms.Button(); + this.comboBox1 = new System.Windows.Forms.ComboBox(); + this.comboBox2 = new System.Windows.Forms.ComboBox(); + this.comboBox3 = new System.Windows.Forms.ComboBox(); + this.comboBox4 = new System.Windows.Forms.ComboBox(); + this.comboBox5 = new System.Windows.Forms.ComboBox(); + this.textBox1 = new System.Windows.Forms.TextBox(); + ((System.ComponentModel.ISupportInitialize)(this.Photo)).BeginInit(); + this.SuspendLayout(); + // + // textBox7 + // + this.textBox7.Location = new System.Drawing.Point(295, 253); + this.textBox7.Name = "textBox7"; + this.textBox7.Size = new System.Drawing.Size(349, 27); + this.textBox7.TabIndex = 17; + // + // textBox5 + // + this.textBox5.Location = new System.Drawing.Point(295, 187); + this.textBox5.Name = "textBox5"; + this.textBox5.Size = new System.Drawing.Size(349, 27); + this.textBox5.TabIndex = 15; + // + // textBox2 + // + this.textBox2.Location = new System.Drawing.Point(290, 46); + this.textBox2.Multiline = true; + this.textBox2.Name = "textBox2"; + this.textBox2.Size = new System.Drawing.Size(354, 69); + this.textBox2.TabIndex = 12; + // + // Skidka + // + this.Skidka.Location = new System.Drawing.Point(669, 12); + this.Skidka.Multiline = true; + this.Skidka.Name = "Skidka"; + this.Skidka.Size = new System.Drawing.Size(185, 72); + this.Skidka.TabIndex = 11; + // + // Photo + // + this.Photo.Location = new System.Drawing.Point(12, 3); + this.Photo.Name = "Photo"; + this.Photo.Size = new System.Drawing.Size(258, 266); + this.Photo.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; + this.Photo.TabIndex = 9; + this.Photo.TabStop = false; + this.Photo.Click += new System.EventHandler(this.Photo_Click); + // + // button1 + // + this.button1.Location = new System.Drawing.Point(23, 307); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(94, 29); + this.button1.TabIndex = 18; + this.button1.Text = "Назад"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // button2 + // + this.button2.Location = new System.Drawing.Point(798, 307); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(94, 29); + this.button2.TabIndex = 19; + this.button2.Text = "Сохранить"; + this.button2.UseVisualStyleBackColor = true; + this.button2.Click += new System.EventHandler(this.button2_Click); + // + // button4 + // + this.button4.Location = new System.Drawing.Point(669, 307); + this.button4.Name = "button4"; + this.button4.Size = new System.Drawing.Size(94, 29); + this.button4.TabIndex = 21; + this.button4.Text = "Удалить"; + this.button4.UseVisualStyleBackColor = true; + this.button4.Click += new System.EventHandler(this.button4_Click); + // + // comboBox1 + // + this.comboBox1.FormattingEnabled = true; + this.comboBox1.Items.AddRange(new object[] { + "Женская обувь", + "Мужская обувь"}); + this.comboBox1.Location = new System.Drawing.Point(290, 12); + this.comboBox1.Name = "comboBox1"; + this.comboBox1.Size = new System.Drawing.Size(151, 28); + this.comboBox1.TabIndex = 22; + // + // comboBox2 + // + this.comboBox2.FormattingEnabled = true; + this.comboBox2.Items.AddRange(new object[] { + "Ботинки", + "Кеды", + "Кроссовки", + "Полуботинки", + "Сапоги", + "Тапочки", + "Туфли"}); + this.comboBox2.Location = new System.Drawing.Point(447, 12); + this.comboBox2.Name = "comboBox2"; + this.comboBox2.Size = new System.Drawing.Size(151, 28); + this.comboBox2.TabIndex = 23; + this.comboBox2.SelectedIndexChanged += new System.EventHandler(this.comboBox2_SelectedIndexChanged); + // + // comboBox3 + // + this.comboBox3.FormattingEnabled = true; + this.comboBox3.Items.AddRange(new object[] { + "Alessio Nesca", + "CROSBY", + "Kari", + "Marco Tozzi", + "Rieker", + "Рос"}); + this.comboBox3.Location = new System.Drawing.Point(295, 121); + this.comboBox3.Name = "comboBox3"; + this.comboBox3.Size = new System.Drawing.Size(349, 28); + this.comboBox3.TabIndex = 24; + // + // comboBox4 + // + this.comboBox4.FormattingEnabled = true; + this.comboBox4.Items.AddRange(new object[] { + "Kari", + "Обувь для вас"}); + this.comboBox4.Location = new System.Drawing.Point(295, 155); + this.comboBox4.Name = "comboBox4"; + this.comboBox4.Size = new System.Drawing.Size(349, 28); + this.comboBox4.TabIndex = 25; + // + // comboBox5 + // + this.comboBox5.FormattingEnabled = true; + this.comboBox5.Items.AddRange(new object[] { + "шт."}); + this.comboBox5.Location = new System.Drawing.Point(295, 219); + this.comboBox5.Name = "comboBox5"; + this.comboBox5.Size = new System.Drawing.Size(349, 28); + this.comboBox5.TabIndex = 26; + // + // textBox1 + // + this.textBox1.Location = new System.Drawing.Point(669, 111); + this.textBox1.Multiline = true; + this.textBox1.Name = "textBox1"; + this.textBox1.Size = new System.Drawing.Size(185, 72); + this.textBox1.TabIndex = 27; + // + // Form2 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(904, 348); + this.Controls.Add(this.textBox1); + this.Controls.Add(this.comboBox5); + this.Controls.Add(this.comboBox4); + this.Controls.Add(this.comboBox3); + this.Controls.Add(this.comboBox2); + this.Controls.Add(this.comboBox1); + this.Controls.Add(this.button4); + this.Controls.Add(this.button2); + this.Controls.Add(this.button1); + this.Controls.Add(this.textBox7); + this.Controls.Add(this.textBox5); + this.Controls.Add(this.textBox2); + this.Controls.Add(this.Skidka); + this.Controls.Add(this.Photo); + this.Name = "Form2"; + this.Text = "Form2"; + ((System.ComponentModel.ISupportInitialize)(this.Photo)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + public System.Windows.Forms.TextBox textBox7; + public System.Windows.Forms.TextBox textBox5; + public System.Windows.Forms.TextBox textBox2; + public System.Windows.Forms.TextBox Skidka; + public System.Windows.Forms.PictureBox Photo; + private System.Windows.Forms.Button button1; + private System.Windows.Forms.Button button2; + private System.Windows.Forms.Button button4; + private System.Windows.Forms.ComboBox comboBox1; + private System.Windows.Forms.ComboBox comboBox2; + private System.Windows.Forms.ComboBox comboBox3; + private System.Windows.Forms.ComboBox comboBox4; + private System.Windows.Forms.ComboBox comboBox5; + public System.Windows.Forms.TextBox textBox1; + } +} \ No newline at end of file diff --git a/demo25052026/Form2.cs b/demo25052026/Form2.cs new file mode 100644 index 0000000..a924ea3 --- /dev/null +++ b/demo25052026/Form2.cs @@ -0,0 +1,116 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using Npgsql; + +namespace demo25052026 +{ + public partial class Form2 : Form + { + static string connS = "Server=localhost;Port=5432;Database=newdemo26;Username=postgres;Password=Swa2sWA13;"; + int ID_pr { get; set; } + public Form2(int ID) + { + InitializeComponent(); + ID_pr = ID; + if (ID != 0) + { + NpgsqlConnection npgsqlConnection = new NpgsqlConnection(connS); + npgsqlConnection.Open(); + NpgsqlCommand command = new NpgsqlCommand(@$"SELECT ""Naimenov_ID"", ""Tip_ID"", ""Ed_izm"", ""Cena"", ""Postav_ID"", ""Proizv_ID"", ""Skidka"", ""Kolichestvo"", ""Opisanie"", ""Photo"", ""Articul"" FROM public.""Tovar"" WHERE ""ID_Tovar"" = {ID};", npgsqlConnection); + DataTable data = new DataTable(); + data.Load(command.ExecuteReader()); + comboBox2.SelectedIndex = int.Parse(data.Rows[0].ItemArray[0].ToString()) - 1; + comboBox1.SelectedIndex = int.Parse(data.Rows[0].ItemArray[1].ToString()) - 1; + comboBox5.SelectedIndex = 0; + textBox5.Text = data.Rows[0].ItemArray[3].ToString(); + comboBox4.SelectedIndex = int.Parse(data.Rows[0].ItemArray[4].ToString()) - 1; + comboBox3.SelectedIndex = int.Parse(data.Rows[0].ItemArray[5].ToString()) - 1; + + Skidka.Text = data.Rows[0].ItemArray[6].ToString(); + + textBox7.Text = data.Rows[0].ItemArray[7].ToString(); + textBox2.Text = data.Rows[0].ItemArray[8].ToString(); + if (data.Rows[0].ItemArray[9].ToString() != "") + { + Photo.Image = Image.FromFile(data.Rows[0].ItemArray[9].ToString()); + PhotoPath = data.Rows[0].ItemArray[9].ToString(); + } + else + { + Photo.Image = Image.FromFile("picture.png"); + } + + textBox1.Text = data.Rows[0].ItemArray[10].ToString(); + + + npgsqlConnection.Close(); + } + + } + + string PhotoPath { get; set; } + private void button2_Click(object sender, EventArgs e) + { + if (ID_pr == 0) + { + NpgsqlConnection npgsqlConnection = new NpgsqlConnection(connS); + npgsqlConnection.Open(); + NpgsqlCommand command = new NpgsqlCommand(@$"INSERT INTO public.""Tovar""(""Articul"", ""Naimenov_ID"", ""Ed_izm"", ""Cena"", ""Postav_ID"", ""Proizv_ID"", ""Tip_ID"", ""Skidka"", ""Kolichestvo"", ""Opisanie"", ""Photo"") VALUES ('{textBox1.Text}', {comboBox2.SelectedIndex + 1}, '{comboBox5.SelectedItem.ToString()}', {textBox5.Text}, {comboBox4.SelectedIndex + 1}, {comboBox3.SelectedIndex + 1}, {comboBox1.SelectedIndex + 1}, {Skidka.Text}, {textBox7.Text}, {textBox2.Text}, {PhotoPath});", npgsqlConnection); + command.ExecuteNonQuery(); + + npgsqlConnection.Close(); + } + else + { + NpgsqlConnection npgsqlConnection = new NpgsqlConnection(connS); + npgsqlConnection.Open(); + NpgsqlCommand command = new NpgsqlCommand(@$"UPDATE public.""Tovar"" SET ""Articul""='{textBox1.Text}', ""Naimenov_ID""={comboBox2.SelectedIndex + 1}, ""Ed_izm""='{comboBox5.SelectedItem.ToString()}', ""Cena""= {textBox5.Text}, ""Postav_ID""={comboBox4.SelectedIndex + 1}, ""Proizv_ID""={comboBox3.SelectedIndex + 1}, ""Tip_ID""={comboBox1.SelectedIndex + 1}, ""Skidka""={Skidka.Text}, ""Kolichestvo""={textBox7.Text}, ""Opisanie""='{textBox2.Text}', ""Photo""= '{PhotoPath}' WHERE ""ID_Tovar""= {ID_pr};", npgsqlConnection); + command.ExecuteNonQuery(); + + npgsqlConnection.Close(); + + } + + } + + private void comboBox2_SelectedIndexChanged(object sender, EventArgs e) + { + + } + + private void Photo_Click(object sender, EventArgs e) + { + OpenFileDialog openFile = new OpenFileDialog(); + if (openFile.ShowDialog() == DialogResult.OK) + { + PhotoPath = openFile.FileName; + Photo.Image = Image.FromFile(PhotoPath); + } + + } + + private void button1_Click(object sender, EventArgs e) + { + this.Hide(); + Form1 form = new Form1(); + form.Hide(); + } + + private void button4_Click(object sender, EventArgs e) + { + NpgsqlConnection npgsqlConnection = new NpgsqlConnection(connS); + npgsqlConnection.Open(); + NpgsqlCommand command = new NpgsqlCommand(@$"DELETE FROM public.""Tovar"" WHERE ""ID_Tovar"" = {ID_pr};", npgsqlConnection); + command.ExecuteNonQuery(); + + npgsqlConnection.Close(); + } + } +} diff --git a/demo25052026/Form2.resx b/demo25052026/Form2.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/demo25052026/Form2.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/demo25052026/Form3.Designer.cs b/demo25052026/Form3.Designer.cs new file mode 100644 index 0000000..0f11e08 --- /dev/null +++ b/demo25052026/Form3.Designer.cs @@ -0,0 +1,85 @@ + +namespace demo25052026 +{ + partial class Form3 + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel(); + this.button1 = new System.Windows.Forms.Button(); + this.button2 = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // flowLayoutPanel1 + // + this.flowLayoutPanel1.AutoScroll = true; + this.flowLayoutPanel1.Location = new System.Drawing.Point(12, 40); + this.flowLayoutPanel1.Name = "flowLayoutPanel1"; + this.flowLayoutPanel1.Size = new System.Drawing.Size(776, 356); + this.flowLayoutPanel1.TabIndex = 0; + // + // button1 + // + this.button1.Location = new System.Drawing.Point(13, 409); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(94, 29); + this.button1.TabIndex = 1; + this.button1.Text = "Назад"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // button2 + // + this.button2.Location = new System.Drawing.Point(694, 409); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(94, 29); + this.button2.TabIndex = 2; + this.button2.Text = "Добавить"; + this.button2.UseVisualStyleBackColor = true; + this.button2.Click += new System.EventHandler(this.button2_Click); + // + // Form3 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 450); + this.Controls.Add(this.button2); + this.Controls.Add(this.button1); + this.Controls.Add(this.flowLayoutPanel1); + this.Name = "Form3"; + this.Text = "Form3"; + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1; + private System.Windows.Forms.Button button1; + private System.Windows.Forms.Button button2; + } +} \ No newline at end of file diff --git a/demo25052026/Form3.cs b/demo25052026/Form3.cs new file mode 100644 index 0000000..6c70cf7 --- /dev/null +++ b/demo25052026/Form3.cs @@ -0,0 +1,79 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using Npgsql; + +namespace demo25052026 +{ + public partial class Form3 : Form + { + static string connS = "Server=localhost;Port=5432;Database=newdemo26;Username=postgres;Password=Swa2sWA13;"; + public Form3() + { + InitializeComponent(); + NpgsqlConnection npgsqlConnection = new NpgsqlConnection(connS); + npgsqlConnection.Open(); + NpgsqlCommand command = new NpgsqlCommand(@$"SELECT ""Data_Z"", ""Data_P"", (SELECT ""Imia"" FROM public.""Punkti"" WHERE ""Punkti"".""ID_Punkt"" = ""Zakaz"".""ID_Punkt""), (SELECT ""Imia"" FROM public.""Status_Zakaz"" WHERE ""ID_StatusZakaz"" = ""Status_Zakaz""), ""ID_Zakaz"" FROM public.""Zakaz"";", npgsqlConnection); + DataTable data = new DataTable(); + data.Load(command.ExecuteReader()); + + for (int i = 0; i < data.Rows.Count; i++) + { + UCZakaz zakaz = new UCZakaz(); + zakaz.textBox4.Text = data.Rows[i].ItemArray[0].ToString(); + zakaz.textBox5.Text = data.Rows[i].ItemArray[1].ToString(); + zakaz.textBox3.Text = data.Rows[i].ItemArray[2].ToString(); + zakaz.textBox2.Text = data.Rows[i].ItemArray[3].ToString(); + zakaz.Name = data.Rows[i].ItemArray[4].ToString(); + + //////////////////// + /// + NpgsqlConnection npgsqlConnections = new NpgsqlConnection(connS); + npgsqlConnections.Open(); + NpgsqlCommand commands = new NpgsqlCommand(@$"SELECT ""ID_Sostav"" FROM public.""ZakazSostav"" WHERE ""ID_Zakaz"" = {data.Rows[i].ItemArray[4].ToString()};", npgsqlConnections); + DataTable datas = new DataTable(); + datas.Load(commands.ExecuteReader()); + + string resultArt = ""; + for (int j = 0; j < datas.Rows.Count; j++) + { + + NpgsqlConnection npgsqlConnectionss = new NpgsqlConnection(connS); + npgsqlConnectionss.Open(); + NpgsqlCommand commandss = new NpgsqlCommand(@$"SELECT (SELECT ""Articul"" FROM public.""Tovar"" WHERE ""Tovar"".""ID_Tovar"" = ""Sostav"".""ID_Tovar""), ""Kolichestvo"" FROM public.""Sostav"" WHERE ""ID_Sostav"" = {datas.Rows[j].ItemArray[0].ToString()};", npgsqlConnectionss); + DataTable datass = new DataTable(); + datass.Load(commandss.ExecuteReader()); + resultArt = resultArt + " " + datass.Rows[0].ItemArray[0] + ", " + datass.Rows[0].ItemArray[1]; + } + + zakaz.textBox1.Text = resultArt; + /// + //////////////////////////// + + flowLayoutPanel1.Controls.Add(zakaz); + } + + npgsqlConnection.Close(); + } + + private void button1_Click(object sender, EventArgs e) + { + this.Hide(); + Form1 form = new Form1(); + form.ShowDialog(); + } + + private void button2_Click(object sender, EventArgs e) + { + this.Hide(); + Form4 form = new Form4(); + form.ShowDialog(); + } + } +} diff --git a/demo25052026/Form3.resx b/demo25052026/Form3.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/demo25052026/Form3.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/demo25052026/Form4.Designer.cs b/demo25052026/Form4.Designer.cs new file mode 100644 index 0000000..8ff9970 --- /dev/null +++ b/demo25052026/Form4.Designer.cs @@ -0,0 +1,245 @@ + +namespace demo25052026 +{ + partial class Form4 + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.comboBox1 = new System.Windows.Forms.ComboBox(); + this.textBox1 = new System.Windows.Forms.TextBox(); + this.textBox2 = new System.Windows.Forms.TextBox(); + this.textBox3 = new System.Windows.Forms.TextBox(); + this.comboBox2 = new System.Windows.Forms.ComboBox(); + this.listBox1 = new System.Windows.Forms.ListBox(); + this.button1 = new System.Windows.Forms.Button(); + this.button2 = new System.Windows.Forms.Button(); + this.button3 = new System.Windows.Forms.Button(); + this.button4 = new System.Windows.Forms.Button(); + this.comboBox3 = new System.Windows.Forms.ComboBox(); + this.SuspendLayout(); + // + // comboBox1 + // + this.comboBox1.FormattingEnabled = true; + this.comboBox1.Items.AddRange(new object[] { + "H782T5", + "G783F5", + "J384T6", + "D572U8", + "F572H7", + "D329H3", + "B320R5", + "G432E4", + "S213E3", + "E482R4", + "S634B5", + "K345R4", + "O754F4", + "G531F4", + "J542F5", + "B431R5", + "P764G4", + "C436G5", + "F427R5", + "N457T5", + "D364R4", + "S326R5", + "L754R4", + "M542T5", + "D268G5", + "T324F5", + "K358H6", + "H535R5"}); + this.comboBox1.Location = new System.Drawing.Point(12, 12); + this.comboBox1.Name = "comboBox1"; + this.comboBox1.Size = new System.Drawing.Size(151, 28); + this.comboBox1.TabIndex = 0; + // + // textBox1 + // + this.textBox1.Location = new System.Drawing.Point(13, 47); + this.textBox1.Name = "textBox1"; + this.textBox1.Size = new System.Drawing.Size(150, 27); + this.textBox1.TabIndex = 1; + // + // textBox2 + // + this.textBox2.Location = new System.Drawing.Point(13, 116); + this.textBox2.Multiline = true; + this.textBox2.Name = "textBox2"; + this.textBox2.Size = new System.Drawing.Size(150, 68); + this.textBox2.TabIndex = 2; + // + // textBox3 + // + this.textBox3.Location = new System.Drawing.Point(13, 190); + this.textBox3.Multiline = true; + this.textBox3.Name = "textBox3"; + this.textBox3.Size = new System.Drawing.Size(150, 68); + this.textBox3.TabIndex = 3; + // + // comboBox2 + // + this.comboBox2.FormattingEnabled = true; + this.comboBox2.Items.AddRange(new object[] { + "Завершен", + "Новый"}); + this.comboBox2.Location = new System.Drawing.Point(12, 288); + this.comboBox2.Name = "comboBox2"; + this.comboBox2.Size = new System.Drawing.Size(151, 28); + this.comboBox2.TabIndex = 4; + // + // listBox1 + // + this.listBox1.FormattingEnabled = true; + this.listBox1.ItemHeight = 20; + this.listBox1.Location = new System.Drawing.Point(258, 12); + this.listBox1.Name = "listBox1"; + this.listBox1.Size = new System.Drawing.Size(243, 304); + this.listBox1.TabIndex = 5; + // + // button1 + // + this.button1.Location = new System.Drawing.Point(13, 406); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(94, 29); + this.button1.TabIndex = 6; + this.button1.Text = "Назад"; + this.button1.UseVisualStyleBackColor = true; + // + // button2 + // + this.button2.Location = new System.Drawing.Point(416, 409); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(94, 29); + this.button2.TabIndex = 7; + this.button2.Text = "Сохранить"; + this.button2.UseVisualStyleBackColor = true; + this.button2.Click += new System.EventHandler(this.button2_Click); + // + // button3 + // + this.button3.Location = new System.Drawing.Point(308, 408); + this.button3.Name = "button3"; + this.button3.Size = new System.Drawing.Size(94, 29); + this.button3.TabIndex = 8; + this.button3.Text = "Удалить"; + this.button3.UseVisualStyleBackColor = true; + // + // button4 + // + this.button4.Location = new System.Drawing.Point(13, 81); + this.button4.Name = "button4"; + this.button4.Size = new System.Drawing.Size(150, 29); + this.button4.TabIndex = 9; + this.button4.Text = "Добавить"; + this.button4.UseVisualStyleBackColor = true; + this.button4.Click += new System.EventHandler(this.button4_Click); + // + // comboBox3 + // + this.comboBox3.FormattingEnabled = true; + this.comboBox3.Items.AddRange(new object[] { + "420151, г. Лесной, ул. Вишневая, 32", + "125061, г. Лесной, ул. Подгорная, 8", + "630370, г. Лесной, ул. Шоссейная, 24", + "400562, г. Лесной, ул. Зеленая, 32", + "614510, г. Лесной, ул. Маяковского, 47", + "410542, г. Лесной, ул. Светлая, 46", + "620839, г. Лесной, ул. Цветочная, 8", + "443890, г. Лесной, ул. Коммунистическая, 1", + "603379, г. Лесной, ул. Спортивная, 46", + "603721, г. Лесной, ул. Гоголя, 41", + "410172, г. Лесной, ул. Северная, 13", + "614611, г. Лесной, ул. Молодежная, 50", + "454311, г.Лесной, ул. Новая, 19", + "660007, г.Лесной, ул. Октябрьская, 19", + "603036, г. Лесной, ул. Садовая, 4", + "394060, г.Лесной, ул. Фрунзе, 43", + "410661, г. Лесной, ул. Школьная, 50", + "625590, г. Лесной, ул. Коммунистическая, 20", + "625683, г. Лесной, ул. 8 Марта", + "450983, г.Лесной, ул. Комсомольская, 26", + "394782, г. Лесной, ул. Чехова, 3", + "603002, г. Лесной, ул. Дзержинского, 28", + "450558, г. Лесной, ул. Набережная, 30", + "344288, г. Лесной, ул. Чехова, 1", + "614164, г.Лесной,  ул. Степная, 30", + "394242, г. Лесной, ул. Коммунистическая, 43", + "660540, г. Лесной, ул. Солнечная, 25", + "125837, г. Лесной, ул. Шоссейная, 40", + "125703, г. Лесной, ул. Партизанская, 49", + "625283, г. Лесной, ул. Победы, 46", + "614753, г. Лесной, ул. Полевая, 35", + "426030, г. Лесной, ул. Маяковского, 44", + "450375, г. Лесной ул. Клубная, 44", + "625560, г. Лесной, ул. Некрасова, 12", + "630201, г. Лесной, ул. Комсомольская, 17", + "190949, г. Лесной, ул. Мичурина, 26"}); + this.comboBox3.Location = new System.Drawing.Point(12, 330); + this.comboBox3.Name = "comboBox3"; + this.comboBox3.Size = new System.Drawing.Size(151, 28); + this.comboBox3.TabIndex = 10; + // + // Form4 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(522, 450); + this.Controls.Add(this.comboBox3); + this.Controls.Add(this.button4); + this.Controls.Add(this.button3); + this.Controls.Add(this.button2); + this.Controls.Add(this.button1); + this.Controls.Add(this.listBox1); + this.Controls.Add(this.comboBox2); + this.Controls.Add(this.textBox3); + this.Controls.Add(this.textBox2); + this.Controls.Add(this.textBox1); + this.Controls.Add(this.comboBox1); + this.Name = "Form4"; + this.Text = "Form4"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.ComboBox comboBox1; + private System.Windows.Forms.TextBox textBox1; + private System.Windows.Forms.TextBox textBox2; + private System.Windows.Forms.TextBox textBox3; + private System.Windows.Forms.ComboBox comboBox2; + private System.Windows.Forms.ListBox listBox1; + private System.Windows.Forms.Button button1; + private System.Windows.Forms.Button button2; + private System.Windows.Forms.Button button3; + private System.Windows.Forms.Button button4; + private System.Windows.Forms.ComboBox comboBox3; + } +} \ No newline at end of file diff --git a/demo25052026/Form4.cs b/demo25052026/Form4.cs new file mode 100644 index 0000000..d075d57 --- /dev/null +++ b/demo25052026/Form4.cs @@ -0,0 +1,79 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using Npgsql; + +namespace demo25052026 +{ + public partial class Form4 : Form + { + static string connS = "Server=localhost;Port=5432;Database=newdemo26;Username=postgres;Password=Swa2sWA13;"; + public Form4() + { + InitializeComponent(); + } + + private void button4_Click(object sender, EventArgs e) + { + listBox1.Items.Add(comboBox1.SelectedItem.ToString() + "|" + textBox1.Text); + + } + + private void button2_Click(object sender, EventArgs e) + { + //INSERT INTO public.""Zakaz""(""Data_Z"", ""Data_P"", ""ID_Punkt"", ""Status_Zakaz"") VALUES(?, ?, ?, ?); + if (true) + { + NpgsqlConnection npgsqlConnection = new NpgsqlConnection(connS); + npgsqlConnection.Open(); + NpgsqlCommand command = new NpgsqlCommand(@$"INSERT INTO public.""Zakaz""(""Data_Z"", ""Data_P"", ""ID_Punkt"", ""Status_Zakaz"") VALUES('{textBox2.Text}', '{textBox2.Text}', {comboBox3.SelectedIndex + 1}, {comboBox2.SelectedIndex + 1}) RETURNING ""ID_Zakaz"";", npgsqlConnection); + DataTable dataTable1 = new DataTable(); + dataTable1.Load(command.ExecuteReader()); + int IDZAKAZ = int.Parse(dataTable1.Rows[0].ItemArray[0].ToString()); + npgsqlConnection.Close(); + + int[] ItemID = new int[listBox1.Items.Count]; + int ii = 0; + foreach (object id in listBox1.Items) { + + string[] Tovar = id.ToString().Split('|'); + + NpgsqlConnection npgsqlConnections = new NpgsqlConnection(connS); + npgsqlConnections.Open(); + NpgsqlCommand commands = new NpgsqlCommand(@$"INSERT INTO public.""Sostav""( ""ID_Tovar"", ""Kolichestvo"") VALUES ({Tovar[0]}, {Tovar[1]}) RETURNING ""ID_Sostav"";", npgsqlConnections); + DataTable dataTable = new DataTable(); + dataTable.Load(commands.ExecuteReader()); + ItemID[ii] = int.Parse(dataTable.Rows[0].ItemArray[0].ToString()); + ii = ii + 1; + + npgsqlConnections.Close(); + } + foreach (int jj in ItemID) + { + NpgsqlConnection npgsqlConnectionss = new NpgsqlConnection(connS); + npgsqlConnectionss.Open(); + NpgsqlCommand commandss = new NpgsqlCommand(@$"INSERT INTO public.""ZakazSostav""(""ID_Sostav"", ""ID_Zakaz"") VALUES ( {jj}, {IDZAKAZ});", npgsqlConnectionss); + + commandss.ExecuteReader(); + } + + } + else + { + /* NpgsqlConnection npgsqlConnection = new NpgsqlConnection(connS); + npgsqlConnection.Open(); + NpgsqlCommand command = new NpgsqlCommand(@$"UPDATE public.""Tovar"" SET ""Articul""='{textBox1.Text}', ""Naimenov_ID""={comboBox2.SelectedIndex + 1}, ""Ed_izm""='{comboBox5.SelectedItem.ToString()}', ""Cena""= {textBox5.Text}, ""Postav_ID""={comboBox4.SelectedIndex + 1}, ""Proizv_ID""={comboBox3.SelectedIndex + 1}, ""Tip_ID""={comboBox1.SelectedIndex + 1}, ""Skidka""={Skidka.Text}, ""Kolichestvo""={textBox7.Text}, ""Opisanie""='{textBox2.Text}', ""Photo""= '{PhotoPath}' WHERE ""ID_Tovar""= {ID_pr};", npgsqlConnection); + command.ExecuteNonQuery(); + + npgsqlConnection.Close();*/ + + } + } + } +} diff --git a/demo25052026/Form4.resx b/demo25052026/Form4.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/demo25052026/Form4.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/demo25052026/Program.cs b/demo25052026/Program.cs new file mode 100644 index 0000000..778b678 --- /dev/null +++ b/demo25052026/Program.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace demo25052026 +{ + static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + Application.SetHighDpiMode(HighDpiMode.SystemAware); + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Form1()); + } + } +} diff --git a/demo25052026/UCTovar.Designer.cs b/demo25052026/UCTovar.Designer.cs new file mode 100644 index 0000000..dd2f557 --- /dev/null +++ b/demo25052026/UCTovar.Designer.cs @@ -0,0 +1,153 @@ + +namespace demo25052026 +{ + public partial class UCTovar + { + /// + /// Обязательная переменная конструктора. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Освободить все используемые ресурсы. + /// + /// истинно, если управляемый ресурс должен быть удален; иначе ложно. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Код, автоматически созданный конструктором компонентов + + /// + /// Требуемый метод для поддержки конструктора — не изменяйте + /// содержимое этого метода с помощью редактора кода. + /// + private void InitializeComponent() + { + this.Photo = new System.Windows.Forms.PictureBox(); + this.textBox1 = new System.Windows.Forms.TextBox(); + this.Skidka = new System.Windows.Forms.TextBox(); + this.textBox2 = new System.Windows.Forms.TextBox(); + this.textBox3 = new System.Windows.Forms.TextBox(); + this.textBox4 = new System.Windows.Forms.TextBox(); + this.textBox5 = new System.Windows.Forms.TextBox(); + this.textBox6 = new System.Windows.Forms.TextBox(); + this.textBox7 = new System.Windows.Forms.TextBox(); + ((System.ComponentModel.ISupportInitialize)(this.Photo)).BeginInit(); + this.SuspendLayout(); + // + // Photo + // + this.Photo.Location = new System.Drawing.Point(8, 10); + this.Photo.Name = "Photo"; + this.Photo.Size = new System.Drawing.Size(258, 266); + this.Photo.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; + this.Photo.TabIndex = 0; + this.Photo.TabStop = false; + this.Photo.Click += new System.EventHandler(this.Photo_Click); + // + // textBox1 + // + this.textBox1.Location = new System.Drawing.Point(287, 14); + this.textBox1.Name = "textBox1"; + this.textBox1.Size = new System.Drawing.Size(372, 27); + this.textBox1.TabIndex = 1; + this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged); + // + // Skidka + // + this.Skidka.Location = new System.Drawing.Point(665, 19); + this.Skidka.Multiline = true; + this.Skidka.Name = "Skidka"; + this.Skidka.Size = new System.Drawing.Size(185, 247); + this.Skidka.TabIndex = 2; + this.Skidka.TextChanged += new System.EventHandler(this.Skidka_TextChanged); + // + // textBox2 + // + this.textBox2.Location = new System.Drawing.Point(286, 53); + this.textBox2.Multiline = true; + this.textBox2.Name = "textBox2"; + this.textBox2.Size = new System.Drawing.Size(354, 69); + this.textBox2.TabIndex = 3; + this.textBox2.TextChanged += new System.EventHandler(this.textBox2_TextChanged); + // + // textBox3 + // + this.textBox3.Location = new System.Drawing.Point(291, 128); + this.textBox3.Name = "textBox3"; + this.textBox3.Size = new System.Drawing.Size(349, 27); + this.textBox3.TabIndex = 4; + this.textBox3.TextChanged += new System.EventHandler(this.textBox3_TextChanged); + // + // textBox4 + // + this.textBox4.Location = new System.Drawing.Point(291, 161); + this.textBox4.Name = "textBox4"; + this.textBox4.Size = new System.Drawing.Size(349, 27); + this.textBox4.TabIndex = 5; + this.textBox4.TextChanged += new System.EventHandler(this.textBox4_TextChanged); + // + // textBox5 + // + this.textBox5.Location = new System.Drawing.Point(291, 194); + this.textBox5.Name = "textBox5"; + this.textBox5.Size = new System.Drawing.Size(349, 27); + this.textBox5.TabIndex = 6; + this.textBox5.TextChanged += new System.EventHandler(this.textBox5_TextChanged); + // + // textBox6 + // + this.textBox6.Location = new System.Drawing.Point(291, 227); + this.textBox6.Name = "textBox6"; + this.textBox6.Size = new System.Drawing.Size(349, 27); + this.textBox6.TabIndex = 7; + this.textBox6.TextChanged += new System.EventHandler(this.textBox6_TextChanged); + // + // textBox7 + // + this.textBox7.Location = new System.Drawing.Point(291, 260); + this.textBox7.Name = "textBox7"; + this.textBox7.Size = new System.Drawing.Size(349, 27); + this.textBox7.TabIndex = 8; + this.textBox7.TextChanged += new System.EventHandler(this.textBox7_TextChanged); + // + // UCTovar + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.textBox7); + this.Controls.Add(this.textBox6); + this.Controls.Add(this.textBox5); + this.Controls.Add(this.textBox4); + this.Controls.Add(this.textBox3); + this.Controls.Add(this.textBox2); + this.Controls.Add(this.Skidka); + this.Controls.Add(this.textBox1); + this.Controls.Add(this.Photo); + this.Name = "UCTovar"; + this.Size = new System.Drawing.Size(866, 292); + ((System.ComponentModel.ISupportInitialize)(this.Photo)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + public System.Windows.Forms.PictureBox Photo; + public System.Windows.Forms.TextBox textBox1; + public System.Windows.Forms.TextBox Skidka; + public System.Windows.Forms.TextBox textBox2; + public System.Windows.Forms.TextBox textBox3; + public System.Windows.Forms.TextBox textBox4; + public System.Windows.Forms.TextBox textBox5; + public System.Windows.Forms.TextBox textBox6; + public System.Windows.Forms.TextBox textBox7; + } +} diff --git a/demo25052026/UCTovar.cs b/demo25052026/UCTovar.cs new file mode 100644 index 0000000..7c5644a --- /dev/null +++ b/demo25052026/UCTovar.cs @@ -0,0 +1,73 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace demo25052026 +{ + public partial class UCTovar : UserControl + { + Form FormClose { get; set; } + public UCTovar(Form form) + { + FormClose = form; + InitializeComponent(); + foreach (Control i in this.Controls) + { + i.Click += Photo_Click; + } + } + + private void Photo_Click(object sender, EventArgs e) + { + FormClose.Hide(); + Form2 form2 = new Form2(int.Parse(this.Name)); + form2.ShowDialog(); + } + + private void textBox1_TextChanged(object sender, EventArgs e) + { + + } + + private void Skidka_TextChanged(object sender, EventArgs e) + { + + } + + private void textBox2_TextChanged(object sender, EventArgs e) + { + + } + + private void textBox3_TextChanged(object sender, EventArgs e) + { + + } + + private void textBox4_TextChanged(object sender, EventArgs e) + { + + } + + private void textBox5_TextChanged(object sender, EventArgs e) + { + + } + + private void textBox6_TextChanged(object sender, EventArgs e) + { + + } + + private void textBox7_TextChanged(object sender, EventArgs e) + { + + } + } +} diff --git a/demo25052026/UCTovar.resx b/demo25052026/UCTovar.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/demo25052026/UCTovar.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/demo25052026/UCZakaz.Designer.cs b/demo25052026/UCZakaz.Designer.cs new file mode 100644 index 0000000..d732073 --- /dev/null +++ b/demo25052026/UCZakaz.Designer.cs @@ -0,0 +1,100 @@ + +namespace demo25052026 +{ + partial class UCZakaz + { + /// + /// Обязательная переменная конструктора. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Освободить все используемые ресурсы. + /// + /// истинно, если управляемый ресурс должен быть удален; иначе ложно. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Код, автоматически созданный конструктором компонентов + + /// + /// Требуемый метод для поддержки конструктора — не изменяйте + /// содержимое этого метода с помощью редактора кода. + /// + private void InitializeComponent() + { + this.textBox1 = new System.Windows.Forms.TextBox(); + this.textBox2 = new System.Windows.Forms.TextBox(); + this.textBox3 = new System.Windows.Forms.TextBox(); + this.textBox4 = new System.Windows.Forms.TextBox(); + this.textBox5 = new System.Windows.Forms.TextBox(); + this.SuspendLayout(); + // + // textBox1 + // + this.textBox1.Location = new System.Drawing.Point(21, 10); + this.textBox1.Name = "textBox1"; + this.textBox1.Size = new System.Drawing.Size(348, 27); + this.textBox1.TabIndex = 0; + // + // textBox2 + // + this.textBox2.Location = new System.Drawing.Point(21, 43); + this.textBox2.Name = "textBox2"; + this.textBox2.Size = new System.Drawing.Size(348, 27); + this.textBox2.TabIndex = 1; + // + // textBox3 + // + this.textBox3.Location = new System.Drawing.Point(19, 76); + this.textBox3.Multiline = true; + this.textBox3.Name = "textBox3"; + this.textBox3.Size = new System.Drawing.Size(350, 59); + this.textBox3.TabIndex = 2; + // + // textBox4 + // + this.textBox4.Location = new System.Drawing.Point(20, 148); + this.textBox4.Name = "textBox4"; + this.textBox4.Size = new System.Drawing.Size(349, 27); + this.textBox4.TabIndex = 3; + // + // textBox5 + // + this.textBox5.Location = new System.Drawing.Point(463, 10); + this.textBox5.Multiline = true; + this.textBox5.Name = "textBox5"; + this.textBox5.Size = new System.Drawing.Size(125, 162); + this.textBox5.TabIndex = 4; + // + // UCZakaz + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.textBox5); + this.Controls.Add(this.textBox4); + this.Controls.Add(this.textBox3); + this.Controls.Add(this.textBox2); + this.Controls.Add(this.textBox1); + this.Name = "UCZakaz"; + this.Size = new System.Drawing.Size(611, 192); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + public System.Windows.Forms.TextBox textBox1; + public System.Windows.Forms.TextBox textBox2; + public System.Windows.Forms.TextBox textBox3; + public System.Windows.Forms.TextBox textBox4; + public System.Windows.Forms.TextBox textBox5; + } +} diff --git a/demo25052026/UCZakaz.cs b/demo25052026/UCZakaz.cs new file mode 100644 index 0000000..20d6a9c --- /dev/null +++ b/demo25052026/UCZakaz.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace demo25052026 +{ + public partial class UCZakaz : UserControl + { + public UCZakaz() + { + InitializeComponent(); + } + } +} diff --git a/demo25052026/UCZakaz.resx b/demo25052026/UCZakaz.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/demo25052026/UCZakaz.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/demo25052026/demo25052026.csproj b/demo25052026/demo25052026.csproj new file mode 100644 index 0000000..3738e86 --- /dev/null +++ b/demo25052026/demo25052026.csproj @@ -0,0 +1,13 @@ + + + + WinExe + net5.0-windows + true + + + + + + + \ No newline at end of file