diff --git a/GarmentFactory/FormAddTextile.Designer.cs b/GarmentFactory/FormAddTextile.Designer.cs new file mode 100644 index 0000000..11c88bb --- /dev/null +++ b/GarmentFactory/FormAddTextile.Designer.cs @@ -0,0 +1,144 @@ +namespace GarmentFactoryView +{ + partial class FormAddTextile + { + /// + /// 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() + { + labelShop = new Label(); + labelCount = new Label(); + labelTextile = new Label(); + comboBoxShop = new ComboBox(); + textBoxCount = new TextBox(); + comboBoxTextile = new ComboBox(); + buttonCancel = new Button(); + buttonSave = new Button(); + SuspendLayout(); + // + // labelShop + // + labelShop.AutoSize = true; + labelShop.Location = new Point(38, 37); + labelShop.Name = "labelShop"; + labelShop.Size = new Size(72, 20); + labelShop.TabIndex = 0; + labelShop.Text = "Магазин:"; + // + // labelCount + // + labelCount.AutoSize = true; + labelCount.Location = new Point(29, 123); + labelCount.Name = "labelCount"; + labelCount.Size = new Size(93, 20); + labelCount.TabIndex = 3; + labelCount.Text = "Количество:"; + // + // labelTextile + // + labelTextile.AutoSize = true; + labelTextile.Location = new Point(38, 79); + labelTextile.Name = "labelTextile"; + labelTextile.Size = new Size(71, 20); + labelTextile.TabIndex = 2; + labelTextile.Text = "Изделие:"; + // + // comboBoxShop + // + comboBoxShop.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxShop.FormattingEnabled = true; + comboBoxShop.Location = new Point(140, 37); + comboBoxShop.Name = "comboBoxShop"; + comboBoxShop.Size = new Size(262, 28); + comboBoxShop.TabIndex = 11; + // + // textBoxCount + // + textBoxCount.Location = new Point(140, 123); + textBoxCount.Name = "textBoxCount"; + textBoxCount.Size = new Size(262, 27); + textBoxCount.TabIndex = 10; + // + // comboBoxTextile + // + comboBoxTextile.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxTextile.FormattingEnabled = true; + comboBoxTextile.Location = new Point(140, 79); + comboBoxTextile.Name = "comboBoxTextile"; + comboBoxTextile.Size = new Size(262, 28); + comboBoxTextile.TabIndex = 9; + // + // buttonCancel + // + buttonCancel.Location = new Point(342, 181); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(94, 29); + buttonCancel.TabIndex = 13; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click; + // + // buttonSave + // + buttonSave.Location = new Point(242, 181); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(94, 29); + buttonSave.TabIndex = 12; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += ButtonSave_Click; + // + // FormAddTextile + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(455, 222); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(comboBoxShop); + Controls.Add(textBoxCount); + Controls.Add(comboBoxTextile); + Controls.Add(labelCount); + Controls.Add(labelTextile); + Controls.Add(labelShop); + Name = "FormAddTextile"; + Text = "Пополнение магазина"; + Load += FormAddTextile_Load; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label labelShop; + private Label labelCount; + private Label labelTextile; + private ComboBox comboBoxShop; + private TextBox textBoxCount; + private ComboBox comboBoxTextile; + private Button buttonCancel; + private Button buttonSave; + } +} \ No newline at end of file diff --git a/GarmentFactory/FormAddTextile.cs b/GarmentFactory/FormAddTextile.cs new file mode 100644 index 0000000..0b26d2b --- /dev/null +++ b/GarmentFactory/FormAddTextile.cs @@ -0,0 +1,109 @@ +using GarmentFactoryContracts.BindingModels; +using GarmentFactoryContracts.BusinessLogicsContracts; +using GarmentFactoryContracts.SearchModels; +using GarmentFactoryContracts.ViewModels; +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 GarmentFactoryView +{ + public partial class FormAddTextile : Form + { + private readonly ILogger _logger; + private readonly ITextileLogic _logicT; + private readonly IShopLogic _logicS; + //Списки для ComboBox + private List _shopList = new List(); + private List _textileList = new List(); + public FormAddTextile(ILogger logger, ITextileLogic logicT, IShopLogic logicS) + { + InitializeComponent(); + _logger = logger; + _logicT = logicT; + _logicS = logicS; + } + + private void FormAddTextile_Load(object sender, EventArgs e) + { + _shopList = _logicS.ReadList(null); + _textileList = _logicT.ReadList(null); + + _logger.LogInformation("Загрузка списка магазинов при пополнении"); + if (_shopList != null) + { + comboBoxShop.DisplayMember = "ShopName"; + comboBoxShop.ValueMember = "Id"; + comboBoxShop.DataSource = _shopList; + comboBoxShop.SelectedItem = null; + } + + _logger.LogInformation("Загрузка списка товаров при пополнении"); + if (_textileList != null) + { + comboBoxTextile.DisplayMember = "TextileName"; + comboBoxTextile.ValueMember = "Id"; + comboBoxTextile.DataSource = _textileList; + comboBoxTextile.SelectedItem = null; + } + } + + private void ButtonSave_Click(object sender, EventArgs e) + { + if (comboBoxShop.SelectedValue == null) + { + MessageBox.Show("Выберите магазин", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + + if (comboBoxTextile.SelectedValue == null) + { + MessageBox.Show("Выберите изделие", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + + if (string.IsNullOrEmpty(textBoxCount.Text)) + { + MessageBox.Show("Заполните поле \"Количество\"", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + + _logger.LogInformation("Пополнение магазина"); + try + { + var operationResult = _logicS.MakeSupply(new SupplyBindingModel + { + ShopId = Convert.ToInt32(comboBoxShop.SelectedValue), + TextileId = Convert.ToInt32(comboBoxTextile.SelectedValue), + Count = Convert.ToInt32(textBoxCount.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 ButtonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); + } + } +} diff --git a/GarmentFactory/FormAddTextile.resx b/GarmentFactory/FormAddTextile.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/GarmentFactory/FormAddTextile.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/GarmentFactory/FormMain.Designer.cs b/GarmentFactory/FormMain.Designer.cs index 33a8a6d..856a685 100644 --- a/GarmentFactory/FormMain.Designer.cs +++ b/GarmentFactory/FormMain.Designer.cs @@ -38,11 +38,18 @@ справочникиToolStripMenuItem = new ToolStripMenuItem(); компонентыToolStripMenuItem = new ToolStripMenuItem(); текстилиToolStripMenuItem = new ToolStripMenuItem(); + магазиныToolStripMenuItem = new ToolStripMenuItem(); + операцииToolStripMenuItem = new ToolStripMenuItem(); + пополнениеМагазинаToolStripMenuItem1 = new ToolStripMenuItem(); + продажаТовараToolStripMenuItem = new ToolStripMenuItem(); клиентыToolStripMenuItem = new ToolStripMenuItem(); отчётыToolStripMenuItem = new ToolStripMenuItem(); textilesToolStripMenuItem = new ToolStripMenuItem(); textileComponentsToolStripMenuItem = new ToolStripMenuItem(); ordersToolStripMenuItem = new ToolStripMenuItem(); + магазиныВDocToolStripMenuItem = new ToolStripMenuItem(); + загруженностьМагазиновToolStripMenuItem = new ToolStripMenuItem(); + заказыПоДатамToolStripMenuItem = new ToolStripMenuItem(); ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); menuStrip1.SuspendLayout(); SuspendLayout(); @@ -121,7 +128,7 @@ // menuStrip1 // menuStrip1.ImageScalingSize = new Size(20, 20); - menuStrip1.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, отчётыToolStripMenuItem }); + menuStrip1.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, операцииToolStripMenuItem, отчётыToolStripMenuItem }); menuStrip1.Location = new Point(0, 0); menuStrip1.Name = "menuStrip1"; menuStrip1.Size = new Size(1380, 28); @@ -130,7 +137,7 @@ // // справочникиToolStripMenuItem // - справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { компонентыToolStripMenuItem, текстилиToolStripMenuItem, клиентыToolStripMenuItem }); + справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { компонентыToolStripMenuItem, текстилиToolStripMenuItem, магазиныToolStripMenuItem, клиентыToolStripMenuItem }); справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem"; справочникиToolStripMenuItem.Size = new Size(117, 24); справочникиToolStripMenuItem.Text = "Справочники"; @@ -149,6 +156,34 @@ текстилиToolStripMenuItem.Text = "Текстили"; текстилиToolStripMenuItem.Click += текстилиToolStripMenuItem_Click; // + // магазиныToolStripMenuItem + // + магазиныToolStripMenuItem.Name = "магазиныToolStripMenuItem"; + магазиныToolStripMenuItem.Size = new Size(182, 26); + магазиныToolStripMenuItem.Text = "Магазины"; + магазиныToolStripMenuItem.Click += магазиныToolStripMenuItem_Click; + // + // операцииToolStripMenuItem + // + операцииToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { пополнениеМагазинаToolStripMenuItem1, продажаТовараToolStripMenuItem }); + операцииToolStripMenuItem.Name = "операцииToolStripMenuItem"; + операцииToolStripMenuItem.Size = new Size(95, 24); + операцииToolStripMenuItem.Text = "Операции"; + // + // пополнениеМагазинаToolStripMenuItem1 + // + пополнениеМагазинаToolStripMenuItem1.Name = "пополнениеМагазинаToolStripMenuItem1"; + пополнениеМагазинаToolStripMenuItem1.Size = new Size(251, 26); + пополнениеМагазинаToolStripMenuItem1.Text = "Пополнение магазина"; + пополнениеМагазинаToolStripMenuItem1.Click += пополнениеМагазинаToolStripMenuItem1_Click; + // + // продажаТовараToolStripMenuItem + // + продажаТовараToolStripMenuItem.Name = "продажаТовараToolStripMenuItem"; + продажаТовараToolStripMenuItem.Size = new Size(251, 26); + продажаТовараToolStripMenuItem.Text = "Продажа товара"; + продажаТовараToolStripMenuItem.Click += продажаТовараToolStripMenuItem_Click; + // // клиентыToolStripMenuItem // клиентыToolStripMenuItem.Name = "клиентыToolStripMenuItem"; @@ -158,7 +193,7 @@ // // отчётыToolStripMenuItem // - отчётыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { textilesToolStripMenuItem, textileComponentsToolStripMenuItem, ordersToolStripMenuItem }); + отчётыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { textilesToolStripMenuItem, textileComponentsToolStripMenuItem, ordersToolStripMenuItem, магазиныВDocToolStripMenuItem, загруженностьМагазиновToolStripMenuItem, заказыПоДатамToolStripMenuItem }); отчётыToolStripMenuItem.Name = "отчётыToolStripMenuItem"; отчётыToolStripMenuItem.Size = new Size(73, 24); отчётыToolStripMenuItem.Text = "Отчёты"; @@ -166,24 +201,45 @@ // textilesToolStripMenuItem // textilesToolStripMenuItem.Name = "textilesToolStripMenuItem"; - textilesToolStripMenuItem.Size = new Size(274, 26); + textilesToolStripMenuItem.Size = new Size(276, 26); textilesToolStripMenuItem.Text = "Текстили"; textilesToolStripMenuItem.Click += TextilesToolStripMenuItem_Click; // // textileComponentsToolStripMenuItem // textileComponentsToolStripMenuItem.Name = "textileComponentsToolStripMenuItem"; - textileComponentsToolStripMenuItem.Size = new Size(274, 26); + textileComponentsToolStripMenuItem.Size = new Size(276, 26); textileComponentsToolStripMenuItem.Text = "Текстили с компонентами"; textileComponentsToolStripMenuItem.Click += ComponentTextilesToolStripMenuItem_Click; // // ordersToolStripMenuItem // ordersToolStripMenuItem.Name = "ordersToolStripMenuItem"; - ordersToolStripMenuItem.Size = new Size(274, 26); + ordersToolStripMenuItem.Size = new Size(276, 26); ordersToolStripMenuItem.Text = "Заказы"; ordersToolStripMenuItem.Click += OrdersToolStripMenuItem_Click; // + // магазиныВDocToolStripMenuItem + // + магазиныВDocToolStripMenuItem.Name = "магазиныВDocToolStripMenuItem"; + магазиныВDocToolStripMenuItem.Size = new Size(276, 26); + магазиныВDocToolStripMenuItem.Text = "Магазины в doc"; + магазиныВDocToolStripMenuItem.Click += магазиныВDocToolStripMenuItem_Click; + // + // загруженностьМагазиновToolStripMenuItem + // + загруженностьМагазиновToolStripMenuItem.Name = "загруженностьМагазиновToolStripMenuItem"; + загруженностьМагазиновToolStripMenuItem.Size = new Size(276, 26); + загруженностьМагазиновToolStripMenuItem.Text = "Загруженность магазинов"; + загруженностьМагазиновToolStripMenuItem.Click += загруженностьМагазиновToolStripMenuItem_Click; + // + // заказыПоДатамToolStripMenuItem + // + заказыПоДатамToolStripMenuItem.Name = "заказыПоДатамToolStripMenuItem"; + заказыПоДатамToolStripMenuItem.Size = new Size(276, 26); + заказыПоДатамToolStripMenuItem.Text = "Заказы по датам"; + заказыПоДатамToolStripMenuItem.Click += заказыПоДатамToolStripMenuItem_Click; + // // FormMain // AutoScaleDimensions = new SizeF(8F, 20F); @@ -219,10 +275,17 @@ private ToolStripMenuItem справочникиToolStripMenuItem; private ToolStripMenuItem компонентыToolStripMenuItem; private ToolStripMenuItem текстилиToolStripMenuItem; + private ToolStripMenuItem магазиныToolStripMenuItem; + private ToolStripMenuItem операцииToolStripMenuItem; + private ToolStripMenuItem пополнениеМагазинаToolStripMenuItem1; + private ToolStripMenuItem продажаТовараToolStripMenuItem; private ToolStripMenuItem отчётыToolStripMenuItem; private ToolStripMenuItem textilesToolStripMenuItem; private ToolStripMenuItem textileComponentsToolStripMenuItem; private ToolStripMenuItem ordersToolStripMenuItem; + private ToolStripMenuItem магазиныВDocToolStripMenuItem; + private ToolStripMenuItem загруженностьМагазиновToolStripMenuItem; + private ToolStripMenuItem заказыПоДатамToolStripMenuItem; private ToolStripMenuItem клиентыToolStripMenuItem; } } \ No newline at end of file diff --git a/GarmentFactory/FormMain.cs b/GarmentFactory/FormMain.cs index 0293a53..ac4d18d 100644 --- a/GarmentFactory/FormMain.cs +++ b/GarmentFactory/FormMain.cs @@ -103,6 +103,17 @@ namespace GarmentFactoryView } + + private void магазиныToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormShops)); + + if (service is FormShops form) + { + form.ShowDialog(); + } + } + private void ButtonCreateOrder_Click(object sender, EventArgs e) { var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder)); @@ -184,6 +195,53 @@ namespace GarmentFactoryView LoadData(); } + private void пополнениеМагазинаToolStripMenuItem1_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormAddTextile)); + + if (service is FormAddTextile form) + { + form.ShowDialog(); + } + } + + private void продажаТовараToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormSellTextile)); + if (service is FormSellTextile form) + { + form.ShowDialog(); + } + } + + private void магазиныВDocToolStripMenuItem_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(FormReportShops)); + if (service is FormReportShops form) + { + form.ShowDialog(); + } + } + + private void заказыПоДатамToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormReportGroupedOrders)); + if (service is FormReportGroupedOrders form) + { + form.ShowDialog(); + } + } + private void клиентыToolStripMenuItem_Click(object sender, EventArgs e) { var service = Program.ServiceProvider?.GetService(typeof(FormClients)); diff --git a/GarmentFactory/FormReportGroupedOrders.Designer.cs b/GarmentFactory/FormReportGroupedOrders.Designer.cs new file mode 100644 index 0000000..911a695 --- /dev/null +++ b/GarmentFactory/FormReportGroupedOrders.Designer.cs @@ -0,0 +1,86 @@ +namespace GarmentFactoryView +{ + partial class FormReportGroupedOrders + { + /// + /// 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() + { + this.panel = new System.Windows.Forms.Panel(); + this.buttonToPDF = new System.Windows.Forms.Button(); + this.buttonMake = new System.Windows.Forms.Button(); + this.panel.SuspendLayout(); + this.SuspendLayout(); + // + // panel + // + this.panel.Controls.Add(this.buttonToPDF); + this.panel.Controls.Add(this.buttonMake); + this.panel.Dock = System.Windows.Forms.DockStyle.Top; + this.panel.Location = new System.Drawing.Point(0, 0); + this.panel.Name = "panel"; + this.panel.Size = new System.Drawing.Size(970, 52); + this.panel.TabIndex = 1; + // + // buttonToPDF + // + this.buttonToPDF.Location = new System.Drawing.Point(486, 12); + this.buttonToPDF.Name = "buttonToPDF"; + this.buttonToPDF.Size = new System.Drawing.Size(411, 29); + this.buttonToPDF.TabIndex = 5; + this.buttonToPDF.Text = "В PDF"; + this.buttonToPDF.UseVisualStyleBackColor = true; + this.buttonToPDF.Click += new System.EventHandler(this.buttonToPDF_Click); + // + // buttonMake + // + this.buttonMake.Location = new System.Drawing.Point(49, 12); + this.buttonMake.Name = "buttonMake"; + this.buttonMake.Size = new System.Drawing.Size(377, 29); + this.buttonMake.TabIndex = 4; + this.buttonMake.Text = "Сформировать"; + this.buttonMake.UseVisualStyleBackColor = true; + this.buttonMake.Click += new System.EventHandler(this.ButtonMake_Click); + // + // FormReportGroupedOrders + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(970, 450); + this.Controls.Add(this.panel); + this.Name = "FormReportGroupedOrders"; + this.Text = "Отчёт по группированным заказам "; + this.panel.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private Panel panel; + private Button buttonToPDF; + private Button buttonMake; + } +} \ No newline at end of file diff --git a/GarmentFactory/FormReportGroupedOrders.cs b/GarmentFactory/FormReportGroupedOrders.cs new file mode 100644 index 0000000..28a041b --- /dev/null +++ b/GarmentFactory/FormReportGroupedOrders.cs @@ -0,0 +1,80 @@ +using GarmentFactoryContracts.BindingModels; +using GarmentFactoryContracts.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 GarmentFactoryView +{ + public partial class FormReportGroupedOrders : Form + { + private readonly ReportViewer reportViewer; + private readonly ILogger _logger; + private readonly IReportLogic _logic; + + public FormReportGroupedOrders(ILogger logger, IReportLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + reportViewer = new ReportViewer + { + Dock = DockStyle.Fill + }; + reportViewer.LocalReport.LoadReportDefinition(new FileStream("ReportGroupedOrders.rdlc", FileMode.Open)); + Controls.Clear(); + Controls.Add(reportViewer); + Controls.Add(panel); + } + + private void ButtonMake_Click(object sender, EventArgs e) + { + try + { + var dataSource = _logic.GetGroupedOrders(); + var source = new ReportDataSource("DataSetGroupedOrders", 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 buttonToPDF_Click(object sender, EventArgs e) + { + using var dialog = new SaveFileDialog { Filter = "pdf|*.pdf" }; + if (dialog.ShowDialog() == DialogResult.OK) + { + try + { + _logic.SaveGroupedOrdersToPdfFile(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/GarmentFactory/FormReportGroupedOrders.resx b/GarmentFactory/FormReportGroupedOrders.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/GarmentFactory/FormReportGroupedOrders.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/GarmentFactory/FormReportShops.Designer.cs b/GarmentFactory/FormReportShops.Designer.cs new file mode 100644 index 0000000..92476bd --- /dev/null +++ b/GarmentFactory/FormReportShops.Designer.cs @@ -0,0 +1,112 @@ +namespace GarmentFactoryView +{ + partial class FormReportShops + { + /// + /// 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() + { + buttonSaveToExcel = new Button(); + dataGridView = new DataGridView(); + ColumnShop = new DataGridViewTextBoxColumn(); + ColumnTextile = new DataGridViewTextBoxColumn(); + ColumnCount = new DataGridViewTextBoxColumn(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // buttonSaveToExcel + // + buttonSaveToExcel.Location = new Point(12, 9); + buttonSaveToExcel.Name = "buttonSaveToExcel"; + buttonSaveToExcel.Size = new Size(169, 29); + buttonSaveToExcel.TabIndex = 3; + buttonSaveToExcel.Text = "Сохранить в Excel"; + buttonSaveToExcel.UseVisualStyleBackColor = true; + buttonSaveToExcel.Click += ButtonSaveToExcel_Click; + // + // dataGridView + // + dataGridView.AllowUserToAddRows = false; + dataGridView.AllowUserToDeleteRows = false; + dataGridView.AllowUserToOrderColumns = true; + dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Columns.AddRange(new DataGridViewColumn[] { ColumnShop, ColumnTextile, ColumnCount }); + dataGridView.Dock = DockStyle.Bottom; + dataGridView.Location = new Point(0, 47); + dataGridView.Name = "dataGridView"; + dataGridView.ReadOnly = true; + dataGridView.RowHeadersWidth = 51; + dataGridView.RowTemplate.Height = 29; + dataGridView.Size = new Size(598, 403); + dataGridView.TabIndex = 2; + // + // ColumnShop + // + ColumnShop.FillWeight = 130F; + ColumnShop.HeaderText = "Магазин"; + ColumnShop.MinimumWidth = 6; + ColumnShop.Name = "ColumnShop"; + ColumnShop.ReadOnly = true; + // + // ColumnTextile + // + ColumnTextile.FillWeight = 140F; + ColumnTextile.HeaderText = "Текстиль"; + ColumnTextile.MinimumWidth = 6; + ColumnTextile.Name = "ColumnTextile"; + ColumnTextile.ReadOnly = true; + // + // ColumnCount + // + ColumnCount.FillWeight = 90F; + ColumnCount.HeaderText = "Количество"; + ColumnCount.MinimumWidth = 6; + ColumnCount.Name = "ColumnCount"; + ColumnCount.ReadOnly = true; + // + // FormReportShops + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(598, 450); + Controls.Add(buttonSaveToExcel); + Controls.Add(dataGridView); + Name = "FormReportShops"; + Text = "Загруженность магазинов"; + Load += FormReportShops_Load; + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Button buttonSaveToExcel; + private DataGridView dataGridView; + private DataGridViewTextBoxColumn ColumnShop; + private DataGridViewTextBoxColumn ColumnTextile; + private DataGridViewTextBoxColumn ColumnCount; + } +} \ No newline at end of file diff --git a/GarmentFactory/FormReportShops.cs b/GarmentFactory/FormReportShops.cs new file mode 100644 index 0000000..6429159 --- /dev/null +++ b/GarmentFactory/FormReportShops.cs @@ -0,0 +1,78 @@ +using GarmentFactoryContracts.BindingModels; +using GarmentFactoryContracts.BusinessLogicsContracts; +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 GarmentFactoryView +{ + public partial class FormReportShops : Form + { + private readonly ILogger _logger; + private readonly IReportLogic _logic; + + public FormReportShops(ILogger logger, IReportLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + } + + private void FormReportShops_Load(object sender, EventArgs e) + { + try + { + var shops = _logic.GetShops(); + if (shops != null) + { + dataGridView.Rows.Clear(); + foreach (var shop in shops) + { + dataGridView.Rows.Add(new object[] { shop.ShopName, "", "" }); + foreach (var textile in shop.Textiles) + { + dataGridView.Rows.Add(new object[] { "", textile.Item1, textile.Item2 }); + } + dataGridView.Rows.Add(new object[] { "Итого", "", shop.TotalCount }); + dataGridView.Rows.Add(Array.Empty()); + } + } + _logger.LogInformation("Загрузка списка текстилей по магазинам"); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки списка текстилей по магазинам"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonSaveToExcel_Click(object sender, EventArgs e) + { + using var dialog = new SaveFileDialog { Filter = "xlsx|*.xlsx" }; + if (dialog.ShowDialog() == DialogResult.OK) + { + try + { + _logic.SaveShopsToExcelFile(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/GarmentFactory/FormReportShops.resx b/GarmentFactory/FormReportShops.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/GarmentFactory/FormReportShops.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/GarmentFactory/FormSellTextile.Designer.cs b/GarmentFactory/FormSellTextile.Designer.cs new file mode 100644 index 0000000..c21f0f5 --- /dev/null +++ b/GarmentFactory/FormSellTextile.Designer.cs @@ -0,0 +1,119 @@ +namespace GarmentFactoryView +{ + partial class FormSellTextile + { + /// + /// 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() + { + labelTextile = new Label(); + comboBoxTextile = new ComboBox(); + labelCount = new Label(); + textBoxCount = new TextBox(); + buttonSell = new Button(); + buttonCancel = new Button(); + SuspendLayout(); + // + // labelTextile + // + labelTextile.AutoSize = true; + labelTextile.Location = new Point(12, 14); + labelTextile.Name = "labelTextile"; + labelTextile.Size = new Size(77, 20); + labelTextile.TabIndex = 0; + labelTextile.Text = "Текстиль: "; + // + // comboBoxTextile + // + comboBoxTextile.FormattingEnabled = true; + comboBoxTextile.Location = new Point(115, 11); + comboBoxTextile.Name = "comboBoxTextile"; + comboBoxTextile.Size = new Size(239, 28); + comboBoxTextile.TabIndex = 1; + // + // labelCount + // + labelCount.AutoSize = true; + labelCount.Location = new Point(12, 55); + labelCount.Name = "labelCount"; + labelCount.Size = new Size(97, 20); + labelCount.TabIndex = 2; + labelCount.Text = "Количество: "; + // + // textBoxCount + // + textBoxCount.Location = new Point(115, 52); + textBoxCount.Name = "textBoxCount"; + textBoxCount.Size = new Size(239, 27); + textBoxCount.TabIndex = 3; + // + // buttonSell + // + buttonSell.Location = new Point(128, 99); + buttonSell.Name = "buttonSell"; + buttonSell.Size = new Size(94, 29); + buttonSell.TabIndex = 4; + buttonSell.Text = "Продать"; + buttonSell.UseVisualStyleBackColor = true; + buttonSell.Click += ButtonSell_Click; + // + // buttonCancel + // + buttonCancel.Location = new Point(242, 99); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(94, 29); + buttonCancel.TabIndex = 5; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click; + // + // FormSellTextile + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(366, 140); + Controls.Add(buttonCancel); + Controls.Add(buttonSell); + Controls.Add(textBoxCount); + Controls.Add(labelCount); + Controls.Add(comboBoxTextile); + Controls.Add(labelTextile); + Name = "FormSellTextile"; + Text = "Продажа текстиля"; + Load += FormSellingTextile_Load; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label labelTextile; + private ComboBox comboBoxTextile; + private Label labelCount; + private TextBox textBoxCount; + private Button buttonSell; + private Button buttonCancel; + } +} \ No newline at end of file diff --git a/GarmentFactory/FormSellTextile.cs b/GarmentFactory/FormSellTextile.cs new file mode 100644 index 0000000..b2a8705 --- /dev/null +++ b/GarmentFactory/FormSellTextile.cs @@ -0,0 +1,87 @@ +using GarmentFactoryContracts.BusinessLogicsContracts; +using GarmentFactoryContracts.SearchModels; +using GarmentFactoryContracts.ViewModels; +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 GarmentFactoryView +{ + public partial class FormSellTextile : Form + { + private readonly ILogger _logger; + private readonly ITextileLogic _logicT; + private readonly IShopLogic _logicS; + private List _TextileList = new List(); + + public FormSellTextile(ILogger logger, ITextileLogic logicT, IShopLogic logicS) + { + InitializeComponent(); + _logger = logger; + _logicT = logicT; + _logicS = logicS; + } + + private void FormSellingTextile_Load(object sender, EventArgs e) + { + _TextileList = _logicT.ReadList(null); + if (_TextileList != null) + { + comboBoxTextile.DisplayMember = "TextileName"; + comboBoxTextile.ValueMember = "Id"; + comboBoxTextile.DataSource = _TextileList; + comboBoxTextile.SelectedItem = null; + _logger.LogInformation("Загрузка пиццы для продажи"); + } + } + + private void ButtonSell_Click(object sender, EventArgs e) + { + if (comboBoxTextile.SelectedValue == null) + { + MessageBox.Show("Выберите пиццу", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + _logger.LogInformation("Создание покупки"); + try + { + bool resout = _logicS.Sell(new SupplySearchModel + { + TextileId = Convert.ToInt32(comboBoxTextile.SelectedValue), + Count = Convert.ToInt32(textBoxCount.Text) + }); + if (resout) + { + _logger.LogInformation("Проверка была выполнена"); + MessageBox.Show("Продажа выполнена", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information); + DialogResult = DialogResult.OK; + Close(); + } + else + { + _logger.LogInformation("Проверка не пройдена"); + MessageBox.Show("Продажа не может быть выполнена.", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Warning); + } + } + 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(); + } + } +} diff --git a/GarmentFactory/FormSellTextile.resx b/GarmentFactory/FormSellTextile.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/GarmentFactory/FormSellTextile.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/GarmentFactory/FormShop.Designer.cs b/GarmentFactory/FormShop.Designer.cs new file mode 100644 index 0000000..3e1c300 --- /dev/null +++ b/GarmentFactory/FormShop.Designer.cs @@ -0,0 +1,230 @@ +namespace GarmentFactoryView +{ + partial class FormShop + { + /// + /// 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() + { + labelName = new Label(); + labelAddress = new Label(); + labelDateOpen = new Label(); + textBoxName = new TextBox(); + textBoxAddress = new TextBox(); + dateTimePicker = new DateTimePicker(); + groupBoxTextiles = new GroupBox(); + dataGridView = new DataGridView(); + ID = new DataGridViewTextBoxColumn(); + ColumnTextileName = new DataGridViewTextBoxColumn(); + ColumnCount = new DataGridViewTextBoxColumn(); + buttonCancel = new Button(); + buttonSave = new Button(); + numericUpTextileMaxCount = new NumericUpDown(); + label2 = new Label(); + groupBoxTextiles.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + ((System.ComponentModel.ISupportInitialize)numericUpTextileMaxCount).BeginInit(); + SuspendLayout(); + // + // labelName + // + labelName.AutoSize = true; + labelName.Location = new Point(30, 21); + labelName.Name = "labelName"; + labelName.Size = new Size(84, 20); + labelName.TabIndex = 0; + labelName.Text = "Название: "; + // + // labelAddress + // + labelAddress.AutoSize = true; + labelAddress.Location = new Point(40, 71); + labelAddress.Name = "labelAddress"; + labelAddress.Size = new Size(58, 20); + labelAddress.TabIndex = 1; + labelAddress.Text = "Адрес: "; + // + // labelDateOpen + // + labelDateOpen.AutoSize = true; + labelDateOpen.Location = new Point(12, 118); + labelDateOpen.Name = "labelDateOpen"; + labelDateOpen.Size = new Size(117, 20); + labelDateOpen.TabIndex = 2; + labelDateOpen.Text = "Дата открытия: "; + // + // textBoxName + // + textBoxName.Location = new Point(135, 21); + textBoxName.Name = "textBoxName"; + textBoxName.Size = new Size(243, 27); + textBoxName.TabIndex = 3; + // + // textBoxAddress + // + textBoxAddress.Location = new Point(135, 68); + textBoxAddress.Name = "textBoxAddress"; + textBoxAddress.Size = new Size(243, 27); + textBoxAddress.TabIndex = 4; + // + // dateTimePicker + // + dateTimePicker.Location = new Point(135, 113); + dateTimePicker.Name = "dateTimePicker"; + dateTimePicker.Size = new Size(243, 27); + dateTimePicker.TabIndex = 5; + // + // groupBoxTextiles + // + groupBoxTextiles.Controls.Add(dataGridView); + groupBoxTextiles.Location = new Point(12, 209); + groupBoxTextiles.Name = "groupBoxTextiles"; + groupBoxTextiles.Size = new Size(651, 306); + groupBoxTextiles.TabIndex = 6; + groupBoxTextiles.TabStop = false; + groupBoxTextiles.Text = "Изделия"; + // + // dataGridView + // + dataGridView.AllowUserToAddRows = false; + dataGridView.AllowUserToDeleteRows = false; + dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Columns.AddRange(new DataGridViewColumn[] { ID, ColumnTextileName, ColumnCount }); + dataGridView.Location = new Point(6, 26); + dataGridView.Name = "dataGridView"; + dataGridView.ReadOnly = true; + dataGridView.RowHeadersWidth = 51; + dataGridView.RowTemplate.Height = 29; + dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridView.Size = new Size(633, 274); + dataGridView.TabIndex = 0; + // + // ID + // + ID.HeaderText = "ID"; + ID.MinimumWidth = 6; + ID.Name = "ID"; + ID.ReadOnly = true; + ID.Visible = false; + // + // ColumnTextileName + // + ColumnTextileName.HeaderText = "Изделие"; + ColumnTextileName.MinimumWidth = 6; + ColumnTextileName.Name = "ColumnTextileName"; + ColumnTextileName.ReadOnly = true; + // + // ColumnCount + // + ColumnCount.HeaderText = "Количество"; + ColumnCount.MinimumWidth = 6; + ColumnCount.Name = "ColumnCount"; + ColumnCount.ReadOnly = true; + // + // buttonCancel + // + buttonCancel.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point); + buttonCancel.Location = new Point(550, 532); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(103, 40); + buttonCancel.TabIndex = 9; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click; + // + // buttonSave + // + buttonSave.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point); + buttonSave.Location = new Point(432, 532); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(103, 40); + buttonSave.TabIndex = 8; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += ButtonSave_Click; + // + // numericUpTextileMaxCount + // + numericUpTextileMaxCount.Location = new Point(135, 163); + numericUpTextileMaxCount.Maximum = new decimal(new int[] { 10000, 0, 0, 0 }); + numericUpTextileMaxCount.Name = "numericUpTextileMaxCount"; + numericUpTextileMaxCount.Size = new Size(243, 27); + numericUpTextileMaxCount.TabIndex = 13; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(19, 165); + label2.Name = "label2"; + label2.Size = new Size(103, 20); + label2.TabIndex = 12; + label2.Text = "Вместимость:"; + // + // FormShop + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(682, 584); + Controls.Add(numericUpTextileMaxCount); + Controls.Add(label2); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(groupBoxTextiles); + Controls.Add(dateTimePicker); + Controls.Add(textBoxAddress); + Controls.Add(textBoxName); + Controls.Add(labelDateOpen); + Controls.Add(labelAddress); + Controls.Add(labelName); + Name = "FormShop"; + Text = "Магазин"; + Load += FormShop_Load; + groupBoxTextiles.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ((System.ComponentModel.ISupportInitialize)numericUpTextileMaxCount).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label labelName; + private Label labelAddress; + private Label labelDateOpen; + private TextBox textBoxName; + private TextBox textBoxAddress; + private DateTimePicker dateTimePicker; + private GroupBox groupBoxTextiles; + private DataGridView dataGridView; + private DataGridViewTextBoxColumn ID; + private DataGridViewTextBoxColumn ColumnTextileName; + private DataGridViewTextBoxColumn ColumnCount; + private Button buttonCancel; + private Button buttonSave; + private NumericUpDown numericUpTextileMaxCount; + private Label label2; + } +} \ No newline at end of file diff --git a/GarmentFactory/FormShop.cs b/GarmentFactory/FormShop.cs new file mode 100644 index 0000000..62a748c --- /dev/null +++ b/GarmentFactory/FormShop.cs @@ -0,0 +1,135 @@ +using GarmentFactoryContracts.BindingModels; +using GarmentFactoryContracts.BusinessLogicsContracts; +using GarmentFactoryContracts.SearchModels; +using GarmentFactoryDataModels.Models; +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 GarmentFactoryView +{ + public partial class FormShop : Form + { + private readonly ILogger _logger; + + private readonly IShopLogic _logic; + + private int? _id; + + public int Id { set { _id = value; } } + + private Dictionary _shopTextiles; + + + public FormShop(ILogger logger, IShopLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + _shopTextiles = new Dictionary(); + } + + private void FormShop_Load(object sender, EventArgs e) + { + if (_id.HasValue) + { + _logger.LogInformation("Загрузка магазина"); + try + { + var view = _logic.ReadElement(new ShopSearchModel + { + Id = _id.Value + }); + if (view != null) + { + textBoxName.Text = view.ShopName; + textBoxAddress.Text = view.Address.ToString(); + dateTimePicker.Value = view.DateOpen; + numericUpTextileMaxCount.Value = view.TextileMaxCount; + _shopTextiles = view.ShopTextiles ?? new Dictionary(); + LoadData(); + } + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки магазина"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + + private void LoadData() + { + _logger.LogInformation("Загрузка изделий в магазине"); + try + { + if (_shopTextiles != null) + { + dataGridView.Rows.Clear(); + foreach (var element in _shopTextiles) + { + dataGridView.Rows.Add(new object[] { element.Key, element.Value.Item1.TextileName, element.Value.Item2 }); + } + } + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки изделий в магазине"); + 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); + return; + } + if (string.IsNullOrEmpty(textBoxAddress.Text)) + { + MessageBox.Show("Заполните адрес", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + _logger.LogInformation("Сохранение магазина"); + try + { + var model = new ShopBindingModel + { + Id = _id ?? 0, + ShopName = textBoxName.Text, + Address = textBoxAddress.Text, + DateOpen = dateTimePicker.Value.Date, + ShopTextiles = _shopTextiles, + TextileMaxCount = (int)numericUpTextileMaxCount.Value + }; + var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model); + 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(); + } + } +} diff --git a/GarmentFactory/FormShop.resx b/GarmentFactory/FormShop.resx new file mode 100644 index 0000000..bc99676 --- /dev/null +++ b/GarmentFactory/FormShop.resx @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + True + + + True + + + True + + \ No newline at end of file diff --git a/GarmentFactory/FormShops.Designer.cs b/GarmentFactory/FormShops.Designer.cs new file mode 100644 index 0000000..1b50209 --- /dev/null +++ b/GarmentFactory/FormShops.Designer.cs @@ -0,0 +1,116 @@ +namespace GarmentFactoryView +{ + partial class FormShops + { + /// + /// 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() + { + dataGridView = new DataGridView(); + buttonRefresh = new Button(); + buttonDelete = new Button(); + buttonUpdate = new Button(); + buttonAdd = new Button(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // dataGridView + // + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Location = new Point(-3, -4); + dataGridView.Name = "dataGridView"; + dataGridView.ReadOnly = true; + dataGridView.RowHeadersWidth = 51; + dataGridView.RowTemplate.Height = 29; + dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridView.Size = new Size(640, 455); + dataGridView.TabIndex = 0; + // + // buttonRefresh + // + buttonRefresh.Location = new Point(658, 252); + buttonRefresh.Name = "buttonRefresh"; + buttonRefresh.Size = new Size(120, 40); + buttonRefresh.TabIndex = 12; + buttonRefresh.Text = "Обновить"; + buttonRefresh.UseVisualStyleBackColor = true; + buttonRefresh.Click += ButtonRefresh_Click; + // + // buttonDelete + // + buttonDelete.Location = new Point(658, 183); + buttonDelete.Name = "buttonDelete"; + buttonDelete.Size = new Size(120, 40); + buttonDelete.TabIndex = 11; + buttonDelete.Text = "Удалить"; + buttonDelete.UseVisualStyleBackColor = true; + buttonDelete.Click += ButtonDelete_Click; + // + // buttonUpdate + // + buttonUpdate.Location = new Point(658, 115); + buttonUpdate.Name = "buttonUpdate"; + buttonUpdate.Size = new Size(120, 40); + buttonUpdate.TabIndex = 10; + buttonUpdate.Text = "Изменить"; + buttonUpdate.UseVisualStyleBackColor = true; + buttonUpdate.Click += ButtonUpdate_Click; + // + // buttonAdd + // + buttonAdd.Location = new Point(658, 50); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(120, 40); + buttonAdd.TabIndex = 9; + buttonAdd.Text = "Добавить"; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += ButtonAdd_Click; + // + // FormShops + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 450); + Controls.Add(buttonRefresh); + Controls.Add(buttonDelete); + Controls.Add(buttonUpdate); + Controls.Add(buttonAdd); + Controls.Add(dataGridView); + Name = "FormShops"; + Text = "Магазины"; + Load += FormShops_Load; + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + } + + #endregion + + private DataGridView dataGridView; + private Button buttonRefresh; + private Button buttonDelete; + private Button buttonUpdate; + private Button buttonAdd; + } +} \ No newline at end of file diff --git a/GarmentFactory/FormShops.cs b/GarmentFactory/FormShops.cs new file mode 100644 index 0000000..f8c95d5 --- /dev/null +++ b/GarmentFactory/FormShops.cs @@ -0,0 +1,115 @@ +using GarmentFactory; +using GarmentFactoryContracts.BindingModels; +using GarmentFactoryContracts.BusinessLogicsContracts; +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 GarmentFactoryView +{ + public partial class FormShops : Form + { + private readonly ILogger _logger; + private readonly IShopLogic _logic; + public FormShops(ILogger logger, IShopLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + } + + private void FormShops_Load(object sender, EventArgs e) + { + LoadData(); + } + + private void LoadData() + { + try + { + var list = _logic.ReadList(null); + if (list != null) + { + dataGridView.DataSource = list; + dataGridView.Columns["Id"].Visible = false; + dataGridView.Columns["ShopTextiles"].Visible = false; + dataGridView.Columns["ShopName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + } + _logger.LogInformation("Загрузка магазинов"); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки магазинов"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonAdd_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormShop)); + if (service is FormShop form) + { + if (form.ShowDialog() == DialogResult.OK) + { + LoadData(); + } + } + } + + private void ButtonUpdate_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + var service = Program.ServiceProvider?.GetService(typeof(FormShop)); + if (service is FormShop form) + { + form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + if (form.ShowDialog() == DialogResult.OK) + { + LoadData(); + } + } + } + } + + private void ButtonDelete_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) + { + int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Удаление магазина"); + try + { + if (!_logic.Delete(new ShopBindingModel + { + Id = id + })) + { + throw new Exception("Ошибка при удалении. Дополнительная информация в логах."); + } + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка удаления магазина"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + } + + private void ButtonRefresh_Click(object sender, EventArgs e) + { + LoadData(); + } + } +} diff --git a/GarmentFactory/FormShops.resx b/GarmentFactory/FormShops.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/GarmentFactory/FormShops.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/GarmentFactory/FormTextiles.Designer.cs b/GarmentFactory/FormTextiles.Designer.cs index 6b41417..a134efe 100644 --- a/GarmentFactory/FormTextiles.Designer.cs +++ b/GarmentFactory/FormTextiles.Designer.cs @@ -38,6 +38,9 @@ // // dataGridView // + dataGridView.AllowUserToAddRows = false; + dataGridView.AllowUserToDeleteRows = false; + dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; dataGridView.Dock = DockStyle.Left; dataGridView.Location = new Point(0, 0); diff --git a/GarmentFactory/GarmentFactoryView.csproj b/GarmentFactory/GarmentFactoryView.csproj index 6b48d02..1ec32c7 100644 --- a/GarmentFactory/GarmentFactoryView.csproj +++ b/GarmentFactory/GarmentFactoryView.csproj @@ -44,6 +44,9 @@ + + Always + Always diff --git a/GarmentFactory/Program.cs b/GarmentFactory/Program.cs index 9ef1d09..dd17bc5 100644 --- a/GarmentFactory/Program.cs +++ b/GarmentFactory/Program.cs @@ -8,7 +8,7 @@ using GarmentFactoryView; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using NLog.Extensions.Logging; - +using GarmentFactoryBusinessLogic; namespace GarmentFactory { @@ -41,12 +41,14 @@ namespace GarmentFactory services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); @@ -59,8 +61,16 @@ namespace GarmentFactory services.AddTransient(); services.AddTransient(); services.AddTransient(); + + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); services.AddTransient(); + services.AddTransient(); + services.AddTransient(); services.AddTransient(); } } diff --git a/GarmentFactory/ReportGroupedOrders.rdlc b/GarmentFactory/ReportGroupedOrders.rdlc new file mode 100644 index 0000000..2eaa478 --- /dev/null +++ b/GarmentFactory/ReportGroupedOrders.rdlc @@ -0,0 +1,444 @@ + + + 0 + + + + System.Data.DataSet + /* Local Connection */ + + 20791c83-cee8-4a38-bbd0-245fc17cefb3 + + + + + + GarmentFactoryContractsViewModels + /* Local Query */ + + + + Date + System.DateTime + + + OrdersCount + System.Int32 + + + OrdersSum + System.Decimal + + + + GarmentFactoryContracts.ViewModels + ReportGroupedOrdersViewModel + GarmentFactoryContracts.ViewModels.ReportGroupedOrdersViewModel, GarmentFactoryContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + + + + + + + + + true + true + + + + + Отчёт по заказам + + + + + + + 0.6cm + 16.51cm + + + Middle + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + =Parameters!ReportParameterPeriod.Value + + + + + + + ReportParameterPeriod + 0.6cm + 0.6cm + 16.51cm + 1 + + + 2pt + 2pt + 2pt + 2pt + + + + + + + 3.90406cm + + + 3.97461cm + + + 3.65711cm + + + + + 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!Date.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!OrdersCount.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!OrdersSum.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + + + + + + + + + + + + After + + + + + + + DataSetGroupedOrders + 1.88242cm + 2.68676cm + 1.2cm + 11.53578cm + 2 + + + + + + true + true + + + + + Итого: + + + + 3.29409cm + 8.06542cm + 0.6cm + 2.5cm + 3 + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + =Sum(Fields!OrdersSum.Value, "DataSetGroupedOrders") + + + + + + + 3.29409cm + 10.70653cm + 0.6cm + 3.48072cm + 4 + + + 2pt + 2pt + 2pt + 2pt + + + + 2in +