From 901e382a5a2e5d7646ddd61e739a6758cb4cac42 Mon Sep 17 00:00:00 2001 From: Dragon35Ziro Date: Sun, 31 May 2026 22:15:06 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D1=8C=D1=82?= =?UTF-8?q?=D0=B5=20=D1=84=D0=B0=D0=B9=D0=BB=D1=8B=20=D0=BF=D1=80=D0=BE?= =?UTF-8?q?=D0=B5=D0=BA=D1=82=D0=B0.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- demo26052026.sln | 25 +++ demo26052026/Form1.Designer.cs | 129 ++++++++++++ demo26052026/Form1.cs | 140 +++++++++++++ demo26052026/Form1.resx | 60 ++++++ demo26052026/Form2.Designer.cs | 233 ++++++++++++++++++++++ demo26052026/Form2.cs | 109 ++++++++++ demo26052026/Form2.resx | 60 ++++++ demo26052026/Form3.Designer.cs | 84 ++++++++ demo26052026/Form3.cs | 67 +++++++ demo26052026/Form3.resx | 60 ++++++ demo26052026/Form4.Designer.cs | 276 ++++++++++++++++++++++++++ demo26052026/Form4.cs | 146 ++++++++++++++ demo26052026/Form4.resx | 60 ++++++ demo26052026/Form4.txt | 146 ++++++++++++++ demo26052026/Program.cs | 23 +++ demo26052026/UserControl1.Designer.cs | 146 ++++++++++++++ demo26052026/UserControl1.cs | 38 ++++ demo26052026/UserControl1.resx | 60 ++++++ demo26052026/UserControl2.Designer.cs | 101 ++++++++++ demo26052026/UserControl2.cs | 38 ++++ demo26052026/UserControl2.resx | 60 ++++++ demo26052026/demo26052026.csproj | 13 ++ 22 files changed, 2074 insertions(+) create mode 100644 demo26052026.sln create mode 100644 demo26052026/Form1.Designer.cs create mode 100644 demo26052026/Form1.cs create mode 100644 demo26052026/Form1.resx create mode 100644 demo26052026/Form2.Designer.cs create mode 100644 demo26052026/Form2.cs create mode 100644 demo26052026/Form2.resx create mode 100644 demo26052026/Form3.Designer.cs create mode 100644 demo26052026/Form3.cs create mode 100644 demo26052026/Form3.resx create mode 100644 demo26052026/Form4.Designer.cs create mode 100644 demo26052026/Form4.cs create mode 100644 demo26052026/Form4.resx create mode 100644 demo26052026/Form4.txt create mode 100644 demo26052026/Program.cs create mode 100644 demo26052026/UserControl1.Designer.cs create mode 100644 demo26052026/UserControl1.cs create mode 100644 demo26052026/UserControl1.resx create mode 100644 demo26052026/UserControl2.Designer.cs create mode 100644 demo26052026/UserControl2.cs create mode 100644 demo26052026/UserControl2.resx create mode 100644 demo26052026/demo26052026.csproj diff --git a/demo26052026.sln b/demo26052026.sln new file mode 100644 index 0000000..b982a78 --- /dev/null +++ b/demo26052026.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}") = "demo26052026", "demo26052026\demo26052026.csproj", "{9CB52BDA-94DE-45FD-BE1E-F4FEB1594E10}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {9CB52BDA-94DE-45FD-BE1E-F4FEB1594E10}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9CB52BDA-94DE-45FD-BE1E-F4FEB1594E10}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9CB52BDA-94DE-45FD-BE1E-F4FEB1594E10}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9CB52BDA-94DE-45FD-BE1E-F4FEB1594E10}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {87B8D565-AF6B-4133-ADFF-A918514F63E6} + EndGlobalSection +EndGlobal diff --git a/demo26052026/Form1.Designer.cs b/demo26052026/Form1.Designer.cs new file mode 100644 index 0000000..51af296 --- /dev/null +++ b/demo26052026/Form1.Designer.cs @@ -0,0 +1,129 @@ + +namespace demo26052026 +{ + 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(9, 70); + this.flowLayoutPanel1.Name = "flowLayoutPanel1"; + this.flowLayoutPanel1.Size = new System.Drawing.Size(843, 359); + this.flowLayoutPanel1.TabIndex = 0; + // + // comboBox1 + // + this.comboBox1.FormattingEnabled = true; + this.comboBox1.Items.AddRange(new object[] { + "По возрастанию", + "По убыванию"}); + this.comboBox1.Location = new System.Drawing.Point(23, 13); + this.comboBox1.Name = "comboBox1"; + this.comboBox1.Size = new System.Drawing.Size(151, 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[] { + "Все поставщики", + "Kari", + "Обувь для вас"}); + this.comboBox2.Location = new System.Drawing.Point(192, 12); + this.comboBox2.Name = "comboBox2"; + this.comboBox2.Size = new System.Drawing.Size(151, 28); + this.comboBox2.TabIndex = 2; + this.comboBox2.SelectedIndexChanged += new System.EventHandler(this.comboBox2_SelectedIndexChanged); + // + // textBox1 + // + this.textBox1.Location = new System.Drawing.Point(370, 13); + this.textBox1.Name = "textBox1"; + this.textBox1.Size = new System.Drawing.Size(251, 27); + this.textBox1.TabIndex = 3; + this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged); + // + // button1 + // + this.button1.Location = new System.Drawing.Point(653, 13); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(94, 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(754, 12); + 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(861, 443); + 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/demo26052026/Form1.cs b/demo26052026/Form1.cs new file mode 100644 index 0000000..a80dbec --- /dev/null +++ b/demo26052026/Form1.cs @@ -0,0 +1,140 @@ +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 demo26052026 +{ + public partial class Form1 : Form + { + static string ConnString = "Server=localhost;Port=5432;Database=newdemo262;Username=postgres;Password=Swa2sWA13;"; + public Form1() + { + InitializeComponent(); + NpgsqlConnection npgsqlConnection = new NpgsqlConnection(ConnString); + npgsqlConnection.Open(); + NpgsqlCommand npgsqlCommand = new NpgsqlCommand(@$"SELECT ""Articul"", (SELECT ""Imia"" FROM public.""Naimenovanie"" WHERE ""ID_Naim"" = ""Naim_ID""), ""Ed_izm"", ""Cena"", (SELECT ""Imia"" FROM public.""Postavchik"" WHERE ""ID_Postavchik"" = ""Postav_ID""), (SELECT ""Imia"" FROM public.""Proizvoditel"" WHERE ""ID_Proizvoditel"" = ""Proizvod_ID"") , (SELECT ""Imia"" FROM public.""Kategory"" WHERE ""ID_Kategory"" = ""Kategory_ID""), ""Skidka"", ""Kolichestvo"", ""Opisanie"", ""Photo"", ""ID_Tovar"" FROM public.""Tovar"";", npgsqlConnection); + DataTable dataTable = new DataTable(); + dataTable.Load(npgsqlCommand.ExecuteReader()); + for (int i = 0; i < dataTable.Rows.Count; i++) + { + UserControl1 us = new UserControl1(this); + us.Name = dataTable.Rows[i].ItemArray[11].ToString(); + us.textBox1.Text = dataTable.Rows[i].ItemArray[1].ToString() + " | " + dataTable.Rows[i].ItemArray[6].ToString(); + us.textBox2.Text = dataTable.Rows[i].ItemArray[9].ToString(); + us.textBox3.Text = dataTable.Rows[i].ItemArray[5].ToString(); + us.textBox4.Text = dataTable.Rows[i].ItemArray[4].ToString(); + us.textBox5.Text = dataTable.Rows[i].ItemArray[3].ToString(); + us.textBox6.Text = dataTable.Rows[i].ItemArray[2].ToString(); + us.textBox7.Text = dataTable.Rows[i].ItemArray[8].ToString(); + us.textBox8.Text = dataTable.Rows[i].ItemArray[7].ToString(); + + if(dataTable.Rows[i].ItemArray[10].ToString() != "") + { + us.pictureBox1.Image = Image.FromFile(dataTable.Rows[i].ItemArray[10].ToString()); + } + else + { + us.pictureBox1.Image = Image.FromFile("picture.png"); + } + flowLayoutPanel1.Controls.Add(us); + } + npgsqlConnection.Close(); + + } + + private void textBox1_TextChanged(object sender, EventArgs e) + { + SearchAll(); + } + + private void comboBox2_SelectedIndexChanged(object sender, EventArgs e) + { + SearchAll(); + } + + private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) + { + SearchAll(); + } + + public void SearchAll() + { + flowLayoutPanel1.Controls.Clear(); + NpgsqlConnection npgsqlConnection = new NpgsqlConnection(ConnString); + npgsqlConnection.Open(); + + string dob = ""; + if(comboBox1.SelectedIndex == 0) + { + dob = $@"ORDER BY ""Kolichestvo"" ASC"; + } + else if(comboBox1.SelectedIndex == 1) + { + dob = $@"ORDER BY ""Kolichestvo"" DESC"; + } + + + string dob2 = ""; + + if (comboBox2.SelectedIndex == 1) + { + dob2 = $@" AND ""Postav_ID"" = 1 "; + } + else if (comboBox2.SelectedIndex == 2) + { + dob2 = $@" AND ""Postav_ID"" = 2 "; + } + + + NpgsqlCommand npgsqlCommand = new NpgsqlCommand(@$"SELECT ""Articul"", (SELECT ""Imia"" FROM public.""Naimenovanie"" WHERE ""ID_Naim"" = ""Naim_ID""), ""Ed_izm"", ""Cena"", (SELECT ""Imia"" FROM public.""Postavchik"" WHERE ""ID_Postavchik"" = ""Postav_ID""), (SELECT ""Imia"" FROM public.""Proizvoditel"" WHERE ""ID_Proizvoditel"" = ""Proizvod_ID"") , (SELECT ""Imia"" FROM public.""Kategory"" WHERE ""ID_Kategory"" = ""Kategory_ID""), ""Skidka"", ""Kolichestvo"", ""Opisanie"", ""Photo"", ""ID_Tovar"" FROM public.""Tovar"" WHERE (SELECT ""Imia"" FROM public.""Naimenovanie"" WHERE ""ID_Naim"" = ""Naim_ID"") || ""Ed_izm"" || ""Cena"" || (SELECT ""Imia"" FROM public.""Postavchik"" WHERE ""ID_Postavchik"" = ""Postav_ID"") || (SELECT ""Imia"" FROM public.""Proizvoditel"" WHERE ""ID_Proizvoditel"" = ""Proizvod_ID"") || (SELECT ""Imia"" FROM public.""Kategory"" WHERE ""ID_Kategory"" = ""Kategory_ID"") || ""Skidka"" || ""Kolichestvo"" || ""Opisanie"" || ""Photo"" ILIKE '%{textBox1.Text}%'" + dob2 + dob, npgsqlConnection); + + DataTable dataTable = new DataTable(); + dataTable.Load(npgsqlCommand.ExecuteReader()); + for (int i = 0; i < dataTable.Rows.Count; i++) + { + UserControl1 us = new UserControl1(this); + us.Name = dataTable.Rows[i].ItemArray[11].ToString(); + us.textBox1.Text = dataTable.Rows[i].ItemArray[1].ToString() + " | " + dataTable.Rows[i].ItemArray[6].ToString(); + us.textBox2.Text = dataTable.Rows[i].ItemArray[9].ToString(); + us.textBox3.Text = dataTable.Rows[i].ItemArray[5].ToString(); + us.textBox4.Text = dataTable.Rows[i].ItemArray[4].ToString(); + us.textBox5.Text = dataTable.Rows[i].ItemArray[3].ToString(); + us.textBox6.Text = dataTable.Rows[i].ItemArray[2].ToString(); + us.textBox7.Text = dataTable.Rows[i].ItemArray[8].ToString(); + us.textBox8.Text = dataTable.Rows[i].ItemArray[7].ToString(); + + if (dataTable.Rows[i].ItemArray[10].ToString() != "") + { + us.pictureBox1.Image = Image.FromFile(dataTable.Rows[i].ItemArray[10].ToString()); + } + else + { + us.pictureBox1.Image = Image.FromFile("picture.png"); + } + flowLayoutPanel1.Controls.Add(us); + } + npgsqlConnection.Close(); + } + + private void button1_Click(object sender, EventArgs e) + { + this.Hide(); + Form2 fr = new Form2(0); + fr.ShowDialog(); + } + + private void button2_Click(object sender, EventArgs e) + { + this.Hide(); + Form3 form3 = new Form3(); + form3.ShowDialog(); + } + } +} diff --git a/demo26052026/Form1.resx b/demo26052026/Form1.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/demo26052026/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/demo26052026/Form2.Designer.cs b/demo26052026/Form2.Designer.cs new file mode 100644 index 0000000..c7ec428 --- /dev/null +++ b/demo26052026/Form2.Designer.cs @@ -0,0 +1,233 @@ + +namespace demo26052026 +{ + 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.pictureBox1 = new System.Windows.Forms.PictureBox(); + this.comboBox1 = new System.Windows.Forms.ComboBox(); + this.comboBox2 = new System.Windows.Forms.ComboBox(); + this.textBox1 = new System.Windows.Forms.TextBox(); + this.textBox2 = new System.Windows.Forms.TextBox(); + this.comboBox3 = new System.Windows.Forms.ComboBox(); + this.comboBox4 = new System.Windows.Forms.ComboBox(); + this.textBox3 = new System.Windows.Forms.TextBox(); + this.comboBox5 = new System.Windows.Forms.ComboBox(); + this.textBox4 = new System.Windows.Forms.TextBox(); + this.textBox5 = new System.Windows.Forms.TextBox(); + this.button1 = new System.Windows.Forms.Button(); + this.button2 = new System.Windows.Forms.Button(); + this.button3 = new System.Windows.Forms.Button(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); + this.SuspendLayout(); + // + // pictureBox1 + // + this.pictureBox1.Location = new System.Drawing.Point(12, 54); + this.pictureBox1.Name = "pictureBox1"; + this.pictureBox1.Size = new System.Drawing.Size(165, 276); + this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; + this.pictureBox1.TabIndex = 0; + this.pictureBox1.TabStop = false; + this.pictureBox1.Click += new System.EventHandler(this.pictureBox1_Click); + // + // comboBox1 + // + this.comboBox1.FormattingEnabled = true; + this.comboBox1.Items.AddRange(new object[] { + "Женская обувь", + "Мужская обувь"}); + this.comboBox1.Location = new System.Drawing.Point(209, 12); + this.comboBox1.Name = "comboBox1"; + this.comboBox1.Size = new System.Drawing.Size(151, 28); + this.comboBox1.TabIndex = 1; + // + // comboBox2 + // + this.comboBox2.FormattingEnabled = true; + this.comboBox2.Items.AddRange(new object[] { + "\"Ботинки\"", + "\"Кеды\"", + "\"Кроссовки\"", + "\"Полуботинки\"", + "\"Сапоги\"", + "\"Тапочки\"", + "\"Туфли\""}); + this.comboBox2.Location = new System.Drawing.Point(385, 12); + this.comboBox2.Name = "comboBox2"; + this.comboBox2.Size = new System.Drawing.Size(151, 28); + this.comboBox2.TabIndex = 2; + // + // textBox1 + // + this.textBox1.Location = new System.Drawing.Point(209, 54); + this.textBox1.Name = "textBox1"; + this.textBox1.Size = new System.Drawing.Size(327, 27); + this.textBox1.TabIndex = 3; + // + // textBox2 + // + this.textBox2.Location = new System.Drawing.Point(209, 99); + this.textBox2.Multiline = true; + this.textBox2.Name = "textBox2"; + this.textBox2.Size = new System.Drawing.Size(327, 48); + this.textBox2.TabIndex = 4; + // + // comboBox3 + // + this.comboBox3.FormattingEnabled = true; + this.comboBox3.Items.AddRange(new object[] { + "\"Ботинки\"", + "\"Кеды\"", + "\"Кроссовки\"", + "\"Полуботинки\"", + "\"Сапоги\"", + "\"Тапочки\"", + "\"Туфли\""}); + this.comboBox3.Location = new System.Drawing.Point(209, 165); + this.comboBox3.Name = "comboBox3"; + this.comboBox3.Size = new System.Drawing.Size(327, 28); + this.comboBox3.TabIndex = 5; + // + // comboBox4 + // + this.comboBox4.FormattingEnabled = true; + this.comboBox4.Items.AddRange(new object[] { + "Kari", + "Обувь для вас"}); + this.comboBox4.Location = new System.Drawing.Point(209, 199); + this.comboBox4.Name = "comboBox4"; + this.comboBox4.Size = new System.Drawing.Size(327, 28); + this.comboBox4.TabIndex = 6; + // + // textBox3 + // + this.textBox3.Location = new System.Drawing.Point(209, 234); + this.textBox3.Name = "textBox3"; + this.textBox3.Size = new System.Drawing.Size(327, 27); + this.textBox3.TabIndex = 7; + // + // comboBox5 + // + this.comboBox5.FormattingEnabled = true; + this.comboBox5.Items.AddRange(new object[] { + "шт."}); + this.comboBox5.Location = new System.Drawing.Point(209, 268); + this.comboBox5.Name = "comboBox5"; + this.comboBox5.Size = new System.Drawing.Size(327, 28); + this.comboBox5.TabIndex = 8; + // + // textBox4 + // + this.textBox4.Location = new System.Drawing.Point(209, 303); + this.textBox4.Name = "textBox4"; + this.textBox4.Size = new System.Drawing.Size(327, 27); + this.textBox4.TabIndex = 9; + // + // textBox5 + // + this.textBox5.Location = new System.Drawing.Point(675, 132); + this.textBox5.Name = "textBox5"; + this.textBox5.Size = new System.Drawing.Size(168, 27); + this.textBox5.TabIndex = 10; + // + // button1 + // + this.button1.Location = new System.Drawing.Point(797, 409); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(94, 29); + this.button1.TabIndex = 11; + this.button1.Text = "Сохранить"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // button2 + // + this.button2.Location = new System.Drawing.Point(689, 409); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(94, 29); + this.button2.TabIndex = 12; + this.button2.Text = "Удалить"; + this.button2.UseVisualStyleBackColor = true; + this.button2.Click += new System.EventHandler(this.button2_Click); + // + // button3 + // + this.button3.Location = new System.Drawing.Point(12, 409); + this.button3.Name = "button3"; + this.button3.Size = new System.Drawing.Size(94, 29); + this.button3.TabIndex = 13; + this.button3.Text = "Назад"; + this.button3.UseVisualStyleBackColor = true; + this.button3.Click += new System.EventHandler(this.button3_Click); + // + // Form2 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(918, 450); + this.Controls.Add(this.button3); + this.Controls.Add(this.button2); + this.Controls.Add(this.button1); + this.Controls.Add(this.textBox5); + this.Controls.Add(this.textBox4); + this.Controls.Add(this.comboBox5); + this.Controls.Add(this.textBox3); + this.Controls.Add(this.comboBox4); + this.Controls.Add(this.comboBox3); + this.Controls.Add(this.textBox2); + this.Controls.Add(this.textBox1); + this.Controls.Add(this.comboBox2); + this.Controls.Add(this.comboBox1); + this.Controls.Add(this.pictureBox1); + this.Name = "Form2"; + this.Text = "Form2"; + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.PictureBox pictureBox1; + private System.Windows.Forms.ComboBox comboBox1; + private System.Windows.Forms.ComboBox comboBox2; + private System.Windows.Forms.TextBox textBox1; + private System.Windows.Forms.TextBox textBox2; + private System.Windows.Forms.ComboBox comboBox3; + private System.Windows.Forms.ComboBox comboBox4; + private System.Windows.Forms.TextBox textBox3; + private System.Windows.Forms.ComboBox comboBox5; + private System.Windows.Forms.TextBox textBox4; + private System.Windows.Forms.TextBox textBox5; + private System.Windows.Forms.Button button1; + private System.Windows.Forms.Button button2; + private System.Windows.Forms.Button button3; + } +} \ No newline at end of file diff --git a/demo26052026/Form2.cs b/demo26052026/Form2.cs new file mode 100644 index 0000000..c2111eb --- /dev/null +++ b/demo26052026/Form2.cs @@ -0,0 +1,109 @@ +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 demo26052026 +{ + public partial class Form2 : Form + { + int IDs { get; set; } + static string ConnString = "Server=localhost;Port=5432;Database=newdemo262;Username=postgres;Password=Swa2sWA13;"; + public Form2(int ID) + { + IDs = ID; + InitializeComponent(); + if (ID != 0) + { + NpgsqlConnection npgsqlConnection = new NpgsqlConnection(ConnString); + npgsqlConnection.Open(); + NpgsqlCommand npgsqlCommand = new NpgsqlCommand(@$"SELECT ""Articul"", ""Naim_ID"", ""Ed_izm"", ""Cena"", ""Postav_ID"", ""Proizvod_ID"", ""Kategory_ID"", ""Skidka"", ""Kolichestvo"", ""Opisanie"", ""Photo"", ""ID_Tovar"" FROM public.""Tovar"" WHERE ""ID_Tovar"" = {ID};", npgsqlConnection); + DataTable dataTable = new DataTable(); + dataTable.Load(npgsqlCommand.ExecuteReader()); + + + comboBox1.SelectedIndex = int.Parse(dataTable.Rows[0].ItemArray[1].ToString()) - 1; + comboBox2.SelectedIndex = int.Parse(dataTable.Rows[0].ItemArray[6].ToString()) - 1; + textBox1.Text = dataTable.Rows[0].ItemArray[0].ToString(); + + textBox2.Text = dataTable.Rows[0].ItemArray[9].ToString(); + comboBox3.SelectedIndex = int.Parse(dataTable.Rows[0].ItemArray[5].ToString()) - 1; + comboBox4.SelectedIndex = int.Parse(dataTable.Rows[0].ItemArray[4].ToString()) - 1; + + textBox3.Text = dataTable.Rows[0].ItemArray[3].ToString(); + comboBox5.SelectedIndex = 0; + + textBox4.Text = dataTable.Rows[0].ItemArray[8].ToString(); + textBox5.Text = dataTable.Rows[0].ItemArray[7].ToString(); + + if (dataTable.Rows[0].ItemArray[10].ToString() != "") + { + pictureBox1.Image = Image.FromFile(dataTable.Rows[0].ItemArray[10].ToString()); + PhotoPath = dataTable.Rows[0].ItemArray[10].ToString(); + } + else + { + pictureBox1.Image = Image.FromFile("picture.png"); + } + + + npgsqlConnection.Close(); + } + } + + string PhotoPath = "picture.png"; + private void pictureBox1_Click(object sender, EventArgs e) + { + OpenFileDialog openFileDialog = new OpenFileDialog(); + if(openFileDialog.ShowDialog() == DialogResult.OK) + { + PhotoPath = openFileDialog.FileName; + } + + } + + private void button3_Click(object sender, EventArgs e) + { + this.Hide(); + Form1 form1 = new Form1(); + form1.ShowDialog(); + } + + private void button1_Click(object sender, EventArgs e) + { + if (IDs == 0) + { + NpgsqlConnection npgsqlConnection = new NpgsqlConnection(ConnString); + npgsqlConnection.Open(); + NpgsqlCommand npgsqlCommand = new NpgsqlCommand(@$"INSERT INTO public.""Tovar""(""Articul"", ""Naim_ID"", ""Ed_izm"", ""Cena"", ""Postav_ID"", ""Proizvod_ID"", ""Kategory_ID"", ""Skidka"", ""Kolichestvo"", ""Opisanie"", ""Photo"") VALUES ('{textBox1.Text}', {comboBox2.SelectedIndex + 1}, '{comboBox5.SelectedItem.ToString()}', {textBox3.Text}, {comboBox4.SelectedIndex + 1}, {comboBox3.SelectedIndex + 1}, {comboBox1.SelectedIndex + 1}, {textBox5.Text}, {textBox4.Text}, {textBox2.Text}, {PhotoPath});", npgsqlConnection); + npgsqlCommand.ExecuteNonQuery(); + npgsqlConnection.Close(); + MessageBox.Show("Запись успешно внесенна"); + } + else + { + NpgsqlConnection npgsqlConnection = new NpgsqlConnection(ConnString); + npgsqlConnection.Open(); + NpgsqlCommand npgsqlCommand = new NpgsqlCommand(@$"UPDATE public.""Tovar"" SET ""Articul""='{textBox1.Text}', ""Naim_ID""={comboBox2.SelectedIndex + 1}, ""Ed_izm""='{comboBox5.SelectedItem.ToString()}', ""Cena""= {textBox3.Text}, ""Postav_ID""={comboBox4.SelectedIndex + 1}, ""Proizvod_ID""={comboBox3.SelectedIndex + 1}, ""Kategory_ID""={comboBox1.SelectedIndex + 1}, ""Skidka""={textBox5.Text}, ""Kolichestvo""={textBox4.Text}, ""Opisanie""={textBox2.Text}, ""Photo""={PhotoPath} WHERE ""ID_Tovar""= {IDs};", npgsqlConnection); + npgsqlCommand.ExecuteNonQuery(); + npgsqlConnection.Close(); + MessageBox.Show("Запись успешно измененна"); + } + } + + private void button2_Click(object sender, EventArgs e) + { + NpgsqlConnection npgsqlConnection = new NpgsqlConnection(ConnString); + npgsqlConnection.Open(); + NpgsqlCommand npgsqlCommand = new NpgsqlCommand(@$"DELETE FROM public.""Tovar"" WHERE ""ID_Tovar"" = {IDs};", npgsqlConnection); + npgsqlCommand.ExecuteNonQuery(); + npgsqlConnection.Close(); + } + } +} diff --git a/demo26052026/Form2.resx b/demo26052026/Form2.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/demo26052026/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/demo26052026/Form3.Designer.cs b/demo26052026/Form3.Designer.cs new file mode 100644 index 0000000..f0964dc --- /dev/null +++ b/demo26052026/Form3.Designer.cs @@ -0,0 +1,84 @@ + +namespace demo26052026 +{ + 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.Location = new System.Drawing.Point(13, 67); + this.flowLayoutPanel1.Name = "flowLayoutPanel1"; + this.flowLayoutPanel1.Size = new System.Drawing.Size(775, 371); + this.flowLayoutPanel1.TabIndex = 0; + // + // button1 + // + this.button1.Location = new System.Drawing.Point(694, 12); + 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(22, 13); + 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/demo26052026/Form3.cs b/demo26052026/Form3.cs new file mode 100644 index 0000000..55b7912 --- /dev/null +++ b/demo26052026/Form3.cs @@ -0,0 +1,67 @@ +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 demo26052026 +{ + public partial class Form3 : Form + { + static string ConnString = "Server=localhost;Port=5432;Database=newdemo262;Username=postgres;Password=Swa2sWA13;"; + public Form3() + { + InitializeComponent(); + NpgsqlConnection npgsqlConnection = new NpgsqlConnection(ConnString); + npgsqlConnection.Open(); + NpgsqlCommand npgsqlCommand = new NpgsqlCommand($@"SELECT ""Data_Z"", ""Data_P"", (SELECT ""Imia"" FROM public.""Adressa"" WHERE ""ID_Adress"" = ""Adress_ID""), (SELECT ""Imia"" FROM public.""Status"" WHERE ""ID_Status"" = ""Status"" ), ""ID_Zakaza"" FROM public.""Zakaz"";", npgsqlConnection); + DataTable dataTable = new DataTable(); + dataTable.Load(npgsqlCommand.ExecuteReader()); + npgsqlConnection.Close(); + for (int i = 0; i < dataTable.Rows.Count; i++) + { + UserControl2 userControl2 = new UserControl2(this); + userControl2.textBox2.Text = dataTable.Rows[i].ItemArray[3].ToString(); + userControl2.textBox3.Text = dataTable.Rows[i].ItemArray[2].ToString(); + userControl2.textBox4.Text = dataTable.Rows[i].ItemArray[0].ToString(); + userControl2.textBox5.Text = dataTable.Rows[i].ItemArray[1].ToString(); + userControl2.Name = dataTable.Rows[i].ItemArray[4].ToString(); + + NpgsqlConnection npgsqlConnection2 = new NpgsqlConnection(ConnString); + npgsqlConnection2.Open(); + NpgsqlCommand npgsqlCommand2 = new NpgsqlCommand($@"SELECT (SELECT ""Articul"" FROM public.""Tovar"" WHERE ""ID_Tovar"" =""Tovar_ID""), ""Kolichestvo"" FROM public.""Sostav"" WHERE ""Zakaz_ID"" = {dataTable.Rows[i].ItemArray[4].ToString()};", npgsqlConnection2); + DataTable dataTable2 = new DataTable(); + dataTable2.Load(npgsqlCommand2.ExecuteReader()); + npgsqlConnection2.Close(); + string dataArt = ""; + for(int j = 0; j < dataTable2.Rows.Count; j++) + { + dataArt = dataArt + dataTable2.Rows[j].ItemArray[0].ToString() + ", " + dataTable2.Rows[j].ItemArray[1].ToString() + " "; + } + userControl2.textBox1.Text = dataArt; + flowLayoutPanel1.Controls.Add(userControl2); + + } + + } + + private void button2_Click(object sender, EventArgs e) + { + this.Hide(); + Form1 form1 = new Form1(); + form1.ShowDialog(); + } + + private void button1_Click(object sender, EventArgs e) + { + this.Hide(); + Form4 form4 = new Form4(0); + form4.ShowDialog(); + } + } +} diff --git a/demo26052026/Form3.resx b/demo26052026/Form3.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/demo26052026/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/demo26052026/Form4.Designer.cs b/demo26052026/Form4.Designer.cs new file mode 100644 index 0000000..b9dfb50 --- /dev/null +++ b/demo26052026/Form4.Designer.cs @@ -0,0 +1,276 @@ + +namespace demo26052026 +{ + 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.listBox1 = new System.Windows.Forms.ListBox(); + this.button1 = 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.numericUpDown1 = new System.Windows.Forms.NumericUpDown(); + this.button2 = new System.Windows.Forms.Button(); + this.button3 = new System.Windows.Forms.Button(); + this.maskedTextBox1 = new System.Windows.Forms.MaskedTextBox(); + this.maskedTextBox2 = new System.Windows.Forms.MaskedTextBox(); + this.button4 = new System.Windows.Forms.Button(); + this.button5 = new System.Windows.Forms.Button(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit(); + this.SuspendLayout(); + // + // listBox1 + // + this.listBox1.FormattingEnabled = true; + this.listBox1.ItemHeight = 20; + this.listBox1.Location = new System.Drawing.Point(568, 13); + this.listBox1.Name = "listBox1"; + this.listBox1.Size = new System.Drawing.Size(220, 184); + this.listBox1.TabIndex = 2; + // + // button1 + // + this.button1.Location = new System.Drawing.Point(264, 13); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(94, 29); + this.button1.TabIndex = 3; + this.button1.Text = "Добавить"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // comboBox1 + // + this.comboBox1.FormattingEnabled = true; + this.comboBox1.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.comboBox1.Location = new System.Drawing.Point(12, 118); + this.comboBox1.Name = "comboBox1"; + this.comboBox1.Size = new System.Drawing.Size(186, 28); + this.comboBox1.TabIndex = 4; + 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(229, 118); + this.comboBox2.Name = "comboBox2"; + this.comboBox2.Size = new System.Drawing.Size(197, 28); + this.comboBox2.TabIndex = 7; + // + // comboBox3 + // + this.comboBox3.FormattingEnabled = true; + this.comboBox3.Items.AddRange(new object[] { + "\"А112Т4\"", + "\"F635R4\"", + "\"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.comboBox3.Location = new System.Drawing.Point(12, 13); + this.comboBox3.Name = "comboBox3"; + this.comboBox3.Size = new System.Drawing.Size(151, 28); + this.comboBox3.TabIndex = 8; + // + // numericUpDown1 + // + this.numericUpDown1.Location = new System.Drawing.Point(13, 70); + this.numericUpDown1.Minimum = new decimal(new int[] { + 1, + 0, + 0, + 0}); + this.numericUpDown1.Name = "numericUpDown1"; + this.numericUpDown1.Size = new System.Drawing.Size(150, 27); + this.numericUpDown1.TabIndex = 9; + this.numericUpDown1.Value = new decimal(new int[] { + 1, + 0, + 0, + 0}); + // + // button2 + // + this.button2.Location = new System.Drawing.Point(675, 399); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(113, 39); + this.button2.TabIndex = 10; + this.button2.Text = "Сохранить"; + this.button2.UseVisualStyleBackColor = true; + this.button2.Click += new System.EventHandler(this.button2_Click); + // + // button3 + // + this.button3.Location = new System.Drawing.Point(13, 409); + this.button3.Name = "button3"; + this.button3.Size = new System.Drawing.Size(94, 29); + this.button3.TabIndex = 11; + this.button3.Text = "Назад"; + this.button3.UseVisualStyleBackColor = true; + this.button3.Click += new System.EventHandler(this.button3_Click); + // + // maskedTextBox1 + // + this.maskedTextBox1.Location = new System.Drawing.Point(13, 210); + this.maskedTextBox1.Mask = "00.00.0000"; + this.maskedTextBox1.Name = "maskedTextBox1"; + this.maskedTextBox1.Size = new System.Drawing.Size(125, 27); + this.maskedTextBox1.TabIndex = 12; + this.maskedTextBox1.ValidatingType = typeof(System.DateTime); + // + // maskedTextBox2 + // + this.maskedTextBox2.Location = new System.Drawing.Point(264, 210); + this.maskedTextBox2.Mask = "00.00.0000"; + this.maskedTextBox2.Name = "maskedTextBox2"; + this.maskedTextBox2.Size = new System.Drawing.Size(125, 27); + this.maskedTextBox2.TabIndex = 13; + this.maskedTextBox2.ValidatingType = typeof(System.DateTime); + // + // button4 + // + this.button4.Location = new System.Drawing.Point(438, 11); + this.button4.Name = "button4"; + this.button4.Size = new System.Drawing.Size(94, 29); + this.button4.TabIndex = 14; + this.button4.Text = "Удалить"; + this.button4.UseVisualStyleBackColor = true; + this.button4.Click += new System.EventHandler(this.button4_Click); + // + // button5 + // + this.button5.Location = new System.Drawing.Point(534, 409); + this.button5.Name = "button5"; + this.button5.Size = new System.Drawing.Size(94, 29); + this.button5.TabIndex = 15; + this.button5.Text = "Удалить"; + this.button5.UseVisualStyleBackColor = true; + this.button5.Click += new System.EventHandler(this.button5_Click); + // + // Form4 + // + 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.button5); + this.Controls.Add(this.button4); + this.Controls.Add(this.maskedTextBox2); + this.Controls.Add(this.maskedTextBox1); + this.Controls.Add(this.button3); + this.Controls.Add(this.button2); + this.Controls.Add(this.numericUpDown1); + this.Controls.Add(this.comboBox3); + this.Controls.Add(this.comboBox2); + this.Controls.Add(this.comboBox1); + this.Controls.Add(this.button1); + this.Controls.Add(this.listBox1); + this.Name = "Form4"; + this.Text = "Form4"; + ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + private System.Windows.Forms.ListBox listBox1; + private System.Windows.Forms.Button button1; + private System.Windows.Forms.ComboBox comboBox1; + private System.Windows.Forms.ComboBox comboBox2; + private System.Windows.Forms.ComboBox comboBox3; + private System.Windows.Forms.NumericUpDown numericUpDown1; + private System.Windows.Forms.Button button2; + private System.Windows.Forms.Button button3; + private System.Windows.Forms.MaskedTextBox maskedTextBox1; + private System.Windows.Forms.MaskedTextBox maskedTextBox2; + private System.Windows.Forms.Button button4; + private System.Windows.Forms.Button button5; + } +} \ No newline at end of file diff --git a/demo26052026/Form4.cs b/demo26052026/Form4.cs new file mode 100644 index 0000000..379773d --- /dev/null +++ b/demo26052026/Form4.cs @@ -0,0 +1,146 @@ +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 demo26052026 +{ + public partial class Form4 : Form + { + static string ConnString = "Server=localhost;Port=5432;Database=newdemo262;Username=postgres;Password=Swa2sWA13;"; + int IDZobsch { get; set; } + public Form4(int IDZ) + { + InitializeComponent(); + IDZobsch = IDZ; + + NpgsqlConnection npgsqlConnection = new NpgsqlConnection(ConnString); + npgsqlConnection.Open(); + NpgsqlCommand npgsqlCommand = new NpgsqlCommand($@"SELECT ""Data_Z"", ""Data_P"", ""Adress_ID"", ""Status"", ""ID_Zakaza"" FROM public.""Zakaz"";", npgsqlConnection); + DataTable dataTable = new DataTable(); + dataTable.Load(npgsqlCommand.ExecuteReader()); + npgsqlConnection.Close(); + maskedTextBox1.Text = dataTable.Rows[0].ItemArray[0].ToString(); + maskedTextBox2.Text = dataTable.Rows[0].ItemArray[1].ToString(); + comboBox1.SelectedIndex = int.Parse(dataTable.Rows[0].ItemArray[2].ToString()); + comboBox2.SelectedIndex = int.Parse(dataTable.Rows[0].ItemArray[3].ToString()); + + + + NpgsqlConnection npgsqlConnection2 = new NpgsqlConnection(ConnString); + npgsqlConnection2.Open(); + NpgsqlCommand npgsqlCommand2 = new NpgsqlCommand($@"SELECT (SELECT ""Articul"" FROM public.""Tovar"" WHERE ""ID_Tovar"" =""Tovar_ID""), ""Kolichestvo"" FROM public.""Sostav"" WHERE ""Zakaz_ID"" = {dataTable.Rows[0].ItemArray[4].ToString()};", npgsqlConnection2); + DataTable dataTable2 = new DataTable(); + dataTable2.Load(npgsqlCommand2.ExecuteReader()); + npgsqlConnection2.Close(); + for (int j = 0; j < dataTable2.Rows.Count; j++) + { + listBox1.Items.Add(dataTable2.Rows[j].ItemArray[0].ToString() + " " + dataTable2.Rows[j].ItemArray[1].ToString()); + } + + + } + + private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) + { + + } + + private void button1_Click(object sender, EventArgs e) + { + listBox1.Items.Add( comboBox3.SelectedItem + " " + numericUpDown1.Value); + } + + private void button3_Click(object sender, EventArgs e) + { + this.Hide(); + Form3 form3 = new Form3(); + form3.ShowDialog(); + } + + private void button2_Click(object sender, EventArgs e) + { + if (IDZobsch == 0) + { + NpgsqlConnection npgsqlConnection = new NpgsqlConnection(ConnString); + npgsqlConnection.Open(); + NpgsqlCommand npgsqlCommand = new NpgsqlCommand($@"INSERT INTO public.""Zakaz""(""Data_Z"", ""Data_P"", ""Adress_ID"", ""Status"") VALUES ('{maskedTextBox1.Text}', '{maskedTextBox2.Text}', {comboBox1.SelectedIndex + 1}, {comboBox2.SelectedIndex + 1}) RETURNING ""ID_Zakaza"";", npgsqlConnection); + + DataTable dataTable = new DataTable(); + dataTable.Load(npgsqlCommand.ExecuteReader()); + int IDZakaz = int.Parse(dataTable.Rows[0].ItemArray[0].ToString()); + npgsqlConnection.Close(); + + int[] IDMnoga = new int[listBox1.Items.Count]; + for (int i = 0; i < listBox1.Items.Count; i++) + { + string rabota = listBox1.Items[i].ToString(); + string[] razdeli = rabota.Split(' '); + + + + NpgsqlConnection npgsqlConnection2 = new NpgsqlConnection(ConnString); + npgsqlConnection2.Open(); + NpgsqlCommand npgsqlCommand2 = new NpgsqlCommand($@"INSERT INTO public.""Sostav""(""Zakaz_ID"", ""Tovar_ID"", ""Kolichestvo"") VALUES ({IDZakaz}, (SELECT ""ID_Tovar"" FROM public.""Tovar"" WHERE ""Articul"" = '{razdeli[0]}'), {razdeli[1]}) RETURNING ""ID_Sostav"";", npgsqlConnection2); + + DataTable dataTable2 = new DataTable(); + dataTable2.Load(npgsqlCommand2.ExecuteReader()); + int IDZakaz2 = int.Parse(dataTable2.Rows[0].ItemArray[0].ToString()); + IDMnoga[i] = IDZakaz2; + npgsqlConnection2.Close(); + } + } + else + { + NpgsqlConnection npgsqlConnection = new NpgsqlConnection(ConnString); + npgsqlConnection.Open(); + NpgsqlCommand npgsqlCommand = new NpgsqlCommand($@"UPDATE public.""Zakaz"" SET ""Data_Z""= '{maskedTextBox1.Text}', ""Data_P""= '{maskedTextBox2.Text}', ""Adress_ID""= {comboBox1.SelectedIndex + 1}, ""Status""= {comboBox2.SelectedIndex + 1} WHERE ""ID_Zakaza""= {IDZobsch};", npgsqlConnection); + + npgsqlCommand.ExecuteNonQuery(); + npgsqlConnection.Close(); + + NpgsqlConnection npgsqlConnection3 = new NpgsqlConnection(ConnString); + npgsqlConnection3.Open(); + NpgsqlCommand npgsqlCommand3 = new NpgsqlCommand($@"DELETE FROM public.""Sostav"" WHERE ""Zakaz_ID"" = {IDZobsch};", npgsqlConnection3); + + npgsqlCommand3.ExecuteNonQuery(); + npgsqlConnection3.Close(); + + for (int i = 0; i < listBox1.Items.Count; i++) + { + string rabota = listBox1.Items[i].ToString(); + string[] razdeli = rabota.Split(' '); + NpgsqlConnection npgsqlConnection2 = new NpgsqlConnection(ConnString); + npgsqlConnection2.Open(); + NpgsqlCommand npgsqlCommand2 = new NpgsqlCommand($@"INSERT INTO public.""Sostav""(""Zakaz_ID"", ""Tovar_ID"", ""Kolichestvo"") VALUES ({IDZobsch}, (SELECT ""ID_Tovar"" FROM public.""Tovar"" WHERE ""Articul"" = '{razdeli[0]}'), {razdeli[1]}) RETURNING ""ID_Sostav"";", npgsqlConnection2); + + DataTable dataTable2 = new DataTable(); + dataTable2.Load(npgsqlCommand2.ExecuteReader()); + int IDZakaz2 = int.Parse(dataTable2.Rows[0].ItemArray[0].ToString()); + npgsqlConnection2.Close(); + } + } + } + + private void button4_Click(object sender, EventArgs e) + { + listBox1.Items.RemoveAt(listBox1.SelectedIndex); + } + + private void button5_Click(object sender, EventArgs e) + { + NpgsqlConnection npgsqlConnection3 = new NpgsqlConnection(ConnString); + npgsqlConnection3.Open(); + NpgsqlCommand npgsqlCommand3 = new NpgsqlCommand($@"DELETE FROM public.""Zakaz"" WHERE ""ID_Zakaza"" = {IDZobsch};", npgsqlConnection3); + + npgsqlCommand3.ExecuteNonQuery(); + npgsqlConnection3.Close(); + } + } +} diff --git a/demo26052026/Form4.resx b/demo26052026/Form4.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/demo26052026/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/demo26052026/Form4.txt b/demo26052026/Form4.txt new file mode 100644 index 0000000..379773d --- /dev/null +++ b/demo26052026/Form4.txt @@ -0,0 +1,146 @@ +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 demo26052026 +{ + public partial class Form4 : Form + { + static string ConnString = "Server=localhost;Port=5432;Database=newdemo262;Username=postgres;Password=Swa2sWA13;"; + int IDZobsch { get; set; } + public Form4(int IDZ) + { + InitializeComponent(); + IDZobsch = IDZ; + + NpgsqlConnection npgsqlConnection = new NpgsqlConnection(ConnString); + npgsqlConnection.Open(); + NpgsqlCommand npgsqlCommand = new NpgsqlCommand($@"SELECT ""Data_Z"", ""Data_P"", ""Adress_ID"", ""Status"", ""ID_Zakaza"" FROM public.""Zakaz"";", npgsqlConnection); + DataTable dataTable = new DataTable(); + dataTable.Load(npgsqlCommand.ExecuteReader()); + npgsqlConnection.Close(); + maskedTextBox1.Text = dataTable.Rows[0].ItemArray[0].ToString(); + maskedTextBox2.Text = dataTable.Rows[0].ItemArray[1].ToString(); + comboBox1.SelectedIndex = int.Parse(dataTable.Rows[0].ItemArray[2].ToString()); + comboBox2.SelectedIndex = int.Parse(dataTable.Rows[0].ItemArray[3].ToString()); + + + + NpgsqlConnection npgsqlConnection2 = new NpgsqlConnection(ConnString); + npgsqlConnection2.Open(); + NpgsqlCommand npgsqlCommand2 = new NpgsqlCommand($@"SELECT (SELECT ""Articul"" FROM public.""Tovar"" WHERE ""ID_Tovar"" =""Tovar_ID""), ""Kolichestvo"" FROM public.""Sostav"" WHERE ""Zakaz_ID"" = {dataTable.Rows[0].ItemArray[4].ToString()};", npgsqlConnection2); + DataTable dataTable2 = new DataTable(); + dataTable2.Load(npgsqlCommand2.ExecuteReader()); + npgsqlConnection2.Close(); + for (int j = 0; j < dataTable2.Rows.Count; j++) + { + listBox1.Items.Add(dataTable2.Rows[j].ItemArray[0].ToString() + " " + dataTable2.Rows[j].ItemArray[1].ToString()); + } + + + } + + private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) + { + + } + + private void button1_Click(object sender, EventArgs e) + { + listBox1.Items.Add( comboBox3.SelectedItem + " " + numericUpDown1.Value); + } + + private void button3_Click(object sender, EventArgs e) + { + this.Hide(); + Form3 form3 = new Form3(); + form3.ShowDialog(); + } + + private void button2_Click(object sender, EventArgs e) + { + if (IDZobsch == 0) + { + NpgsqlConnection npgsqlConnection = new NpgsqlConnection(ConnString); + npgsqlConnection.Open(); + NpgsqlCommand npgsqlCommand = new NpgsqlCommand($@"INSERT INTO public.""Zakaz""(""Data_Z"", ""Data_P"", ""Adress_ID"", ""Status"") VALUES ('{maskedTextBox1.Text}', '{maskedTextBox2.Text}', {comboBox1.SelectedIndex + 1}, {comboBox2.SelectedIndex + 1}) RETURNING ""ID_Zakaza"";", npgsqlConnection); + + DataTable dataTable = new DataTable(); + dataTable.Load(npgsqlCommand.ExecuteReader()); + int IDZakaz = int.Parse(dataTable.Rows[0].ItemArray[0].ToString()); + npgsqlConnection.Close(); + + int[] IDMnoga = new int[listBox1.Items.Count]; + for (int i = 0; i < listBox1.Items.Count; i++) + { + string rabota = listBox1.Items[i].ToString(); + string[] razdeli = rabota.Split(' '); + + + + NpgsqlConnection npgsqlConnection2 = new NpgsqlConnection(ConnString); + npgsqlConnection2.Open(); + NpgsqlCommand npgsqlCommand2 = new NpgsqlCommand($@"INSERT INTO public.""Sostav""(""Zakaz_ID"", ""Tovar_ID"", ""Kolichestvo"") VALUES ({IDZakaz}, (SELECT ""ID_Tovar"" FROM public.""Tovar"" WHERE ""Articul"" = '{razdeli[0]}'), {razdeli[1]}) RETURNING ""ID_Sostav"";", npgsqlConnection2); + + DataTable dataTable2 = new DataTable(); + dataTable2.Load(npgsqlCommand2.ExecuteReader()); + int IDZakaz2 = int.Parse(dataTable2.Rows[0].ItemArray[0].ToString()); + IDMnoga[i] = IDZakaz2; + npgsqlConnection2.Close(); + } + } + else + { + NpgsqlConnection npgsqlConnection = new NpgsqlConnection(ConnString); + npgsqlConnection.Open(); + NpgsqlCommand npgsqlCommand = new NpgsqlCommand($@"UPDATE public.""Zakaz"" SET ""Data_Z""= '{maskedTextBox1.Text}', ""Data_P""= '{maskedTextBox2.Text}', ""Adress_ID""= {comboBox1.SelectedIndex + 1}, ""Status""= {comboBox2.SelectedIndex + 1} WHERE ""ID_Zakaza""= {IDZobsch};", npgsqlConnection); + + npgsqlCommand.ExecuteNonQuery(); + npgsqlConnection.Close(); + + NpgsqlConnection npgsqlConnection3 = new NpgsqlConnection(ConnString); + npgsqlConnection3.Open(); + NpgsqlCommand npgsqlCommand3 = new NpgsqlCommand($@"DELETE FROM public.""Sostav"" WHERE ""Zakaz_ID"" = {IDZobsch};", npgsqlConnection3); + + npgsqlCommand3.ExecuteNonQuery(); + npgsqlConnection3.Close(); + + for (int i = 0; i < listBox1.Items.Count; i++) + { + string rabota = listBox1.Items[i].ToString(); + string[] razdeli = rabota.Split(' '); + NpgsqlConnection npgsqlConnection2 = new NpgsqlConnection(ConnString); + npgsqlConnection2.Open(); + NpgsqlCommand npgsqlCommand2 = new NpgsqlCommand($@"INSERT INTO public.""Sostav""(""Zakaz_ID"", ""Tovar_ID"", ""Kolichestvo"") VALUES ({IDZobsch}, (SELECT ""ID_Tovar"" FROM public.""Tovar"" WHERE ""Articul"" = '{razdeli[0]}'), {razdeli[1]}) RETURNING ""ID_Sostav"";", npgsqlConnection2); + + DataTable dataTable2 = new DataTable(); + dataTable2.Load(npgsqlCommand2.ExecuteReader()); + int IDZakaz2 = int.Parse(dataTable2.Rows[0].ItemArray[0].ToString()); + npgsqlConnection2.Close(); + } + } + } + + private void button4_Click(object sender, EventArgs e) + { + listBox1.Items.RemoveAt(listBox1.SelectedIndex); + } + + private void button5_Click(object sender, EventArgs e) + { + NpgsqlConnection npgsqlConnection3 = new NpgsqlConnection(ConnString); + npgsqlConnection3.Open(); + NpgsqlCommand npgsqlCommand3 = new NpgsqlCommand($@"DELETE FROM public.""Zakaz"" WHERE ""ID_Zakaza"" = {IDZobsch};", npgsqlConnection3); + + npgsqlCommand3.ExecuteNonQuery(); + npgsqlConnection3.Close(); + } + } +} diff --git a/demo26052026/Program.cs b/demo26052026/Program.cs new file mode 100644 index 0000000..a9c15ce --- /dev/null +++ b/demo26052026/Program.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace demo26052026 +{ + 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/demo26052026/UserControl1.Designer.cs b/demo26052026/UserControl1.Designer.cs new file mode 100644 index 0000000..877831e --- /dev/null +++ b/demo26052026/UserControl1.Designer.cs @@ -0,0 +1,146 @@ + +namespace demo26052026 +{ + partial class UserControl1 + { + /// + /// Обязательная переменная конструктора. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Освободить все используемые ресурсы. + /// + /// истинно, если управляемый ресурс должен быть удален; иначе ложно. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Код, автоматически созданный конструктором компонентов + + /// + /// Требуемый метод для поддержки конструктора — не изменяйте + /// содержимое этого метода с помощью редактора кода. + /// + public void InitializeComponent() + { + this.pictureBox1 = new System.Windows.Forms.PictureBox(); + 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.textBox6 = new System.Windows.Forms.TextBox(); + this.textBox7 = new System.Windows.Forms.TextBox(); + this.textBox8 = new System.Windows.Forms.TextBox(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); + this.SuspendLayout(); + // + // pictureBox1 + // + this.pictureBox1.Location = new System.Drawing.Point(21, 37); + this.pictureBox1.Name = "pictureBox1"; + this.pictureBox1.Size = new System.Drawing.Size(184, 276); + this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; + this.pictureBox1.TabIndex = 0; + this.pictureBox1.TabStop = false; + this.pictureBox1.Click += new System.EventHandler(this.pictureBox1_Click); + // + // textBox1 + // + this.textBox1.Location = new System.Drawing.Point(239, 23); + this.textBox1.Name = "textBox1"; + this.textBox1.Size = new System.Drawing.Size(386, 27); + this.textBox1.TabIndex = 1; + // + // textBox2 + // + this.textBox2.Location = new System.Drawing.Point(248, 71); + this.textBox2.Multiline = true; + this.textBox2.Name = "textBox2"; + this.textBox2.Size = new System.Drawing.Size(377, 54); + this.textBox2.TabIndex = 2; + // + // textBox3 + // + this.textBox3.Location = new System.Drawing.Point(248, 131); + this.textBox3.Name = "textBox3"; + this.textBox3.Size = new System.Drawing.Size(377, 27); + this.textBox3.TabIndex = 3; + // + // textBox4 + // + this.textBox4.Location = new System.Drawing.Point(248, 164); + this.textBox4.Name = "textBox4"; + this.textBox4.Size = new System.Drawing.Size(377, 27); + this.textBox4.TabIndex = 4; + this.textBox4.TextChanged += new System.EventHandler(this.textBox4_TextChanged); + // + // textBox5 + // + this.textBox5.Location = new System.Drawing.Point(248, 215); + this.textBox5.Name = "textBox5"; + this.textBox5.Size = new System.Drawing.Size(377, 27); + this.textBox5.TabIndex = 5; + // + // textBox6 + // + this.textBox6.Location = new System.Drawing.Point(248, 264); + this.textBox6.Name = "textBox6"; + this.textBox6.Size = new System.Drawing.Size(377, 27); + this.textBox6.TabIndex = 6; + // + // textBox7 + // + this.textBox7.Location = new System.Drawing.Point(248, 311); + this.textBox7.Name = "textBox7"; + this.textBox7.Size = new System.Drawing.Size(377, 27); + this.textBox7.TabIndex = 7; + // + // textBox8 + // + this.textBox8.Location = new System.Drawing.Point(670, 23); + this.textBox8.Multiline = true; + this.textBox8.Name = "textBox8"; + this.textBox8.Size = new System.Drawing.Size(171, 315); + this.textBox8.TabIndex = 8; + // + // UserControl1 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.textBox8); + 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.textBox1); + this.Controls.Add(this.pictureBox1); + this.Name = "UserControl1"; + this.Size = new System.Drawing.Size(868, 369); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + public System.Windows.Forms.PictureBox pictureBox1; + 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; + public System.Windows.Forms.TextBox textBox6; + public System.Windows.Forms.TextBox textBox7; + public System.Windows.Forms.TextBox textBox8; + } +} diff --git a/demo26052026/UserControl1.cs b/demo26052026/UserControl1.cs new file mode 100644 index 0000000..432672a --- /dev/null +++ b/demo26052026/UserControl1.cs @@ -0,0 +1,38 @@ +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 demo26052026 +{ + public partial class UserControl1 : UserControl + { + Form form { get; set; } + public UserControl1(Form s) + { + form = s; + InitializeComponent(); + foreach(Control control in this.Controls) + { + control.Click += pictureBox1_Click; + } + } + + private void textBox4_TextChanged(object sender, EventArgs e) + { + + } + + private void pictureBox1_Click(object sender, EventArgs e) + { + form.Hide(); + Form2 form2 = new Form2(int.Parse(this.Name)); + form2.ShowDialog(); + } + } +} diff --git a/demo26052026/UserControl1.resx b/demo26052026/UserControl1.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/demo26052026/UserControl1.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/demo26052026/UserControl2.Designer.cs b/demo26052026/UserControl2.Designer.cs new file mode 100644 index 0000000..29de27e --- /dev/null +++ b/demo26052026/UserControl2.Designer.cs @@ -0,0 +1,101 @@ + +namespace demo26052026 +{ + partial class UserControl2 + { + /// + /// Обязательная переменная конструктора. + /// + 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(12, 15); + this.textBox1.Name = "textBox1"; + this.textBox1.Size = new System.Drawing.Size(236, 27); + this.textBox1.TabIndex = 0; + // + // textBox2 + // + this.textBox2.Location = new System.Drawing.Point(12, 60); + this.textBox2.Name = "textBox2"; + this.textBox2.Size = new System.Drawing.Size(236, 27); + this.textBox2.TabIndex = 1; + // + // textBox3 + // + this.textBox3.Location = new System.Drawing.Point(12, 105); + this.textBox3.Name = "textBox3"; + this.textBox3.Size = new System.Drawing.Size(236, 27); + this.textBox3.TabIndex = 2; + // + // textBox4 + // + this.textBox4.Location = new System.Drawing.Point(12, 160); + this.textBox4.Name = "textBox4"; + this.textBox4.Size = new System.Drawing.Size(236, 27); + this.textBox4.TabIndex = 3; + // + // textBox5 + // + this.textBox5.Location = new System.Drawing.Point(329, 15); + this.textBox5.Multiline = true; + this.textBox5.Name = "textBox5"; + this.textBox5.Size = new System.Drawing.Size(211, 180); + this.textBox5.TabIndex = 4; + this.textBox5.Click += new System.EventHandler(this.textBox5_Click); + this.textBox5.TextChanged += new System.EventHandler(this.textBox5_TextChanged); + // + // UserControl2 + // + 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 = "UserControl2"; + this.Size = new System.Drawing.Size(558, 225); + 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/demo26052026/UserControl2.cs b/demo26052026/UserControl2.cs new file mode 100644 index 0000000..5ccd643 --- /dev/null +++ b/demo26052026/UserControl2.cs @@ -0,0 +1,38 @@ +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 demo26052026 +{ + public partial class UserControl2 : UserControl + { + Form form { get; set; } + public UserControl2(Form s) + { + form = s; + InitializeComponent(); + foreach (Control control in this.Controls) + { + control.Click += textBox5_Click; + } + } + + private void textBox5_TextChanged(object sender, EventArgs e) + { + + } + + private void textBox5_Click(object sender, EventArgs e) + { + form.Hide(); + Form4 form2 = new Form4(int.Parse(this.Name)); + form2.ShowDialog(); + } + } +} diff --git a/demo26052026/UserControl2.resx b/demo26052026/UserControl2.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/demo26052026/UserControl2.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/demo26052026/demo26052026.csproj b/demo26052026/demo26052026.csproj new file mode 100644 index 0000000..3738e86 --- /dev/null +++ b/demo26052026/demo26052026.csproj @@ -0,0 +1,13 @@ + + + + WinExe + net5.0-windows + true + + + + + + + \ No newline at end of file