From bbe2fa4b79a1bab24f4ff88aa965466fbe9c7ff7 Mon Sep 17 00:00:00 2001 From: VictoriaPresnyakova Date: Mon, 3 Apr 2023 16:54:22 +0400 Subject: [PATCH] =?UTF-8?q?=D0=B2=20=D1=84=D0=BE=D1=80=D0=BC=D1=83=20?= =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=20=D0=B2=D1=8B?= =?UTF-8?q?=D0=B1=D0=BE=D1=80=20=D0=BA=D0=BB=D0=B8=D0=B5=D0=BD=D1=82=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- JewelryStore/FormCreateOrder.Designer.cs | 39 ++++++++++++--- JewelryStore/FormCreateOrder.cs | 25 +++++++++- JewelryStore/FormCreateOrder.resx | 62 +----------------------- 3 files changed, 56 insertions(+), 70 deletions(-) diff --git a/JewelryStore/FormCreateOrder.Designer.cs b/JewelryStore/FormCreateOrder.Designer.cs index 57c334d..4c41d97 100644 --- a/JewelryStore/FormCreateOrder.Designer.cs +++ b/JewelryStore/FormCreateOrder.Designer.cs @@ -36,12 +36,14 @@ this.textBoxSum = new System.Windows.Forms.TextBox(); this.buttonSave = new System.Windows.Forms.Button(); this.buttonCancel = new System.Windows.Forms.Button(); + this.comboBoxClient = new System.Windows.Forms.ComboBox(); + this.label1 = new System.Windows.Forms.Label(); this.SuspendLayout(); // // comboBoxJewel // this.comboBoxJewel.FormattingEnabled = true; - this.comboBoxJewel.Location = new System.Drawing.Point(115, 14); + this.comboBoxJewel.Location = new System.Drawing.Point(166, 22); this.comboBoxJewel.Name = "comboBoxJewel"; this.comboBoxJewel.Size = new System.Drawing.Size(250, 33); this.comboBoxJewel.TabIndex = 0; @@ -58,7 +60,7 @@ // labelCount // this.labelCount.AutoSize = true; - this.labelCount.Location = new System.Drawing.Point(12, 67); + this.labelCount.Location = new System.Drawing.Point(12, 70); this.labelCount.Name = "labelCount"; this.labelCount.Size = new System.Drawing.Size(107, 25); this.labelCount.TabIndex = 2; @@ -67,7 +69,7 @@ // labelSum // this.labelSum.AutoSize = true; - this.labelSum.Location = new System.Drawing.Point(12, 118); + this.labelSum.Location = new System.Drawing.Point(12, 174); this.labelSum.Name = "labelSum"; this.labelSum.Size = new System.Drawing.Size(67, 25); this.labelSum.TabIndex = 3; @@ -75,7 +77,7 @@ // // textBoxCount // - this.textBoxCount.Location = new System.Drawing.Point(115, 64); + this.textBoxCount.Location = new System.Drawing.Point(166, 72); this.textBoxCount.Name = "textBoxCount"; this.textBoxCount.Size = new System.Drawing.Size(250, 31); this.textBoxCount.TabIndex = 4; @@ -83,7 +85,7 @@ // // textBoxSum // - this.textBoxSum.Location = new System.Drawing.Point(115, 115); + this.textBoxSum.Location = new System.Drawing.Point(166, 176); this.textBoxSum.Name = "textBoxSum"; this.textBoxSum.ReadOnly = true; this.textBoxSum.Size = new System.Drawing.Size(250, 31); @@ -91,7 +93,7 @@ // // buttonSave // - this.buttonSave.Location = new System.Drawing.Point(31, 161); + this.buttonSave.Location = new System.Drawing.Point(74, 234); this.buttonSave.Name = "buttonSave"; this.buttonSave.Size = new System.Drawing.Size(112, 34); this.buttonSave.TabIndex = 6; @@ -101,7 +103,7 @@ // // buttonCancel // - this.buttonCancel.Location = new System.Drawing.Point(253, 161); + this.buttonCancel.Location = new System.Drawing.Point(253, 234); this.buttonCancel.Name = "buttonCancel"; this.buttonCancel.Size = new System.Drawing.Size(112, 34); this.buttonCancel.TabIndex = 7; @@ -109,11 +111,30 @@ this.buttonCancel.UseVisualStyleBackColor = true; this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); // + // comboBoxClient + // + this.comboBoxClient.FormattingEnabled = true; + this.comboBoxClient.Location = new System.Drawing.Point(166, 124); + this.comboBoxClient.Name = "comboBoxClient"; + this.comboBoxClient.Size = new System.Drawing.Size(250, 33); + this.comboBoxClient.TabIndex = 8; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(12, 122); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(126, 25); + this.label1.TabIndex = 9; + this.label1.Text = "Пользователь"; + // // FormCreateOrder // this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(401, 207); + this.ClientSize = new System.Drawing.Size(550, 292); + this.Controls.Add(this.label1); + this.Controls.Add(this.comboBoxClient); this.Controls.Add(this.buttonCancel); this.Controls.Add(this.buttonSave); this.Controls.Add(this.textBoxSum); @@ -140,5 +161,7 @@ private TextBox textBoxSum; private Button buttonSave; private Button buttonCancel; + private ComboBox comboBoxClient; + private Label label1; } } \ No newline at end of file diff --git a/JewelryStore/FormCreateOrder.cs b/JewelryStore/FormCreateOrder.cs index b6c1d21..3746e0b 100644 --- a/JewelryStore/FormCreateOrder.cs +++ b/JewelryStore/FormCreateOrder.cs @@ -19,12 +19,14 @@ namespace JewelryStore private readonly ILogger _logger; private readonly IJewelLogic _logicP; private readonly IOrderLogic _logicO; - public FormCreateOrder(ILogger logger, IJewelLogic logicP, IOrderLogic logicO) + private readonly IClientLogic _logicC; + public FormCreateOrder(ILogger logger, IJewelLogic logicP, IOrderLogic logicO, IClientLogic logicC) { InitializeComponent(); _logger = logger; _logicP = logicP; _logicO = logicO; + _logicC = logicC; } private void OrderForm_Load(object sender, EventArgs e) @@ -47,6 +49,24 @@ namespace JewelryStore _logger.LogError(ex, "Ошибка загрузки списка драгоценностей"); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } + _logger.LogInformation("Загрузка клиентов для заказа"); + try + { + var list = _logicC.ReadList(null); + if (list != null) + { + comboBoxClient.DisplayMember = "Клиент"; + comboBoxClient.ValueMember = "Id"; + comboBoxClient.DataSource = list.Select(c => c.ClientFIO).ToList(); + comboBoxClient.SelectedItem = null; + } + + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки списка клиентов"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } } private void CalcSum() { @@ -98,6 +118,7 @@ namespace JewelryStore { JewelId = Convert.ToInt32(comboBoxJewel.SelectedIndex) + 1, JewelName = comboBoxJewel.SelectedValue.ToString(), + ClientId = Convert.ToInt32(comboBoxClient.SelectedIndex) + 1, Count = Convert.ToInt32(textBoxCount.Text), Sum = Convert.ToDouble(textBoxSum.Text) }); @@ -123,5 +144,7 @@ namespace JewelryStore DialogResult = DialogResult.Cancel; Close(); } + + } } diff --git a/JewelryStore/FormCreateOrder.resx b/JewelryStore/FormCreateOrder.resx index 1af7de1..f298a7b 100644 --- a/JewelryStore/FormCreateOrder.resx +++ b/JewelryStore/FormCreateOrder.resx @@ -1,64 +1,4 @@ - - - +