From 2a2d3d1845b286b2df7c9f63960ef7779629e3c5 Mon Sep 17 00:00:00 2001 From: Oleg Shabunov Date: Fri, 19 Apr 2024 23:21:23 +0400 Subject: [PATCH] Forms --- AutoWorkshopView/Forms/FormMail.Designer.cs | 68 ++++ AutoWorkshopView/Forms/FormMail.cs | 47 +++ AutoWorkshopView/Forms/FormMail.resx | 120 +++++++ AutoWorkshopView/MainForm.Designer.cs | 357 ++++++++++---------- AutoWorkshopView/MainForm.cs | 15 +- 5 files changed, 431 insertions(+), 176 deletions(-) create mode 100644 AutoWorkshopView/Forms/FormMail.Designer.cs create mode 100644 AutoWorkshopView/Forms/FormMail.cs create mode 100644 AutoWorkshopView/Forms/FormMail.resx diff --git a/AutoWorkshopView/Forms/FormMail.Designer.cs b/AutoWorkshopView/Forms/FormMail.Designer.cs new file mode 100644 index 0000000..3857bf9 --- /dev/null +++ b/AutoWorkshopView/Forms/FormMail.Designer.cs @@ -0,0 +1,68 @@ +namespace AutoWorkshopView.Forms +{ + partial class FormMail + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + DataGridView = new DataGridView(); + ((System.ComponentModel.ISupportInitialize)DataGridView).BeginInit(); + SuspendLayout(); + // + // DataGridView + // + DataGridView.AllowUserToAddRows = false; + DataGridView.AllowUserToDeleteRows = false; + DataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + DataGridView.Dock = DockStyle.Fill; + DataGridView.Location = new Point(0, 0); + 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(688, 202); + DataGridView.TabIndex = 0; + // + // FormMail + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(688, 202); + Controls.Add(DataGridView); + Margin = new Padding(3, 2, 3, 2); + Name = "FormMail"; + Text = "Письма"; + Load += FormMail_Load; + ((System.ComponentModel.ISupportInitialize)DataGridView).EndInit(); + ResumeLayout(false); + } + + #endregion + + private DataGridView DataGridView; + } +} \ No newline at end of file diff --git a/AutoWorkshopView/Forms/FormMail.cs b/AutoWorkshopView/Forms/FormMail.cs new file mode 100644 index 0000000..0b75716 --- /dev/null +++ b/AutoWorkshopView/Forms/FormMail.cs @@ -0,0 +1,47 @@ +using AutoWorkshopContracts.BusinessLogicContracts; +using Microsoft.Extensions.Logging; + +namespace AutoWorkshopView.Forms +{ + public partial class FormMail : Form + { + private readonly ILogger _logger; + private readonly IMessageInfoLogic _messageLogic; + + public FormMail(ILogger Logger, IMessageInfoLogic MessageLogic) + { + InitializeComponent(); + + _logger = Logger; + _messageLogic = MessageLogic; + } + + private void LoadData() + { + try + { + var List = _messageLogic.ReadList(null); + + if (List != null) + { + DataGridView.DataSource = List; + DataGridView.Columns["MessageId"].Visible = false; + DataGridView.Columns["ClientId"].Visible = false; + DataGridView.Columns["Body"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + } + + _logger.LogInformation("Загрузка почтовых собщений"); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки почтовых сообщений"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void FormMail_Load(object sender, EventArgs e) + { + LoadData(); + } + } +} diff --git a/AutoWorkshopView/Forms/FormMail.resx b/AutoWorkshopView/Forms/FormMail.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/AutoWorkshopView/Forms/FormMail.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/AutoWorkshopView/MainForm.Designer.cs b/AutoWorkshopView/MainForm.Designer.cs index 773454d..524d01e 100644 --- a/AutoWorkshopView/MainForm.Designer.cs +++ b/AutoWorkshopView/MainForm.Designer.cs @@ -20,182 +20,190 @@ 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() - { - MenuStrip = new MenuStrip(); - ToolStripMenu = new ToolStripMenuItem(); - ComponentsStripMenuItem = new ToolStripMenuItem(); - RepairStripMenuItem = new ToolStripMenuItem(); - ClientsToolStripMenuItem = new ToolStripMenuItem(); - ImplementersToolStripMenuItem = new ToolStripMenuItem(); - ReportsToolStripMenuItem = new ToolStripMenuItem(); - ComponentsToolStripMenuItem1 = new ToolStripMenuItem(); - ComponentRepairToolStripMenuItem1 = new ToolStripMenuItem(); - OrdersToolStripMenuItem = new ToolStripMenuItem(); - WorkStartToolStripMenuItem = new ToolStripMenuItem(); - DataGridView = new DataGridView(); - CreateOrderButton = new Button(); - IssuedButton = new Button(); - RefreshButton = new Button(); - MenuStrip.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)DataGridView).BeginInit(); - SuspendLayout(); - // - // MenuStrip - // - MenuStrip.ImageScalingSize = new Size(20, 20); - MenuStrip.Items.AddRange(new ToolStripItem[] { ToolStripMenu, ReportsToolStripMenuItem, WorkStartToolStripMenuItem }); - MenuStrip.Location = new Point(0, 0); - MenuStrip.Name = "MenuStrip"; - MenuStrip.Padding = new Padding(5, 2, 0, 2); - MenuStrip.Size = new Size(1356, 24); - MenuStrip.TabIndex = 0; - MenuStrip.Text = "TopMenuStrip"; - // - // ToolStripMenu - // - ToolStripMenu.DropDownItems.AddRange(new ToolStripItem[] { ComponentsStripMenuItem, RepairStripMenuItem, ClientsToolStripMenuItem, ImplementersToolStripMenuItem }); - ToolStripMenu.Name = "ToolStripMenu"; - ToolStripMenu.Size = new Size(94, 20); - ToolStripMenu.Text = "Справочники"; - // - // ComponentsStripMenuItem - // - ComponentsStripMenuItem.Name = "ComponentsStripMenuItem"; - ComponentsStripMenuItem.Size = new Size(149, 22); - ComponentsStripMenuItem.Text = "Компоненты"; - ComponentsStripMenuItem.Click += ComponentsStripMenuItem_Click; - // - // RepairStripMenuItem - // - RepairStripMenuItem.Name = "RepairStripMenuItem"; - RepairStripMenuItem.Size = new Size(149, 22); - RepairStripMenuItem.Text = "Ремонты"; - RepairStripMenuItem.Click += RepairsStripMenuItem_Click; - // - // ClientsToolStripMenuItem - // - ClientsToolStripMenuItem.Name = "ClientsToolStripMenuItem"; - ClientsToolStripMenuItem.Size = new Size(149, 22); - ClientsToolStripMenuItem.Text = "Клиенты"; - ClientsToolStripMenuItem.Click += ClientsToolStripMenuItem_Click; - // - // ImplementersToolStripMenuItem - // - ImplementersToolStripMenuItem.Name = "ImplementersToolStripMenuItem"; - ImplementersToolStripMenuItem.Size = new Size(149, 22); - ImplementersToolStripMenuItem.Text = "Исполнители"; - ImplementersToolStripMenuItem.Click += EmployersToolStripMenuItem_Click; - // - // ReportsToolStripMenuItem - // - ReportsToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { ComponentsToolStripMenuItem1, ComponentRepairToolStripMenuItem1, OrdersToolStripMenuItem }); - ReportsToolStripMenuItem.Name = "ReportsToolStripMenuItem"; - ReportsToolStripMenuItem.Size = new Size(60, 20); - ReportsToolStripMenuItem.Text = "Отчёты"; - // - // ComponentsToolStripMenuItem1 - // - ComponentsToolStripMenuItem1.Name = "ComponentsToolStripMenuItem1"; - ComponentsToolStripMenuItem1.Size = new Size(210, 22); - ComponentsToolStripMenuItem1.Text = "Ремонты"; - ComponentsToolStripMenuItem1.Click += ComponentsToolStripMenuItem_Click; - // - // ComponentRepairToolStripMenuItem1 - // - ComponentRepairToolStripMenuItem1.Name = "ComponentRepairToolStripMenuItem1"; - ComponentRepairToolStripMenuItem1.Size = new Size(210, 22); - ComponentRepairToolStripMenuItem1.Text = "Ремонт с компонентами"; - ComponentRepairToolStripMenuItem1.Click += ComponentRepairToolStripMenuItem_Click; - // - // OrdersToolStripMenuItem - // - OrdersToolStripMenuItem.Name = "OrdersToolStripMenuItem"; - OrdersToolStripMenuItem.Size = new Size(210, 22); - OrdersToolStripMenuItem.Text = "Заказы"; - OrdersToolStripMenuItem.Click += OrdersToolStripMenuItem_Click; - // - // WorkStartToolStripMenuItem - // - WorkStartToolStripMenuItem.Name = "WorkStartToolStripMenuItem"; - WorkStartToolStripMenuItem.Size = new Size(92, 20); - WorkStartToolStripMenuItem.Text = "Запуск работ"; - WorkStartToolStripMenuItem.Click += StartWorkToolStripMenuItem_Click; - // - // DataGridView - // - DataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; - DataGridView.Location = new Point(10, 23); - DataGridView.Margin = new Padding(3, 2, 3, 2); - DataGridView.Name = "DataGridView"; - DataGridView.RowHeadersWidth = 51; - DataGridView.Size = new Size(1101, 358); - DataGridView.TabIndex = 1; - // - // CreateOrderButton - // - CreateOrderButton.Location = new Point(1117, 26); - CreateOrderButton.Margin = new Padding(3, 2, 3, 2); - CreateOrderButton.Name = "CreateOrderButton"; - CreateOrderButton.Size = new Size(227, 30); - CreateOrderButton.TabIndex = 2; - CreateOrderButton.Text = "Создать заказ"; - CreateOrderButton.UseVisualStyleBackColor = true; - CreateOrderButton.Click += CreateOrderButton_Click; - // - // IssuedButton - // - IssuedButton.Location = new Point(1117, 70); - IssuedButton.Margin = new Padding(3, 2, 3, 2); - IssuedButton.Name = "IssuedButton"; - IssuedButton.Size = new Size(227, 30); - IssuedButton.TabIndex = 5; - IssuedButton.Text = "Заказ выдан"; - IssuedButton.UseVisualStyleBackColor = true; - IssuedButton.Click += OrderDeliveredButton_Click; - // - // RefreshButton - // - RefreshButton.Location = new Point(1117, 114); - RefreshButton.Margin = new Padding(3, 2, 3, 2); - RefreshButton.Name = "RefreshButton"; - RefreshButton.Size = new Size(227, 30); - RefreshButton.TabIndex = 6; - RefreshButton.Text = "Обновить"; - RefreshButton.UseVisualStyleBackColor = true; - RefreshButton.Click += RefreshButton_Click; - // - // MainForm - // - AutoScaleDimensions = new SizeF(7F, 15F); - AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(1356, 392); - Controls.Add(RefreshButton); - Controls.Add(IssuedButton); - Controls.Add(CreateOrderButton); - Controls.Add(DataGridView); - Controls.Add(MenuStrip); - MainMenuStrip = MenuStrip; - Margin = new Padding(3, 2, 3, 2); - Name = "MainForm"; - Text = "Основная форма"; - Load += MainForm_Load; - MenuStrip.ResumeLayout(false); - MenuStrip.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)DataGridView).EndInit(); - ResumeLayout(false); - PerformLayout(); - } + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + MenuStrip = new MenuStrip(); + ToolStripMenu = new ToolStripMenuItem(); + ComponentsStripMenuItem = new ToolStripMenuItem(); + RepairStripMenuItem = new ToolStripMenuItem(); + ClientsToolStripMenuItem = new ToolStripMenuItem(); + ImplementersToolStripMenuItem = new ToolStripMenuItem(); + ReportsToolStripMenuItem = new ToolStripMenuItem(); + ComponentsToolStripMenuItem1 = new ToolStripMenuItem(); + ComponentRepairToolStripMenuItem1 = new ToolStripMenuItem(); + OrdersToolStripMenuItem = new ToolStripMenuItem(); + WorkStartToolStripMenuItem = new ToolStripMenuItem(); + MailToolStripMenuItem = new ToolStripMenuItem(); + DataGridView = new DataGridView(); + CreateOrderButton = new Button(); + IssuedButton = new Button(); + RefreshButton = new Button(); + MenuStrip.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)DataGridView).BeginInit(); + SuspendLayout(); + // + // MenuStrip + // + MenuStrip.ImageScalingSize = new Size(20, 20); + MenuStrip.Items.AddRange(new ToolStripItem[] { ToolStripMenu, ReportsToolStripMenuItem, WorkStartToolStripMenuItem, MailToolStripMenuItem }); + MenuStrip.Location = new Point(0, 0); + MenuStrip.Name = "MenuStrip"; + MenuStrip.Padding = new Padding(5, 2, 0, 2); + MenuStrip.Size = new Size(1356, 24); + MenuStrip.TabIndex = 0; + MenuStrip.Text = "TopMenuStrip"; + // + // ToolStripMenu + // + ToolStripMenu.DropDownItems.AddRange(new ToolStripItem[] { ComponentsStripMenuItem, RepairStripMenuItem, ClientsToolStripMenuItem, ImplementersToolStripMenuItem }); + ToolStripMenu.Name = "ToolStripMenu"; + ToolStripMenu.Size = new Size(94, 20); + ToolStripMenu.Text = "Справочники"; + // + // ComponentsStripMenuItem + // + ComponentsStripMenuItem.Name = "ComponentsStripMenuItem"; + ComponentsStripMenuItem.Size = new Size(149, 22); + ComponentsStripMenuItem.Text = "Компоненты"; + ComponentsStripMenuItem.Click += ComponentsStripMenuItem_Click; + // + // RepairStripMenuItem + // + RepairStripMenuItem.Name = "RepairStripMenuItem"; + RepairStripMenuItem.Size = new Size(149, 22); + RepairStripMenuItem.Text = "Ремонты"; + RepairStripMenuItem.Click += RepairsStripMenuItem_Click; + // + // ClientsToolStripMenuItem + // + ClientsToolStripMenuItem.Name = "ClientsToolStripMenuItem"; + ClientsToolStripMenuItem.Size = new Size(149, 22); + ClientsToolStripMenuItem.Text = "Клиенты"; + ClientsToolStripMenuItem.Click += ClientsToolStripMenuItem_Click; + // + // ImplementersToolStripMenuItem + // + ImplementersToolStripMenuItem.Name = "ImplementersToolStripMenuItem"; + ImplementersToolStripMenuItem.Size = new Size(149, 22); + ImplementersToolStripMenuItem.Text = "Исполнители"; + ImplementersToolStripMenuItem.Click += EmployersToolStripMenuItem_Click; + // + // ReportsToolStripMenuItem + // + ReportsToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { ComponentsToolStripMenuItem1, ComponentRepairToolStripMenuItem1, OrdersToolStripMenuItem }); + ReportsToolStripMenuItem.Name = "ReportsToolStripMenuItem"; + ReportsToolStripMenuItem.Size = new Size(60, 20); + ReportsToolStripMenuItem.Text = "Отчёты"; + // + // ComponentsToolStripMenuItem1 + // + ComponentsToolStripMenuItem1.Name = "ComponentsToolStripMenuItem1"; + ComponentsToolStripMenuItem1.Size = new Size(210, 22); + ComponentsToolStripMenuItem1.Text = "Ремонты"; + ComponentsToolStripMenuItem1.Click += ComponentsToolStripMenuItem_Click; + // + // ComponentRepairToolStripMenuItem1 + // + ComponentRepairToolStripMenuItem1.Name = "ComponentRepairToolStripMenuItem1"; + ComponentRepairToolStripMenuItem1.Size = new Size(210, 22); + ComponentRepairToolStripMenuItem1.Text = "Ремонт с компонентами"; + ComponentRepairToolStripMenuItem1.Click += ComponentRepairToolStripMenuItem_Click; + // + // OrdersToolStripMenuItem + // + OrdersToolStripMenuItem.Name = "OrdersToolStripMenuItem"; + OrdersToolStripMenuItem.Size = new Size(210, 22); + OrdersToolStripMenuItem.Text = "Заказы"; + OrdersToolStripMenuItem.Click += OrdersToolStripMenuItem_Click; + // + // WorkStartToolStripMenuItem + // + WorkStartToolStripMenuItem.Name = "WorkStartToolStripMenuItem"; + WorkStartToolStripMenuItem.Size = new Size(92, 20); + WorkStartToolStripMenuItem.Text = "Запуск работ"; + WorkStartToolStripMenuItem.Click += StartWorkToolStripMenuItem_Click; + // + // MailToolStripMenuItem + // + MailToolStripMenuItem.Name = "MailToolStripMenuItem"; + MailToolStripMenuItem.Size = new Size(53, 20); + MailToolStripMenuItem.Text = "Почта"; + MailToolStripMenuItem.Click += MailToolStripMenuItem_Click; + // + // DataGridView + // + DataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + DataGridView.Location = new Point(10, 23); + DataGridView.Margin = new Padding(3, 2, 3, 2); + DataGridView.Name = "DataGridView"; + DataGridView.RowHeadersWidth = 51; + DataGridView.Size = new Size(1101, 358); + DataGridView.TabIndex = 1; + // + // CreateOrderButton + // + CreateOrderButton.Location = new Point(1117, 26); + CreateOrderButton.Margin = new Padding(3, 2, 3, 2); + CreateOrderButton.Name = "CreateOrderButton"; + CreateOrderButton.Size = new Size(227, 30); + CreateOrderButton.TabIndex = 2; + CreateOrderButton.Text = "Создать заказ"; + CreateOrderButton.UseVisualStyleBackColor = true; + CreateOrderButton.Click += CreateOrderButton_Click; + // + // IssuedButton + // + IssuedButton.Location = new Point(1117, 70); + IssuedButton.Margin = new Padding(3, 2, 3, 2); + IssuedButton.Name = "IssuedButton"; + IssuedButton.Size = new Size(227, 30); + IssuedButton.TabIndex = 5; + IssuedButton.Text = "Заказ выдан"; + IssuedButton.UseVisualStyleBackColor = true; + IssuedButton.Click += OrderDeliveredButton_Click; + // + // RefreshButton + // + RefreshButton.Location = new Point(1117, 114); + RefreshButton.Margin = new Padding(3, 2, 3, 2); + RefreshButton.Name = "RefreshButton"; + RefreshButton.Size = new Size(227, 30); + RefreshButton.TabIndex = 6; + RefreshButton.Text = "Обновить"; + RefreshButton.UseVisualStyleBackColor = true; + RefreshButton.Click += RefreshButton_Click; + // + // MainForm + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(1356, 392); + Controls.Add(RefreshButton); + Controls.Add(IssuedButton); + Controls.Add(CreateOrderButton); + Controls.Add(DataGridView); + Controls.Add(MenuStrip); + MainMenuStrip = MenuStrip; + Margin = new Padding(3, 2, 3, 2); + Name = "MainForm"; + Text = "Основная форма"; + Load += MainForm_Load; + MenuStrip.ResumeLayout(false); + MenuStrip.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)DataGridView).EndInit(); + ResumeLayout(false); + PerformLayout(); + } - #endregion + #endregion - private MenuStrip MenuStrip; + private MenuStrip MenuStrip; private ToolStripMenuItem ToolStripMenu; private ToolStripMenuItem ComponentsStripMenuItem; private ToolStripMenuItem RepairStripMenuItem; @@ -210,5 +218,6 @@ private ToolStripMenuItem ClientsToolStripMenuItem; private ToolStripMenuItem ImplementersToolStripMenuItem; private ToolStripMenuItem WorkStartToolStripMenuItem; - } + private ToolStripMenuItem MailToolStripMenuItem; + } } \ No newline at end of file diff --git a/AutoWorkshopView/MainForm.cs b/AutoWorkshopView/MainForm.cs index f4808c4..b5c7830 100644 --- a/AutoWorkshopView/MainForm.cs +++ b/AutoWorkshopView/MainForm.cs @@ -42,7 +42,8 @@ namespace AutoWorkshopView DataGridView.DataSource = List; DataGridView.Columns["RepairId"].Visible = false; DataGridView.Columns["ClientId"].Visible = false; - DataGridView.Columns["ImplementerId"].Visible = false; + DataGridView.Columns["ClientEmail"].Visible = false; + DataGridView.Columns["ImplementerId"].Visible = false; DataGridView.Columns["RepairName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; } @@ -232,5 +233,15 @@ namespace AutoWorkshopView MessageBox.Show("Процесс обработки запущен", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); } - } + + private void MailToolStripMenuItem_Click(object sender, EventArgs e) + { + var Service = Program.ServiceProvider?.GetService(typeof(FormMail)); + + if (Service is FormMail Form) + { + Form.ShowDialog(); + } + } + } }