From f25c31887145921e4e16ff28c9c8dba9e9e45d33 Mon Sep 17 00:00:00 2001 From: pp Date: Mon, 11 Apr 2022 14:55:02 +0200 Subject: [PATCH] =?UTF-8?q?Majdnem=20k=C3=A9sz?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cukraszda/Form1.cs | 2 +- Cukraszda/Rendelo.Designer.cs | 38 ++++++++++++++++++++++-- Cukraszda/Rendelo.cs | 55 +++++++++++++++++++++++++++++++++-- Cukraszda/Rendelo.resx | 3 ++ 4 files changed, 93 insertions(+), 5 deletions(-) diff --git a/Cukraszda/Form1.cs b/Cukraszda/Form1.cs index 64afd2e..946f972 100644 --- a/Cukraszda/Form1.cs +++ b/Cukraszda/Form1.cs @@ -36,7 +36,7 @@ namespace Cukraszda Console.WriteLine(segedtomb.Length); sutemenyekToolStripMenuItem.Enabled = true; - //sutemenyekToolStripMenuItem_Click(this, null); + sutemenyekToolStripMenuItem_Click(this, null); } } diff --git a/Cukraszda/Rendelo.Designer.cs b/Cukraszda/Rendelo.Designer.cs index ad66d71..a12226e 100644 --- a/Cukraszda/Rendelo.Designer.cs +++ b/Cukraszda/Rendelo.Designer.cs @@ -29,9 +29,14 @@ namespace Cukraszda /// private void InitializeComponent() { + this.components = new System.ComponentModel.Container(); this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); this.button1 = new System.Windows.Forms.Button(); this.label1 = new System.Windows.Forms.Label(); + this.richTextBox1 = new System.Windows.Forms.RichTextBox(); + this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); + this.sToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.contextMenuStrip1.SuspendLayout(); this.SuspendLayout(); // // tableLayoutPanel1 @@ -45,12 +50,13 @@ namespace Cukraszda this.tableLayoutPanel1.RowCount = 2; this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle()); this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle()); - this.tableLayoutPanel1.Size = new System.Drawing.Size(453, 426); + this.tableLayoutPanel1.Size = new System.Drawing.Size(453, 259); this.tableLayoutPanel1.TabIndex = 0; // // button1 // - this.button1.Location = new System.Drawing.Point(176, 498); + this.button1.ContextMenuStrip = this.contextMenuStrip1; + this.button1.Location = new System.Drawing.Point(181, 527); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(75, 23); this.button1.TabIndex = 1; @@ -67,16 +73,41 @@ namespace Cukraszda this.label1.TabIndex = 2; this.label1.Text = "ÁRLISTA"; // + // richTextBox1 + // + this.richTextBox1.Location = new System.Drawing.Point(22, 329); + this.richTextBox1.Name = "richTextBox1"; + this.richTextBox1.Size = new System.Drawing.Size(418, 176); + this.richTextBox1.TabIndex = 3; + this.richTextBox1.Text = ""; + this.richTextBox1.Visible = false; + // + // contextMenuStrip1 + // + this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.sToolStripMenuItem}); + this.contextMenuStrip1.Name = "contextMenuStrip1"; + this.contextMenuStrip1.Size = new System.Drawing.Size(181, 48); + // + // sToolStripMenuItem + // + this.sToolStripMenuItem.Name = "sToolStripMenuItem"; + this.sToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.sToolStripMenuItem.Text = "Számlát kér"; + this.sToolStripMenuItem.Click += new System.EventHandler(this.sToolStripMenuItem_Click); + // // Rendelo // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(478, 562); + this.Controls.Add(this.richTextBox1); this.Controls.Add(this.label1); this.Controls.Add(this.button1); this.Controls.Add(this.tableLayoutPanel1); this.Name = "Rendelo"; this.Text = "ItallapForm"; + this.contextMenuStrip1.ResumeLayout(false); this.ResumeLayout(false); this.PerformLayout(); @@ -87,5 +118,8 @@ namespace Cukraszda private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; private System.Windows.Forms.Button button1; private System.Windows.Forms.Label label1; + private System.Windows.Forms.RichTextBox richTextBox1; + private System.Windows.Forms.ContextMenuStrip contextMenuStrip1; + private System.Windows.Forms.ToolStripMenuItem sToolStripMenuItem; } } \ No newline at end of file diff --git a/Cukraszda/Rendelo.cs b/Cukraszda/Rendelo.cs index 74d77b0..5f00bc7 100644 --- a/Cukraszda/Rendelo.cs +++ b/Cukraszda/Rendelo.cs @@ -12,6 +12,9 @@ namespace Cukraszda { public partial class Rendelo : Form { + + bool nincsjelolve; + String[,] sutiktomb; public Rendelo() { InitializeComponent(); @@ -19,17 +22,19 @@ namespace Cukraszda public void setSuti(String[,] tomb) { - for (int i = 0; i < tomb.Length; i++) + sutiktomb = tomb; + for (int i = 0; i < tomb.GetLength(0); i++) { CheckBox cb = new CheckBox(); cb.Size = new Size(300,25); cb.Text = tomb[i,0]+" ("+tomb[i,1]+" Ft)"; - cb.Tag = i; tableLayoutPanel1.Controls.Add(cb, 0, i); TextBox tb = new TextBox(); tb.Size = new Size(30, 25); tableLayoutPanel1.Controls.Add(tb, 1, i); + tb.Tag = tomb[i, 1]; + cb.Tag = tb; Label label = new Label(); label.Text = " adag"; @@ -39,7 +44,53 @@ namespace Cukraszda private void button1_Click(object sender, EventArgs e) { + nincsjelolve = true; + foreach (var item in tableLayoutPanel1.Controls) + { + if ( item is CheckBox) + { + if( (item as CheckBox).Checked) nincsjelolve=false; + } + } + if (nincsjelolve) MessageBox.Show("Nincs jelölt süti!", "Hiba!", MessageBoxButtons.OK, MessageBoxIcon.Error); } + + private void sToolStripMenuItem_Click(object sender, EventArgs e) + { + button1_Click(sender, e); + if(!nincsjelolve) + { + string[] sorok = new string[tableLayoutPanel1.RowCount+10]; + sorok[0] = "SZÁMLA"; + sorok[1] = ""; + int sox = 2; + foreach (var item in tableLayoutPanel1.Controls) + { + + if (item is CheckBox) + { + CheckBox cb = (CheckBox)item; + if (cb.Checked) + { + TextBox tb = (TextBox)cb.Tag; + if (tb.Text.Length>0) + { + int darab = int.Parse(tb.Text); + int ear = int.Parse((String)tb.Tag); + sorok[sox] = $"{cb.Text,-50} {ear,4} {darab,2} db {darab*ear,6}"; + sox++; + + } + } + + } + } + richTextBox1.Lines = sorok; + richTextBox1.Visible = true; + } + } + + } } diff --git a/Cukraszda/Rendelo.resx b/Cukraszda/Rendelo.resx index 1af7de1..ad53752 100644 --- a/Cukraszda/Rendelo.resx +++ b/Cukraszda/Rendelo.resx @@ -117,4 +117,7 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 17, 17 + \ No newline at end of file