diff --git a/TravelCompany/TravelCompany/FormCreateOrder.Designer.cs b/TravelCompany/TravelCompany/FormCreateOrder.Designer.cs index 1ec37f3..5376b08 100644 --- a/TravelCompany/TravelCompany/FormCreateOrder.Designer.cs +++ b/TravelCompany/TravelCompany/FormCreateOrder.Designer.cs @@ -28,117 +28,124 @@ /// private void InitializeComponent() { - label1 = new Label(); - label2 = new Label(); - label3 = new Label(); - textBoxCount = new TextBox(); - comboBoxTravel = new ComboBox(); - textBoxSum = new TextBox(); - buttonSave = new Button(); - buttonCancel = new Button(); - SuspendLayout(); + this.labelTravel = new System.Windows.Forms.Label(); + this.comboBoxTravel = new System.Windows.Forms.ComboBox(); + this.labelCount = new System.Windows.Forms.Label(); + this.textBoxCount = new System.Windows.Forms.TextBox(); + this.labelSum = new System.Windows.Forms.Label(); + this.textBoxSum = new System.Windows.Forms.TextBox(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.buttonSave = new System.Windows.Forms.Button(); + this.SuspendLayout(); // - // label1 + // labelTravel // - label1.AutoSize = true; - label1.Location = new Point(19, 12); - label1.Name = "label1"; - label1.Size = new Size(56, 15); - label1.TabIndex = 0; - label1.Text = "Изделие:"; - // - // label2 - // - label2.AutoSize = true; - label2.Location = new Point(19, 44); - label2.Name = "label2"; - label2.Size = new Size(75, 15); - label2.TabIndex = 1; - label2.Text = "Количество:"; - // - // label3 - // - label3.AutoSize = true; - label3.Location = new Point(19, 70); - label3.Name = "label3"; - label3.Size = new Size(48, 15); - label3.TabIndex = 2; - label3.Text = "Сумма:"; - // - // textBoxCount - // - textBoxCount.Location = new Point(103, 41); - textBoxCount.Name = "textBoxCount"; - textBoxCount.Size = new Size(246, 23); - textBoxCount.TabIndex = 3; - textBoxCount.TextChanged += textBoxCount_TextChanged; + this.labelTravel.AutoSize = true; + this.labelTravel.Location = new System.Drawing.Point(10, 11); + this.labelTravel.Name = "labelTravel"; + this.labelTravel.Size = new System.Drawing.Size(43, 15); + this.labelTravel.TabIndex = 0; + this.labelTravel.Text = "Пицца"; // // comboBoxTravel // - comboBoxTravel.FormattingEnabled = true; - comboBoxTravel.Location = new Point(103, 10); - comboBoxTravel.Name = "comboBoxTravel"; - comboBoxTravel.Size = new Size(246, 23); - comboBoxTravel.TabIndex = 4; - comboBoxTravel.SelectedIndexChanged += ComboBoxTravel_SelectedIndexChanged; + this.comboBoxTravel.FormattingEnabled = true; + this.comboBoxTravel.Location = new System.Drawing.Point(101, 9); + this.comboBoxTravel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.comboBoxTravel.Name = "comboBoxTravel"; + this.comboBoxTravel.Size = new System.Drawing.Size(314, 23); + this.comboBoxTravel.TabIndex = 1; + this.comboBoxTravel.SelectedIndexChanged += new System.EventHandler(this.ComboBoxTravel_SelectedIndexChanged); + // + // labelCount + // + this.labelCount.AutoSize = true; + this.labelCount.Location = new System.Drawing.Point(10, 37); + this.labelCount.Name = "labelCount"; + this.labelCount.Size = new System.Drawing.Size(78, 15); + this.labelCount.TabIndex = 2; + this.labelCount.Text = "Количество: "; + // + // textBoxCount + // + this.textBoxCount.Location = new System.Drawing.Point(101, 34); + this.textBoxCount.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.textBoxCount.Name = "textBoxCount"; + this.textBoxCount.Size = new System.Drawing.Size(314, 23); + this.textBoxCount.TabIndex = 3; + this.textBoxCount.TextChanged += new System.EventHandler(this.TextBoxCount_TextChanged); + // + // labelSum + // + this.labelSum.AutoSize = true; + this.labelSum.Location = new System.Drawing.Point(10, 60); + this.labelSum.Name = "labelSum"; + this.labelSum.Size = new System.Drawing.Size(51, 15); + this.labelSum.TabIndex = 4; + this.labelSum.Text = "Сумма: "; // // textBoxSum // - textBoxSum.Location = new Point(103, 70); - textBoxSum.Name = "textBoxSum"; - textBoxSum.ReadOnly = true; - textBoxSum.Size = new Size(246, 23); - textBoxSum.TabIndex = 5; - // - // buttonSave - // - buttonSave.Location = new Point(150, 101); - buttonSave.Name = "buttonSave"; - buttonSave.Size = new Size(94, 26); - buttonSave.TabIndex = 6; - buttonSave.Text = "Сохранить"; - buttonSave.UseVisualStyleBackColor = true; - buttonSave.Click += buttonSave_Click; + this.textBoxSum.Location = new System.Drawing.Point(101, 60); + this.textBoxSum.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.textBoxSum.Name = "textBoxSum"; + this.textBoxSum.ReadOnly = true; + this.textBoxSum.Size = new System.Drawing.Size(314, 23); + this.textBoxSum.TabIndex = 5; // // buttonCancel // - buttonCancel.Location = new Point(249, 101); - buttonCancel.Name = "buttonCancel"; - buttonCancel.Size = new Size(94, 26); - buttonCancel.TabIndex = 7; - buttonCancel.Text = "Отмена"; - buttonCancel.UseVisualStyleBackColor = true; - buttonCancel.Click += buttonCancel_Click; + this.buttonCancel.Location = new System.Drawing.Point(295, 85); + this.buttonCancel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(96, 24); + this.buttonCancel.TabIndex = 6; + this.buttonCancel.Text = "Отмена"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); + // + // buttonSave + // + this.buttonSave.Location = new System.Drawing.Point(193, 85); + this.buttonSave.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.buttonSave.Name = "buttonSave"; + this.buttonSave.Size = new System.Drawing.Size(96, 24); + this.buttonSave.TabIndex = 7; + this.buttonSave.Text = "Сохранить"; + this.buttonSave.UseVisualStyleBackColor = true; + this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click); // // FormCreateOrder // - AutoScaleDimensions = new SizeF(7F, 15F); - AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(374, 136); - Controls.Add(buttonCancel); - Controls.Add(buttonSave); - Controls.Add(textBoxSum); - Controls.Add(comboBoxTravel); - Controls.Add(textBoxCount); - Controls.Add(label3); - Controls.Add(label2); - Controls.Add(label1); - Name = "FormCreateOrder"; - Text = "Заказ"; - Load += FormCreateOrder_Load; - ResumeLayout(false); - PerformLayout(); + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(424, 118); + this.Controls.Add(this.buttonSave); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.textBoxSum); + this.Controls.Add(this.labelSum); + this.Controls.Add(this.textBoxCount); + this.Controls.Add(this.labelCount); + this.Controls.Add(this.comboBoxTravel); + this.Controls.Add(this.labelTravel); + this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.Name = "FormCreateOrder"; + this.Text = "Заказ"; + this.Load += new System.EventHandler(this.FormCreateOrder_Load); + this.ResumeLayout(false); + this.PerformLayout(); + } #endregion - private Label label1; - private Label label2; - private Label label3; - private TextBox textBoxCount; + private Label labelTravel; private ComboBox comboBoxTravel; + private Label labelCount; + private TextBox textBoxCount; + private Label labelSum; private TextBox textBoxSum; - private Button buttonSave; private Button buttonCancel; + private Button buttonSave; } } \ No newline at end of file diff --git a/TravelCompany/TravelCompany/FormCreateOrder.cs b/TravelCompany/TravelCompany/FormCreateOrder.cs index 8cff27f..75b89da 100644 --- a/TravelCompany/TravelCompany/FormCreateOrder.cs +++ b/TravelCompany/TravelCompany/FormCreateOrder.cs @@ -1,7 +1,8 @@ -using TravelCompanyContracts.BindingModels; +using Microsoft.Extensions.Logging; +using TravelCompanyContracts.BindingModels; using TravelCompanyContracts.BusinessLogicsContracts; using TravelCompanyContracts.SearchModels; -using Microsoft.Extensions.Logging; +using TravelCompanyContracts.ViewModels; using System; using System.Collections.Generic; using System.ComponentModel; @@ -19,6 +20,8 @@ namespace TravelCompany.Forms private readonly ILogger _logger; private readonly ITravelLogic _logicP; private readonly IOrderLogic _logicO; + private List? _list; + public FormCreateOrder(ILogger logger, ITravelLogic logicP, IOrderLogic logicO) { InitializeComponent(); @@ -29,23 +32,17 @@ namespace TravelCompany.Forms private void FormCreateOrder_Load(object sender, EventArgs e) { - try + _list = _logicP.ReadList(null); + if (_list != null) { - var list = _logicP.ReadList(null); - if (list != null) - { - comboBoxTravel.DisplayMember = "TravelName"; - comboBoxTravel.ValueMember = "Id"; - comboBoxTravel.DataSource = list; - comboBoxTravel.SelectedItem = null; - _logger.LogInformation("Загрузка изделий для заказа"); - } - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка загрузки списка изделий"); + comboBoxTravel.DisplayMember = "TravelName"; + comboBoxTravel.ValueMember = "Id"; + comboBoxTravel.DataSource = _list; + comboBoxTravel.SelectedItem = null; + _logger.LogInformation("Загрузка путевок для заказа"); } } + private void CalcSum() { if (comboBoxTravel.SelectedValue != null && !string.IsNullOrEmpty(textBoxCount.Text)) @@ -68,7 +65,8 @@ namespace TravelCompany.Forms } } } - private void textBoxCount_TextChanged(object sender, EventArgs e) + + private void TextBoxCount_TextChanged(object sender, EventArgs e) { CalcSum(); } @@ -78,7 +76,7 @@ namespace TravelCompany.Forms CalcSum(); } - private void buttonSave_Click(object sender, EventArgs e) + private void ButtonSave_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(textBoxCount.Text)) { @@ -87,7 +85,7 @@ namespace TravelCompany.Forms } if (comboBoxTravel.SelectedValue == null) { - MessageBox.Show("Выберите изделие", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show("Выберите путевку", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } _logger.LogInformation("Создание заказа"); @@ -109,15 +107,15 @@ namespace TravelCompany.Forms } catch (Exception ex) { - _logger.LogError(ex, "Ошибка создания заказа"); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + _logger.LogError(ex, "Ошибка создания заказа"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } - private void buttonCancel_Click(object sender, EventArgs e) + private void ButtonCancel_Click(object sender, EventArgs e) { DialogResult = DialogResult.Cancel; Close(); } - } } diff --git a/TravelCompany/TravelCompany/FormCreateOrder.resx b/TravelCompany/TravelCompany/FormCreateOrder.resx index af32865..1af7de1 100644 --- a/TravelCompany/TravelCompany/FormCreateOrder.resx +++ b/TravelCompany/TravelCompany/FormCreateOrder.resx @@ -1,17 +1,17 @@  - diff --git a/TravelCompany/TravelCompany/FormCreateSupply.Designer.cs b/TravelCompany/TravelCompany/FormCreateSupply.Designer.cs new file mode 100644 index 0000000..d7bebf1 --- /dev/null +++ b/TravelCompany/TravelCompany/FormCreateSupply.Designer.cs @@ -0,0 +1,143 @@ +namespace TravelCompany.Forms +{ + partial class FormCreateSupply + { + /// + /// 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.comboBoxShop = new System.Windows.Forms.ComboBox(); + this.labelShop = new System.Windows.Forms.Label(); + this.labelTravel = new System.Windows.Forms.Label(); + this.comboBoxTravel = new System.Windows.Forms.ComboBox(); + this.labelCount = new System.Windows.Forms.Label(); + this.textBoxCount = new System.Windows.Forms.TextBox(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.buttonSave = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // comboBoxShop + // + this.comboBoxShop.FormattingEnabled = true; + this.comboBoxShop.Location = new System.Drawing.Point(115, 12); + this.comboBoxShop.Name = "comboBoxShop"; + this.comboBoxShop.Size = new System.Drawing.Size(344, 28); + this.comboBoxShop.TabIndex = 0; + // + // labelShop + // + this.labelShop.AutoSize = true; + this.labelShop.Location = new System.Drawing.Point(12, 15); + this.labelShop.Name = "labelShop"; + this.labelShop.Size = new System.Drawing.Size(76, 20); + this.labelShop.TabIndex = 1; + this.labelShop.Text = "Магазин: "; + // + // labelTravel + // + this.labelTravel.AutoSize = true; + this.labelTravel.Location = new System.Drawing.Point(12, 49); + this.labelTravel.Name = "labelTravel"; + this.labelTravel.Size = new System.Drawing.Size(75, 20); + this.labelTravel.TabIndex = 2; + this.labelTravel.Text = "Изделие: "; + // + // comboBoxTravel + // + this.comboBoxTravel.FormattingEnabled = true; + this.comboBoxTravel.Location = new System.Drawing.Point(115, 46); + this.comboBoxTravel.Name = "comboBoxTravel"; + this.comboBoxTravel.Size = new System.Drawing.Size(344, 28); + this.comboBoxTravel.TabIndex = 3; + // + // labelCount + // + this.labelCount.AutoSize = true; + this.labelCount.Location = new System.Drawing.Point(12, 83); + this.labelCount.Name = "labelCount"; + this.labelCount.Size = new System.Drawing.Size(97, 20); + this.labelCount.TabIndex = 4; + this.labelCount.Text = "Количество: "; + // + // textBoxCount + // + this.textBoxCount.Location = new System.Drawing.Point(115, 80); + this.textBoxCount.Name = "textBoxCount"; + this.textBoxCount.Size = new System.Drawing.Size(344, 27); + this.textBoxCount.TabIndex = 5; + // + // buttonCancel + // + this.buttonCancel.Location = new System.Drawing.Point(300, 113); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(116, 39); + this.buttonCancel.TabIndex = 6; + this.buttonCancel.Text = "Отмена"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); + // + // buttonSave + // + this.buttonSave.Location = new System.Drawing.Point(168, 113); + this.buttonSave.Name = "buttonSave"; + this.buttonSave.Size = new System.Drawing.Size(116, 39); + this.buttonSave.TabIndex = 7; + this.buttonSave.Text = "Сохранить"; + this.buttonSave.UseVisualStyleBackColor = true; + this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click); + // + // FormCreateSupply + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(471, 164); + this.Controls.Add(this.buttonSave); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.textBoxCount); + this.Controls.Add(this.labelCount); + this.Controls.Add(this.comboBoxTravel); + this.Controls.Add(this.labelTravel); + this.Controls.Add(this.labelShop); + this.Controls.Add(this.comboBoxShop); + this.Name = "FormCreateSupply"; + this.Text = "Создание поставки"; + this.Load += new System.EventHandler(this.FormCreateSupply_Load); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private ComboBox comboBoxShop; + private Label labelShop; + private Label labelTravel; + private ComboBox comboBoxTravel; + private Label labelCount; + private TextBox textBoxCount; + private Button buttonCancel; + private Button buttonSave; + } +} \ No newline at end of file diff --git a/TravelCompany/TravelCompany/FormCreateSupply.cs b/TravelCompany/TravelCompany/FormCreateSupply.cs new file mode 100644 index 0000000..6ca4901 --- /dev/null +++ b/TravelCompany/TravelCompany/FormCreateSupply.cs @@ -0,0 +1,99 @@ +using Microsoft.Extensions.Logging; +using TravelCompanyContracts.BindingModels; +using TravelCompanyContracts.BusinessLogicsContracts; +using TravelCompanyContracts.ViewModels; +using System; +using System.Collections; +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; +using static System.Windows.Forms.VisualStyles.VisualStyleElement; + +namespace TravelCompany.Forms +{ + public partial class FormCreateSupply : Form + { + private readonly ILogger _logger; + private readonly ITravelLogic _logicP; + private readonly IShopLogic _logicS; + private List _shopList = new List(); + private List _TravelList = new List(); + + public FormCreateSupply(ILogger logger, ITravelLogic logicP, IShopLogic logicS) + { + InitializeComponent(); + _logger = logger; + _logicP = logicP; + _logicS = logicS; + } + + private void FormCreateSupply_Load(object sender, EventArgs e) + { + _shopList = _logicS.ReadList(null); + _TravelList = _logicP.ReadList(null); + if (_shopList != null) + { + comboBoxShop.DisplayMember = "ShopName"; + comboBoxShop.ValueMember = "Id"; + comboBoxShop.DataSource = _shopList; + comboBoxShop.SelectedItem = null; + _logger.LogInformation("Загрузка магазинов для поставок"); + } + if (_TravelList != null) + { + comboBoxTravel.DisplayMember = "TravelName"; + comboBoxTravel.ValueMember = "Id"; + comboBoxTravel.DataSource = _TravelList; + comboBoxTravel.SelectedItem = null; + _logger.LogInformation("Загрузка путёвок для поставок"); + } + } + + private void ButtonSave_Click(object sender, EventArgs e) + { + if (comboBoxShop.SelectedValue == null) + { + MessageBox.Show("Выберите магазин", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + if (comboBoxTravel.SelectedValue == null) + { + MessageBox.Show("Выберите изделие", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + _logger.LogInformation("Создание поставки"); + try + { + var operationResult = _logicS.MakeSupply(new SupplyBindingModel + { + ShopId = Convert.ToInt32(comboBoxShop.SelectedValue), + TravelId = Convert.ToInt32(comboBoxTravel.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/TravelCompany/TravelCompany/FormCreateSupply.resx b/TravelCompany/TravelCompany/FormCreateSupply.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/TravelCompany/TravelCompany/FormCreateSupply.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/TravelCompany/TravelCompany/FormMain.Designer.cs b/TravelCompany/TravelCompany/FormMain.Designer.cs index cd45176..d4a6985 100644 --- a/TravelCompany/TravelCompany/FormMain.Designer.cs +++ b/TravelCompany/TravelCompany/FormMain.Designer.cs @@ -33,16 +33,27 @@ toolStripDropDownButton1 = new ToolStripDropDownButton(); компонентыToolStripMenuItem = new ToolStripMenuItem(); ПутёвкиToolStripMenuItem = new ToolStripMenuItem(); + магазиныToolStripMenuItem = new ToolStripMenuItem(); + operationToolStripMenuItem = new ToolStripMenuItem(); + transactionToolStripMenuItem = 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(); + заказыToolStripMenuItem1 = new ToolStripMenuItem(); + заказыПоГруппамToolStripMenuItem = new ToolStripMenuItem(); buttonCreateOrder = new Button(); buttonTakeOrderInWork = new Button(); buttonOrderReady = new Button(); buttonIssuedOrder = new Button(); buttonRef = new Button(); dataGridView = new DataGridView(); - отчетыToolStripMenuItem = new ToolStripMenuItem(); - списокКомпонентовToolStripMenuItem = new ToolStripMenuItem(); - компонентыПоПутёвкамToolStripMenuItem = new ToolStripMenuItem(); - списокЗаказовToolStripMenuItem = new ToolStripMenuItem(); + отчётыToolStripMenuItem1 = new ToolStripMenuItem(); toolStrip1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); SuspendLayout(); @@ -50,7 +61,7 @@ // toolStrip1 // toolStrip1.ImageScalingSize = new Size(20, 20); - toolStrip1.Items.AddRange(new ToolStripItem[] { toolStripDropDownButton1, отчетыToolStripMenuItem }); + toolStrip1.Items.AddRange(new ToolStripItem[] { toolStripDropDownButton1, operationToolStripMenuItem, отчётыToolStripMenuItem }); toolStrip1.Location = new Point(0, 0); toolStrip1.Name = "toolStrip1"; toolStrip1.Size = new Size(969, 25); @@ -60,7 +71,7 @@ // toolStripDropDownButton1 // toolStripDropDownButton1.DisplayStyle = ToolStripItemDisplayStyle.Text; - toolStripDropDownButton1.DropDownItems.AddRange(new ToolStripItem[] { компонентыToolStripMenuItem, ПутёвкиToolStripMenuItem }); + toolStripDropDownButton1.DropDownItems.AddRange(new ToolStripItem[] { компонентыToolStripMenuItem, ПутёвкиToolStripMenuItem, магазиныToolStripMenuItem }); toolStripDropDownButton1.Image = (Image)resources.GetObject("toolStripDropDownButton1.Image"); toolStripDropDownButton1.ImageTransparentColor = Color.Magenta; toolStripDropDownButton1.Name = "toolStripDropDownButton1"; @@ -81,6 +92,104 @@ ПутёвкиToolStripMenuItem.Text = "Туристич. путёвки"; ПутёвкиToolStripMenuItem.Click += консервыToolStripMenuItem_Click; // + // магазиныToolStripMenuItem + // + магазиныToolStripMenuItem.Name = "магазиныToolStripMenuItem"; + магазиныToolStripMenuItem.Size = new Size(174, 22); + магазиныToolStripMenuItem.Text = "Магазины"; + магазиныToolStripMenuItem.Click += shopsToolStripMenuItem_Click; + // + // operationToolStripMenuItem + // + operationToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { transactionToolStripMenuItem, продажаToolStripMenuItem, отчётыToolStripMenuItem1 }); + operationToolStripMenuItem.Name = "operationToolStripMenuItem"; + operationToolStripMenuItem.Size = new Size(75, 25); + operationToolStripMenuItem.Text = "Операции"; + // + // transactionToolStripMenuItem + // + transactionToolStripMenuItem.Name = "transactionToolStripMenuItem"; + transactionToolStripMenuItem.Size = new Size(180, 22); + transactionToolStripMenuItem.Text = "Поставка"; + transactionToolStripMenuItem.Click += transactionToolStripMenuItem_Click; + // + // продажаToolStripMenuItem + // + продажаToolStripMenuItem.Name = "продажаToolStripMenuItem"; + продажаToolStripMenuItem.Size = new Size(180, 22); + продажаToolStripMenuItem.Text = "Продажа"; + продажаToolStripMenuItem.Click += SellToolStripMenuItem_Click; + // + // отчётыToolStripMenuItem + // + отчётыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { изделияToolStripMenuItem, магазинToolStripMenuItem, заказыToolStripMenuItem }); + отчётыToolStripMenuItem.Name = "отчётыToolStripMenuItem"; + отчётыToolStripMenuItem.Size = new Size(60, 25); + отчётыToolStripMenuItem.Text = "Отчёты"; + // + // изделияToolStripMenuItem + // + изделияToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { списокИзделийToolStripMenuItem, пиццаСИнгридиентамиToolStripMenuItem }); + изделияToolStripMenuItem.Name = "изделияToolStripMenuItem"; + изделияToolStripMenuItem.Size = new Size(180, 22); + изделияToolStripMenuItem.Text = "Путевки"; + // + // списокИзделийToolStripMenuItem + // + списокИзделийToolStripMenuItem.Name = "списокИзделийToolStripMenuItem"; + списокИзделийToolStripMenuItem.Size = new Size(213, 22); + списокИзделийToolStripMenuItem.Text = "Список путевок"; + списокИзделийToolStripMenuItem.Click += ComponentsToolStripMenuItem_Click; + // + // пиццаСИнгридиентамиToolStripMenuItem + // + пиццаСИнгридиентамиToolStripMenuItem.Name = "пиццаСИнгридиентамиToolStripMenuItem"; + пиццаСИнгридиентамиToolStripMenuItem.Size = new Size(213, 22); + пиццаСИнгридиентамиToolStripMenuItem.Text = "Путевка с компонентами"; + пиццаСИнгридиентамиToolStripMenuItem.Click += ComponentTravelToolStripMenuItem_Click; + // + // магазинToolStripMenuItem + // + магазинToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { информацияToolStripMenuItem, загруженностьToolStripMenuItem }); + магазинToolStripMenuItem.Name = "магазинToolStripMenuItem"; + магазинToolStripMenuItem.Size = new Size(180, 22); + магазинToolStripMenuItem.Text = "Магазин"; + // + // информацияToolStripMenuItem + // + информацияToolStripMenuItem.Name = "информацияToolStripMenuItem"; + информацияToolStripMenuItem.Size = new Size(158, 22); + информацияToolStripMenuItem.Text = "Информация"; + информацияToolStripMenuItem.Click += InfoToolStripMenuItem_Click; + // + // загруженностьToolStripMenuItem + // + загруженностьToolStripMenuItem.Name = "загруженностьToolStripMenuItem"; + загруженностьToolStripMenuItem.Size = new Size(158, 22); + загруженностьToolStripMenuItem.Text = "Загруженность"; + загруженностьToolStripMenuItem.Click += BusyShopsToolStripMenuItem_Click; + // + // заказыToolStripMenuItem + // + заказыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { заказыToolStripMenuItem1, заказыПоГруппамToolStripMenuItem }); + заказыToolStripMenuItem.Name = "заказыToolStripMenuItem"; + заказыToolStripMenuItem.Size = new Size(180, 22); + заказыToolStripMenuItem.Text = "Заказы"; + // + // заказыToolStripMenuItem1 + // + заказыToolStripMenuItem1.Name = "заказыToolStripMenuItem1"; + заказыToolStripMenuItem1.Size = new Size(180, 22); + заказыToolStripMenuItem1.Text = "Заказы"; + заказыToolStripMenuItem1.Click += OrdersToolStripMenuItem_Click; + // + // заказыПоГруппамToolStripMenuItem + // + заказыПоГруппамToolStripMenuItem.Name = "заказыПоГруппамToolStripMenuItem"; + заказыПоГруппамToolStripMenuItem.Size = new Size(180, 22); + заказыПоГруппамToolStripMenuItem.Text = "Заказы по группам"; + заказыПоГруппамToolStripMenuItem.Click += GroupOrdersToolStripMenuItem_Click; + // // buttonCreateOrder // buttonCreateOrder.Location = new Point(800, 56); @@ -143,33 +252,11 @@ dataGridView.Size = new Size(763, 435); dataGridView.TabIndex = 6; // - // отчетыToolStripMenuItem + // отчётыToolStripMenuItem1 // - отчетыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { списокКомпонентовToolStripMenuItem, компонентыПоПутёвкамToolStripMenuItem, списокЗаказовToolStripMenuItem }); - отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem"; - отчетыToolStripMenuItem.Size = new Size(60, 25); - отчетыToolStripMenuItem.Text = "Отчеты"; - // - // списокКомпонентовToolStripMenuItem - // - списокКомпонентовToolStripMenuItem.Name = "списокКомпонентовToolStripMenuItem"; - списокКомпонентовToolStripMenuItem.Size = new Size(216, 22); - списокКомпонентовToolStripMenuItem.Text = "Список компонентов"; - списокКомпонентовToolStripMenuItem.Click += списокКомпонентовToolStripMenuItem_Click; - // - // компонентыПоПутёвкамToolStripMenuItem - // - компонентыПоПутёвкамToolStripMenuItem.Name = "компонентыПоПутёвкамToolStripMenuItem"; - компонентыПоПутёвкамToolStripMenuItem.Size = new Size(216, 22); - компонентыПоПутёвкамToolStripMenuItem.Text = "Компоненты по путёвкам"; - компонентыПоПутёвкамToolStripMenuItem.Click += компонентыПоПутёвкамToolStripMenuItem_Click; - // - // списокЗаказовToolStripMenuItem - // - списокЗаказовToolStripMenuItem.Name = "списокЗаказовToolStripMenuItem"; - списокЗаказовToolStripMenuItem.Size = new Size(216, 22); - списокЗаказовToolStripMenuItem.Text = "Список заказов"; - списокЗаказовToolStripMenuItem.Click += списокЗаказовToolStripMenuItem_Click; + отчётыToolStripMenuItem1.Name = "отчётыToolStripMenuItem1"; + отчётыToolStripMenuItem1.Size = new Size(180, 22); + отчётыToolStripMenuItem1.Text = "Отчёты"; // // FormMain // @@ -205,9 +292,20 @@ private ToolStripDropDownButton toolStripDropDownButton1; private ToolStripMenuItem компонентыToolStripMenuItem; private ToolStripMenuItem ПутёвкиToolStripMenuItem; - private ToolStripMenuItem отчетыToolStripMenuItem; - private ToolStripMenuItem списокКомпонентовToolStripMenuItem; - private ToolStripMenuItem компонентыПоПутёвкамToolStripMenuItem; - private ToolStripMenuItem списокЗаказовToolStripMenuItem; + private ToolStripMenuItem магазиныToolStripMenuItem; + private ToolStripMenuItem operationToolStripMenuItem; + private ToolStripMenuItem transactionToolStripMenuItem; + 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 заказыToolStripMenuItem1; + private ToolStripMenuItem заказыПоГруппамToolStripMenuItem; + private ToolStripMenuItem отчётыToolStripMenuItem1; } } \ No newline at end of file diff --git a/TravelCompany/TravelCompany/FormMain.cs b/TravelCompany/TravelCompany/FormMain.cs index 744ae02..bc3ecca 100644 --- a/TravelCompany/TravelCompany/FormMain.cs +++ b/TravelCompany/TravelCompany/FormMain.cs @@ -1,16 +1,6 @@ using TravelCompanyContracts.BindingModels; using TravelCompanyContracts.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; -using TravelCompanyBusinessLogic.BusinessLogic; namespace TravelCompany.Forms { @@ -155,38 +145,89 @@ namespace TravelCompany.Forms LoadData(); } - private void списокКомпонентовToolStripMenuItem_Click(object sender, EventArgs e) + private void shopsToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormShops)); + if (service is FormShops form) + { + form.ShowDialog(); + } + } + + private void transactionToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormCreateSupply)); + if (service is FormCreateSupply form) + { + form.ShowDialog(); + } + } + + private void SellToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormSellTravels)); + if (service is FormSellTravels form) + { + form.ShowDialog(); + } + } + + private void ComponentsToolStripMenuItem_Click(object sender, EventArgs e) { using var dialog = new SaveFileDialog { Filter = "docx|*.docx" }; if (dialog.ShowDialog() == DialogResult.OK) { - _reportLogic.SaveTravelsToWordFile(new ReportBindingModel - { - FileName = dialog.FileName - }); - MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, - MessageBoxIcon.Information); + _reportLogic.SaveTravelsToWordFile(new ReportBindingModel { FileName = dialog.FileName }); + MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information); } } - private void компонентыПоПутёвкамToolStripMenuItem_Click(object sender, EventArgs e) + private void ComponentTravelToolStripMenuItem_Click(object sender, EventArgs e) { - var service = -Program.ServiceProvider?.GetService(typeof(FormReportTravelComponents)); + var service = Program.ServiceProvider?.GetService(typeof(FormReportTravelComponents)); if (service is FormReportTravelComponents form) { form.ShowDialog(); } } - private void списокЗаказовToolStripMenuItem_Click(object sender, EventArgs e) + private void OrdersToolStripMenuItem_Click(object sender, EventArgs e) { - var service = -Program.ServiceProvider?.GetService(typeof(FormReportOrders)); + var service = Program.ServiceProvider?.GetService(typeof(FormReportOrders)); if (service is FormReportOrders form) { form.ShowDialog(); } } + + private void InfoToolStripMenuItem_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 BusyShopsToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormReportShop)); + if (service is FormReportShop form) + { + form.ShowDialog(); + } + } + + private void GroupOrdersToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormReportGroupedOrders)); + if (service is FormReportGroupedOrders form) + { + form.ShowDialog(); + } + } + + } } diff --git a/TravelCompany/TravelCompany/FormReportGroupedOrders.Designer.cs b/TravelCompany/TravelCompany/FormReportGroupedOrders.Designer.cs new file mode 100644 index 0000000..b5d86a8 --- /dev/null +++ b/TravelCompany/TravelCompany/FormReportGroupedOrders.Designer.cs @@ -0,0 +1,86 @@ +namespace TravelCompany.Forms +{ + 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/TravelCompany/TravelCompany/FormReportGroupedOrders.cs b/TravelCompany/TravelCompany/FormReportGroupedOrders.cs new file mode 100644 index 0000000..2ed78e6 --- /dev/null +++ b/TravelCompany/TravelCompany/FormReportGroupedOrders.cs @@ -0,0 +1,80 @@ +using Microsoft.Extensions.Logging; +using Microsoft.Reporting.WinForms; +using TravelCompanyContracts.BindingModels; +using TravelCompanyContracts.BusinessLogicsContracts; +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 TravelCompany.Forms +{ + 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("C:\\Users\\goldfest\\Desktop\\RPP\\TravelCompany\\TravelCompany\\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/TravelCompany/TravelCompany/FormReportGroupedOrders.resx b/TravelCompany/TravelCompany/FormReportGroupedOrders.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/TravelCompany/TravelCompany/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/TravelCompany/TravelCompany/FormReportOrders.cs b/TravelCompany/TravelCompany/FormReportOrders.cs index f52301f..54284f6 100644 --- a/TravelCompany/TravelCompany/FormReportOrders.cs +++ b/TravelCompany/TravelCompany/FormReportOrders.cs @@ -29,7 +29,7 @@ namespace TravelCompany.Forms { Dock = DockStyle.Fill }; - reportViewer.LocalReport.LoadReportDefinition(new FileStream("C:\\Users\\goldfest\\Desktop\\TravelCompany\\PrecastConcretePlant\\PrecastConcretePlantView\\ReportOrders.rdlc", FileMode.Open)); + reportViewer.LocalReport.LoadReportDefinition(new FileStream("C:\\Users\\goldfest\\Desktop\\RPP\\TravelCompany\\TravelCompany\\ReportOrders.rdlc", FileMode.Open)); Controls.Clear(); Controls.Add(reportViewer); Controls.Add(panel); diff --git a/TravelCompany/TravelCompany/FormReportShop.Designer.cs b/TravelCompany/TravelCompany/FormReportShop.Designer.cs new file mode 100644 index 0000000..20e0caa --- /dev/null +++ b/TravelCompany/TravelCompany/FormReportShop.Designer.cs @@ -0,0 +1,115 @@ +namespace TravelCompany.Forms +{ + partial class FormReportShop + { + /// + /// 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(); + ColumnTravel = new DataGridViewTextBoxColumn(); + ColumnCount = new DataGridViewTextBoxColumn(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // buttonSaveToExcel + // + buttonSaveToExcel.Location = new Point(0, 4); + buttonSaveToExcel.Margin = new Padding(3, 2, 3, 2); + buttonSaveToExcel.Name = "buttonSaveToExcel"; + buttonSaveToExcel.Size = new Size(195, 22); + 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, ColumnTravel, ColumnCount }); + dataGridView.Dock = DockStyle.Bottom; + dataGridView.Location = new Point(0, 36); + dataGridView.Margin = new Padding(3, 2, 3, 2); + dataGridView.Name = "dataGridView"; + dataGridView.ReadOnly = true; + dataGridView.RowHeadersWidth = 51; + dataGridView.RowTemplate.Height = 29; + dataGridView.Size = new Size(523, 302); + dataGridView.TabIndex = 2; + // + // ColumnShop + // + ColumnShop.FillWeight = 130F; + ColumnShop.HeaderText = "Магазин"; + ColumnShop.MinimumWidth = 6; + ColumnShop.Name = "ColumnShop"; + ColumnShop.ReadOnly = true; + // + // ColumnTravel + // + ColumnTravel.FillWeight = 140F; + ColumnTravel.HeaderText = "Путевка"; + ColumnTravel.MinimumWidth = 6; + ColumnTravel.Name = "ColumnTravel"; + ColumnTravel.ReadOnly = true; + // + // ColumnCount + // + ColumnCount.FillWeight = 90F; + ColumnCount.HeaderText = "Количество"; + ColumnCount.MinimumWidth = 6; + ColumnCount.Name = "ColumnCount"; + ColumnCount.ReadOnly = true; + // + // FormReportShop + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(523, 338); + Controls.Add(buttonSaveToExcel); + Controls.Add(dataGridView); + Margin = new Padding(3, 2, 3, 2); + Name = "FormReportShop"; + Text = "Наполненость магазинов"; + Load += FormReportShop_Load; + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Button buttonSaveToExcel; + private DataGridView dataGridView; + private DataGridViewTextBoxColumn ColumnShop; + private DataGridViewTextBoxColumn ColumnTravel; + private DataGridViewTextBoxColumn ColumnCount; + } +} \ No newline at end of file diff --git a/TravelCompany/TravelCompany/FormReportShop.cs b/TravelCompany/TravelCompany/FormReportShop.cs new file mode 100644 index 0000000..72b252c --- /dev/null +++ b/TravelCompany/TravelCompany/FormReportShop.cs @@ -0,0 +1,78 @@ +using Microsoft.Extensions.Logging; +using TravelCompanyContracts.BindingModels; +using TravelCompanyContracts.BusinessLogicsContracts; +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 TravelCompany.Forms +{ + public partial class FormReportShop : Form + { + private readonly ILogger _logger; + private readonly IReportLogic _logic; + + public FormReportShop(ILogger logger, IReportLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + } + + private void FormReportShop_Load(object sender, EventArgs e) + { + try + { + var dict = _logic.GetShops(); + if (dict != null) + { + dataGridView.Rows.Clear(); + foreach (var elem in dict) + { + dataGridView.Rows.Add(new object[] { elem.ShopName, "", "" }); + foreach (var listElem in elem.Travels) + { + dataGridView.Rows.Add(new object[] { "", listElem.Item1, listElem.Item2 }); + } + dataGridView.Rows.Add(new object[] { "Итого", "", elem.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/TravelCompany/TravelCompany/FormReportShop.resx b/TravelCompany/TravelCompany/FormReportShop.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/TravelCompany/TravelCompany/FormReportShop.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/TravelCompany/TravelCompany/FormSellTravels.Designer.cs b/TravelCompany/TravelCompany/FormSellTravels.Designer.cs new file mode 100644 index 0000000..17577cf --- /dev/null +++ b/TravelCompany/TravelCompany/FormSellTravels.Designer.cs @@ -0,0 +1,124 @@ +namespace TravelCompany.Forms +{ + partial class FormSellTravels + { + /// + /// 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() + { + labelTravel = new Label(); + comboBoxTravel = new ComboBox(); + labelCount = new Label(); + textBoxCount = new TextBox(); + buttonSell = new Button(); + buttonCancel = new Button(); + SuspendLayout(); + // + // labelTravel + // + labelTravel.AutoSize = true; + labelTravel.Location = new Point(10, 10); + labelTravel.Name = "labelTravel"; + labelTravel.Size = new Size(57, 15); + labelTravel.TabIndex = 0; + labelTravel.Text = "Путёвка: "; + // + // comboBoxTravel + // + comboBoxTravel.FormattingEnabled = true; + comboBoxTravel.Location = new Point(101, 8); + comboBoxTravel.Margin = new Padding(3, 2, 3, 2); + comboBoxTravel.Name = "comboBoxTravel"; + comboBoxTravel.Size = new Size(210, 23); + comboBoxTravel.TabIndex = 1; + // + // labelCount + // + labelCount.AutoSize = true; + labelCount.Location = new Point(10, 41); + labelCount.Name = "labelCount"; + labelCount.Size = new Size(78, 15); + labelCount.TabIndex = 2; + labelCount.Text = "Количество: "; + // + // textBoxCount + // + textBoxCount.Location = new Point(101, 39); + textBoxCount.Margin = new Padding(3, 2, 3, 2); + textBoxCount.Name = "textBoxCount"; + textBoxCount.Size = new Size(210, 23); + textBoxCount.TabIndex = 3; + // + // buttonSell + // + buttonSell.Location = new Point(112, 74); + buttonSell.Margin = new Padding(3, 2, 3, 2); + buttonSell.Name = "buttonSell"; + buttonSell.Size = new Size(82, 22); + buttonSell.TabIndex = 4; + buttonSell.Text = "Продать"; + buttonSell.UseVisualStyleBackColor = true; + buttonSell.Click += ButtonSell_Click; + // + // buttonCancel + // + buttonCancel.Location = new Point(212, 74); + buttonCancel.Margin = new Padding(3, 2, 3, 2); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(82, 22); + buttonCancel.TabIndex = 5; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click; + // + // FormSellTravels + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(320, 105); + Controls.Add(buttonCancel); + Controls.Add(buttonSell); + Controls.Add(textBoxCount); + Controls.Add(labelCount); + Controls.Add(comboBoxTravel); + Controls.Add(labelTravel); + Margin = new Padding(3, 2, 3, 2); + Name = "FormSellTravels"; + Text = "Продажа путёвок"; + Load += FormSellingTravel_Load; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label labelTravel; + private ComboBox comboBoxTravel; + private Label labelCount; + private TextBox textBoxCount; + private Button buttonSell; + private Button buttonCancel; + } +} \ No newline at end of file diff --git a/TravelCompany/TravelCompany/FormSellTravels.cs b/TravelCompany/TravelCompany/FormSellTravels.cs new file mode 100644 index 0000000..84128c5 --- /dev/null +++ b/TravelCompany/TravelCompany/FormSellTravels.cs @@ -0,0 +1,88 @@ +using Microsoft.Extensions.Logging; +using TravelCompanyContracts.BusinessLogicsContracts; +using TravelCompanyContracts.SearchModels; +using TravelCompanyContracts.StoragesContracts; +using TravelCompanyContracts.ViewModels; +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 TravelCompany.Forms +{ + public partial class FormSellTravels : Form + { + private readonly ILogger _logger; + private readonly ITravelLogic _logicP; + private readonly IShopLogic _logicS; + private List _TravelList = new List(); + + public FormSellTravels(ILogger logger, ITravelLogic logicP, IShopLogic logicS) + { + InitializeComponent(); + _logger = logger; + _logicP = logicP; + _logicS = logicS; + } + + private void FormSellingTravel_Load(object sender, EventArgs e) + { + _TravelList = _logicP.ReadList(null); + if (_TravelList != null) + { + comboBoxTravel.DisplayMember = "TravelName"; + comboBoxTravel.ValueMember = "Id"; + comboBoxTravel.DataSource = _TravelList; + comboBoxTravel.SelectedItem = null; + _logger.LogInformation("Загрузка путёвок для продажи"); + } + } + + private void ButtonSell_Click(object sender, EventArgs e) + { + if (comboBoxTravel.SelectedValue == null) + { + MessageBox.Show("Выберите пиццу", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + _logger.LogInformation("Создание покупки"); + try + { + bool resout = _logicS.Sale(new SupplySearchModel + { + TravelId = Convert.ToInt32(comboBoxTravel.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(); + } + } +} \ No newline at end of file diff --git a/TravelCompany/TravelCompany/FormSellTravels.resx b/TravelCompany/TravelCompany/FormSellTravels.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/TravelCompany/TravelCompany/FormSellTravels.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/TravelCompany/TravelCompany/FormShop.Designer.cs b/TravelCompany/TravelCompany/FormShop.Designer.cs new file mode 100644 index 0000000..3321d32 --- /dev/null +++ b/TravelCompany/TravelCompany/FormShop.Designer.cs @@ -0,0 +1,222 @@ +namespace TravelCompany.Forms +{ + 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() + { + this.labelName = new System.Windows.Forms.Label(); + this.textBoxName = new System.Windows.Forms.TextBox(); + this.textBoxAdress = new System.Windows.Forms.TextBox(); + this.labelAdress = new System.Windows.Forms.Label(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.buttonSave = new System.Windows.Forms.Button(); + this.dataGridView = new System.Windows.Forms.DataGridView(); + this.id = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.TravelName = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Count = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.label1 = new System.Windows.Forms.Label(); + this.dateTimeOpen = new System.Windows.Forms.DateTimePicker(); + this.label2 = new System.Windows.Forms.Label(); + this.numericUpTravelMaxCount = new System.Windows.Forms.NumericUpDown(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpTravelMaxCount)).BeginInit(); + this.SuspendLayout(); + // + // labelName + // + this.labelName.AutoSize = true; + this.labelName.Location = new System.Drawing.Point(11, 15); + this.labelName.Name = "labelName"; + this.labelName.Size = new System.Drawing.Size(84, 20); + this.labelName.TabIndex = 0; + this.labelName.Text = "Название: "; + // + // textBoxName + // + this.textBoxName.Location = new System.Drawing.Point(102, 12); + this.textBoxName.Name = "textBoxName"; + this.textBoxName.Size = new System.Drawing.Size(276, 27); + this.textBoxName.TabIndex = 1; + // + // textBoxAdress + // + this.textBoxAdress.Location = new System.Drawing.Point(102, 59); + this.textBoxAdress.Name = "textBoxAdress"; + this.textBoxAdress.Size = new System.Drawing.Size(427, 27); + this.textBoxAdress.TabIndex = 3; + // + // labelAdress + // + this.labelAdress.AutoSize = true; + this.labelAdress.Location = new System.Drawing.Point(11, 61); + this.labelAdress.Name = "labelAdress"; + this.labelAdress.Size = new System.Drawing.Size(58, 20); + this.labelAdress.TabIndex = 2; + this.labelAdress.Text = "Адрес: "; + // + // buttonCancel + // + this.buttonCancel.Location = new System.Drawing.Point(451, 457); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(130, 44); + this.buttonCancel.TabIndex = 5; + this.buttonCancel.Text = "Отмена"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); + // + // buttonSave + // + this.buttonSave.Location = new System.Drawing.Point(315, 457); + this.buttonSave.Name = "buttonSave"; + this.buttonSave.Size = new System.Drawing.Size(130, 44); + this.buttonSave.TabIndex = 6; + this.buttonSave.Text = "Сохранить"; + this.buttonSave.UseVisualStyleBackColor = true; + this.buttonSave.Click += new System.EventHandler(this.buttonSave_Click); + // + // dataGridView + // + this.dataGridView.AllowUserToAddRows = false; + this.dataGridView.AllowUserToDeleteRows = false; + this.dataGridView.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; + this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.id, + this.TravelName, + this.Count}); + this.dataGridView.Location = new System.Drawing.Point(12, 185); + this.dataGridView.Name = "dataGridView"; + this.dataGridView.ReadOnly = true; + this.dataGridView.RowHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.None; + this.dataGridView.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.AutoSizeToDisplayedHeaders; + this.dataGridView.RowTemplate.Height = 29; + this.dataGridView.Size = new System.Drawing.Size(569, 266); + this.dataGridView.TabIndex = 7; + // + // id + // + this.id.HeaderText = "id"; + this.id.MinimumWidth = 6; + this.id.Name = "id"; + this.id.ReadOnly = true; + this.id.Visible = false; + // + // TravelName + // + this.TravelName.HeaderText = "Пицца"; + this.TravelName.MinimumWidth = 6; + this.TravelName.Name = "TravelName"; + this.TravelName.ReadOnly = true; + // + // Count + // + this.Count.HeaderText = "Количество"; + this.Count.MinimumWidth = 6; + this.Count.Name = "Count"; + this.Count.ReadOnly = true; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(12, 103); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(110, 20); + this.label1.TabIndex = 8; + this.label1.Text = "Дата открытия"; + // + // dateTimeOpen + // + this.dateTimeOpen.Location = new System.Drawing.Point(128, 103); + this.dateTimeOpen.Name = "dateTimeOpen"; + this.dateTimeOpen.Size = new System.Drawing.Size(401, 27); + this.dateTimeOpen.TabIndex = 9; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(12, 148); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(100, 20); + this.label2.TabIndex = 10; + this.label2.Text = "Вместимость"; + // + // numericUpTravelMaxCount + // + this.numericUpTravelMaxCount.Location = new System.Drawing.Point(128, 146); + this.numericUpTravelMaxCount.Maximum = new decimal(new int[] { + 10000, + 0, + 0, + 0}); + this.numericUpTravelMaxCount.Name = "numericUpTravelMaxCount"; + this.numericUpTravelMaxCount.Size = new System.Drawing.Size(401, 27); + this.numericUpTravelMaxCount.TabIndex = 11; + // + // FormShop + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(593, 513); + this.Controls.Add(this.numericUpTravelMaxCount); + this.Controls.Add(this.label2); + this.Controls.Add(this.dateTimeOpen); + this.Controls.Add(this.label1); + this.Controls.Add(this.dataGridView); + this.Controls.Add(this.buttonSave); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.textBoxAdress); + this.Controls.Add(this.labelAdress); + this.Controls.Add(this.textBoxName); + this.Controls.Add(this.labelName); + this.Name = "FormShop"; + this.Text = "Магазин"; + this.Load += new System.EventHandler(this.FormShop_Load); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpTravelMaxCount)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private Label labelName; + private TextBox textBoxName; + private TextBox textBoxAdress; + private Label labelAdress; + private Button buttonCancel; + private Button buttonSave; + private DataGridView dataGridView; + private DataGridViewTextBoxColumn id; + private DataGridViewTextBoxColumn TravelName; + private DataGridViewTextBoxColumn Count; + private Label label1; + private DateTimePicker dateTimeOpen; + private Label label2; + private NumericUpDown numericUpTravelMaxCount; + } +} \ No newline at end of file diff --git a/TravelCompany/TravelCompany/FormShop.cs b/TravelCompany/TravelCompany/FormShop.cs new file mode 100644 index 0000000..e177fe6 --- /dev/null +++ b/TravelCompany/TravelCompany/FormShop.cs @@ -0,0 +1,127 @@ +using TravelCompanyDataModels.Models; +using Microsoft.Extensions.Logging; +using TravelCompanyContracts.BindingModels; +using TravelCompanyContracts.BusinessLogicsContracts; +using TravelCompanyContracts.SearchModels; +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 TravelCompany.Forms +{ + public partial class FormShop : Form + { + private readonly ILogger _logger; + private readonly IShopLogic _logic; + private int? _id; + public int Id { set { _id = value; } } + private Dictionary _ShopTravels; + private DateTime? _openingDate = null; + public FormShop(ILogger logger, IShopLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + _ShopTravels = 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; + textBoxAdress.Text = view.Adress; + dateTimeOpen.Value = view.OpeningDate; + numericUpTravelMaxCount.Value = view.TravelMaxCount; + _ShopTravels = view.ShopTravels ?? new Dictionary(); + LoadData(); + } + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки магазина"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + + private void LoadData() + { + _logger.LogInformation("Загрузка изделий в магазине"); + try + { + if (_ShopTravels != null) + { + dataGridView.Rows.Clear(); + foreach (var sr in _ShopTravels) + { + dataGridView.Rows.Add(new object[] { sr.Key, sr.Value.Item1.TravelName, sr.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(textBoxAdress.Text)) + { + MessageBox.Show("Заполните адрес", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + _logger.LogInformation("Сохранение магазина"); + try + { + var model = new ShopBindingModel + { + Id = _id ?? 0, + ShopName = textBoxName.Text, + Adress = textBoxAdress.Text, + OpeningDate = dateTimeOpen.Value, + TravelMaxCount = (int)numericUpTravelMaxCount.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/TravelCompany/TravelCompany/FormShop.resx b/TravelCompany/TravelCompany/FormShop.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/TravelCompany/TravelCompany/FormShop.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/TravelCompany/TravelCompany/FormShops.Designer.cs b/TravelCompany/TravelCompany/FormShops.Designer.cs new file mode 100644 index 0000000..ddcc07f --- /dev/null +++ b/TravelCompany/TravelCompany/FormShops.Designer.cs @@ -0,0 +1,130 @@ +namespace TravelCompany.Forms +{ + 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() + { + this.ToolsPanel = new System.Windows.Forms.Panel(); + this.buttonRef = new System.Windows.Forms.Button(); + this.buttonDel = new System.Windows.Forms.Button(); + this.buttonUpd = new System.Windows.Forms.Button(); + this.buttonAdd = new System.Windows.Forms.Button(); + this.dataGridView = new System.Windows.Forms.DataGridView(); + this.ToolsPanel.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); + this.SuspendLayout(); + // + // ToolsPanel + // + this.ToolsPanel.Controls.Add(this.buttonRef); + this.ToolsPanel.Controls.Add(this.buttonDel); + this.ToolsPanel.Controls.Add(this.buttonUpd); + this.ToolsPanel.Controls.Add(this.buttonAdd); + this.ToolsPanel.Location = new System.Drawing.Point(608, 12); + this.ToolsPanel.Name = "ToolsPanel"; + this.ToolsPanel.Size = new System.Drawing.Size(180, 426); + this.ToolsPanel.TabIndex = 3; + // + // buttonRef + // + this.buttonRef.Location = new System.Drawing.Point(31, 206); + this.buttonRef.Name = "buttonRef"; + this.buttonRef.Size = new System.Drawing.Size(126, 36); + this.buttonRef.TabIndex = 3; + this.buttonRef.Text = "Обновить"; + this.buttonRef.UseVisualStyleBackColor = true; + this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click); + // + // buttonDel + // + this.buttonDel.Location = new System.Drawing.Point(31, 142); + this.buttonDel.Name = "buttonDel"; + this.buttonDel.Size = new System.Drawing.Size(126, 36); + this.buttonDel.TabIndex = 2; + this.buttonDel.Text = "Удалить"; + this.buttonDel.UseVisualStyleBackColor = true; + this.buttonDel.Click += new System.EventHandler(this.ButtonDel_Click); + // + // buttonUpd + // + this.buttonUpd.Location = new System.Drawing.Point(31, 76); + this.buttonUpd.Name = "buttonUpd"; + this.buttonUpd.Size = new System.Drawing.Size(126, 36); + this.buttonUpd.TabIndex = 1; + this.buttonUpd.Text = "Изменить"; + this.buttonUpd.UseVisualStyleBackColor = true; + this.buttonUpd.Click += new System.EventHandler(this.ButtonUpd_Click); + // + // buttonAdd + // + this.buttonAdd.Location = new System.Drawing.Point(31, 16); + this.buttonAdd.Name = "buttonAdd"; + this.buttonAdd.Size = new System.Drawing.Size(126, 36); + this.buttonAdd.TabIndex = 0; + this.buttonAdd.Text = "Добавить"; + this.buttonAdd.UseVisualStyleBackColor = true; + this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click); + // + // dataGridView + // + this.dataGridView.AllowUserToAddRows = false; + this.dataGridView.AllowUserToDeleteRows = false; + this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView.Location = new System.Drawing.Point(12, 12); + this.dataGridView.Name = "dataGridView"; + this.dataGridView.ReadOnly = true; + this.dataGridView.RowHeadersWidth = 51; + this.dataGridView.RowTemplate.Height = 29; + this.dataGridView.Size = new System.Drawing.Size(590, 426); + this.dataGridView.TabIndex = 2; + // + // FormShops + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 450); + this.Controls.Add(this.ToolsPanel); + this.Controls.Add(this.dataGridView); + this.Name = "FormShops"; + this.Text = "Магазины"; + this.Load += new System.EventHandler(this.FormShops_Load); + this.ToolsPanel.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private Panel ToolsPanel; + private Button buttonRef; + private Button buttonDel; + private Button buttonUpd; + private Button buttonAdd; + private DataGridView dataGridView; + } +} \ No newline at end of file diff --git a/TravelCompany/TravelCompany/FormShops.cs b/TravelCompany/TravelCompany/FormShops.cs new file mode 100644 index 0000000..14dc763 --- /dev/null +++ b/TravelCompany/TravelCompany/FormShops.cs @@ -0,0 +1,117 @@ +using Microsoft.Extensions.Logging; +using TravelCompany; +using TravelCompanyContracts.BindingModels; +using TravelCompanyContracts.BusinessLogicsContracts; +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 TravelCompany.Forms +{ + 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["ShopTravels"].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 ButtonUpd_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 ButtonDel_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 ButtonRef_Click(object sender, EventArgs e) + { + LoadData(); + } + } +} diff --git a/TravelCompany/TravelCompany/FormShops.resx b/TravelCompany/TravelCompany/FormShops.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/TravelCompany/TravelCompany/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/TravelCompany/TravelCompany/Program.cs b/TravelCompany/TravelCompany/Program.cs index 0603102..28402d3 100644 --- a/TravelCompany/TravelCompany/Program.cs +++ b/TravelCompany/TravelCompany/Program.cs @@ -5,6 +5,7 @@ using TravelCompanyDatabaseImplement.Implements; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using NLog.Extensions.Logging; +using TravelCompanyBusinessLogic.BusinessLogics; using TravelCompanyBusinessLogic.OfficePackage.Implements; using TravelCompanyBusinessLogic.OfficePackage; @@ -53,11 +54,19 @@ namespace TravelCompany.Forms services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + 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/TravelCompany/TravelCompany/ReportGroupedOrders.rdlc b/TravelCompany/TravelCompany/ReportGroupedOrders.rdlc new file mode 100644 index 0000000..34bd985 --- /dev/null +++ b/TravelCompany/TravelCompany/ReportGroupedOrders.rdlc @@ -0,0 +1,441 @@ + + + 0 + + + + System.Data.DataSet + /* Local Connection */ + + 20791c83-cee8-4a38-bbd0-245fc17cefb3 + + + + + + TravelCompanyContractsViewModels + /* Local Query */ + + + + Date + System.DateTime + + + OrdersCount + System.Int32 + + + OrdersSum + System.Decimal + + + + TravelCompanyContracts.ViewModels + ReportGroupOrdersViewModel + TravelCompanyContracts.ViewModels.ReportGroupOrdersViewModel, TravelCompanyContracts, 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 + @@ -235,6 +235,38 @@ + + + + true + true + + + + + Статус Заказа + + + + + + 2pt + 2pt + 2pt + 2pt + + + + @@ -267,38 +299,6 @@ - - - - true - true - - - - - Статус - - - - - - 2pt - 2pt - 2pt - 2pt - - - - @@ -398,21 +398,21 @@ - + true true - =Fields!Sum.Value + =Fields!OrderStatus.Value