From 39ae477367cf1969cb22941bf2875db971bdedb5 Mon Sep 17 00:00:00 2001 From: devil_1nc Date: Mon, 13 Mar 2023 10:26:55 +0400 Subject: [PATCH] =?UTF-8?q?=D0=A1=D0=B4=D0=B0=D0=BD=D0=BD=D0=B0=D1=8F=201?= =?UTF-8?q?=20=D0=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BusinessLogic/OrderLogic.cs | 2 +- .../ViewModels/PackageViewModel.cs | 4 ++-- .../Implements/SoftwareStorage.cs | 1 + .../SoftwareInstallation/FormMain.Designer.cs | 2 +- .../SoftwareInstallation/FormMain.cs | 4 ++-- .../SoftwareInstallation/FormPackage.cs | 12 +++++++---- .../FormPackages.Designer.cs | 21 +++++++++++-------- .../SoftwareInstallation/FormPackages.cs | 9 +++----- .../SoftwareInstallation/FormSoftwares.cs | 17 +++++++++++++-- 9 files changed, 45 insertions(+), 27 deletions(-) diff --git a/SoftwareInstallation/AbstractSoftwareInstallationBusinessLogic/BusinessLogic/OrderLogic.cs b/SoftwareInstallation/AbstractSoftwareInstallationBusinessLogic/BusinessLogic/OrderLogic.cs index 107bd27..e10fa1b 100644 --- a/SoftwareInstallation/AbstractSoftwareInstallationBusinessLogic/BusinessLogic/OrderLogic.cs +++ b/SoftwareInstallation/AbstractSoftwareInstallationBusinessLogic/BusinessLogic/OrderLogic.cs @@ -86,7 +86,7 @@ namespace AbstractSoftwareInstallationBusinessLogic.BusinessLogic return false; } model.Status = _newStatus; - if (model.Status == OrderStatus.Готов) model.DateImplement = DateTime.Now; + if (model.Status == OrderStatus.Выдан) model.DateImplement = DateTime.Now; else { model.DateImplement = viewModel.DateImplement; diff --git a/SoftwareInstallation/AbstractSoftwareInstallationContracts/ViewModels/PackageViewModel.cs b/SoftwareInstallation/AbstractSoftwareInstallationContracts/ViewModels/PackageViewModel.cs index b58ea0c..8b5a248 100644 --- a/SoftwareInstallation/AbstractSoftwareInstallationContracts/ViewModels/PackageViewModel.cs +++ b/SoftwareInstallation/AbstractSoftwareInstallationContracts/ViewModels/PackageViewModel.cs @@ -11,9 +11,9 @@ namespace AbstractSoftwareInstallationContracts.ViewModels public class PackageViewModel : IPackageModel { public int Id { get; set; } - [DisplayName("Package Name")] + [DisplayName("Имя пакета")] public string PackageName { get; set; } = string.Empty; - [DisplayName("Price")] + [DisplayName("Цена")] public double Price { get; set; } public Dictionary PackageSoftware { diff --git a/SoftwareInstallation/AbstractSoftwareInstallationListImplement/Implements/SoftwareStorage.cs b/SoftwareInstallation/AbstractSoftwareInstallationListImplement/Implements/SoftwareStorage.cs index 137f530..42e24b5 100644 --- a/SoftwareInstallation/AbstractSoftwareInstallationListImplement/Implements/SoftwareStorage.cs +++ b/SoftwareInstallation/AbstractSoftwareInstallationListImplement/Implements/SoftwareStorage.cs @@ -83,6 +83,7 @@ namespace AbstractSoftwareInstallationListImplement.Implements component.Update(model); return component.GetViewModel; } + throw new ArgumentNullException("Новая цена", nameof(model.Cost)); } return null; } diff --git a/SoftwareInstallation/SoftwareInstallation/FormMain.Designer.cs b/SoftwareInstallation/SoftwareInstallation/FormMain.Designer.cs index 58ce484..bf25c66 100644 --- a/SoftwareInstallation/SoftwareInstallation/FormMain.Designer.cs +++ b/SoftwareInstallation/SoftwareInstallation/FormMain.Designer.cs @@ -88,7 +88,7 @@ this.buttonIssuedOrder.Name = "buttonIssuedOrder"; this.buttonIssuedOrder.Size = new System.Drawing.Size(153, 23); this.buttonIssuedOrder.TabIndex = 5; - this.buttonIssuedOrder.Text = "Заказ принят"; + this.buttonIssuedOrder.Text = "Заказ выдан"; this.buttonIssuedOrder.UseVisualStyleBackColor = true; this.buttonIssuedOrder.Click += new System.EventHandler(this.buttonIssuedOrder_Click); // diff --git a/SoftwareInstallation/SoftwareInstallation/FormMain.cs b/SoftwareInstallation/SoftwareInstallation/FormMain.cs index e200157..7151148 100644 --- a/SoftwareInstallation/SoftwareInstallation/FormMain.cs +++ b/SoftwareInstallation/SoftwareInstallation/FormMain.cs @@ -145,8 +145,8 @@ namespace SoftwareInstallationView } private void packageToolStripMenuItem_Click(object sender, EventArgs e) { - var service = Program.ServiceProvider?.GetService(typeof(FormPackage)); - if (service is FormPackage form) + var service = Program.ServiceProvider?.GetService(typeof(FormPackages)); + if (service is FormPackages form) { form.ShowDialog(); } diff --git a/SoftwareInstallation/SoftwareInstallation/FormPackage.cs b/SoftwareInstallation/SoftwareInstallation/FormPackage.cs index 92bb6c0..8b3dc17 100644 --- a/SoftwareInstallation/SoftwareInstallation/FormPackage.cs +++ b/SoftwareInstallation/SoftwareInstallation/FormPackage.cs @@ -60,7 +60,12 @@ namespace SoftwareInstallationView dataGridView.Rows.Clear(); foreach (var pc in _packageSoftwares) { - dataGridView.Rows.Add(new object[] { pc.Key, pc.Value.Item1.SoftwareName, pc.Value.Item2 }); + dataGridView.Rows.Add(new object[] + { + pc.Key, + pc.Value.Item1. + SoftwareName, + pc.Value.Item2 }); } textBoxPrice.Text = CalcPrice().ToString(); } @@ -184,9 +189,7 @@ namespace SoftwareInstallationView Id = _id ?? 0, PackageName = textBoxName.Text, Price = Convert.ToDouble(textBoxPrice.Text), - PackageSoftware = _packageSoftwares }; - var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model); if (!operationResult) @@ -207,7 +210,8 @@ namespace SoftwareInstallationView private void buttonCancel_Click(object sender, EventArgs e) { - + DialogResult = DialogResult.Cancel; + Close(); } private double CalcPrice() { diff --git a/SoftwareInstallation/SoftwareInstallation/FormPackages.Designer.cs b/SoftwareInstallation/SoftwareInstallation/FormPackages.Designer.cs index 77499ec..e1bb352 100644 --- a/SoftwareInstallation/SoftwareInstallation/FormPackages.Designer.cs +++ b/SoftwareInstallation/SoftwareInstallation/FormPackages.Designer.cs @@ -29,11 +29,11 @@ private void InitializeComponent() { this.dataGridView = new System.Windows.Forms.DataGridView(); + this.ColumnId = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.buttonUpdate = new System.Windows.Forms.Button(); this.buttonDelete = new System.Windows.Forms.Button(); this.buttonEdit = new System.Windows.Forms.Button(); this.buttonAdd = new System.Windows.Forms.Button(); - this.ColumnId = new System.Windows.Forms.DataGridViewTextBoxColumn(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); this.SuspendLayout(); // @@ -49,6 +49,14 @@ this.dataGridView.Size = new System.Drawing.Size(445, 373); this.dataGridView.TabIndex = 10; // + // ColumnId + // + this.ColumnId.FillWeight = 200F; + this.ColumnId.HeaderText = "Id"; + this.ColumnId.Name = "ColumnId"; + this.ColumnId.Visible = false; + this.ColumnId.Width = 200; + // // buttonUpdate // this.buttonUpdate.Location = new System.Drawing.Point(461, 193); @@ -57,6 +65,7 @@ this.buttonUpdate.TabIndex = 9; this.buttonUpdate.Text = "Обновить"; this.buttonUpdate.UseVisualStyleBackColor = true; + this.buttonUpdate.Click += new System.EventHandler(this.ButtonUpd_Click); // // buttonDelete // @@ -66,6 +75,7 @@ this.buttonDelete.TabIndex = 8; this.buttonDelete.Text = "Удалить"; this.buttonDelete.UseVisualStyleBackColor = true; + this.buttonDelete.Click += new System.EventHandler(this.ButtonDel_Click); // // buttonEdit // @@ -85,14 +95,7 @@ this.buttonAdd.TabIndex = 6; this.buttonAdd.Text = "Добавить"; this.buttonAdd.UseVisualStyleBackColor = true; - // - // ColumnId - // - this.ColumnId.FillWeight = 200F; - this.ColumnId.HeaderText = "Id"; - this.ColumnId.Name = "ColumnId"; - this.ColumnId.Visible = false; - this.ColumnId.Width = 200; + this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click); // // FormPackages // diff --git a/SoftwareInstallation/SoftwareInstallation/FormPackages.cs b/SoftwareInstallation/SoftwareInstallation/FormPackages.cs index 978a305..acf6220 100644 --- a/SoftwareInstallation/SoftwareInstallation/FormPackages.cs +++ b/SoftwareInstallation/SoftwareInstallation/FormPackages.cs @@ -14,6 +14,7 @@ namespace SoftwareInstallationView InitializeComponent(); _logger = logger; _logic = logic; + LoadData(); } private void FormPackages_Load(object sender, EventArgs e) { @@ -29,7 +30,7 @@ namespace SoftwareInstallationView dataGridView.DataSource = list; dataGridView.Columns["Id"].Visible = false; dataGridView.Columns["PackageName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; - dataGridView.Columns["PackageSoftwares"].Visible = false; + dataGridView.Columns["PackageSoftware"].Visible = false; } _logger.LogInformation("Загрузка пакетов"); } @@ -53,7 +54,7 @@ namespace SoftwareInstallationView } private void ButtonUpd_Click(object sender, EventArgs e) { - + LoadData(); } private void ButtonDel_Click(object sender, EventArgs e) { @@ -84,10 +85,6 @@ namespace SoftwareInstallationView } } } - private void ButtonRef_Click(object sender, EventArgs e) - { - LoadData(); - } private void buttonEdit_Click(object sender, EventArgs e) { diff --git a/SoftwareInstallation/SoftwareInstallation/FormSoftwares.cs b/SoftwareInstallation/SoftwareInstallation/FormSoftwares.cs index d0db248..cffd2b8 100644 --- a/SoftwareInstallation/SoftwareInstallation/FormSoftwares.cs +++ b/SoftwareInstallation/SoftwareInstallation/FormSoftwares.cs @@ -54,7 +54,7 @@ namespace SoftwareInstallationView } private void ButtonUpd_Click(object sender, EventArgs e) { - + LoadData(); } private void ButtonDel_Click(object sender, EventArgs e) { @@ -88,7 +88,20 @@ namespace SoftwareInstallationView } private void ButtonRef_Click(object sender, EventArgs e) { - LoadData(); + if (dataGridView.SelectedRows.Count == 1) + { + var service = Program.ServiceProvider?.GetService(typeof(FormSoftware)); + + if (service is FormSoftware form) + { + form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + + if (form.ShowDialog() == DialogResult.OK) + { + LoadData(); + } + } + } } }