From 63ae753b2aedae8a1ce288eb83ac66c4bd7bf9fc Mon Sep 17 00:00:00 2001 From: Anastasia Date: Wed, 1 Mar 2023 10:48:21 +0400 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=82=D0=BE=D0=B3=D0=BE=D0=B2=D1=8B?= =?UTF-8?q?=D0=B9=20=D0=B2=D0=B0=D1=80=D0=B8=D0=B0=D0=BD=D1=82=20+=20?= =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=20=D1=84=D0=B0?= =?UTF-8?q?=D0=B9=D0=BB=20nlog.config.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Models/IComponentModel.cs | 1 - JewelryStore/JewelryStore/FormComponent.cs | 25 +++--- .../JewelryStore/FormComponents.Designer.cs | 24 +++-- JewelryStore/JewelryStore/FormComponents.cs | 33 ++----- .../JewelryStore/FormCreateOrder.Designer.cs | 40 ++++----- JewelryStore/JewelryStore/FormCreateOrder.cs | 12 +-- .../JewelryStore/FormJewel.Designer.cs | 75 ++++++++-------- JewelryStore/JewelryStore/FormJewel.cs | 60 +++++-------- JewelryStore/JewelryStore/FormJewel.resx | 9 ++ .../FormJewelComponent.Designer.cs | 4 +- .../JewelryStore/FormJewelComponent.cs | 13 +-- .../JewelryStore/FormJewels.Designer.cs | 23 +++-- JewelryStore/JewelryStore/FormJewels.cs | 30 ++----- .../JewelryStore/FormMain.Designer.cs | 90 +++++++++---------- JewelryStore/JewelryStore/FormMain.cs | 22 ++--- JewelryStore/JewelryStore/JewelryStore.csproj | 4 + JewelryStore/JewelryStore/nlog.config | 15 ++++ .../BusinessLogics/JewelLogic.cs | 3 +- .../BusinessLogics/OrderLogic.cs | 2 +- .../DataListSingleton.cs | 2 + .../Implements/ComponentStorage.cs | 6 ++ .../Implements/JewelStorage.cs | 3 +- .../Implements/OrderStorage.cs | 3 +- .../Models/Component.cs | 2 + .../JewelryStoreListImplement/Models/Jewel.cs | 2 + .../JewelryStoreListImplement/Models/Order.cs | 10 +-- 26 files changed, 248 insertions(+), 265 deletions(-) create mode 100644 JewelryStore/JewelryStore/nlog.config diff --git a/JewelryStore/JewelryShopDataModels/Models/IComponentModel.cs b/JewelryStore/JewelryShopDataModels/Models/IComponentModel.cs index ea7566c..213f341 100644 --- a/JewelryStore/JewelryShopDataModels/Models/IComponentModel.cs +++ b/JewelryStore/JewelryShopDataModels/Models/IComponentModel.cs @@ -7,5 +7,4 @@ namespace JewelryStoreDataModels.Models string ComponentName { get; } double Cost { get; } } - } \ No newline at end of file diff --git a/JewelryStore/JewelryStore/FormComponent.cs b/JewelryStore/JewelryStore/FormComponent.cs index ef76da3..6e964e6 100644 --- a/JewelryStore/JewelryStore/FormComponent.cs +++ b/JewelryStore/JewelryStore/FormComponent.cs @@ -20,13 +20,14 @@ namespace JewelryStore private readonly IComponentLogic _logic; private int? _id; public int Id { set { _id = value; } } - public FormComponent(ILogger logger, IComponentLogic - logic) + + public FormComponent(ILogger logger, IComponentLogic logic) { InitializeComponent(); _logger = logger; _logic = logic; } + private void FormComponent_Load(object sender, EventArgs e) { if (_id.HasValue) @@ -36,8 +37,7 @@ namespace JewelryStore _logger.LogInformation("Получение компонента"); var view = _logic.ReadElement(new ComponentSearchModel { - Id = - _id.Value + Id = _id.Value }); if (view != null) { @@ -48,17 +48,16 @@ namespace JewelryStore catch (Exception ex) { _logger.LogError(ex, "Ошибка получения компонента"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, - MessageBoxIcon.Error); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } + private void ButtonSave_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(textBoxName.Text)) { - MessageBox.Show("Заполните название", "Ошибка", - MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } _logger.LogInformation("Сохранение компонента"); @@ -70,24 +69,22 @@ namespace JewelryStore ComponentName = textBoxName.Text, Cost = Convert.ToDouble(textBoxCost.Text) }; - var operationResult = _id.HasValue ? _logic.Update(model) : - _logic.Create(model); + var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model); if (!operationResult) { throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); } - MessageBox.Show("Сохранение прошло успешно", "Сообщение", - MessageBoxButtons.OK, MessageBoxIcon.Information); + MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); DialogResult = DialogResult.OK; Close(); } catch (Exception ex) { _logger.LogError(ex, "Ошибка сохранения компонента"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, - MessageBoxIcon.Error); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } + private void ButtonCancel_Click(object sender, EventArgs e) { DialogResult = DialogResult.Cancel; diff --git a/JewelryStore/JewelryStore/FormComponents.Designer.cs b/JewelryStore/JewelryStore/FormComponents.Designer.cs index f4d7e82..3977446 100644 --- a/JewelryStore/JewelryStore/FormComponents.Designer.cs +++ b/JewelryStore/JewelryStore/FormComponents.Designer.cs @@ -30,7 +30,7 @@ { this.dataGridView = new System.Windows.Forms.DataGridView(); this.buttonAdd = new System.Windows.Forms.Button(); - this.buttonRef = new System.Windows.Forms.Button(); + this.buttonRefresh = new System.Windows.Forms.Button(); this.buttonDelete = new System.Windows.Forms.Button(); this.buttonUpdate = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); @@ -46,7 +46,6 @@ this.dataGridView.RowTemplate.Height = 33; this.dataGridView.Size = new System.Drawing.Size(525, 427); this.dataGridView.TabIndex = 0; - this.dataGridView.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_CellContentClick); // // buttonAdd // @@ -58,15 +57,15 @@ this.buttonAdd.UseVisualStyleBackColor = true; this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click); // - // buttonRef + // buttonRefresh // - this.buttonRef.Location = new System.Drawing.Point(569, 107); - this.buttonRef.Name = "buttonRef"; - this.buttonRef.Size = new System.Drawing.Size(164, 34); - this.buttonRef.TabIndex = 2; - this.buttonRef.Text = "Изменить"; - this.buttonRef.UseVisualStyleBackColor = true; - this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click); + this.buttonRefresh.Location = new System.Drawing.Point(569, 107); + this.buttonRefresh.Name = "buttonRefresh"; + this.buttonRefresh.Size = new System.Drawing.Size(164, 34); + this.buttonRefresh.TabIndex = 2; + this.buttonRefresh.Text = "Изменить"; + this.buttonRefresh.UseVisualStyleBackColor = true; + this.buttonRefresh.Click += new System.EventHandler(this.ButtonRefresh_Click); // // buttonDelete // @@ -95,12 +94,11 @@ this.ClientSize = new System.Drawing.Size(756, 450); this.Controls.Add(this.buttonUpdate); this.Controls.Add(this.buttonDelete); - this.Controls.Add(this.buttonRef); + this.Controls.Add(this.buttonRefresh); this.Controls.Add(this.buttonAdd); this.Controls.Add(this.dataGridView); this.Name = "FormComponents"; this.Text = "Компоненты"; - this.Load += new System.EventHandler(this.FormComponents_Load_1); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); this.ResumeLayout(false); @@ -110,7 +108,7 @@ private DataGridView dataGridView; private Button buttonAdd; - private Button buttonRef; + private Button buttonRefresh; private Button buttonDelete; private Button buttonUpdate; } diff --git a/JewelryStore/JewelryStore/FormComponents.cs b/JewelryStore/JewelryStore/FormComponents.cs index 95dca4b..00a7a46 100644 --- a/JewelryStore/JewelryStore/FormComponents.cs +++ b/JewelryStore/JewelryStore/FormComponents.cs @@ -9,6 +9,7 @@ namespace JewelryStore { private readonly ILogger _logger; private readonly IComponentLogic _logic; + public FormComponents(ILogger logger, IComponentLogic logic) { InitializeComponent(); @@ -20,6 +21,7 @@ namespace JewelryStore { LoadData(); } + private void LoadData() { try @@ -29,16 +31,14 @@ namespace JewelryStore { dataGridView.DataSource = list; dataGridView.Columns["Id"].Visible = false; - dataGridView.Columns["ComponentName"].AutoSizeMode = - DataGridViewAutoSizeColumnMode.Fill; + dataGridView.Columns["ComponentName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; } _logger.LogInformation("Загрузка компонентов"); } catch (Exception ex) { _logger.LogError(ex, "Ошибка загрузки компонентов"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, - MessageBoxIcon.Error); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } @@ -63,11 +63,9 @@ namespace JewelryStore { if (dataGridView.SelectedRows.Count == 1) { - if (MessageBox.Show("Удалить запись?", "Вопрос", - MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) + if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { - int id = - Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); _logger.LogInformation("Удаление компонента"); try { @@ -83,20 +81,17 @@ namespace JewelryStore catch (Exception ex) { _logger.LogError(ex, "Ошибка удаления компонента"); - MessageBox.Show(ex.Message, "Ошибка", - MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } - } - private void ButtonRef_Click(object sender, EventArgs e) + private void ButtonRefresh_Click(object sender, EventArgs e) { if (dataGridView.SelectedRows.Count == 1) { - var service = - Program.ServiceProvider?.GetService(typeof(FormComponent)); + var service = Program.ServiceProvider?.GetService(typeof(FormComponent)); if (service is FormComponent form) { form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); @@ -107,15 +102,5 @@ namespace JewelryStore } } } - - private void FormComponents_Load_1(object sender, EventArgs e) - { - - } - - private void dataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e) - { - - } } } \ No newline at end of file diff --git a/JewelryStore/JewelryStore/FormCreateOrder.Designer.cs b/JewelryStore/JewelryStore/FormCreateOrder.Designer.cs index ac480b2..dd25676 100644 --- a/JewelryStore/JewelryStore/FormCreateOrder.Designer.cs +++ b/JewelryStore/JewelryStore/FormCreateOrder.Designer.cs @@ -29,8 +29,8 @@ private void InitializeComponent() { this.labelJewel = new System.Windows.Forms.Label(); - this.label2 = new System.Windows.Forms.Label(); - this.label3 = new System.Windows.Forms.Label(); + this.labelCount = new System.Windows.Forms.Label(); + this.labelSum = new System.Windows.Forms.Label(); this.comboBoxJewel = new System.Windows.Forms.ComboBox(); this.textBoxCount = new System.Windows.Forms.TextBox(); this.textBoxSum = new System.Windows.Forms.TextBox(); @@ -47,23 +47,23 @@ this.labelJewel.TabIndex = 0; this.labelJewel.Text = "Изделие:"; // - // label2 + // labelCount // - this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(17, 62); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(111, 25); - this.label2.TabIndex = 1; - this.label2.Text = "Количество:"; + this.labelCount.AutoSize = true; + this.labelCount.Location = new System.Drawing.Point(17, 62); + this.labelCount.Name = "labelCount"; + this.labelCount.Size = new System.Drawing.Size(111, 25); + this.labelCount.TabIndex = 1; + this.labelCount.Text = "Количество:"; // - // label3 + // labelSum // - this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(17, 107); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(71, 25); - this.label3.TabIndex = 2; - this.label3.Text = "Сумма:"; + this.labelSum.AutoSize = true; + this.labelSum.Location = new System.Drawing.Point(17, 107); + this.labelSum.Name = "labelSum"; + this.labelSum.Size = new System.Drawing.Size(71, 25); + this.labelSum.TabIndex = 2; + this.labelSum.Text = "Сумма:"; // // comboBoxJewel // @@ -120,8 +120,8 @@ this.Controls.Add(this.textBoxSum); this.Controls.Add(this.textBoxCount); this.Controls.Add(this.comboBoxJewel); - this.Controls.Add(this.label3); - this.Controls.Add(this.label2); + this.Controls.Add(this.labelSum); + this.Controls.Add(this.labelCount); this.Controls.Add(this.labelJewel); this.Name = "FormCreateOrder"; this.Text = "Заказ"; @@ -134,8 +134,8 @@ #endregion private Label labelJewel; - private Label label2; - private Label label3; + private Label labelCount; + private Label labelSum; private ComboBox comboBoxJewel; private TextBox textBoxCount; private TextBox textBoxSum; diff --git a/JewelryStore/JewelryStore/FormCreateOrder.cs b/JewelryStore/JewelryStore/FormCreateOrder.cs index d9e0bd9..1f1eab4 100644 --- a/JewelryStore/JewelryStore/FormCreateOrder.cs +++ b/JewelryStore/JewelryStore/FormCreateOrder.cs @@ -12,7 +12,6 @@ namespace JewelryStore private readonly ILogger _logger; private readonly IJewelLogic _logicJ; private readonly IOrderLogic _logicO; - private List? _list; public FormCreateOrder(ILogger logger, IJewelLogic logicJ, IOrderLogic logicO) @@ -89,14 +88,12 @@ namespace JewelryStore { if (string.IsNullOrEmpty(textBoxCount.Text)) { - MessageBox.Show("Заполните поле Количество", "Ошибка", - MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (comboBoxJewel.SelectedValue == null) { - MessageBox.Show("Выберите драгоценность", "Ошибка", - MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show("Выберите драгоценность", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } _logger.LogInformation("Создание заказа"); @@ -119,10 +116,8 @@ namespace JewelryStore catch (Exception ex) { _logger.LogError(ex, "Ошибка создания заказа"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, - MessageBoxIcon.Error); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } - } private void ComboBoxJewel_SelectedIndexChanged(object sender, EventArgs e) @@ -130,7 +125,6 @@ namespace JewelryStore CalcSum(); } - private void ButtonCancel_Click(object sender, EventArgs e) { DialogResult = DialogResult.Cancel; diff --git a/JewelryStore/JewelryStore/FormJewel.Designer.cs b/JewelryStore/JewelryStore/FormJewel.Designer.cs index 5dfb5ce..f1094b1 100644 --- a/JewelryStore/JewelryStore/FormJewel.Designer.cs +++ b/JewelryStore/JewelryStore/FormJewel.Designer.cs @@ -29,6 +29,9 @@ private void InitializeComponent() { this.dataGridView = new System.Windows.Forms.DataGridView(); + this.JewelId = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.ComponentName = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Count = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.labelName = new System.Windows.Forms.Label(); this.labelPrice = new System.Windows.Forms.Label(); this.textBoxName = new System.Windows.Forms.TextBox(); @@ -36,13 +39,10 @@ this.groupBox = new System.Windows.Forms.GroupBox(); this.buttonUpdate = new System.Windows.Forms.Button(); this.buttonDelete = new System.Windows.Forms.Button(); - this.buttonChange = new System.Windows.Forms.Button(); + this.buttonRefresh = new System.Windows.Forms.Button(); this.buttonAdd = new System.Windows.Forms.Button(); this.buttonSave = new System.Windows.Forms.Button(); this.buttonCancel = new System.Windows.Forms.Button(); - this.JewelId = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.ComponentName = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.Count = new System.Windows.Forms.DataGridViewTextBoxColumn(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); this.groupBox.SuspendLayout(); this.SuspendLayout(); @@ -61,7 +61,29 @@ this.dataGridView.RowTemplate.Height = 33; this.dataGridView.Size = new System.Drawing.Size(468, 325); this.dataGridView.TabIndex = 0; - this.dataGridView.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_CellContentClick); + // + // JewelId + // + this.JewelId.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None; + this.JewelId.HeaderText = "Id"; + this.JewelId.MinimumWidth = 8; + this.JewelId.Name = "JewelId"; + this.JewelId.Visible = false; + this.JewelId.Width = 8; + // + // ComponentName + // + this.ComponentName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.ComponentName.HeaderText = "Компонент"; + this.ComponentName.MinimumWidth = 8; + this.ComponentName.Name = "ComponentName"; + // + // Count + // + this.Count.HeaderText = "Количество"; + this.Count.MinimumWidth = 8; + this.Count.Name = "Count"; + this.Count.Width = 150; // // labelName // @@ -99,7 +121,7 @@ // this.groupBox.Controls.Add(this.buttonUpdate); this.groupBox.Controls.Add(this.buttonDelete); - this.groupBox.Controls.Add(this.buttonChange); + this.groupBox.Controls.Add(this.buttonRefresh); this.groupBox.Controls.Add(this.buttonAdd); this.groupBox.Controls.Add(this.dataGridView); this.groupBox.Location = new System.Drawing.Point(15, 94); @@ -129,15 +151,15 @@ this.buttonDelete.UseVisualStyleBackColor = true; this.buttonDelete.Click += new System.EventHandler(this.ButtonDelete_Click); // - // buttonChange + // buttonRefresh // - this.buttonChange.Location = new System.Drawing.Point(505, 118); - this.buttonChange.Name = "buttonChange"; - this.buttonChange.Size = new System.Drawing.Size(141, 34); - this.buttonChange.TabIndex = 2; - this.buttonChange.Text = "Изменить"; - this.buttonChange.UseVisualStyleBackColor = true; - this.buttonChange.Click += new System.EventHandler(this.ButtonChange_Click); + this.buttonRefresh.Location = new System.Drawing.Point(505, 118); + this.buttonRefresh.Name = "buttonRefresh"; + this.buttonRefresh.Size = new System.Drawing.Size(141, 34); + this.buttonRefresh.TabIndex = 2; + this.buttonRefresh.Text = "Изменить"; + this.buttonRefresh.UseVisualStyleBackColor = true; + this.buttonRefresh.Click += new System.EventHandler(this.ButtonRefresh_Click); // // buttonAdd // @@ -169,29 +191,6 @@ this.buttonCancel.UseVisualStyleBackColor = true; this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); // - // JewelId - // - this.JewelId.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None; - this.JewelId.HeaderText = "Id"; - this.JewelId.MinimumWidth = 8; - this.JewelId.Name = "JewelId"; - this.JewelId.Visible = false; - this.JewelId.Width = 8; - // - // ComponentName - // - this.ComponentName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; - this.ComponentName.HeaderText = "Компонент"; - this.ComponentName.MinimumWidth = 8; - this.ComponentName.Name = "ComponentName"; - // - // Count - // - this.Count.HeaderText = "Количество"; - this.Count.MinimumWidth = 8; - this.Count.Name = "Count"; - this.Count.Width = 150; - // // FormJewel // this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F); @@ -223,7 +222,7 @@ private GroupBox groupBox; private Button buttonUpdate; private Button buttonDelete; - private Button buttonChange; + private Button buttonRefresh; private Button buttonAdd; private Button buttonSave; private Button buttonCancel; diff --git a/JewelryStore/JewelryStore/FormJewel.cs b/JewelryStore/JewelryStore/FormJewel.cs index a4bda25..380cf8d 100644 --- a/JewelryStore/JewelryStore/FormJewel.cs +++ b/JewelryStore/JewelryStore/FormJewel.cs @@ -14,6 +14,7 @@ namespace JewelryStore private int? _id; private Dictionary _JewelComponents; public int Id { set { _id = value; } } + public FormJewel(ILogger logger, IJewelLogic logic) { InitializeComponent(); @@ -26,7 +27,7 @@ namespace JewelryStore { if (_id.HasValue) { - _logger.LogInformation("Загрузка драгоценности"); + _logger.LogInformation("Загрузка изделия"); try { var view = _logic.ReadElement(new JewelSearchModel @@ -37,40 +38,37 @@ namespace JewelryStore { textBoxName.Text = view.JewelName; textBoxPrice.Text = view.Price.ToString(); - _JewelComponents = view.JewelComponents ?? new - Dictionary(); + _JewelComponents = view.JewelComponents ?? new Dictionary(); LoadData(); } } catch (Exception ex) { - _logger.LogError(ex, "Ошибка загрузки драгоценности"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, - MessageBoxIcon.Error); + _logger.LogError(ex, "Ошибка загрузки изделия"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } - } + private void LoadData() { - _logger.LogInformation("Загрузка компонент драгоценности"); + _logger.LogInformation("Загрузка компонентов изделия"); try { if (_JewelComponents != null) { dataGridView.Rows.Clear(); - foreach (var pc in _JewelComponents) + foreach (var jc in _JewelComponents) { - dataGridView.Rows.Add(new object[] { pc.Key, pc.Value.Item1.ComponentName, pc.Value.Item2 }); + dataGridView.Rows.Add(new object[] { jc.Key, jc.Value.Item1.ComponentName, jc.Value.Item2 }); } textBoxPrice.Text = CalcPrice().ToString(); } } catch (Exception ex) { - _logger.LogError(ex, "Ошибка загрузки компонент драгоценности"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, - MessageBoxIcon.Error); + _logger.LogError(ex, "Ошибка загрузки компонентов изделия"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } @@ -97,10 +95,9 @@ namespace JewelryStore LoadData(); } } - } - private void ButtonChange_Click(object sender, EventArgs e) + private void ButtonRefresh_Click(object sender, EventArgs e) { if (dataGridView.SelectedRows.Count == 1) { @@ -122,15 +119,13 @@ namespace JewelryStore } } } - } private void ButtonDelete_Click(object sender, EventArgs e) { if (dataGridView.SelectedRows.Count == 1) { - if (MessageBox.Show("Удалить запись?", "Вопрос", - MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) + if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { try { @@ -139,8 +134,7 @@ namespace JewelryStore } catch (Exception ex) { - MessageBox.Show(ex.Message, "Ошибка", - MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } LoadData(); } @@ -156,23 +150,20 @@ namespace JewelryStore { if (string.IsNullOrEmpty(textBoxName.Text)) { - MessageBox.Show("Заполните название", "Ошибка", - MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (string.IsNullOrEmpty(textBoxPrice.Text)) { - MessageBox.Show("Заполните цену", "Ошибка", MessageBoxButtons.OK, - MessageBoxIcon.Error); + MessageBox.Show("Заполните цену", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (_JewelComponents == null || _JewelComponents.Count == 0) { - MessageBox.Show("Заполните компоненты", "Ошибка", - MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show("Заполните компоненты", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } - _logger.LogInformation("Сохранение драгоценности"); + _logger.LogInformation("Сохранение изделия"); try { var model = new JewelBindingModel @@ -182,23 +173,20 @@ namespace JewelryStore Price = Convert.ToDouble(textBoxPrice.Text), JewelComponents = _JewelComponents }; - var operationResult = _id.HasValue ? _logic.Update(model) : - _logic.Create(model); + var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model); if (!operationResult) { throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); } - MessageBox.Show("Сохранение прошло успешно", "Сообщение", - MessageBoxButtons.OK, MessageBoxIcon.Information); + MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); DialogResult = DialogResult.OK; Close(); } catch (Exception ex) { - _logger.LogError(ex, "Ошибка сохранения драгоценности"); + _logger.LogError(ex, "Ошибка сохранения изделия"); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } - } private void ButtonCancel_Click(object sender, EventArgs e) @@ -206,6 +194,7 @@ namespace JewelryStore DialogResult = DialogResult.Cancel; Close(); } + private double CalcPrice() { double price = 0; @@ -215,10 +204,5 @@ namespace JewelryStore } return Math.Round(price * 1.1, 2); } - - private void dataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e) - { - - } } } \ No newline at end of file diff --git a/JewelryStore/JewelryStore/FormJewel.resx b/JewelryStore/JewelryStore/FormJewel.resx index 3983a23..7cc63c3 100644 --- a/JewelryStore/JewelryStore/FormJewel.resx +++ b/JewelryStore/JewelryStore/FormJewel.resx @@ -66,4 +66,13 @@ True + + True + + + True + + + True + \ No newline at end of file diff --git a/JewelryStore/JewelryStore/FormJewelComponent.Designer.cs b/JewelryStore/JewelryStore/FormJewelComponent.Designer.cs index 6782f9e..ebe459c 100644 --- a/JewelryStore/JewelryStore/FormJewelComponent.Designer.cs +++ b/JewelryStore/JewelryStore/FormJewelComponent.Designer.cs @@ -77,7 +77,7 @@ this.buttonSave.TabIndex = 4; this.buttonSave.Text = "Сохранить"; this.buttonSave.UseVisualStyleBackColor = true; - this.buttonSave.Click += new System.EventHandler(this.buttonSave_Click); + this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click); // // buttonCancel // @@ -87,7 +87,7 @@ this.buttonCancel.TabIndex = 5; this.buttonCancel.Text = "Отмена"; this.buttonCancel.UseVisualStyleBackColor = true; - this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); + this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); // // FormJewelComponent // diff --git a/JewelryStore/JewelryStore/FormJewelComponent.cs b/JewelryStore/JewelryStore/FormJewelComponent.cs index 3e83f5d..14fe2ee 100644 --- a/JewelryStore/JewelryStore/FormJewelComponent.cs +++ b/JewelryStore/JewelryStore/FormJewelComponent.cs @@ -7,6 +7,7 @@ namespace JewelryStore public partial class FormJewelComponent : Form { private readonly List? _list; + public int Id { get @@ -18,6 +19,7 @@ namespace JewelryStore comboBoxComponent.SelectedValue = value; } } + public IComponentModel? ComponentModel { get @@ -36,6 +38,7 @@ namespace JewelryStore return null; } } + public int Count { get { return Convert.ToInt32(textBoxCount.Text); } @@ -55,18 +58,16 @@ namespace JewelryStore } } - private void buttonSave_Click(object sender, EventArgs e) + private void ButtonSave_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(textBoxCount.Text)) { - MessageBox.Show("Заполните поле Количество", "Ошибка", - MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (comboBoxComponent.SelectedValue == null) { - MessageBox.Show("Выберите компонент", "Ошибка", - MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show("Выберите компонент", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } DialogResult = DialogResult.OK; @@ -74,7 +75,7 @@ namespace JewelryStore } - private void buttonCancel_Click(object sender, EventArgs e) + private void ButtonCancel_Click(object sender, EventArgs e) { DialogResult = DialogResult.Cancel; Close(); diff --git a/JewelryStore/JewelryStore/FormJewels.Designer.cs b/JewelryStore/JewelryStore/FormJewels.Designer.cs index b2715da..3d7d620 100644 --- a/JewelryStore/JewelryStore/FormJewels.Designer.cs +++ b/JewelryStore/JewelryStore/FormJewels.Designer.cs @@ -31,7 +31,7 @@ this.dataGridView = new System.Windows.Forms.DataGridView(); this.buttonUpdate = new System.Windows.Forms.Button(); this.buttonDelete = new System.Windows.Forms.Button(); - this.buttonRef = new System.Windows.Forms.Button(); + this.buttonRefresh = new System.Windows.Forms.Button(); this.buttonAdd = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); this.SuspendLayout(); @@ -47,7 +47,6 @@ this.dataGridView.RowTemplate.Height = 33; this.dataGridView.Size = new System.Drawing.Size(467, 333); this.dataGridView.TabIndex = 0; - this.dataGridView.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_CellContentClick); // // buttonUpdate // @@ -69,15 +68,15 @@ this.buttonDelete.UseVisualStyleBackColor = true; this.buttonDelete.Click += new System.EventHandler(this.ButtonDelete_Click); // - // buttonRef + // buttonRefresh // - this.buttonRef.Location = new System.Drawing.Point(516, 120); - this.buttonRef.Name = "buttonRef"; - this.buttonRef.Size = new System.Drawing.Size(164, 34); - this.buttonRef.TabIndex = 6; - this.buttonRef.Text = "Изменить"; - this.buttonRef.UseVisualStyleBackColor = true; - this.buttonRef.Click += new System.EventHandler(this.ButtonChange_Click); + this.buttonRefresh.Location = new System.Drawing.Point(516, 120); + this.buttonRefresh.Name = "buttonRefresh"; + this.buttonRefresh.Size = new System.Drawing.Size(164, 34); + this.buttonRefresh.TabIndex = 6; + this.buttonRefresh.Text = "Изменить"; + this.buttonRefresh.UseVisualStyleBackColor = true; + this.buttonRefresh.Click += new System.EventHandler(this.ButtonRefresh_Click); // // buttonAdd // @@ -96,7 +95,7 @@ this.ClientSize = new System.Drawing.Size(709, 364); this.Controls.Add(this.buttonUpdate); this.Controls.Add(this.buttonDelete); - this.Controls.Add(this.buttonRef); + this.Controls.Add(this.buttonRefresh); this.Controls.Add(this.buttonAdd); this.Controls.Add(this.dataGridView); this.Name = "FormJewels"; @@ -111,7 +110,7 @@ private DataGridView dataGridView; private Button buttonUpdate; private Button buttonDelete; - private Button buttonRef; + private Button buttonRefresh; private Button buttonAdd; } } \ No newline at end of file diff --git a/JewelryStore/JewelryStore/FormJewels.cs b/JewelryStore/JewelryStore/FormJewels.cs index 53c72c1..c770810 100644 --- a/JewelryStore/JewelryStore/FormJewels.cs +++ b/JewelryStore/JewelryStore/FormJewels.cs @@ -4,7 +4,7 @@ using Microsoft.Extensions.Logging; namespace JewelryStore { - public partial class FormJewels : Form //TODO + public partial class FormJewels : Form { private readonly ILogger _logger; private readonly IJewelLogic _logic; @@ -25,16 +25,14 @@ namespace JewelryStore { dataGridView.DataSource = list; dataGridView.Columns["Id"].Visible = false; - dataGridView.Columns["JewelName"].AutoSizeMode = - DataGridViewAutoSizeColumnMode.Fill; + dataGridView.Columns["JewelName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; } _logger.LogInformation("Загрузка изделий"); } catch (Exception ex) { _logger.LogError(ex, "Ошибка загрузки изделий"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, - MessageBoxIcon.Error); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } @@ -50,16 +48,14 @@ namespace JewelryStore } } - private void ButtonChange_Click(object sender, EventArgs e) + private void ButtonRefresh_Click(object sender, EventArgs e) { if (dataGridView.SelectedRows.Count == 1) { - var service = - Program.ServiceProvider?.GetService(typeof(FormJewel)); + var service = Program.ServiceProvider?.GetService(typeof(FormJewel)); if (service is FormJewel form) { - form.Id = - Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); if (form.ShowDialog() == DialogResult.OK) { LoadData(); @@ -72,11 +68,9 @@ namespace JewelryStore { if (dataGridView.SelectedRows.Count == 1) { - if (MessageBox.Show("Удалить запись?", "Вопрос", - MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) + if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { - int id = - Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); _logger.LogInformation("Удаление изделия"); try { @@ -92,8 +86,7 @@ namespace JewelryStore catch (Exception ex) { _logger.LogError(ex, "Ошибка удаления изделия"); - MessageBox.Show(ex.Message, "Ошибка", - MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } @@ -108,10 +101,5 @@ namespace JewelryStore { LoadData(); } - - private void dataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e) - { - - } } } \ No newline at end of file diff --git a/JewelryStore/JewelryStore/FormMain.Designer.cs b/JewelryStore/JewelryStore/FormMain.Designer.cs index 9150f33..e0e7277 100644 --- a/JewelryStore/JewelryStore/FormMain.Designer.cs +++ b/JewelryStore/JewelryStore/FormMain.Designer.cs @@ -33,10 +33,10 @@ this.КомпонентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.ИзделияToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.dataGridView = new System.Windows.Forms.DataGridView(); - this.buttonCreate = new System.Windows.Forms.Button(); - this.buttonToWork = new System.Windows.Forms.Button(); - this.buttonReady = new System.Windows.Forms.Button(); - this.buttonPut = new System.Windows.Forms.Button(); + this.buttonCreateOrder = new System.Windows.Forms.Button(); + this.buttonTakeOrderInWork = new System.Windows.Forms.Button(); + this.buttonOrderReady = new System.Windows.Forms.Button(); + this.buttonIssuedOrder = new System.Windows.Forms.Button(); this.buttonRefresh = new System.Windows.Forms.Button(); this.menuStrip.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); @@ -87,45 +87,45 @@ this.dataGridView.Size = new System.Drawing.Size(851, 402); this.dataGridView.TabIndex = 1; // - // buttonCreate + // buttonCreateOrder // - this.buttonCreate.Location = new System.Drawing.Point(884, 78); - this.buttonCreate.Name = "buttonCreate"; - this.buttonCreate.Size = new System.Drawing.Size(210, 34); - this.buttonCreate.TabIndex = 2; - this.buttonCreate.Text = "Создать заказ"; - this.buttonCreate.UseVisualStyleBackColor = true; - this.buttonCreate.Click += new System.EventHandler(this.ButtonCreateOrder_Click); + this.buttonCreateOrder.Location = new System.Drawing.Point(884, 78); + this.buttonCreateOrder.Name = "buttonCreateOrder"; + this.buttonCreateOrder.Size = new System.Drawing.Size(210, 34); + this.buttonCreateOrder.TabIndex = 2; + this.buttonCreateOrder.Text = "Создать заказ"; + this.buttonCreateOrder.UseVisualStyleBackColor = true; + this.buttonCreateOrder.Click += new System.EventHandler(this.ButtonCreateOrder_Click); // - // buttonToWork + // buttonTakeOrderInWork // - this.buttonToWork.Location = new System.Drawing.Point(884, 150); - this.buttonToWork.Name = "buttonToWork"; - this.buttonToWork.Size = new System.Drawing.Size(210, 34); - this.buttonToWork.TabIndex = 3; - this.buttonToWork.Text = "Отдать на выполнение"; - this.buttonToWork.UseVisualStyleBackColor = true; - this.buttonToWork.Click += new System.EventHandler(this.ButtonTakeOrderInWork_Click); + this.buttonTakeOrderInWork.Location = new System.Drawing.Point(884, 150); + this.buttonTakeOrderInWork.Name = "buttonTakeOrderInWork"; + this.buttonTakeOrderInWork.Size = new System.Drawing.Size(210, 34); + this.buttonTakeOrderInWork.TabIndex = 3; + this.buttonTakeOrderInWork.Text = "Отдать на выполнение"; + this.buttonTakeOrderInWork.UseVisualStyleBackColor = true; + this.buttonTakeOrderInWork.Click += new System.EventHandler(this.ButtonTakeOrderInWork_Click); // - // buttonReady + // buttonOrderReady // - this.buttonReady.Location = new System.Drawing.Point(884, 221); - this.buttonReady.Name = "buttonReady"; - this.buttonReady.Size = new System.Drawing.Size(210, 34); - this.buttonReady.TabIndex = 4; - this.buttonReady.Text = "Заказ готов"; - this.buttonReady.UseVisualStyleBackColor = true; - this.buttonReady.Click += new System.EventHandler(this.ButtonOrderReady_Click); + this.buttonOrderReady.Location = new System.Drawing.Point(884, 221); + this.buttonOrderReady.Name = "buttonOrderReady"; + this.buttonOrderReady.Size = new System.Drawing.Size(210, 34); + this.buttonOrderReady.TabIndex = 4; + this.buttonOrderReady.Text = "Заказ готов"; + this.buttonOrderReady.UseVisualStyleBackColor = true; + this.buttonOrderReady.Click += new System.EventHandler(this.ButtonOrderReady_Click); // - // buttonPut + // buttonIssuedOrder // - this.buttonPut.Location = new System.Drawing.Point(884, 292); - this.buttonPut.Name = "buttonPut"; - this.buttonPut.Size = new System.Drawing.Size(210, 34); - this.buttonPut.TabIndex = 5; - this.buttonPut.Text = "Заказ выдан"; - this.buttonPut.UseVisualStyleBackColor = true; - this.buttonPut.Click += new System.EventHandler(this.ButtonIssuedOrder_Click); + this.buttonIssuedOrder.Location = new System.Drawing.Point(884, 292); + this.buttonIssuedOrder.Name = "buttonIssuedOrder"; + this.buttonIssuedOrder.Size = new System.Drawing.Size(210, 34); + this.buttonIssuedOrder.TabIndex = 5; + this.buttonIssuedOrder.Text = "Заказ выдан"; + this.buttonIssuedOrder.UseVisualStyleBackColor = true; + this.buttonIssuedOrder.Click += new System.EventHandler(this.ButtonIssuedOrder_Click); // // buttonRefresh // @@ -135,7 +135,7 @@ this.buttonRefresh.TabIndex = 6; this.buttonRefresh.Text = "Обновить список"; this.buttonRefresh.UseVisualStyleBackColor = true; - this.buttonRefresh.Click += new System.EventHandler(this.ButtonRef_Click); + this.buttonRefresh.Click += new System.EventHandler(this.ButtonRefresh_Click); // // FormMain // @@ -143,10 +143,10 @@ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(1121, 450); this.Controls.Add(this.buttonRefresh); - this.Controls.Add(this.buttonPut); - this.Controls.Add(this.buttonReady); - this.Controls.Add(this.buttonToWork); - this.Controls.Add(this.buttonCreate); + this.Controls.Add(this.buttonIssuedOrder); + this.Controls.Add(this.buttonOrderReady); + this.Controls.Add(this.buttonTakeOrderInWork); + this.Controls.Add(this.buttonCreateOrder); this.Controls.Add(this.dataGridView); this.Controls.Add(this.menuStrip); this.MainMenuStrip = this.menuStrip; @@ -167,10 +167,10 @@ private ToolStripMenuItem КомпонентыToolStripMenuItem; private ToolStripMenuItem ИзделияToolStripMenuItem; private DataGridView dataGridView; - private Button buttonCreate; - private Button buttonToWork; - private Button buttonReady; - private Button buttonPut; + private Button buttonCreateOrder; + private Button buttonTakeOrderInWork; + private Button buttonOrderReady; + private Button buttonIssuedOrder; private Button buttonRefresh; } } \ No newline at end of file diff --git a/JewelryStore/JewelryStore/FormMain.cs b/JewelryStore/JewelryStore/FormMain.cs index 5897324..d35464d 100644 --- a/JewelryStore/JewelryStore/FormMain.cs +++ b/JewelryStore/JewelryStore/FormMain.cs @@ -10,16 +10,19 @@ namespace JewelryStore { private readonly ILogger _logger; private readonly IOrderLogic _orderLogic; + public FormMain(ILogger logger, IOrderLogic orderLogic) { InitializeComponent(); _logger = logger; _orderLogic = orderLogic; } + private void FormMain_Load(object sender, EventArgs e) { LoadData(); } + private void LoadData() { try @@ -35,14 +38,13 @@ namespace JewelryStore catch (Exception ex) { _logger.LogError(ex, "Ошибка загрузки заказов"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, - MessageBoxIcon.Error); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } + private void КомпонентыToolStripMenuItem_Click(object sender, EventArgs e) { - var service = - Program.ServiceProvider?.GetService(typeof(FormComponents)); + var service = Program.ServiceProvider?.GetService(typeof(FormComponents)); if (service is FormComponents form) { form.ShowDialog(); @@ -51,8 +53,7 @@ namespace JewelryStore private void ИзделияToolStripMenuItem_Click(object sender, EventArgs e) { - var service = - Program.ServiceProvider?.GetService(typeof(FormJewels)); + var service = Program.ServiceProvider?.GetService(typeof(FormJewels)); if (service is FormJewels form) { form.ShowDialog(); @@ -68,6 +69,7 @@ namespace JewelryStore LoadData(); } } + private void ButtonTakeOrderInWork_Click(object sender, EventArgs e) { if (dataGridView.SelectedRows.Count == 1) @@ -96,8 +98,7 @@ namespace JewelryStore if (dataGridView.SelectedRows.Count == 1) { int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); - _logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'", - id); + _logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'", id); try { var operationResult = _orderLogic.FinishOrder(new OrderBindingModel { Id = id }); @@ -121,8 +122,7 @@ namespace JewelryStore if (dataGridView.SelectedRows.Count == 1) { int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); - _logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'", - id); + _logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'", id); try { var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel { Id = id }); @@ -141,7 +141,7 @@ namespace JewelryStore } } } - private void ButtonRef_Click(object sender, EventArgs e) + private void ButtonRefresh_Click(object sender, EventArgs e) { LoadData(); } diff --git a/JewelryStore/JewelryStore/JewelryStore.csproj b/JewelryStore/JewelryStore/JewelryStore.csproj index ed17f82..cbfa7e5 100644 --- a/JewelryStore/JewelryStore/JewelryStore.csproj +++ b/JewelryStore/JewelryStore/JewelryStore.csproj @@ -8,6 +8,10 @@ enable + + + + diff --git a/JewelryStore/JewelryStore/nlog.config b/JewelryStore/JewelryStore/nlog.config new file mode 100644 index 0000000..85797a7 --- /dev/null +++ b/JewelryStore/JewelryStore/nlog.config @@ -0,0 +1,15 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/JewelryStore/JewelryStoreBusinessLogic/BusinessLogics/JewelLogic.cs b/JewelryStore/JewelryStoreBusinessLogic/BusinessLogics/JewelLogic.cs index a9b3230..c0dd189 100644 --- a/JewelryStore/JewelryStoreBusinessLogic/BusinessLogics/JewelLogic.cs +++ b/JewelryStore/JewelryStoreBusinessLogic/BusinessLogics/JewelLogic.cs @@ -7,7 +7,7 @@ using Microsoft.Extensions.Logging; namespace JewelryStoreBusinessLogic.BusinessLogics { - public class JewelLogic : IJewelLogic // TODO реализовать интерфейс идентично componentLogic + public class JewelLogic : IJewelLogic { private readonly ILogger _logger; private readonly IJewelStorage _jewelStorage; @@ -69,6 +69,7 @@ namespace JewelryStoreBusinessLogic.BusinessLogics } return true; } + public bool Delete(JewelBindingModel model) { CheckModel(model, false); diff --git a/JewelryStore/JewelryStoreBusinessLogic/BusinessLogics/OrderLogic.cs b/JewelryStore/JewelryStoreBusinessLogic/BusinessLogics/OrderLogic.cs index d3e47f1..aeba2c9 100644 --- a/JewelryStore/JewelryStoreBusinessLogic/BusinessLogics/OrderLogic.cs +++ b/JewelryStore/JewelryStoreBusinessLogic/BusinessLogics/OrderLogic.cs @@ -8,7 +8,7 @@ using Microsoft.Extensions.Logging; namespace JewelryStoreBusinessLogic.BusinessLogics { - public class OrderLogic : IOrderLogic //TODO реализовать интерфейс + public class OrderLogic : IOrderLogic { private readonly ILogger _logger; private readonly IOrderStorage _orderStorage; diff --git a/JewelryStore/JewelryStoreListImplement/DataListSingleton.cs b/JewelryStore/JewelryStoreListImplement/DataListSingleton.cs index 6ddcac3..4630a52 100644 --- a/JewelryStore/JewelryStoreListImplement/DataListSingleton.cs +++ b/JewelryStore/JewelryStoreListImplement/DataListSingleton.cs @@ -8,12 +8,14 @@ namespace JewelryStoreListImplement public List Components { get; set; } public List Orders { get; set; } public List Jewels { get; set; } + private DataListSingleton() { Components = new List(); Orders = new List(); Jewels = new List(); } + public static DataListSingleton GetInstance() { if (_instance == null) diff --git a/JewelryStore/JewelryStoreListImplement/Implements/ComponentStorage.cs b/JewelryStore/JewelryStoreListImplement/Implements/ComponentStorage.cs index fda42e9..5d1f604 100644 --- a/JewelryStore/JewelryStoreListImplement/Implements/ComponentStorage.cs +++ b/JewelryStore/JewelryStoreListImplement/Implements/ComponentStorage.cs @@ -14,6 +14,7 @@ namespace JewelryStoreListImplement.Implements { _source = DataListSingleton.GetInstance(); } + public List GetFullList() { var result = new List(); @@ -23,6 +24,7 @@ namespace JewelryStoreListImplement.Implements } return result; } + public List GetFilteredList(ComponentSearchModel model) { var result = new List(); @@ -39,6 +41,7 @@ namespace JewelryStoreListImplement.Implements } return result; } + public ComponentViewModel? GetElement(ComponentSearchModel model) { if (string.IsNullOrEmpty(model.ComponentName) && !model.Id.HasValue) @@ -56,6 +59,7 @@ namespace JewelryStoreListImplement.Implements } return null; } + public ComponentViewModel? Insert(ComponentBindingModel model) { model.Id = 1; @@ -74,6 +78,7 @@ namespace JewelryStoreListImplement.Implements _source.Components.Add(newComponent); return newComponent.GetViewModel; } + public ComponentViewModel? Update(ComponentBindingModel model) { foreach (var component in _source.Components) @@ -86,6 +91,7 @@ namespace JewelryStoreListImplement.Implements } return null; } + public ComponentViewModel? Delete(ComponentBindingModel model) { for (int i = 0; i < _source.Components.Count; ++i) diff --git a/JewelryStore/JewelryStoreListImplement/Implements/JewelStorage.cs b/JewelryStore/JewelryStoreListImplement/Implements/JewelStorage.cs index be5419d..25bcedb 100644 --- a/JewelryStore/JewelryStoreListImplement/Implements/JewelStorage.cs +++ b/JewelryStore/JewelryStoreListImplement/Implements/JewelStorage.cs @@ -6,7 +6,7 @@ using JewelryStoreListImplement.Models; namespace JewelryStoreListImplement.Implements { - public class JewelStorage : IJewelStorage // TODO реализовать интерфейс + public class JewelStorage : IJewelStorage { private readonly DataListSingleton _source; @@ -14,6 +14,7 @@ namespace JewelryStoreListImplement.Implements { _source = DataListSingleton.GetInstance(); } + public List GetFullList() { var result = new List(); diff --git a/JewelryStore/JewelryStoreListImplement/Implements/OrderStorage.cs b/JewelryStore/JewelryStoreListImplement/Implements/OrderStorage.cs index b0f92c3..6d7c8ae 100644 --- a/JewelryStore/JewelryStoreListImplement/Implements/OrderStorage.cs +++ b/JewelryStore/JewelryStoreListImplement/Implements/OrderStorage.cs @@ -6,7 +6,7 @@ using JewelryStoreListImplement.Models; namespace JewelryStoreListImplement.Implements { - public class OrderStorage : IOrderStorage // TODO реализовать интерфейс + public class OrderStorage : IOrderStorage { private readonly DataListSingleton _source; @@ -14,6 +14,7 @@ namespace JewelryStoreListImplement.Implements { _source = DataListSingleton.GetInstance(); } + public List GetFullList() { var result = new List(); diff --git a/JewelryStore/JewelryStoreListImplement/Models/Component.cs b/JewelryStore/JewelryStoreListImplement/Models/Component.cs index 4dc4508..45bc5b4 100644 --- a/JewelryStore/JewelryStoreListImplement/Models/Component.cs +++ b/JewelryStore/JewelryStoreListImplement/Models/Component.cs @@ -23,6 +23,7 @@ namespace JewelryStoreListImplement.Models Cost = model.Cost }; } + public void Update(ComponentBindingModel? model) { if (model == null) @@ -32,6 +33,7 @@ namespace JewelryStoreListImplement.Models ComponentName = model.ComponentName; Cost = model.Cost; } + public ComponentViewModel GetViewModel => new() { Id = Id, diff --git a/JewelryStore/JewelryStoreListImplement/Models/Jewel.cs b/JewelryStore/JewelryStoreListImplement/Models/Jewel.cs index 987ad6c..e9a590d 100644 --- a/JewelryStore/JewelryStoreListImplement/Models/Jewel.cs +++ b/JewelryStore/JewelryStoreListImplement/Models/Jewel.cs @@ -29,6 +29,7 @@ namespace JewelryStoreListImplement.Models JewelComponents = model.JewelComponents }; } + public void Update(JewelBindingModel? model) { if (model == null) @@ -39,6 +40,7 @@ namespace JewelryStoreListImplement.Models Price = model.Price; JewelComponents = model.JewelComponents; } + public JewelViewModel GetViewModel => new() { Id = Id, diff --git a/JewelryStore/JewelryStoreListImplement/Models/Order.cs b/JewelryStore/JewelryStoreListImplement/Models/Order.cs index bde0930..12f5a72 100644 --- a/JewelryStore/JewelryStoreListImplement/Models/Order.cs +++ b/JewelryStore/JewelryStoreListImplement/Models/Order.cs @@ -5,20 +5,14 @@ using JewelryStoreDataModels.Models; namespace JewelryStoreListImplement.Models { - public class Order : IOrderModel // TODO Класс для модели сущности «Заказ» разработать самостоятельно + public class Order : IOrderModel { public int Id { get; private set; } - public int JewelId { get; private set; } - public int Count { get; private set; } - public double Sum { get; private set; } - public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен; - public DateTime DateCreate { get; private set; } = DateTime.Now; - public DateTime? DateImplement { get; private set; } public static Order? Create(OrderBindingModel? model) @@ -38,6 +32,7 @@ namespace JewelryStoreListImplement.Models DateImplement = model.DateImplement }; } + public void Update(OrderBindingModel? model) { if (model == null) @@ -50,6 +45,7 @@ namespace JewelryStoreListImplement.Models DateImplement = model.DateImplement; } } + public OrderViewModel GetViewModel => new() { Id = Id,