From 2fa3cbcfb4e4a08a679f9f5c58373450d11f3095 Mon Sep 17 00:00:00 2001 From: dimazhelovanov Date: Sun, 9 Apr 2023 23:58:03 +0400 Subject: [PATCH] =?UTF-8?q?=D0=93=D0=BE=D1=82=D0=BE=D0=B2=D0=B0=D1=8F=205?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FormClients.Designer.cs | 37 -- .../BlacksmithWorkshop/FormClients.resx | 12 - .../FormCreateOrder.Designer.cs | 321 ++++++++++-------- .../BlacksmithWorkshop/FormCreateOrder.cs | 254 +++++++------- .../BlacksmithWorkshop/FormMain.cs | 15 +- .../BusinessLogics/ClientLogic.cs | 3 +- .../BusinessLogics/ReportLogic.cs | 3 - .../OfficePackage/AbstractSaveToWord.cs | 13 - .../Controllers/HomeController.cs | 4 + .../BlacksmithWorkshopClientApp/Program.cs | 4 +- .../Views/Home/Create.cshtml | 7 +- .../Views/Home/Index.cshtml | 96 ++++-- .../Views/Home/Privacy.cshtml | 42 ++- .../Views/Home/Register.cshtml | 28 +- .../Views/Shared/_Layout.cshtml | 5 +- .../BusinessLogicsContracts/IReportLogic.cs | 1 + .../Models/IComponentModel.cs | 2 +- .../Implements/ClientStorage.cs | 15 +- .../Implements/OrderStorage.cs | 43 ++- .../20230310215555_InitMigration.cs | 160 +++------ .../20230327051139_Lab5Migra.Designer.cs | 201 +++++++++++ .../Migrations/20230327051139_Lab5Migra.cs | 47 +++ ...BlacksmithWorkshopDatabaseModelSnapshot.cs | 28 ++ .../Models/Order.cs | 38 ++- .../Implements/ClientStorage.cs | 1 + .../Implements/OrderStorage.cs | 13 +- .../Models/Order.cs | 5 +- .../Controllers/MainController.cs | 12 +- 28 files changed, 868 insertions(+), 542 deletions(-) create mode 100644 BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230327051139_Lab5Migra.Designer.cs create mode 100644 BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230327051139_Lab5Migra.cs diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormClients.Designer.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormClients.Designer.cs index 884e814..c6cb0cd 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/FormClients.Designer.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormClients.Designer.cs @@ -29,10 +29,6 @@ private void InitializeComponent() { dataGridView = new DataGridView(); - Id = new DataGridViewTextBoxColumn(); - СlientFIO = new DataGridViewTextBoxColumn(); - Email = new DataGridViewTextBoxColumn(); - Password = new DataGridViewTextBoxColumn(); buttonDelete = new Button(); buttonUpdate = new Button(); ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); @@ -42,7 +38,6 @@ // dataGridView.BackgroundColor = SystemColors.ButtonHighlight; dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; - dataGridView.Columns.AddRange(new DataGridViewColumn[] { Id, СlientFIO, Email, Password }); dataGridView.Location = new Point(-4, 1); dataGridView.Name = "dataGridView"; dataGridView.RowHeadersWidth = 51; @@ -50,34 +45,6 @@ dataGridView.Size = new Size(657, 450); dataGridView.TabIndex = 0; // - // Id - // - Id.HeaderText = "Id"; - Id.MinimumWidth = 6; - Id.Name = "Id"; - Id.Width = 125; - // - // СlientFIO - // - СlientFIO.HeaderText = "ФИО клиента"; - СlientFIO.MinimumWidth = 6; - СlientFIO.Name = "СlientFIO"; - СlientFIO.Width = 125; - // - // Email - // - Email.HeaderText = "E-mail"; - Email.MinimumWidth = 6; - Email.Name = "Email"; - Email.Width = 125; - // - // Password - // - Password.HeaderText = "Пароль"; - Password.MinimumWidth = 6; - Password.Name = "Password"; - Password.Width = 125; - // // buttonDelete // buttonDelete.Location = new Point(671, 28); @@ -117,9 +84,5 @@ private DataGridView dataGridView; private Button buttonDelete; private Button buttonUpdate; - private DataGridViewTextBoxColumn Id; - private DataGridViewTextBoxColumn СlientFIO; - private DataGridViewTextBoxColumn Email; - private DataGridViewTextBoxColumn Password; } } \ No newline at end of file diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormClients.resx b/BlacksmithWorkshop/BlacksmithWorkshop/FormClients.resx index 073cbb8..f298a7b 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/FormClients.resx +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormClients.resx @@ -57,16 +57,4 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - True - - - True - - - True - - - True - \ No newline at end of file diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormCreateOrder.Designer.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormCreateOrder.Designer.cs index b636a09..74d0be0 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/FormCreateOrder.Designer.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormCreateOrder.Designer.cs @@ -1,158 +1,179 @@ namespace BlacksmithWorkshop { - partial class FormCreateOrder - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; + partial class FormCreateOrder + { + /// + /// 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); - } + /// + /// 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 + #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.label1 = new System.Windows.Forms.Label(); - this.label2 = new System.Windows.Forms.Label(); - this.label3 = new System.Windows.Forms.Label(); - this.comboBoxManufacture = new System.Windows.Forms.ComboBox(); - this.textBoxCount = new System.Windows.Forms.TextBox(); - this.labelSum = new System.Windows.Forms.Label(); - this.buttonSave = new System.Windows.Forms.Button(); - this.buttonCancel = new System.Windows.Forms.Button(); - this.textBoxSum = new System.Windows.Forms.TextBox(); - this.SuspendLayout(); - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(43, 41); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(68, 20); - this.label1.TabIndex = 0; - this.label1.Text = "Изделие"; - // - // label2 - // - this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(43, 97); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(90, 20); - this.label2.TabIndex = 1; - this.label2.Text = "Количество"; - // - // label3 - // - this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(43, 151); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(58, 20); - this.label3.TabIndex = 2; - this.label3.Text = "Сумма:"; - // - // comboBoxManufacture - // - this.comboBoxManufacture.FormattingEnabled = true; - this.comboBoxManufacture.Location = new System.Drawing.Point(133, 38); - this.comboBoxManufacture.Name = "comboBoxManufacture"; - this.comboBoxManufacture.Size = new System.Drawing.Size(446, 28); - this.comboBoxManufacture.TabIndex = 3; - this.comboBoxManufacture.SelectedIndexChanged += new System.EventHandler(this.ComboBoxManufacture_SelectedIndexChanged); - // - // textBoxCount - // - this.textBoxCount.Location = new System.Drawing.Point(133, 94); - this.textBoxCount.Name = "textBoxCount"; - this.textBoxCount.Size = new System.Drawing.Size(446, 27); - this.textBoxCount.TabIndex = 4; - this.textBoxCount.TextChanged += new System.EventHandler(this.TextBoxCount_TextChanged); - // - // labelSum - // - this.labelSum.AutoSize = true; - this.labelSum.BackColor = System.Drawing.SystemColors.ActiveBorder; - this.labelSum.Location = new System.Drawing.Point(133, 151); - this.labelSum.Name = "labelSum"; - this.labelSum.Size = new System.Drawing.Size(0, 20); - this.labelSum.TabIndex = 5; - // - // buttonSave - // - this.buttonSave.Location = new System.Drawing.Point(332, 216); - this.buttonSave.Name = "buttonSave"; - this.buttonSave.Size = new System.Drawing.Size(94, 29); - this.buttonSave.TabIndex = 6; - this.buttonSave.Text = "Сохранить"; - this.buttonSave.UseVisualStyleBackColor = true; - this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click); - // - // buttonCancel - // - this.buttonCancel.Location = new System.Drawing.Point(485, 216); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(94, 29); - this.buttonCancel.TabIndex = 7; - this.buttonCancel.Text = "Отмена"; - this.buttonCancel.UseVisualStyleBackColor = true; - this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); - // - // textBoxSum - // - this.textBoxSum.BackColor = System.Drawing.SystemColors.ActiveBorder; - this.textBoxSum.Location = new System.Drawing.Point(133, 151); - this.textBoxSum.Name = "textBoxSum"; - this.textBoxSum.ReadOnly = true; - this.textBoxSum.Size = new System.Drawing.Size(446, 27); - this.textBoxSum.TabIndex = 8; - - // - // FormCreateOrder - // - this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(720, 257); - this.Controls.Add(this.textBoxSum); - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.buttonSave); - this.Controls.Add(this.labelSum); - this.Controls.Add(this.textBoxCount); - this.Controls.Add(this.comboBoxManufacture); - this.Controls.Add(this.label3); - this.Controls.Add(this.label2); - this.Controls.Add(this.label1); - this.Name = "FormCreateOrder"; - this.Text = "Создание заказа"; - this.ResumeLayout(false); - this.PerformLayout(); + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + label1 = new Label(); + label2 = new Label(); + label3 = new Label(); + comboBoxManufacture = new ComboBox(); + textBoxCount = new TextBox(); + labelSum = new Label(); + buttonSave = new Button(); + buttonCancel = new Button(); + textBoxSum = new TextBox(); + label4 = new Label(); + comboBoxClients = new ComboBox(); + SuspendLayout(); + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(44, 18); + label1.Name = "label1"; + label1.Size = new Size(68, 20); + label1.TabIndex = 0; + label1.Text = "Изделие"; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(22, 68); + label2.Name = "label2"; + label2.Size = new Size(90, 20); + label2.TabIndex = 1; + label2.Text = "Количество"; + // + // label3 + // + label3.AutoSize = true; + label3.Location = new Point(54, 154); + label3.Name = "label3"; + label3.Size = new Size(58, 20); + label3.TabIndex = 2; + label3.Text = "Сумма:"; + // + // comboBoxManufacture + // + comboBoxManufacture.FormattingEnabled = true; + comboBoxManufacture.Location = new Point(133, 10); + comboBoxManufacture.Name = "comboBoxManufacture"; + comboBoxManufacture.Size = new Size(446, 28); + comboBoxManufacture.TabIndex = 3; + comboBoxManufacture.SelectedIndexChanged += ComboBoxManufacture_SelectedIndexChanged; + // + // textBoxCount + // + textBoxCount.Location = new Point(133, 65); + textBoxCount.Name = "textBoxCount"; + textBoxCount.Size = new Size(446, 27); + textBoxCount.TabIndex = 4; + textBoxCount.TextChanged += TextBoxCount_TextChanged; + // + // labelSum + // + labelSum.AutoSize = true; + labelSum.BackColor = SystemColors.ActiveBorder; + labelSum.Location = new Point(133, 151); + labelSum.Name = "labelSum"; + labelSum.Size = new Size(0, 20); + labelSum.TabIndex = 5; + // + // buttonSave + // + buttonSave.Location = new Point(332, 216); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(94, 29); + buttonSave.TabIndex = 6; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += ButtonSave_Click; + // + // buttonCancel + // + buttonCancel.Location = new Point(485, 216); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(94, 29); + buttonCancel.TabIndex = 7; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click; + // + // textBoxSum + // + textBoxSum.BackColor = SystemColors.ActiveBorder; + textBoxSum.Location = new Point(133, 151); + textBoxSum.Name = "textBoxSum"; + textBoxSum.ReadOnly = true; + textBoxSum.Size = new Size(446, 27); + textBoxSum.TabIndex = 8; + // + // label4 + // + label4.AutoSize = true; + label4.Location = new Point(62, 110); + label4.Name = "label4"; + label4.Size = new Size(58, 20); + label4.TabIndex = 9; + label4.Text = "Клиент"; + // + // comboBoxClients + // + comboBoxClients.FormattingEnabled = true; + comboBoxClients.Location = new Point(133, 107); + comboBoxClients.Name = "comboBoxClients"; + comboBoxClients.Size = new Size(446, 28); + comboBoxClients.TabIndex = 10; + // + // FormCreateOrder + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(720, 257); + Controls.Add(comboBoxClients); + Controls.Add(label4); + Controls.Add(textBoxSum); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(labelSum); + Controls.Add(textBoxCount); + Controls.Add(comboBoxManufacture); + Controls.Add(label3); + Controls.Add(label2); + Controls.Add(label1); + Name = "FormCreateOrder"; + Text = "Создание заказа"; + ResumeLayout(false); + PerformLayout(); + } - } + #endregion - #endregion - - private Label label1; - private Label label2; - private Label label3; - private ComboBox comboBoxManufacture; - private TextBox textBoxCount; - private Label labelSum; - private Button buttonSave; - private Button buttonCancel; - private TextBox textBoxSum; - } + private Label label1; + private Label label2; + private Label label3; + private ComboBox comboBoxManufacture; + private TextBox textBoxCount; + private Label labelSum; + private Button buttonSave; + private Button buttonCancel; + private TextBox textBoxSum; + private Label label4; + private ComboBox comboBoxClients; + } } \ No newline at end of file diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormCreateOrder.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormCreateOrder.cs index 00bb665..bbcff59 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/FormCreateOrder.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormCreateOrder.cs @@ -15,127 +15,143 @@ using System.Windows.Forms; namespace BlacksmithWorkshop { - public partial class FormCreateOrder : Form - { - private readonly ILogger _logger; - private readonly IManufactureLogic _logicM; - private readonly IOrderLogic _logicO; - public FormCreateOrder(ILogger logger, IManufactureLogic logicM, IOrderLogic logicO) - { - InitializeComponent(); - - _logger = logger; - _logicM = logicM; - _logicO = logicO; - LoadData(); - } - private void FormCreateOrder_Load(object sender, EventArgs e) - { - _logger.LogInformation("Загрузка изделий для заказа"); - LoadData(); - - } - private void LoadData() - { - var _list = _logicM.ReadList(null); - - if (_list != null) - { - comboBoxManufacture.DisplayMember = "ManufactureName"; - comboBoxManufacture.ValueMember = "Id"; - comboBoxManufacture.DataSource = _list; - comboBoxManufacture.SelectedItem = null; - } - - } - private void CalcSum() - { - if (comboBoxManufacture.SelectedValue != null && - !string.IsNullOrEmpty(textBoxCount.Text)) - { - try - { - int id = Convert.ToInt32(comboBoxManufacture.SelectedValue); - var product = _logicM.ReadElement(new ManufactureSearchModel - { - Id - = id - }); - int count = Convert.ToInt32(textBoxCount.Text); - textBoxSum.Text = Math.Round(count * (product?.Price ?? 0), - 2).ToString(); - _logger.LogInformation("Расчет суммы заказа"); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка расчета суммы заказа"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, - MessageBoxIcon.Error); - } - } - } - private void TextBoxCount_TextChanged(object sender, EventArgs e) - { - CalcSum(); + public partial class FormCreateOrder : Form + { + private readonly ILogger _logger; + private readonly IManufactureLogic _logicM; + private readonly IOrderLogic _logicO; + private readonly IClientLogic _logicC; + public FormCreateOrder(ILogger logger, IManufactureLogic logicM, IOrderLogic logicO, IClientLogic logicC) + { + InitializeComponent(); - } - private void ComboBoxManufacture_SelectedIndexChanged(object sender, EventArgs e) - { - CalcSum(); - } + _logger = logger; + _logicM = logicM; + _logicO = logicO; + _logicC = logicC; + LoadData(); + } + private void FormCreateOrder_Load(object sender, EventArgs e) + { + _logger.LogInformation("Загрузка изделий для заказа"); + LoadData(); - private void ButtonSave_Click(object sender, EventArgs e) - { - if (string.IsNullOrEmpty(textBoxCount.Text)) - { - MessageBox.Show("Заполните поле Количество", "Ошибка", - MessageBoxButtons.OK, MessageBoxIcon.Error); - return; - } - if (comboBoxManufacture.SelectedValue == null) - { - MessageBox.Show("Выберите изделие", "Ошибка", - MessageBoxButtons.OK, MessageBoxIcon.Error); - return; - } - _logger.LogInformation("Создание заказа"); - try - { - var operationResult = _logicO.CreateOrder(new OrderBindingModel - { - ManufactureId = Convert.ToInt32(comboBoxManufacture.SelectedValue), - ManufactureName = comboBoxManufacture.Text, - Count = Convert.ToInt32(textBoxCount.Text), - Sum = Convert.ToDouble(textBoxSum.Text) - }); - - if (!operationResult) - { - throw new Exception("Ошибка при создании заказа. Дополнительная информация в логах."); - } - MessageBox.Show("Сохранение прошло успешно", "Сообщение", - MessageBoxButtons.OK, MessageBoxIcon.Information); - DialogResult = DialogResult.OK; - Close(); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка создания заказа"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, - MessageBoxIcon.Error); - } - } + } + private void LoadData() + { + var _list = _logicM.ReadList(null); + var _listClient = _logicC.ReadList(null); - private void ButtonCancel_Click(object sender, EventArgs e) - { - DialogResult = DialogResult.Cancel; - Close(); - } + if (_list != null && _listClient != null) + { + comboBoxManufacture.DisplayMember = "ManufactureName"; + comboBoxManufacture.ValueMember = "Id"; + comboBoxManufacture.DataSource = _list; + comboBoxManufacture.SelectedItem = null; + + comboBoxClients.DisplayMember = "ClientFIO"; + comboBoxClients.ValueMember = "Id"; + comboBoxClients.DataSource = _listClient; + comboBoxClients.SelectedItem = null; + } - private void button1_Click(object sender, EventArgs e) - { - var _list = _logicM.ReadList(null); - MessageBox.Show(_list.Count.ToString()); - } - } + } + private void CalcSum() + { + if (comboBoxManufacture.SelectedValue != null && + !string.IsNullOrEmpty(textBoxCount.Text)) + { + try + { + int id = Convert.ToInt32(comboBoxManufacture.SelectedValue); + var product = _logicM.ReadElement(new ManufactureSearchModel + { + Id + = id + }); + int count = Convert.ToInt32(textBoxCount.Text); + textBoxSum.Text = Math.Round(count * (product?.Price ?? 0), + 2).ToString(); + _logger.LogInformation("Расчет суммы заказа"); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка расчета суммы заказа"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + } + private void TextBoxCount_TextChanged(object sender, EventArgs e) + { + CalcSum(); + + } + private void ComboBoxManufacture_SelectedIndexChanged(object sender, EventArgs e) + { + CalcSum(); + } + + private void ButtonSave_Click(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(textBoxCount.Text)) + { + MessageBox.Show("Заполните поле Количество", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + if (comboBoxManufacture.SelectedValue == null) + { + MessageBox.Show("Выберите изделие", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + if (comboBoxClients.SelectedValue == null) + { + MessageBox.Show("Выберите клиента", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + _logger.LogInformation("Создание заказа"); + try + { + var operationResult = _logicO.CreateOrder(new OrderBindingModel + { + ManufactureId = Convert.ToInt32(comboBoxManufacture.SelectedValue), + ManufactureName = comboBoxManufacture.Text, + Count = Convert.ToInt32(textBoxCount.Text), + Sum = Convert.ToDouble(textBoxSum.Text), + ClientId = Convert.ToInt32(comboBoxClients.SelectedValue) + + }); + + if (!operationResult) + { + throw new Exception("Ошибка при создании заказа. Дополнительная информация в логах."); + } + MessageBox.Show("Сохранение прошло успешно", "Сообщение", + MessageBoxButtons.OK, MessageBoxIcon.Information); + DialogResult = DialogResult.OK; + Close(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка создания заказа"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + + private void ButtonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); + } + + private void button1_Click(object sender, EventArgs e) + { + var _list = _logicM.ReadList(null); + MessageBox.Show(_list.Count.ToString()); + } + } } diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.cs index 946c915..4db48fb 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.cs @@ -26,8 +26,9 @@ namespace BlacksmithWorkshop InitializeComponent(); _logger = logger; _orderLogic = orderLogic; - LoadData(); + _reportLogic = reportLogic; + LoadData(); } private void FormMain_Load(object sender, EventArgs e) @@ -44,6 +45,7 @@ namespace BlacksmithWorkshop { dataGridView.DataSource = list; dataGridView.Columns["ManufactureId"].Visible = false; + dataGridView.Columns["ClientId"].Visible = false; } _logger.LogInformation("Загрузка компонентов"); @@ -104,7 +106,9 @@ namespace BlacksmithWorkshop Status = Enum.Parse(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()), Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value), Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()), - DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()) + DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()), + ClientId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value) + }); @@ -143,7 +147,8 @@ namespace BlacksmithWorkshop Status = Enum.Parse(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()), Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value), Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()), - DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()) + DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()), + ClientId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value) }); if (!operationResult) { @@ -180,7 +185,9 @@ namespace BlacksmithWorkshop ManufactureName = dataGridView.SelectedRows[0].Cells["ManufactureName"].Value.ToString(), Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value), Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()), - DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()) + DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()), + ClientId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value) + }); if (!operationResult) { diff --git a/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogics/ClientLogic.cs b/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogics/ClientLogic.cs index 7dfe420..00900c6 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogics/ClientLogic.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogics/ClientLogic.cs @@ -24,6 +24,7 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogics } public bool Create(ClientBindingModel model) { + CheckModel(model); if (_clientStorage.Insert(model) == null) { @@ -65,7 +66,7 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogics public List? ReadList(ClientSearchModel? model) { - _logger.LogInformation("ReadElement. ClientFIO:{ ClientFIO}. ClientEmail:{ ClientEmail}. Id:{ Id}", model.ClientFIO, model.Email, model.Id); + _logger.LogInformation("ReadElement. ClientFIO:{ ClientFIO}. ClientEmail:{ ClientEmail}. Id:{ Id}", model?.ClientFIO, model?.Email, model?.Id); var list = model == null ? _clientStorage.GetFullList() : _clientStorage.GetFilteredList(model); if (list == null) diff --git a/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogics/ReportLogic.cs b/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogics/ReportLogic.cs index b3d5fc3..d062389 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogics/ReportLogic.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogics/ReportLogic.cs @@ -57,9 +57,6 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogics record.Components.Add(new Tuple(component.Value.Item1.ComponentName, component.Value.Item2)); record.TotalCount += component.Value.Item2; - - - } list.Add(record); } diff --git a/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/OfficePackage/AbstractSaveToWord.cs b/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/OfficePackage/AbstractSaveToWord.cs index b16941e..c430a84 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/OfficePackage/AbstractSaveToWord.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/OfficePackage/AbstractSaveToWord.cs @@ -24,19 +24,6 @@ WordTextProperties { Bold = true, Size = "24", }) }, JustificationType = WordJustificationType.Center } }); - /* foreach (var component in info.Components) - { - CreateParagraph(new WordParagraph - { - Texts = new List<(string, WordTextProperties)> { -(component.ComponentName, new WordTextProperties { Size = "24"}) }, - TextProperties = new WordTextProperties - { - Size = "24", - JustificationType = WordJustificationType.Both - } - }); - }*/ foreach (var manufacture in info.Manufactures) { CreateParagraph(new WordParagraph diff --git a/BlacksmithWorkshop/BlacksmithWorkshopClientApp/Controllers/HomeController.cs b/BlacksmithWorkshop/BlacksmithWorkshopClientApp/Controllers/HomeController.cs index 84736d2..148207a 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopClientApp/Controllers/HomeController.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopClientApp/Controllers/HomeController.cs @@ -1,7 +1,9 @@ using BlacksmithWorkshopClientApp.Models; using BlacksmithWorkshopContracts.BindingModels; +using BlacksmithWorkshopContracts.SearchModels; using BlacksmithWorkshopContracts.ViewModels; using Microsoft.AspNetCore.Mvc; +using System.Collections.Generic; using System.Diagnostics; namespace BlacksmithWorkshopClientApp.Controllers @@ -128,6 +130,8 @@ namespace BlacksmithWorkshopClientApp.Controllers { throw new Exception("Количество и сумма должны быть больше 0"); } + + APIClient.PostRequest("api/main/createorder", new OrderBindingModel { diff --git a/BlacksmithWorkshop/BlacksmithWorkshopClientApp/Program.cs b/BlacksmithWorkshop/BlacksmithWorkshopClientApp/Program.cs index 0727468..05dec10 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopClientApp/Program.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopClientApp/Program.cs @@ -1,10 +1,12 @@ +using BlacksmithWorkshopClientApp; + var builder = WebApplication.CreateBuilder(args); // Add services to the container. builder.Services.AddControllersWithViews(); var app = builder.Build(); - +APIClient.Connect(builder.Configuration); // Configure the HTTP request pipeline. if (!app.Environment.IsDevelopment()) { diff --git a/BlacksmithWorkshop/BlacksmithWorkshopClientApp/Views/Home/Create.cshtml b/BlacksmithWorkshop/BlacksmithWorkshopClientApp/Views/Home/Create.cshtml index 66b77cc..c569c1a 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopClientApp/Views/Home/Create.cshtml +++ b/BlacksmithWorkshop/BlacksmithWorkshopClientApp/Views/Home/Create.cshtml @@ -1,6 +1,7 @@ @{ ViewData["Title"] = "Create"; } +

Создание заказа

@@ -8,7 +9,7 @@
Изделие:
- +
@@ -32,13 +33,15 @@ btn-primary" />