diff --git a/SoftwareInstallation/FormMain.Designer.cs b/SoftwareInstallation/FormMain.Designer.cs index bf6e25c..46a71a8 100644 --- a/SoftwareInstallation/FormMain.Designer.cs +++ b/SoftwareInstallation/FormMain.Designer.cs @@ -1,4 +1,4 @@ -namespace SoftwareInstallationView +namespace SoftwareInstallation { partial class FormMain { @@ -20,193 +20,245 @@ 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() - { - menuStrip1 = new MenuStrip(); - bookToolStripMenuItem = new ToolStripMenuItem(); - ingridientsToolStripMenuItem = new ToolStripMenuItem(); - pizzasToolStripMenuItem = new ToolStripMenuItem(); - shopsToolStripMenuItem = new ToolStripMenuItem(); - operationToolStripMenuItem = new ToolStripMenuItem(); - transactionToolStripMenuItem = new ToolStripMenuItem(); - продажаToolStripMenuItem = new ToolStripMenuItem(); - dataGridView = new DataGridView(); - buttonCreateOrder = new Button(); - buttonTakeOrderInWork = new Button(); - buttonOrderReady = new Button(); - buttonIssuedOrder = new Button(); - buttonRef = new Button(); - menuStrip1.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); - SuspendLayout(); - // - // menuStrip1 - // - menuStrip1.ImageScalingSize = new Size(20, 20); - menuStrip1.Items.AddRange(new ToolStripItem[] { bookToolStripMenuItem, operationToolStripMenuItem }); - menuStrip1.Location = new Point(0, 0); - menuStrip1.Name = "menuStrip1"; - menuStrip1.Padding = new Padding(6, 3, 0, 3); - menuStrip1.Size = new Size(1313, 30); - menuStrip1.TabIndex = 0; - menuStrip1.Text = "menuStrip1"; - // - // bookToolStripMenuItem - // - bookToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { ingridientsToolStripMenuItem, pizzasToolStripMenuItem, shopsToolStripMenuItem }); - bookToolStripMenuItem.Name = "bookToolStripMenuItem"; - bookToolStripMenuItem.Size = new Size(108, 24); - bookToolStripMenuItem.Text = "Справочник"; - // - // ingridientsToolStripMenuItem - // - ingridientsToolStripMenuItem.Name = "ingridientsToolStripMenuItem"; - ingridientsToolStripMenuItem.Size = new Size(224, 26); - ingridientsToolStripMenuItem.Text = "Компоненты"; - ingridientsToolStripMenuItem.Click += IngridentsToolStripMenuItem_Click; - // - // pizzasToolStripMenuItem - // - pizzasToolStripMenuItem.Name = "pizzasToolStripMenuItem"; - pizzasToolStripMenuItem.Size = new Size(224, 26); - pizzasToolStripMenuItem.Text = "ПО"; - pizzasToolStripMenuItem.Click += PackagesToolStripMenuItem_Click; - // - // shopsToolStripMenuItem - // - shopsToolStripMenuItem.Name = "shopsToolStripMenuItem"; - shopsToolStripMenuItem.Size = new Size(224, 26); - shopsToolStripMenuItem.Text = "Магазины"; - shopsToolStripMenuItem.Click += shopsToolStripMenuItem_Click; - // - // operationToolStripMenuItem - // - operationToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { transactionToolStripMenuItem, продажаToolStripMenuItem }); - operationToolStripMenuItem.Name = "operationToolStripMenuItem"; - operationToolStripMenuItem.Size = new Size(95, 24); - operationToolStripMenuItem.Text = "Операции"; - // - // transactionToolStripMenuItem - // - transactionToolStripMenuItem.Name = "transactionToolStripMenuItem"; - transactionToolStripMenuItem.Size = new Size(224, 26); - transactionToolStripMenuItem.Text = "Поставка"; - transactionToolStripMenuItem.Click += transactionToolStripMenuItem_Click; - // - // продажаToolStripMenuItem - // - продажаToolStripMenuItem.Name = "продажаToolStripMenuItem"; - продажаToolStripMenuItem.Size = new Size(224, 26); - продажаToolStripMenuItem.Text = "Продажа"; - продажаToolStripMenuItem.Click += SellToolStripMenuItem_Click; - // - // dataGridView - // - dataGridView.AllowUserToAddRows = false; - dataGridView.AllowUserToDeleteRows = false; - dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; - dataGridView.Location = new Point(11, 31); - dataGridView.Name = "dataGridView"; - dataGridView.ReadOnly = true; - dataGridView.RowHeadersWidth = 51; - dataGridView.RowTemplate.Height = 29; - dataGridView.Size = new Size(977, 381); - dataGridView.TabIndex = 1; - // - // buttonCreateOrder - // - buttonCreateOrder.Location = new Point(1026, 71); - buttonCreateOrder.Name = "buttonCreateOrder"; - buttonCreateOrder.Size = new Size(247, 29); - buttonCreateOrder.TabIndex = 2; - buttonCreateOrder.Text = "Создать заказ"; - buttonCreateOrder.UseVisualStyleBackColor = true; - buttonCreateOrder.Click += ButtonCreateOrder_Click; - // - // buttonTakeOrderInWork - // - buttonTakeOrderInWork.Location = new Point(1026, 123); - buttonTakeOrderInWork.Name = "buttonTakeOrderInWork"; - buttonTakeOrderInWork.Size = new Size(247, 29); - buttonTakeOrderInWork.TabIndex = 3; - buttonTakeOrderInWork.Text = "Отдать на выполнение"; - buttonTakeOrderInWork.UseVisualStyleBackColor = true; - buttonTakeOrderInWork.Click += ButtonTakeOrderInWork_Click; - // - // buttonOrderReady - // - buttonOrderReady.Location = new Point(1026, 172); - buttonOrderReady.Name = "buttonOrderReady"; - buttonOrderReady.Size = new Size(247, 29); - buttonOrderReady.TabIndex = 4; - buttonOrderReady.Text = "Заказ готов"; - buttonOrderReady.UseVisualStyleBackColor = true; - buttonOrderReady.Click += ButtonOrderReady_Click; - // - // buttonIssuedOrder - // - buttonIssuedOrder.Location = new Point(1026, 225); - buttonIssuedOrder.Name = "buttonIssuedOrder"; - buttonIssuedOrder.Size = new Size(247, 29); - buttonIssuedOrder.TabIndex = 5; - buttonIssuedOrder.Text = "Заказ выдан"; - buttonIssuedOrder.UseVisualStyleBackColor = true; - buttonIssuedOrder.Click += ButtonIssuedOrder_Click; - // - // buttonRef - // - buttonRef.Location = new Point(1026, 280); - buttonRef.Name = "buttonRef"; - buttonRef.Size = new Size(247, 29); - buttonRef.TabIndex = 6; - buttonRef.Text = "Обновить список"; - buttonRef.UseVisualStyleBackColor = true; - buttonRef.Click += ButtonRef_Click; - // - // FormMain - // - AutoScaleDimensions = new SizeF(8F, 20F); - AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(1313, 425); - Controls.Add(buttonRef); - Controls.Add(buttonIssuedOrder); - Controls.Add(buttonOrderReady); - Controls.Add(buttonTakeOrderInWork); - Controls.Add(buttonCreateOrder); - Controls.Add(dataGridView); - Controls.Add(menuStrip1); - MainMenuStrip = menuStrip1; - Name = "FormMain"; - Text = "Установка ПО"; - Load += FormMain_Load; - menuStrip1.ResumeLayout(false); - menuStrip1.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); - ResumeLayout(false); - PerformLayout(); - } + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + menuStrip1 = new MenuStrip(); + ToolStripMenu = new ToolStripMenuItem(); + КомпонентыStripMenuItem = new ToolStripMenuItem(); + ПутевкаStripMenuItem = new ToolStripMenuItem(); + магазиныToolStripMenuItem = new ToolStripMenuItem(); + поставкиToolStripMenuItem = new ToolStripMenuItem(); + продажиToolStripMenuItem = new ToolStripMenuItem(); + отчетыToolStripMenuItem = new ToolStripMenuItem(); + списокПутевокToolStripMenuItem = new ToolStripMenuItem(); + компонентыПоПутевкамToolStripMenuItem = new ToolStripMenuItem(); + списокЗаказовToolStripMenuItem = new ToolStripMenuItem(); + списокМагазиновToolStripMenuItem = new ToolStripMenuItem(); + ПутевкаПоМагазинамToolStripMenuItem = new ToolStripMenuItem(); + заказыПоДатамToolStripMenuItem = new ToolStripMenuItem(); + DataGridView = new DataGridView(); + CreateOrderButton = new Button(); + TakeInWorkButton = new Button(); + ReadyButton = new Button(); + IssuedButton = new Button(); + RefreshButton = new Button(); + menuStrip1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)DataGridView).BeginInit(); + SuspendLayout(); + // + // menuStrip1 + // + menuStrip1.ImageScalingSize = new Size(20, 20); + menuStrip1.Items.AddRange(new ToolStripItem[] { ToolStripMenu, отчетыToolStripMenuItem }); + menuStrip1.Location = new Point(0, 0); + menuStrip1.Name = "menuStrip1"; + menuStrip1.Padding = new Padding(7, 4, 0, 4); + menuStrip1.Size = new Size(1290, 32); + menuStrip1.TabIndex = 0; + menuStrip1.Text = "menuStrip1"; + // + // ToolStripMenu + // + ToolStripMenu.DropDownItems.AddRange(new ToolStripItem[] { КомпонентыStripMenuItem, ПутевкаStripMenuItem, магазиныToolStripMenuItem, поставкиToolStripMenuItem, продажиToolStripMenuItem }); + ToolStripMenu.Name = "ToolStripMenu"; + ToolStripMenu.Size = new Size(117, 24); + ToolStripMenu.Text = "Справочники"; + // + // КомпонентыStripMenuItem + // + КомпонентыStripMenuItem.Name = "КомпонентыStripMenuItem"; + КомпонентыStripMenuItem.Size = new Size(224, 26); + КомпонентыStripMenuItem.Text = "Компоненты"; + КомпонентыStripMenuItem.Click += КомпонентыStripMenuItem_Click; + // + // ПутевкаStripMenuItem + // + ПутевкаStripMenuItem.Name = "ПутевкаStripMenuItem"; + ПутевкаStripMenuItem.Size = new Size(224, 26); + ПутевкаStripMenuItem.Text = "ПО"; + ПутевкаStripMenuItem.Click += ПутевкаStripMenuItem_Click; + // + // магазиныToolStripMenuItem + // + магазиныToolStripMenuItem.Name = "магазиныToolStripMenuItem"; + магазиныToolStripMenuItem.Size = new Size(224, 26); + магазиныToolStripMenuItem.Text = "Магазины"; + магазиныToolStripMenuItem.Click += магазиныToolStripMenuItem_Click; + // + // поставкиToolStripMenuItem + // + поставкиToolStripMenuItem.Name = "поставкиToolStripMenuItem"; + поставкиToolStripMenuItem.Size = new Size(224, 26); + поставкиToolStripMenuItem.Text = "Поставки"; + поставкиToolStripMenuItem.Click += поставкиToolStripMenuItem_Click; + // + // продажиToolStripMenuItem + // + продажиToolStripMenuItem.Name = "продажиToolStripMenuItem"; + продажиToolStripMenuItem.Size = new Size(224, 26); + продажиToolStripMenuItem.Text = "Продажи"; + продажиToolStripMenuItem.Click += продажиToolStripMenuItem_Click; + // + // отчетыToolStripMenuItem + // + отчетыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { списокПутевокToolStripMenuItem, компонентыПоПутевкамToolStripMenuItem, списокЗаказовToolStripMenuItem, списокМагазиновToolStripMenuItem, ПутевкаПоМагазинамToolStripMenuItem, заказыПоДатамToolStripMenuItem }); + отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem"; + отчетыToolStripMenuItem.Size = new Size(73, 24); + отчетыToolStripMenuItem.Text = "Отчеты"; + // + // списокПутевокToolStripMenuItem + // + списокПутевокToolStripMenuItem.Name = "списокПутевокToolStripMenuItem"; + списокПутевокToolStripMenuItem.Size = new Size(230, 26); + списокПутевокToolStripMenuItem.Text = "Список ПО"; + списокПутевокToolStripMenuItem.Click += списокПутевокToolStripMenuItem_Click; + // + // компонентыПоПутевкамToolStripMenuItem + // + компонентыПоПутевкамToolStripMenuItem.Name = "компонентыПоПутевкамToolStripMenuItem"; + компонентыПоПутевкамToolStripMenuItem.Size = new Size(230, 26); + компонентыПоПутевкамToolStripMenuItem.Text = "Компоненты по ПО"; + компонентыПоПутевкамToolStripMenuItem.Click += компонентыПоПутевкамToolStripMenuItem_Click; + // + // списокЗаказовToolStripMenuItem + // + списокЗаказовToolStripMenuItem.Name = "списокЗаказовToolStripMenuItem"; + списокЗаказовToolStripMenuItem.Size = new Size(230, 26); + списокЗаказовToolStripMenuItem.Text = "Список заказов"; + списокЗаказовToolStripMenuItem.Click += списокЗаказовToolStripMenuItem_Click; + // + // списокМагазиновToolStripMenuItem + // + списокМагазиновToolStripMenuItem.Name = "списокМагазиновToolStripMenuItem"; + списокМагазиновToolStripMenuItem.Size = new Size(230, 26); + списокМагазиновToolStripMenuItem.Text = "Список магазинов"; + списокМагазиновToolStripMenuItem.Click += списокМагазиновToolStripMenuItem_Click; + // + // ПутевкаПоМагазинамToolStripMenuItem + // + ПутевкаПоМагазинамToolStripMenuItem.Name = "ПутевкаПоМагазинамToolStripMenuItem"; + ПутевкаПоМагазинамToolStripMenuItem.Size = new Size(230, 26); + ПутевкаПоМагазинамToolStripMenuItem.Text = "ПО по магазинам"; + ПутевкаПоМагазинамToolStripMenuItem.Click += ПутевкаПоМагазинамToolStripMenuItem_Click; + // + // заказыПоДатамToolStripMenuItem + // + заказыПоДатамToolStripMenuItem.Name = "заказыПоДатамToolStripMenuItem"; + заказыПоДатамToolStripMenuItem.Size = new Size(230, 26); + заказыПоДатамToolStripMenuItem.Text = "Заказы по датам"; + заказыПоДатамToolStripMenuItem.Click += заказыПоДатамToolStripMenuItem_Click; + // + // DataGridView + // + DataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + DataGridView.Location = new Point(13, 41); + DataGridView.Margin = new Padding(3, 4, 3, 4); + DataGridView.Name = "DataGridView"; + DataGridView.RowHeadersWidth = 51; + DataGridView.Size = new Size(1007, 407); + DataGridView.TabIndex = 1; + // + // CreateOrderButton + // + CreateOrderButton.Location = new Point(1025, 31); + CreateOrderButton.Name = "CreateOrderButton"; + CreateOrderButton.Size = new Size(259, 29); + CreateOrderButton.TabIndex = 2; + CreateOrderButton.Text = "Создать заказ"; + CreateOrderButton.UseVisualStyleBackColor = true; + CreateOrderButton.Click += CreateOrderButton_Click; + // + // TakeInWorkButton + // + TakeInWorkButton.Location = new Point(1026, 65); + TakeInWorkButton.Margin = new Padding(3, 4, 3, 4); + TakeInWorkButton.Name = "TakeInWorkButton"; + TakeInWorkButton.Size = new Size(259, 29); + TakeInWorkButton.TabIndex = 3; + TakeInWorkButton.Text = "Отдать заказ в работу"; + TakeInWorkButton.UseVisualStyleBackColor = true; + TakeInWorkButton.Click += TakeInWorkButton_Click; + // + // ReadyButton + // + ReadyButton.Location = new Point(1025, 101); + ReadyButton.Name = "ReadyButton"; + ReadyButton.Size = new Size(259, 29); + ReadyButton.TabIndex = 4; + ReadyButton.Text = "Заказ готов"; + ReadyButton.UseVisualStyleBackColor = true; + ReadyButton.Click += ReadyButton_Click; + // + // IssuedButton + // + IssuedButton.Location = new Point(1025, 136); + IssuedButton.Name = "IssuedButton"; + IssuedButton.Size = new Size(259, 29); + IssuedButton.TabIndex = 5; + IssuedButton.Text = "Заказ выдан"; + IssuedButton.UseVisualStyleBackColor = true; + IssuedButton.Click += IssuedButton_Click; + // + // RefreshButton + // + RefreshButton.Location = new Point(1025, 171); + RefreshButton.Name = "RefreshButton"; + RefreshButton.Size = new Size(259, 29); + RefreshButton.TabIndex = 6; + RefreshButton.Text = "Обновить"; + RefreshButton.UseVisualStyleBackColor = true; + RefreshButton.Click += RefreshButton_Click; + // + // MainForm + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(1290, 476); + Controls.Add(RefreshButton); + Controls.Add(IssuedButton); + Controls.Add(ReadyButton); + Controls.Add(TakeInWorkButton); + Controls.Add(CreateOrderButton); + Controls.Add(DataGridView); + Controls.Add(menuStrip1); + MainMenuStrip = menuStrip1; + Name = "MainForm"; + Text = "Форма главная"; + Load += MainForm_Load; + menuStrip1.ResumeLayout(false); + menuStrip1.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)DataGridView).EndInit(); + ResumeLayout(false); + PerformLayout(); + } - #endregion + #endregion - private MenuStrip menuStrip1; - private ToolStripMenuItem bookToolStripMenuItem; - private ToolStripMenuItem ingridientsToolStripMenuItem; - private ToolStripMenuItem pizzasToolStripMenuItem; - private DataGridView dataGridView; - private Button buttonCreateOrder; - private Button buttonTakeOrderInWork; - private Button buttonOrderReady; - private Button buttonIssuedOrder; - private Button buttonRef; - private ToolStripMenuItem shopsToolStripMenuItem; - private ToolStripMenuItem operationToolStripMenuItem; - private ToolStripMenuItem transactionToolStripMenuItem; - private ToolStripMenuItem продажаToolStripMenuItem; + private MenuStrip menuStrip1; + private ToolStripMenuItem ToolStripMenu; + private ToolStripMenuItem КомпонентыStripMenuItem; + private ToolStripMenuItem ПутевкаStripMenuItem; + private DataGridView DataGridView; + private Button CreateOrderButton; + private Button TakeInWorkButton; + private Button ReadyButton; + private Button IssuedButton; + private Button RefreshButton; + private ToolStripMenuItem отчетыToolStripMenuItem; + private ToolStripMenuItem списокПутевокToolStripMenuItem; + private ToolStripMenuItem компонентыПоПутевкамToolStripMenuItem; + private ToolStripMenuItem списокЗаказовToolStripMenuItem; + private ToolStripMenuItem магазиныToolStripMenuItem; + private ToolStripMenuItem поставкиToolStripMenuItem; + private ToolStripMenuItem продажиToolStripMenuItem; + private ToolStripMenuItem списокМагазиновToolStripMenuItem; + private ToolStripMenuItem ПутевкаПоМагазинамToolStripMenuItem; + private ToolStripMenuItem заказыПоДатамToolStripMenuItem; } } \ No newline at end of file diff --git a/SoftwareInstallation/FormMain.cs b/SoftwareInstallation/FormMain.cs index e13c859..82c06c7 100644 --- a/SoftwareInstallation/FormMain.cs +++ b/SoftwareInstallation/FormMain.cs @@ -1,38 +1,61 @@ -using Microsoft.Extensions.Logging; -using SoftwareInstallation; +using SoftwareInstallationBusinessLogic.BusinessLogic; using SoftwareInstallationContracts.BindingModels; using SoftwareInstallationContracts.BusinessLogicsContracts; +using SoftwareInstallationDataModels; +using SoftwareInstallationDataModels.Enums; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; -namespace SoftwareInstallationView +namespace SoftwareInstallation { public partial class FormMain : Form { private readonly ILogger _logger; private readonly IOrderLogic _orderLogic; - - public FormMain(ILogger logger, IOrderLogic orderLogic) + private readonly IReportLogic _reportLogic; + public FormMain(ILogger logger, IOrderLogic orderLogic, IReportLogic reportLogic) { InitializeComponent(); _logger = logger; _orderLogic = orderLogic; + _reportLogic = reportLogic; } - private void FormMain_Load(object sender, EventArgs e) + private void КомпонентыStripMenuItem_Click(object sender, EventArgs e) + { + var service = +Program.ServiceProvider?.GetService(typeof(ComponentsForm)); + if (service is ComponentsForm form) + { + form.ShowDialog(); + } + + } + + private void MainForm_Load(object sender, EventArgs e) { LoadData(); } private void LoadData() { + _logger.LogInformation("Загрузка заказов"); try { var list = _orderLogic.ReadList(null); if (list != null) { - dataGridView.DataSource = list; - dataGridView.Columns["PackageId"].Visible = false; - dataGridView.Columns["PackageName"].AutoSizeMode = - DataGridViewAutoSizeColumnMode.Fill; + DataGridView.DataSource = list; + DataGridView.Columns["PackageId"].Visible = false; + DataGridView.Columns["PackageName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; } _logger.LogInformation("Загрузка заказов"); } @@ -43,16 +66,7 @@ namespace SoftwareInstallationView } } - private void IngridentsToolStripMenuItem_Click(object sender, EventArgs e) - { - var service = Program.ServiceProvider?.GetService(typeof(FormComponents)); - if (service is FormComponents form) - { - form.ShowDialog(); - } - } - - private void PackagesToolStripMenuItem_Click(object sender, EventArgs e) + private void ПутевкаStripMenuItem_Click(object sender, EventArgs e) { var service = Program.ServiceProvider?.GetService(typeof(FormPackages)); if (service is FormPackages form) @@ -61,28 +75,40 @@ namespace SoftwareInstallationView } } - private void ButtonCreateOrder_Click(object sender, EventArgs e) + private void CreateOrderButton_Click(object sender, EventArgs e) { - var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder)); - if (service is FormCreateOrder form) + var service = +Program.ServiceProvider?.GetService(typeof(OrderForm)); + if (service is OrderForm form) { form.ShowDialog(); LoadData(); } } - private void ButtonTakeOrderInWork_Click(object sender, EventArgs e) + private OrderBindingModel CreateBindingModel(int id, bool isDone = false) { - if (dataGridView.SelectedRows.Count == 1) + return new OrderBindingModel { - int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); - _logger.LogInformation("Заказ No{id}. Меняется статус на 'В работе'", id); + Id = id, + PackageId = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["PackageId"].Value), + 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()), + }; + } + + private void TakeInWorkButton_Click(object sender, EventArgs e) + { + if (DataGridView.SelectedRows.Count == 1) + { + int id = + Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id); try { - var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel - { - Id = id - }); + var operationResult = _orderLogic.TakeOrderInWork(CreateBindingModel(id)); if (!operationResult) { throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); @@ -92,23 +118,24 @@ namespace SoftwareInstallationView catch (Exception ex) { _logger.LogError(ex, "Ошибка передачи заказа в работу"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); } } + } - private void ButtonOrderReady_Click(object sender, EventArgs e) + private void ReadyButton_Click(object sender, EventArgs e) { - if (dataGridView.SelectedRows.Count == 1) + if (DataGridView.SelectedRows.Count == 1) { - int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); - _logger.LogInformation("Заказ No{id}. Меняется статус на 'Готов'", id); + int id = + Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'", + id); try { - var operationResult = _orderLogic.FinishOrder(new OrderBindingModel - { - Id = id - }); + var operationResult = _orderLogic.FinishOrder(CreateBindingModel(id)); if (!operationResult) { throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); @@ -118,65 +145,138 @@ namespace SoftwareInstallationView catch (Exception ex) { _logger.LogError(ex, "Ошибка отметки о готовности заказа"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); } } } - private void ButtonIssuedOrder_Click(object sender, EventArgs e) + private void IssuedButton_Click(object sender, EventArgs e) { - if (dataGridView.SelectedRows.Count == 1) + if (DataGridView.SelectedRows.Count == 1) { - int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); - _logger.LogInformation("Заказ No{id}. Меняется статус на 'Выдан'", id); + int id = + Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'", + id); try { - var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel - { - Id = id - }); + var operationResult = _orderLogic.DeliveryOrder(CreateBindingModel(id)); if (!operationResult) { throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); } - _logger.LogInformation("Заказ No{id} выдан", id); + _logger.LogInformation("Заказ №{id} выдан", id); LoadData(); } 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 RefreshButton_Click(object sender, EventArgs e) { LoadData(); } - private void shopsToolStripMenuItem_Click(object sender, EventArgs e) + private void магазиныToolStripMenuItem_Click(object sender, EventArgs e) { - var service = Program.ServiceProvider?.GetService(typeof(FormShops)); - if (service is FormShops form) + var service = Program.ServiceProvider?.GetService(typeof(ShopsForm)); + if (service is ShopsForm form) { form.ShowDialog(); } } - private void transactionToolStripMenuItem_Click(object sender, EventArgs e) + private void поставкиToolStripMenuItem_Click(object sender, EventArgs e) { - var service = Program.ServiceProvider?.GetService(typeof(FormCreateSupply)); - if (service is FormCreateSupply form) + var service = Program.ServiceProvider?.GetService(typeof(SupplyForm)); + if (service is SupplyForm form) { form.ShowDialog(); } } - private void SellToolStripMenuItem_Click(object sender, EventArgs e) + private void продажиToolStripMenuItem_Click(object sender, EventArgs e) { - var service = Program.ServiceProvider?.GetService(typeof(FormSellPackage)); - if (service is FormSellPackage form) + var service = Program.ServiceProvider?.GetService(typeof(SellForm)); + if (service is SellForm form) + { + form.ShowDialog(); + } + } + + private void списокПутевокToolStripMenuItem_Click(object sender, EventArgs e) + { + using var dialog = new SaveFileDialog { Filter = "docx|*.docx" }; + if (dialog.ShowDialog() == DialogResult.OK) + { + _reportLogic.SavePackageToWordFile(new ReportBindingModel + { + FileName = dialog.FileName + }); + MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, + MessageBoxIcon.Information); + } + + } + + private void компонентыПоПутевкамToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = +Program.ServiceProvider?.GetService(typeof(ReportPackageComponentForm)); + if (service is ReportPackageComponentForm form) + { + form.ShowDialog(); + } + + } + + private void списокЗаказовToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = +Program.ServiceProvider?.GetService(typeof(ReportOrdersForm)); + if (service is ReportOrdersForm form) + { + form.ShowDialog(); + } + + } + + private void списокМагазиновToolStripMenuItem_Click(object sender, EventArgs e) + { + using var dialog = new SaveFileDialog { Filter = "docx|*.docx" }; + if (dialog.ShowDialog() == DialogResult.OK) + { + _reportLogic.SaveShopsToWordFile(new ReportBindingModel + { + FileName = dialog.FileName + }); + MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, + MessageBoxIcon.Information); + } + } + + private void ПутевкаПоМагазинамToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = +Program.ServiceProvider?.GetService(typeof(ReportShopsSoftwareInstallationForm)); + if (service is ReportShopsSoftwareInstallationForm form) + { + form.ShowDialog(); + } + } + + private void заказыПоДатамToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = +Program.ServiceProvider?.GetService(typeof(ReportDateOrdersForm)); + if (service is ReportDateOrdersForm form) { form.ShowDialog(); } diff --git a/SoftwareInstallation/Program.cs b/SoftwareInstallation/Program.cs index f84a878..57d6e24 100644 --- a/SoftwareInstallation/Program.cs +++ b/SoftwareInstallation/Program.cs @@ -2,6 +2,8 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using NLog.Extensions.Logging; using SoftwareInstallationBusinessLogic.BusinessLogics; +using SoftwareInstallationBusinessLogic.OfficePackage.Implements; +using SoftwareInstallationBusinessLogic.OfficePackage; using SoftwareInstallationContracts.BusinessLogicsContracts; using SoftwareInstallationContracts.StoragesContracts; using SoftwareInstallationDatabaseImplement.Implements; @@ -43,6 +45,7 @@ namespace SoftwareInstallation services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); @@ -55,6 +58,14 @@ namespace SoftwareInstallation services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + } } } \ No newline at end of file diff --git a/SoftwareInstallation/ReportDateOrdersForm.Designer.cs b/SoftwareInstallation/ReportDateOrdersForm.Designer.cs new file mode 100644 index 0000000..1156367 --- /dev/null +++ b/SoftwareInstallation/ReportDateOrdersForm.Designer.cs @@ -0,0 +1,82 @@ +namespace SoftwareInstallation +{ + partial class ReportDateOrdersForm + { + /// + /// 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); + } + + #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() + { + panel = new Panel(); + MakeButton = new Button(); + ToPdfButton = new Button(); + SuspendLayout(); + // + // panel + // + panel.Location = new Point(12, 71); + panel.Name = "panel"; + panel.Size = new Size(776, 367); + panel.TabIndex = 0; + // + // MakeButton + // + MakeButton.Location = new Point(12, 36); + MakeButton.Name = "MakeButton"; + MakeButton.Size = new Size(131, 29); + MakeButton.TabIndex = 1; + MakeButton.Text = "Сформировать"; + MakeButton.UseVisualStyleBackColor = true; + MakeButton.Click += MakeButton_Click; + // + // ToPdfButton + // + ToPdfButton.Location = new Point(149, 36); + ToPdfButton.Name = "ToPdfButton"; + ToPdfButton.Size = new Size(94, 29); + ToPdfButton.TabIndex = 2; + ToPdfButton.Text = "В PDF"; + ToPdfButton.UseVisualStyleBackColor = true; + ToPdfButton.Click += ToPdfButton_Click; + // + // ReportDateOrdersForm + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 450); + Controls.Add(ToPdfButton); + Controls.Add(MakeButton); + Controls.Add(panel); + Name = "ReportDateOrdersForm"; + Text = "Заказы по датам"; + ResumeLayout(false); + } + + #endregion + + private Panel panel; + private Button MakeButton; + private Button ToPdfButton; + } +} \ No newline at end of file diff --git a/SoftwareInstallation/ReportDateOrdersForm.cs b/SoftwareInstallation/ReportDateOrdersForm.cs new file mode 100644 index 0000000..1bd9eda --- /dev/null +++ b/SoftwareInstallation/ReportDateOrdersForm.cs @@ -0,0 +1,77 @@ +using SoftwareInstallationContracts.BindingModels; +using SoftwareInstallationContracts.BusinessLogicsContracts; +using Microsoft.Extensions.Logging; +using Microsoft.Reporting.WinForms; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace SoftwareInstallation +{ + public partial class ReportDateOrdersForm : Form + { + private readonly ReportViewer reportViewer; + + private readonly ILogger _logger; + + private readonly IReportLogic _logic; + public ReportDateOrdersForm(ILogger logger, IReportLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + reportViewer = new ReportViewer + { + Dock = DockStyle.Fill + }; + reportViewer.LocalReport.LoadReportDefinition(new FileStream("C:\\Users\\днс\\Desktop\\РПП 2 семестр\\доп инфа\\4lab_hard\\PackageCompany\\IceCreamShop\\ReportOrdersByDate.rdlc", FileMode.Open)); + panel.Controls.Add(reportViewer); + } + + private void MakeButton_Click(object sender, EventArgs e) + { + try + { + var dataSource = _logic.GetDatesOrders(); + var source = new ReportDataSource("DataSetOrders", dataSource); + reportViewer.LocalReport.DataSources.Clear(); + reportViewer.LocalReport.DataSources.Add(source); + reportViewer.RefreshReport(); + _logger.LogInformation("Загрузка списка заказов на весь период по датам"); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки списка заказов на период"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ToPdfButton_Click(object sender, EventArgs e) + { + using var dialog = new SaveFileDialog { Filter = "pdf|*.pdf" }; + if (dialog.ShowDialog() == DialogResult.OK) + { + try + { + _logic.SaveDatesOrdersToPdfFile(new ReportBindingModel + { + FileName = dialog.FileName + }); + _logger.LogInformation("Сохранение списка заказов на весь период по датам"); + MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка сохранения списка заказов на период"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + } +} diff --git a/SoftwareInstallation/ReportDateOrdersForm.resx b/SoftwareInstallation/ReportDateOrdersForm.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/SoftwareInstallation/ReportDateOrdersForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/SoftwareInstallation/ReportOrders.rdlc b/SoftwareInstallation/ReportOrders.rdlc new file mode 100644 index 0000000..7e35bbd --- /dev/null +++ b/SoftwareInstallation/ReportOrders.rdlc @@ -0,0 +1,599 @@ + + + 0 + + + + System.Data.DataSet + /* Local Connection */ + + 47cb53f0-7dde-4717-ba03-866a0bc4f4dd + + + + + + SoftwareInstallationContractsViewModels + /* Local Query */ + + + + Id + System.Int32 + + + DateCreate + System.DateTime + + + PackageName + System.String + + + Sum + System.Decimal + + + OrderStatus + SoftwareInstallationDataModels.OrderStatus + + + + SoftwareInstallationContracts.ViewModels + ReportOrderViewModel + SoftwareInstallationContracts.ViewModels.ReportOrderViewModel, SoftwareInstallationContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + + + + + + + + + true + true + + + + + =Parameters!ReportParameterPeriod.Value + + + + + + + ReportParameterPeriod + 1cm + 1cm + 21cm + + + Middle + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + Заказы + + + + + + + 1cm + 21cm + 1 + + + Middle + 2pt + 2pt + 2pt + 2pt + + + + + + + 2.5cm + + + 3.21438cm + + + 8.23317cm + + + 2.5cm + + + 2.5cm + + + + + 0.6cm + + + + + true + true + + + + + Номер + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Дата создания + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Путевка + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Статус Заказа + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Сумма + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + 0.6cm + + + + + true + true + + + + + =Fields!Id.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!DateCreate.Value + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!PackageName.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!OrderStatus.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!Sum.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + + + + + + + + + + + + + + After + + + + + + + DataSetOrders + 2.48391cm + 0.55245cm + 1.2cm + 18.94755cm + 2 + + + + + + true + true + + + + + Итого: + + + + + + + 4cm + 12cm + 0.6cm + 2.5cm + 3 + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + =Sum(Fields!Sum.Value, "DataSetOrders") + + + + + + + 4cm + 14.5cm + 0.6cm + 2.5cm + 4 + + + 2pt + 2pt + 2pt + 2pt + + + + 5.72875cm + + + + + + + 0.24cm + 1cm + 21cm + + + Middle + 2pt + 2pt + 2pt + 2pt + + + + + + + 3cm + + + 3cm + + + 7cm + + + + + 0.6cm + + + + + true + true + + + + + Дата + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Количество + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Сумма + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + 0.6cm + + + + + true + true + + + + + =Fields!DateOfOrders.Value + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!Count.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!Sum.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + + + + + + + + + + + + After + + + + + + + DataSetOrders + 2.72391cm + 0.55245cm + 1.2cm + 13cm + 1 + + + + + + true + true + + + + + Всего: + + + + + + + 4.24cm + 8.55245cm + 0.6cm + 2.5cm + 2 + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + =Sum(Fields!Sum.Value, "DataSetOrders") + + + + + + + 4.24cm + 11.05245cm + 0.6cm + 2.5cm + 3 + + + 2pt + 2pt + 2pt + 2pt + + + + 2in +