diff --git a/TravelCompany/TravelCompany/FormMain.Designer.cs b/TravelCompany/TravelCompany/FormMain.Designer.cs index 30234c8..4e05c1b 100644 --- a/TravelCompany/TravelCompany/FormMain.Designer.cs +++ b/TravelCompany/TravelCompany/FormMain.Designer.cs @@ -1,223 +1,223 @@ namespace TravelCompanyView { - partial class FormMain - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; + partial class FormMain + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } - #region Windows Form Designer generated code + #region Windows Form Designer generated code - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormMain)); - dataGridView = new DataGridView(); - toolStrip1 = new ToolStrip(); - toolStripDropDownButton1 = new ToolStripDropDownButton(); - компонентыToolStripMenuItem = new ToolStripMenuItem(); - туристическиеПутевкиToolStripMenuItem = new ToolStripMenuItem(); - toolStripDropDownButton2 = new ToolStripDropDownButton(); - toolStripMenuItem1 = new ToolStripMenuItem(); - toolStripMenuItem2 = new ToolStripMenuItem(); - списокЗаказовToolStripMenuItem = new ToolStripMenuItem(); - buttonCreateeOrder = new Button(); - buttonTakeOrderInWork = new Button(); - buttonOrderReady = new Button(); - buttonIssuedOrder = new Button(); - buttonRefresh = new Button(); - ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); - toolStrip1.SuspendLayout(); - SuspendLayout(); - // - // dataGridView - // - dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.DisplayedCells; - dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; - dataGridView.Location = new Point(1, 31); - dataGridView.Margin = new Padding(3, 2, 3, 2); - dataGridView.Name = "dataGridView"; - dataGridView.ReadOnly = true; - dataGridView.RowHeadersWidth = 51; - dataGridView.RowTemplate.Height = 29; - dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; - dataGridView.Size = new Size(820, 427); - dataGridView.TabIndex = 0; - // - // toolStrip1 - // - toolStrip1.ImageScalingSize = new Size(20, 20); - toolStrip1.Items.AddRange(new ToolStripItem[] { toolStripDropDownButton1, toolStripDropDownButton2 }); - toolStrip1.Location = new Point(0, 0); - toolStrip1.Name = "toolStrip1"; - toolStrip1.Size = new Size(1047, 25); - toolStrip1.TabIndex = 1; - toolStrip1.Text = "toolStrip1"; - // - // toolStripDropDownButton1 - // - toolStripDropDownButton1.DisplayStyle = ToolStripItemDisplayStyle.Text; - toolStripDropDownButton1.DropDownItems.AddRange(new ToolStripItem[] { компонентыToolStripMenuItem, туристическиеПутевкиToolStripMenuItem }); - toolStripDropDownButton1.Image = (Image)resources.GetObject("toolStripDropDownButton1.Image"); - toolStripDropDownButton1.ImageTransparentColor = Color.Magenta; - toolStripDropDownButton1.Name = "toolStripDropDownButton1"; - toolStripDropDownButton1.Size = new Size(88, 22); - toolStripDropDownButton1.Text = "Справочник"; - // - // компонентыToolStripMenuItem - // - компонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem"; - компонентыToolStripMenuItem.Size = new Size(202, 22); - компонентыToolStripMenuItem.Text = "Компоненты"; - компонентыToolStripMenuItem.Click += компонентыToolStripMenuItem_Click; - // - // туристическиеПутевкиToolStripMenuItem - // - туристическиеПутевкиToolStripMenuItem.Name = "туристическиеПутевкиToolStripMenuItem"; - туристическиеПутевкиToolStripMenuItem.Size = new Size(202, 22); - туристическиеПутевкиToolStripMenuItem.Text = "Туристические путевки"; - туристическиеПутевкиToolStripMenuItem.Click += путевкиToolStripMenuItem_Click; - // - // toolStripDropDownButton2 - // - toolStripDropDownButton2.DisplayStyle = ToolStripItemDisplayStyle.Text; - toolStripDropDownButton2.DropDownItems.AddRange(new ToolStripItem[] { toolStripMenuItem1, toolStripMenuItem2, списокЗаказовToolStripMenuItem }); - toolStripDropDownButton2.Image = (Image)resources.GetObject("toolStripDropDownButton2.Image"); - toolStripDropDownButton2.ImageTransparentColor = Color.Magenta; - toolStripDropDownButton2.Name = "toolStripDropDownButton2"; - toolStripDropDownButton2.Size = new Size(61, 22); - toolStripDropDownButton2.Text = "Отчеты"; - // - // toolStripMenuItem1 - // - toolStripMenuItem1.Name = "toolStripMenuItem1"; - toolStripMenuItem1.Size = new Size(216, 22); - toolStripMenuItem1.Text = "Список компонентов"; - toolStripMenuItem1.Click += списокКомпонентовToolStripMenuItem_Click; - // - // toolStripMenuItem2 - // - toolStripMenuItem2.Name = "toolStripMenuItem2"; - toolStripMenuItem2.Size = new Size(216, 22); - toolStripMenuItem2.Text = "Компоненты по путевкам"; - toolStripMenuItem2.Click += компонентыПоПутeвкамToolStripMenuItem_Click; - // - // списокЗаказовToolStripMenuItem - // - списокЗаказовToolStripMenuItem.Name = "списокЗаказовToolStripMenuItem"; - списокЗаказовToolStripMenuItem.Size = new Size(216, 22); - списокЗаказовToolStripMenuItem.Text = "Список заказов"; - списокЗаказовToolStripMenuItem.Click += списокЗаказовToolStripMenuItem_Click; - // - // buttonCreateeOrder - // - buttonCreateeOrder.Location = new Point(869, 68); - buttonCreateeOrder.Margin = new Padding(3, 2, 3, 2); - buttonCreateeOrder.Name = "buttonCreateeOrder"; - buttonCreateeOrder.Size = new Size(136, 29); - buttonCreateeOrder.TabIndex = 2; - buttonCreateeOrder.Text = "Создать заказ"; - buttonCreateeOrder.UseVisualStyleBackColor = true; - buttonCreateeOrder.Click += buttonCreateOrder_Click; - // - // buttonTakeOrderInWork - // - buttonTakeOrderInWork.Location = new Point(869, 102); - buttonTakeOrderInWork.Margin = new Padding(3, 2, 3, 2); - buttonTakeOrderInWork.Name = "buttonTakeOrderInWork"; - buttonTakeOrderInWork.Size = new Size(136, 40); - buttonTakeOrderInWork.TabIndex = 3; - buttonTakeOrderInWork.Text = "Отдать на выполнение"; - buttonTakeOrderInWork.UseVisualStyleBackColor = true; - buttonTakeOrderInWork.Click += buttonTakeOrderInWork_Click; - // - // buttonOrderReady - // - buttonOrderReady.Location = new Point(869, 146); - buttonOrderReady.Margin = new Padding(3, 2, 3, 2); - buttonOrderReady.Name = "buttonOrderReady"; - buttonOrderReady.Size = new Size(136, 29); - buttonOrderReady.TabIndex = 4; - buttonOrderReady.Text = "Заказ готов"; - buttonOrderReady.UseVisualStyleBackColor = true; - buttonOrderReady.Click += buttonOrderReady_Click; - // - // buttonIssuedOrder - // - buttonIssuedOrder.Location = new Point(869, 180); - buttonIssuedOrder.Margin = new Padding(3, 2, 3, 2); - buttonIssuedOrder.Name = "buttonIssuedOrder"; - buttonIssuedOrder.Size = new Size(136, 29); - buttonIssuedOrder.TabIndex = 5; - buttonIssuedOrder.Text = "Заказ выдан"; - buttonIssuedOrder.UseVisualStyleBackColor = true; - buttonIssuedOrder.Click += buttonIssuedOrder_Click; - // - // buttonRefresh - // - buttonRefresh.Location = new Point(869, 214); - buttonRefresh.Margin = new Padding(3, 2, 3, 2); - buttonRefresh.Name = "buttonRefresh"; - buttonRefresh.Size = new Size(136, 29); - buttonRefresh.TabIndex = 6; - buttonRefresh.Text = "Обновить список"; - buttonRefresh.UseVisualStyleBackColor = true; - buttonRefresh.Click += buttonRefresh_Click; - // - // FormMain - // - AutoScaleDimensions = new SizeF(7F, 15F); - AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(1047, 458); - Controls.Add(buttonRefresh); - Controls.Add(buttonIssuedOrder); - Controls.Add(buttonOrderReady); - Controls.Add(buttonTakeOrderInWork); - Controls.Add(buttonCreateeOrder); - Controls.Add(toolStrip1); - Controls.Add(dataGridView); - Margin = new Padding(3, 2, 3, 2); - Name = "FormMain"; - Text = "Туристическая фирма"; - ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); - toolStrip1.ResumeLayout(false); - toolStrip1.PerformLayout(); - ResumeLayout(false); - PerformLayout(); - } + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormMain)); + dataGridView = new DataGridView(); + toolStrip1 = new ToolStrip(); + toolStripDropDownButton1 = new ToolStripDropDownButton(); + компонентыToolStripMenuItem = new ToolStripMenuItem(); + туристическиеПутевкиToolStripMenuItem = new ToolStripMenuItem(); + toolStripDropDownButton2 = new ToolStripDropDownButton(); + toolStripMenuItem1 = new ToolStripMenuItem(); + toolStripMenuItem2 = new ToolStripMenuItem(); + списокЗаказовToolStripMenuItem = new ToolStripMenuItem(); + buttonCreateeOrder = new Button(); + buttonTakeOrderInWork = new Button(); + buttonOrderReady = new Button(); + buttonIssuedOrder = new Button(); + buttonRefresh = new Button(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + toolStrip1.SuspendLayout(); + SuspendLayout(); + // + // dataGridView + // + dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.DisplayedCells; + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Location = new Point(1, 31); + dataGridView.Margin = new Padding(3, 2, 3, 2); + dataGridView.Name = "dataGridView"; + dataGridView.ReadOnly = true; + dataGridView.RowHeadersWidth = 51; + dataGridView.RowTemplate.Height = 29; + dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridView.Size = new Size(938, 427); + dataGridView.TabIndex = 0; + // + // toolStrip1 + // + toolStrip1.ImageScalingSize = new Size(20, 20); + toolStrip1.Items.AddRange(new ToolStripItem[] { toolStripDropDownButton1, toolStripDropDownButton2 }); + toolStrip1.Location = new Point(0, 0); + toolStrip1.Name = "toolStrip1"; + toolStrip1.Size = new Size(1171, 25); + toolStrip1.TabIndex = 1; + toolStrip1.Text = "toolStrip1"; + // + // toolStripDropDownButton1 + // + toolStripDropDownButton1.DisplayStyle = ToolStripItemDisplayStyle.Text; + toolStripDropDownButton1.DropDownItems.AddRange(new ToolStripItem[] { компонентыToolStripMenuItem, туристическиеПутевкиToolStripMenuItem }); + toolStripDropDownButton1.Image = (Image)resources.GetObject("toolStripDropDownButton1.Image"); + toolStripDropDownButton1.ImageTransparentColor = Color.Magenta; + toolStripDropDownButton1.Name = "toolStripDropDownButton1"; + toolStripDropDownButton1.Size = new Size(88, 22); + toolStripDropDownButton1.Text = "Справочник"; + // + // компонентыToolStripMenuItem + // + компонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem"; + компонентыToolStripMenuItem.Size = new Size(202, 22); + компонентыToolStripMenuItem.Text = "Компоненты"; + компонентыToolStripMenuItem.Click += компонентыToolStripMenuItem_Click; + // + // туристическиеПутевкиToolStripMenuItem + // + туристическиеПутевкиToolStripMenuItem.Name = "туристическиеПутевкиToolStripMenuItem"; + туристическиеПутевкиToolStripMenuItem.Size = new Size(202, 22); + туристическиеПутевкиToolStripMenuItem.Text = "Туристические путевки"; + туристическиеПутевкиToolStripMenuItem.Click += путевкиToolStripMenuItem_Click; + // + // toolStripDropDownButton2 + // + toolStripDropDownButton2.DisplayStyle = ToolStripItemDisplayStyle.Text; + toolStripDropDownButton2.DropDownItems.AddRange(new ToolStripItem[] { toolStripMenuItem1, toolStripMenuItem2, списокЗаказовToolStripMenuItem }); + toolStripDropDownButton2.Image = (Image)resources.GetObject("toolStripDropDownButton2.Image"); + toolStripDropDownButton2.ImageTransparentColor = Color.Magenta; + toolStripDropDownButton2.Name = "toolStripDropDownButton2"; + toolStripDropDownButton2.Size = new Size(61, 22); + toolStripDropDownButton2.Text = "Отчеты"; + // + // toolStripMenuItem1 + // + toolStripMenuItem1.Name = "toolStripMenuItem1"; + toolStripMenuItem1.Size = new Size(216, 22); + toolStripMenuItem1.Text = "Список компонентов"; + toolStripMenuItem1.Click += списокКомпонентовToolStripMenuItem_Click; + // + // toolStripMenuItem2 + // + toolStripMenuItem2.Name = "toolStripMenuItem2"; + toolStripMenuItem2.Size = new Size(216, 22); + toolStripMenuItem2.Text = "Компоненты по путевкам"; + toolStripMenuItem2.Click += компонентыПоПутeвкамToolStripMenuItem_Click; + // + // списокЗаказовToolStripMenuItem + // + списокЗаказовToolStripMenuItem.Name = "списокЗаказовToolStripMenuItem"; + списокЗаказовToolStripMenuItem.Size = new Size(216, 22); + списокЗаказовToolStripMenuItem.Text = "Список заказов"; + списокЗаказовToolStripMenuItem.Click += списокЗаказовToolStripMenuItem_Click; + // + // buttonCreateeOrder + // + buttonCreateeOrder.Location = new Point(989, 75); + buttonCreateeOrder.Margin = new Padding(3, 2, 3, 2); + buttonCreateeOrder.Name = "buttonCreateeOrder"; + buttonCreateeOrder.Size = new Size(136, 29); + buttonCreateeOrder.TabIndex = 2; + buttonCreateeOrder.Text = "Создать заказ"; + buttonCreateeOrder.UseVisualStyleBackColor = true; + buttonCreateeOrder.Click += buttonCreateOrder_Click; + // + // buttonTakeOrderInWork + // + buttonTakeOrderInWork.Location = new Point(989, 109); + buttonTakeOrderInWork.Margin = new Padding(3, 2, 3, 2); + buttonTakeOrderInWork.Name = "buttonTakeOrderInWork"; + buttonTakeOrderInWork.Size = new Size(136, 40); + buttonTakeOrderInWork.TabIndex = 3; + buttonTakeOrderInWork.Text = "Отдать на выполнение"; + buttonTakeOrderInWork.UseVisualStyleBackColor = true; + buttonTakeOrderInWork.Click += buttonTakeOrderInWork_Click; + // + // buttonOrderReady + // + buttonOrderReady.Location = new Point(989, 153); + buttonOrderReady.Margin = new Padding(3, 2, 3, 2); + buttonOrderReady.Name = "buttonOrderReady"; + buttonOrderReady.Size = new Size(136, 29); + buttonOrderReady.TabIndex = 4; + buttonOrderReady.Text = "Заказ готов"; + buttonOrderReady.UseVisualStyleBackColor = true; + buttonOrderReady.Click += buttonOrderReady_Click; + // + // buttonIssuedOrder + // + buttonIssuedOrder.Location = new Point(989, 187); + buttonIssuedOrder.Margin = new Padding(3, 2, 3, 2); + buttonIssuedOrder.Name = "buttonIssuedOrder"; + buttonIssuedOrder.Size = new Size(136, 29); + buttonIssuedOrder.TabIndex = 5; + buttonIssuedOrder.Text = "Заказ выдан"; + buttonIssuedOrder.UseVisualStyleBackColor = true; + buttonIssuedOrder.Click += buttonIssuedOrder_Click; + // + // buttonRefresh + // + buttonRefresh.Location = new Point(989, 221); + buttonRefresh.Margin = new Padding(3, 2, 3, 2); + buttonRefresh.Name = "buttonRefresh"; + buttonRefresh.Size = new Size(136, 29); + buttonRefresh.TabIndex = 6; + buttonRefresh.Text = "Обновить список"; + buttonRefresh.UseVisualStyleBackColor = true; + buttonRefresh.Click += buttonRefresh_Click; + // + // FormMain + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(1171, 458); + Controls.Add(buttonRefresh); + Controls.Add(buttonIssuedOrder); + Controls.Add(buttonOrderReady); + Controls.Add(buttonTakeOrderInWork); + Controls.Add(buttonCreateeOrder); + Controls.Add(toolStrip1); + Controls.Add(dataGridView); + Margin = new Padding(3, 2, 3, 2); + Name = "FormMain"; + Text = "Туристическая фирма"; + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + toolStrip1.ResumeLayout(false); + toolStrip1.PerformLayout(); + ResumeLayout(false); + PerformLayout(); + } - #endregion + #endregion - private DataGridView dataGridView; - private ToolStrip toolStrip1; - private ToolStripDropDownButton toolStripDropDownButton1; - private ToolStripMenuItem компонентыToolStripMenuItem; - private ToolStripMenuItem туристическиеПутевкиToolStripMenuItem; - private Button buttonCreateeOrder; - private Button buttonTakeOrderInWork; - private Button buttonOrderReady; - private Button buttonIssuedOrder; - private Button buttonRefresh; - private ToolStripDropDownButton toolStripDropDownButton2; - private ToolStripMenuItem toolStripMenuItem1; - private ToolStripMenuItem toolStripMenuItem2; - private ToolStripMenuItem списокЗаказовToolStripMenuItem; - } + private DataGridView dataGridView; + private ToolStrip toolStrip1; + private ToolStripDropDownButton toolStripDropDownButton1; + private ToolStripMenuItem компонентыToolStripMenuItem; + private ToolStripMenuItem туристическиеПутевкиToolStripMenuItem; + private Button buttonCreateeOrder; + private Button buttonTakeOrderInWork; + private Button buttonOrderReady; + private Button buttonIssuedOrder; + private Button buttonRefresh; + private ToolStripDropDownButton toolStripDropDownButton2; + private ToolStripMenuItem toolStripMenuItem1; + private ToolStripMenuItem toolStripMenuItem2; + private ToolStripMenuItem списокЗаказовToolStripMenuItem; + } } \ No newline at end of file diff --git a/TravelCompany/TravelCompany/FormMain.cs b/TravelCompany/TravelCompany/FormMain.cs index 62279bc..721c9f8 100644 --- a/TravelCompany/TravelCompany/FormMain.cs +++ b/TravelCompany/TravelCompany/FormMain.cs @@ -15,178 +15,178 @@ using TravelCompanyBusinessLogic.BusinessLogic; namespace TravelCompanyView { - public partial class FormMain : Form - { - private readonly ILogger _logger; - private readonly IOrderLogic _orderLogic; - private readonly IReportLogic _reportLogic; - public FormMain(ILogger logger, IOrderLogic orderLogic, IReportLogic reportLogic) - { - InitializeComponent(); - _logger = logger; - _orderLogic = orderLogic; - _reportLogic = reportLogic; - LoadData(); - } - private void FormMain_Load(object sender, EventArgs e) - { - LoadData(); - } - private void LoadData() - { - _logger.LogInformation("Загрузка заказов"); - try - { - var list = _orderLogic.ReadList(null); + public partial class FormMain : Form + { + private readonly ILogger _logger; + private readonly IOrderLogic _orderLogic; + private readonly IReportLogic _reportLogic; + public FormMain(ILogger logger, IOrderLogic orderLogic, IReportLogic reportLogic) + { + InitializeComponent(); + _logger = logger; + _orderLogic = orderLogic; + _reportLogic = reportLogic; + LoadData(); + } + private void FormMain_Load(object sender, EventArgs e) + { + LoadData(); + } + private void LoadData() + { + _logger.LogInformation("Загрузка заказов"); + try + { + var list = _orderLogic.ReadList(null); - if (list != null) - { - dataGridView.DataSource = list; - dataGridView.Columns["TravelId"].Visible = false; - dataGridView.Columns["TravelName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; - } + if (list != null) + { + dataGridView.DataSource = list; + dataGridView.Columns["TravelId"].Visible = false; + dataGridView.Columns["TravelName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + } - _logger.LogInformation("Загрузка заказов"); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка загрузки заказов"); - } - } - private void компонентыToolStripMenuItem_Click(object sender, EventArgs e) - { - var service = Program.ServiceProvider?.GetService(typeof(FormComponents)); - if (service is FormComponents form) - { - form.ShowDialog(); - } - } - private void путевкиToolStripMenuItem_Click(object sender, EventArgs e) - { - var service = Program.ServiceProvider?.GetService(typeof(FormTravels)); + _logger.LogInformation("Загрузка заказов"); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки заказов"); + } + } + private void компонентыToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormComponents)); + if (service is FormComponents form) + { + form.ShowDialog(); + } + } + private void путевкиToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormTravels)); - if (service is FormTravels form) - { - form.ShowDialog(); - } - } - private void buttonCreateOrder_Click(object sender, EventArgs e) - { - var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder)); - if (service is FormCreateOrder form) - { - form.ShowDialog(); - LoadData(); - } - } - private void buttonTakeOrderInWork_Click(object sender, EventArgs e) - { - if (dataGridView.SelectedRows.Count == 1) - { - int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); - _logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id); - try - { - var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel - { - Id = id, - }); - if (!operationResult) - { - throw new Exception("Ошибка передачи заказа в работу"); - } - LoadData(); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка передачи заказа в работу"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - } - } - private void buttonOrderReady_Click(object sender, EventArgs e) - { - if (dataGridView.SelectedRows.Count == 1) - { - int id = - Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); - _logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'", id); - try - { - var operationResult = _orderLogic.FinishOrder(new OrderBindingModel { Id = id }); - if (!operationResult) - { - throw new Exception("Ошибка отметки о готовности заказа"); - } - LoadData(); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка отметки о готовности заказа"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - } - } - private void buttonIssuedOrder_Click(object sender, EventArgs e) - { - if (dataGridView.SelectedRows.Count == 1) - { - int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); - _logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'", id); - try - { - var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel - { - Id = id - }); - if (!operationResult) - { - throw new Exception("Ошибка отметки о выдачи заказа"); - } - _logger.LogInformation("Заказ №{id} выдан", id); - LoadData(); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка отметки о выдачи заказа"); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - } - } - private void buttonRefresh_Click(object sender, EventArgs e) - { - LoadData(); - } + if (service is FormTravels form) + { + form.ShowDialog(); + } + } + private void buttonCreateOrder_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder)); + if (service is FormCreateOrder form) + { + form.ShowDialog(); + LoadData(); + } + } + private void buttonTakeOrderInWork_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id); + try + { + var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel + { + Id = id, + }); + if (!operationResult) + { + throw new Exception("Ошибка передачи заказа в работу"); + } + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка передачи заказа в работу"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + private void buttonOrderReady_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + int id = + Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'", id); + try + { + var operationResult = _orderLogic.FinishOrder(new OrderBindingModel { Id = id }); + if (!operationResult) + { + throw new Exception("Ошибка отметки о готовности заказа"); + } + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка отметки о готовности заказа"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + private void buttonIssuedOrder_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'", id); + try + { + var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel + { + Id = id + }); + if (!operationResult) + { + throw new Exception("Ошибка отметки о выдачи заказа"); + } + _logger.LogInformation("Заказ №{id} выдан", id); + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка отметки о выдачи заказа"); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + private void buttonRefresh_Click(object sender, EventArgs e) + { + LoadData(); + } - private void списокКомпонентовToolStripMenuItem_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); - } - } + private void списокКомпонентовToolStripMenuItem_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); + } + } - private void компонентыПоПутeвкамToolStripMenuItem_Click(object sender, EventArgs e) - { - var service = Program.ServiceProvider?.GetService(typeof(FormReportTravelComponents)); - if (service is FormReportTravelComponents form) - { - form.ShowDialog(); - } - } + private void компонентыПоПутeвкамToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormReportTravelComponents)); + if (service is FormReportTravelComponents form) + { + form.ShowDialog(); + } + } - private void списокЗаказовToolStripMenuItem_Click(object sender, EventArgs e) - { - var service = Program.ServiceProvider?.GetService(typeof(FormReportOrders)); - if (service is FormReportOrders form) - { - form.ShowDialog(); - } - } - } + private void списокЗаказовToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormReportOrders)); + if (service is FormReportOrders form) + { + form.ShowDialog(); + } + } + } } diff --git a/TravelCompany/TravelCompanyContracts/ViewModels/OrderViewModel.cs b/TravelCompany/TravelCompanyContracts/ViewModels/OrderViewModel.cs index cc065aa..629e545 100644 --- a/TravelCompany/TravelCompanyContracts/ViewModels/OrderViewModel.cs +++ b/TravelCompany/TravelCompanyContracts/ViewModels/OrderViewModel.cs @@ -15,11 +15,10 @@ namespace TravelCompanyContracts.ViewModels public int TravelId { get; set; } [DisplayName("Изделие")] public string TravelName { get; set; } = string.Empty; - [DisplayName("Количество")] - public int ClientId { get; set; } [DisplayName("ФИО клиента")] public string ClientFIO { get; set; } = string.Empty; + [DisplayName("Количество")] public int Count { get; set; } [DisplayName("Сумма")] public double Sum { get; set; } diff --git a/TravelCompany/TravelCompanyDatabaseImplement/Migrations/20240326174656_InitialCreate.Designer.cs b/TravelCompany/TravelCompanyDatabaseImplement/Migrations/20240326174656_InitialCreate.Designer.cs deleted file mode 100644 index 71e5b96..0000000 --- a/TravelCompany/TravelCompanyDatabaseImplement/Migrations/20240326174656_InitialCreate.Designer.cs +++ /dev/null @@ -1,171 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using TravelCompanyDatabaseImplement; - -#nullable disable - -namespace TravelCompanyDatabaseImplement.Migrations -{ - [DbContext(typeof(TravelCompanyDataBase))] - [Migration("20240326174656_InitialCreate")] - partial class InitialCreate - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("TravelVersion", "7.0.17") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("TravelCompanyDatabaseImplement.Models.Component", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ComponentName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Cost") - .HasColumnType("float"); - - b.HasKey("Id"); - - b.ToTable("Components"); - }); - - modelBuilder.Entity("TravelCompanyDatabaseImplement.Models.Order", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Count") - .HasColumnType("int"); - - b.Property("DateCreate") - .HasColumnType("datetime2"); - - b.Property("DateImplement") - .HasColumnType("datetime2"); - - b.Property("Status") - .HasColumnType("int"); - - b.Property("Sum") - .HasColumnType("float"); - - b.Property("TravelId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("TravelId"); - - b.ToTable("Orders"); - }); - - modelBuilder.Entity("TravelCompanyDatabaseImplement.Models.Travel", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Price") - .HasColumnType("float"); - - b.Property("TravelName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("Travels"); - }); - - modelBuilder.Entity("TravelCompanyDatabaseImplement.Models.TravelComponent", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ComponentId") - .HasColumnType("int"); - - b.Property("Count") - .HasColumnType("int"); - - b.Property("TravelId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("ComponentId"); - - b.HasIndex("TravelId"); - - b.ToTable("TravelComponents"); - }); - - modelBuilder.Entity("TravelCompanyDatabaseImplement.Models.Order", b => - { - b.HasOne("TravelCompanyDatabaseImplement.Models.Travel", "Travel") - .WithMany("Orders") - .HasForeignKey("TravelId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Travel"); - }); - - modelBuilder.Entity("TravelCompanyDatabaseImplement.Models.TravelComponent", b => - { - b.HasOne("TravelCompanyDatabaseImplement.Models.Component", "Component") - .WithMany("TravelComponents") - .HasForeignKey("ComponentId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("TravelCompanyDatabaseImplement.Models.Travel", "Travel") - .WithMany("Components") - .HasForeignKey("TravelId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Component"); - - b.Navigation("Travel"); - }); - - modelBuilder.Entity("TravelCompanyDatabaseImplement.Models.Component", b => - { - b.Navigation("TravelComponents"); - }); - - modelBuilder.Entity("TravelCompanyDatabaseImplement.Models.Travel", b => - { - b.Navigation("Components"); - - b.Navigation("Orders"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/TravelCompany/TravelCompanyDatabaseImplement/Migrations/20240421173408_AddClient.cs b/TravelCompany/TravelCompanyDatabaseImplement/Migrations/20240421173408_AddClient.cs deleted file mode 100644 index 745c1ae..0000000 --- a/TravelCompany/TravelCompanyDatabaseImplement/Migrations/20240421173408_AddClient.cs +++ /dev/null @@ -1,68 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace TravelCompanyDatabaseImplement.Migrations -{ - /// - public partial class AddClient : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "ClientId", - table: "Orders", - type: "int", - nullable: false, - defaultValue: 0); - - migrationBuilder.CreateTable( - name: "Clients", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - ClientFIO = table.Column(type: "nvarchar(max)", nullable: false), - Email = table.Column(type: "nvarchar(max)", nullable: false), - Password = table.Column(type: "nvarchar(max)", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Clients", x => x.Id); - }); - - migrationBuilder.CreateIndex( - name: "IX_Orders_ClientId", - table: "Orders", - column: "ClientId"); - - migrationBuilder.AddForeignKey( - name: "FK_Orders_Clients_ClientId", - table: "Orders", - column: "ClientId", - principalTable: "Clients", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_Orders_Clients_ClientId", - table: "Orders"); - - migrationBuilder.DropTable( - name: "Clients"); - - migrationBuilder.DropIndex( - name: "IX_Orders_ClientId", - table: "Orders"); - - migrationBuilder.DropColumn( - name: "ClientId", - table: "Orders"); - } - } -} diff --git a/TravelCompany/TravelCompanyDatabaseImplement/Migrations/20240421173408_AddClient.Designer.cs b/TravelCompany/TravelCompanyDatabaseImplement/Migrations/20240421205017_InitialCreate.Designer.cs similarity index 98% rename from TravelCompany/TravelCompanyDatabaseImplement/Migrations/20240421173408_AddClient.Designer.cs rename to TravelCompany/TravelCompanyDatabaseImplement/Migrations/20240421205017_InitialCreate.Designer.cs index fe6661f..a5e2625 100644 --- a/TravelCompany/TravelCompanyDatabaseImplement/Migrations/20240421173408_AddClient.Designer.cs +++ b/TravelCompany/TravelCompanyDatabaseImplement/Migrations/20240421205017_InitialCreate.Designer.cs @@ -12,8 +12,8 @@ using TravelCompanyDatabaseImplement; namespace TravelCompanyDatabaseImplement.Migrations { [DbContext(typeof(TravelCompanyDataBase))] - [Migration("20240421173408_AddClient")] - partial class AddClient + [Migration("20240421205017_InitialCreate")] + partial class InitialCreate { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) diff --git a/TravelCompany/TravelCompanyDatabaseImplement/Migrations/20240326174656_InitialCreate.cs b/TravelCompany/TravelCompanyDatabaseImplement/Migrations/20240421205017_InitialCreate.cs similarity index 79% rename from TravelCompany/TravelCompanyDatabaseImplement/Migrations/20240326174656_InitialCreate.cs rename to TravelCompany/TravelCompanyDatabaseImplement/Migrations/20240421205017_InitialCreate.cs index 9b1d5c0..b9f0297 100644 --- a/TravelCompany/TravelCompanyDatabaseImplement/Migrations/20240326174656_InitialCreate.cs +++ b/TravelCompany/TravelCompanyDatabaseImplement/Migrations/20240421205017_InitialCreate.cs @@ -11,6 +11,21 @@ namespace TravelCompanyDatabaseImplement.Migrations /// protected override void Up(MigrationBuilder migrationBuilder) { + migrationBuilder.CreateTable( + name: "Clients", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ClientFIO = table.Column(type: "nvarchar(max)", nullable: false), + Email = table.Column(type: "nvarchar(max)", nullable: false), + Password = table.Column(type: "nvarchar(max)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Clients", x => x.Id); + }); + migrationBuilder.CreateTable( name: "Components", columns: table => new @@ -50,11 +65,18 @@ namespace TravelCompanyDatabaseImplement.Migrations Status = table.Column(type: "int", nullable: false), DateCreate = table.Column(type: "datetime2", nullable: false), DateImplement = table.Column(type: "datetime2", nullable: true), - TravelId = table.Column(type: "int", nullable: false) + TravelId = table.Column(type: "int", nullable: false), + ClientId = table.Column(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Orders", x => x.Id); + table.ForeignKey( + name: "FK_Orders_Clients_ClientId", + column: x => x.ClientId, + principalTable: "Clients", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_Orders_Travels_TravelId", column: x => x.TravelId, @@ -90,6 +112,11 @@ namespace TravelCompanyDatabaseImplement.Migrations onDelete: ReferentialAction.Cascade); }); + migrationBuilder.CreateIndex( + name: "IX_Orders_ClientId", + table: "Orders", + column: "ClientId"); + migrationBuilder.CreateIndex( name: "IX_Orders_TravelId", table: "Orders", @@ -115,6 +142,9 @@ namespace TravelCompanyDatabaseImplement.Migrations migrationBuilder.DropTable( name: "TravelComponents"); + migrationBuilder.DropTable( + name: "Clients"); + migrationBuilder.DropTable( name: "Components"); diff --git a/TravelCompany/TravelCompanyDatabaseImplement/Models/Order.cs b/TravelCompany/TravelCompanyDatabaseImplement/Models/Order.cs index 3435598..ec40cdf 100644 --- a/TravelCompany/TravelCompanyDatabaseImplement/Models/Order.cs +++ b/TravelCompany/TravelCompanyDatabaseImplement/Models/Order.cs @@ -62,7 +62,6 @@ namespace TravelCompanyDatabaseImplement.Models public OrderViewModel GetViewModel => new() { TravelId = TravelId, - ClientId = ClientId, Count = Count, Sum = Sum, Status = Status, diff --git a/TravelCompany/TravelCompanyDatabaseImplement/TravelCompanyDataBase.cs b/TravelCompany/TravelCompanyDatabaseImplement/TravelCompanyDataBase.cs index 7a67a5f..9eae137 100644 --- a/TravelCompany/TravelCompanyDatabaseImplement/TravelCompanyDataBase.cs +++ b/TravelCompany/TravelCompanyDatabaseImplement/TravelCompanyDataBase.cs @@ -9,7 +9,7 @@ namespace TravelCompanyDatabaseImplement { if (optionsBuilder.IsConfigured == false) { - optionsBuilder.UseSqlServer(@"Data Source=PC-Anna\SQLEXPRESS;Initial Catalog=TravelCompanyDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); + optionsBuilder.UseSqlServer(@"Data Source=PC-Anna\SQLEXPRESS;Initial Catalog=TravelCompanyDatabase2;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); } base.OnConfiguring(optionsBuilder); }