PIbd22_Kamcharova_K.A_hard_lab1

This commit is contained in:
mayday 2024-06-22 16:29:31 +04:00
parent febd548e04
commit 9bec306e6a
4 changed files with 350 additions and 166 deletions

View File

@ -22,150 +22,236 @@
#region Windows Form Designer generated code #region Windows Form Designer generated code
/// <summary> /// <summary>
/// Required method for Designer support - do not modify /// Required method for Designer support - do not modify
/// the contents of this method with the code editor. /// the contents of this method with the code editor.
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
menuStrip = new MenuStrip(); menuStrip = new MenuStrip();
refbooksToolStripMenuItem = new ToolStripMenuItem(); refbooksToolStripMenuItem = new ToolStripMenuItem();
componentsToolStripMenuItem = new ToolStripMenuItem(); componentsToolStripMenuItem = new ToolStripMenuItem();
JobTypeToolStripMenuItem = new ToolStripMenuItem(); JobTypeToolStripMenuItem = new ToolStripMenuItem();
dataGridView = new DataGridView(); ClientsToolStripMenuItem = new ToolStripMenuItem();
buttonCreateOrder = new Button(); ImplementersToolStripMenuItem = new ToolStripMenuItem();
buttonTakeOrderInWork = new Button(); отчетыToolStripMenuItem = new ToolStripMenuItem();
buttonOrderReady = new Button(); listComponentsToolStripMenuItem = new ToolStripMenuItem();
buttonIssuedOrder = new Button(); componentRepairsПоИзделиямToolStripMenuItem = new ToolStripMenuItem();
buttonRef = new Button(); OrdersToolStripMenuItem = new ToolStripMenuItem();
menuStrip.SuspendLayout(); StartWorkingToolStripMenuItem = new ToolStripMenuItem();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); mailToolStripMenuItem = new ToolStripMenuItem();
SuspendLayout(); createBackUpToolStripMenuItem = new ToolStripMenuItem();
// dataGridView = new DataGridView();
// menuStrip buttonCreateOrder = new Button();
// buttonTakeOrderInWork = new Button();
menuStrip.Items.AddRange(new ToolStripItem[] { refbooksToolStripMenuItem }); buttonOrderReady = new Button();
menuStrip.Location = new Point(0, 0); buttonIssuedOrder = new Button();
menuStrip.Name = "menuStrip"; buttonRef = new Button();
menuStrip.Size = new Size(984, 24); menuStrip.SuspendLayout();
menuStrip.TabIndex = 0; ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
menuStrip.Text = "menuStrip1"; SuspendLayout();
// //
// refbooksToolStripMenuItem // menuStrip
// //
refbooksToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { componentsToolStripMenuItem, JobTypeToolStripMenuItem }); menuStrip.Items.AddRange(new ToolStripItem[] { refbooksToolStripMenuItem, отчетыToolStripMenuItem, StartWorkingToolStripMenuItem, mailToolStripMenuItem, createBackUpToolStripMenuItem });
refbooksToolStripMenuItem.Name = "refbooksToolStripMenuItem"; menuStrip.Location = new Point(0, 0);
refbooksToolStripMenuItem.Size = new Size(94, 20); menuStrip.Name = "menuStrip";
refbooksToolStripMenuItem.Text = "Справочники"; menuStrip.Size = new Size(1236, 24);
// menuStrip.TabIndex = 0;
// componentsToolStripMenuItem menuStrip.Text = "menuStrip1";
// //
componentsToolStripMenuItem.Name = "componentsToolStripMenuItem"; // refbooksToolStripMenuItem
componentsToolStripMenuItem.Size = new Size(145, 22); //
componentsToolStripMenuItem.Text = "Компоненты"; refbooksToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { componentsToolStripMenuItem, JobTypeToolStripMenuItem, ClientsToolStripMenuItem, ImplementersToolStripMenuItem });
componentsToolStripMenuItem.Click += componentsToolStripMenuItem_Click; refbooksToolStripMenuItem.Name = "refbooksToolStripMenuItem";
// refbooksToolStripMenuItem.Size = new Size(94, 20);
// JobTypeToolStripMenuItem refbooksToolStripMenuItem.Text = "Справочники";
// //
JobTypeToolStripMenuItem.Name = "JobTypeToolStripMenuItem"; // componentsToolStripMenuItem
JobTypeToolStripMenuItem.Size = new Size(145, 22); //
JobTypeToolStripMenuItem.Text = "Вид работы"; componentsToolStripMenuItem.Name = "componentsToolStripMenuItem";
JobTypeToolStripMenuItem.Click += JobTypeToolStripMenuItem_Click; componentsToolStripMenuItem.Size = new Size(149, 22);
// componentsToolStripMenuItem.Text = "Компоненты";
// dataGridView componentsToolStripMenuItem.Click += componentsToolStripMenuItem_Click;
// //
dataGridView.BackgroundColor = SystemColors.ControlLightLight; // JobTypeToolStripMenuItem
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; //
dataGridView.Location = new Point(12, 27); JobTypeToolStripMenuItem.Name = "JobTypeToolStripMenuItem";
dataGridView.Name = "dataGridView"; JobTypeToolStripMenuItem.Size = new Size(149, 22);
dataGridView.RowTemplate.Height = 25; JobTypeToolStripMenuItem.Text = "Вид работы";
dataGridView.Size = new Size(797, 341); JobTypeToolStripMenuItem.Click += JobTypeToolStripMenuItem_Click;
dataGridView.TabIndex = 1; //
// // ClientsToolStripMenuItem
// buttonCreateOrder //
// ClientsToolStripMenuItem.Name = "ClientsToolStripMenuItem";
buttonCreateOrder.Location = new Point(815, 42); ClientsToolStripMenuItem.Size = new Size(149, 22);
buttonCreateOrder.Name = "buttonCreateOrder"; ClientsToolStripMenuItem.Text = "Клиенты";
buttonCreateOrder.Size = new Size(157, 23); ClientsToolStripMenuItem.Click += ClientsToolStripMenuItem_Click;
buttonCreateOrder.TabIndex = 2; //
buttonCreateOrder.Text = "Создать заказ"; // ImplementersToolStripMenuItem
buttonCreateOrder.UseVisualStyleBackColor = true; //
buttonCreateOrder.Click += buttonCreateOrder_Click; ImplementersToolStripMenuItem.Name = "ImplementersToolStripMenuItem";
// ImplementersToolStripMenuItem.Size = new Size(149, 22);
// buttonTakeOrderInWork ImplementersToolStripMenuItem.Text = "Исполнители";
// ImplementersToolStripMenuItem.Click += ImplementersToolStripMenuItem_Click;
buttonTakeOrderInWork.Location = new Point(815, 71); //
buttonTakeOrderInWork.Name = "buttonTakeOrderInWork"; // отчетыToolStripMenuItem
buttonTakeOrderInWork.Size = new Size(157, 23); //
buttonTakeOrderInWork.TabIndex = 3; отчетыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { listComponentsToolStripMenuItem, componentRepairsПоИзделиямToolStripMenuItem, OrdersToolStripMenuItem });
buttonTakeOrderInWork.Text = "Отладить на выполнение"; отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
buttonTakeOrderInWork.UseVisualStyleBackColor = true; отчетыToolStripMenuItem.Size = new Size(60, 20);
buttonTakeOrderInWork.Click += buttonTakeOrderInWork_Click; отчетыToolStripMenuItem.Text = "Отчеты";
// //
// buttonOrderReady // listComponentsToolStripMenuItem
// //
buttonOrderReady.Location = new Point(815, 100); listComponentsToolStripMenuItem.Name = "listComponentsToolStripMenuItem";
buttonOrderReady.Name = "buttonOrderReady"; listComponentsToolStripMenuItem.Size = new Size(218, 22);
buttonOrderReady.Size = new Size(157, 23); listComponentsToolStripMenuItem.Text = "Список изделий";
buttonOrderReady.TabIndex = 4; listComponentsToolStripMenuItem.Click += listComponentsToolStripMenuItem_Click;
buttonOrderReady.Text = "Заказ готов"; //
buttonOrderReady.UseVisualStyleBackColor = true; // componentRepairsПоИзделиямToolStripMenuItem
buttonOrderReady.Click += buttonOrderReady_Click; //
// componentRepairsПоИзделиямToolStripMenuItem.Name = "componentRepairsПоИзделиямToolStripMenuItem";
// buttonIssuedOrder componentRepairsПоИзделиямToolStripMenuItem.Size = new Size(218, 22);
// componentRepairsПоИзделиямToolStripMenuItem.Text = "Компоненты по изделиям";
buttonIssuedOrder.Location = new Point(815, 129); componentRepairsПоИзделиямToolStripMenuItem.Click += componentRepairsПоИзделиямToolStripMenuItem_Click;
buttonIssuedOrder.Name = "buttonIssuedOrder"; //
buttonIssuedOrder.Size = new Size(157, 23); // OrdersToolStripMenuItem
buttonIssuedOrder.TabIndex = 5; //
buttonIssuedOrder.Text = "Заказ выдан"; OrdersToolStripMenuItem.Name = "OrdersToolStripMenuItem";
buttonIssuedOrder.UseVisualStyleBackColor = true; OrdersToolStripMenuItem.Size = new Size(218, 22);
buttonIssuedOrder.Click += buttonIssuedOrder_Click; OrdersToolStripMenuItem.Text = "Список заказов";
// OrdersToolStripMenuItem.Click += OrdersToolStripMenuItem_Click;
// buttonRef //
// // StartWorkingToolStripMenuItem
buttonRef.Location = new Point(815, 158); //
buttonRef.Name = "buttonRef"; StartWorkingToolStripMenuItem.Name = "StartWorkingToolStripMenuItem";
buttonRef.Size = new Size(157, 23); StartWorkingToolStripMenuItem.Size = new Size(92, 20);
buttonRef.TabIndex = 6; StartWorkingToolStripMenuItem.Text = "Запуск работ";
buttonRef.Text = "Обновить список"; StartWorkingToolStripMenuItem.Click += StartWorkingToolStripMenuItem_Click_1;
buttonRef.UseVisualStyleBackColor = true; //
buttonRef.Click += buttonRef_Click; // mailToolStripMenuItem
// //
// FormMain mailToolStripMenuItem.Name = "mailToolStripMenuItem";
// mailToolStripMenuItem.Size = new Size(62, 20);
AutoScaleDimensions = new SizeF(7F, 15F); mailToolStripMenuItem.Text = "Письма";
AutoScaleMode = AutoScaleMode.Font; mailToolStripMenuItem.Click += mailToolStripMenuItem_Click;
ClientSize = new Size(984, 370); //
Controls.Add(buttonRef); // createBackUpToolStripMenuItem
Controls.Add(buttonIssuedOrder); //
Controls.Add(buttonOrderReady); createBackUpToolStripMenuItem.Name = "createBackUpToolStripMenuItem";
Controls.Add(buttonTakeOrderInWork); createBackUpToolStripMenuItem.Size = new Size(97, 20);
Controls.Add(buttonCreateOrder); createBackUpToolStripMenuItem.Text = "Создать бекап";
Controls.Add(dataGridView); createBackUpToolStripMenuItem.Click += createBackUpToolStripMenuItem_Click;
Controls.Add(menuStrip); //
MainMenuStrip = menuStrip; // dataGridView
Name = "FormMain"; //
Text = "Ремонтные работы"; dataGridView.BackgroundColor = SystemColors.ControlLightLight;
Load += FormMain_Load; dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
menuStrip.ResumeLayout(false); dataGridView.Location = new Point(12, 27);
menuStrip.PerformLayout(); dataGridView.Name = "dataGridView";
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); dataGridView.RowTemplate.Height = 25;
ResumeLayout(false); dataGridView.Size = new Size(1049, 341);
PerformLayout(); dataGridView.TabIndex = 1;
} //
// buttonCreateOrder
//
buttonCreateOrder.ImageAlign = ContentAlignment.MiddleRight;
buttonCreateOrder.Location = new Point(1067, 42);
buttonCreateOrder.Name = "buttonCreateOrder";
buttonCreateOrder.Size = new Size(157, 23);
buttonCreateOrder.TabIndex = 2;
buttonCreateOrder.Text = "Создать заказ";
buttonCreateOrder.UseVisualStyleBackColor = true;
buttonCreateOrder.Click += buttonCreateOrder_Click;
//
// buttonTakeOrderInWork
//
buttonTakeOrderInWork.ImageAlign = ContentAlignment.MiddleRight;
buttonTakeOrderInWork.Location = new Point(1067, 71);
buttonTakeOrderInWork.Name = "buttonTakeOrderInWork";
buttonTakeOrderInWork.Size = new Size(157, 23);
buttonTakeOrderInWork.TabIndex = 3;
buttonTakeOrderInWork.Text = "Отладить на выполнение";
buttonTakeOrderInWork.UseVisualStyleBackColor = true;
buttonTakeOrderInWork.Click += buttonTakeOrderInWork_Click;
//
// buttonOrderReady
//
buttonOrderReady.ImageAlign = ContentAlignment.MiddleRight;
buttonOrderReady.Location = new Point(1067, 100);
buttonOrderReady.Name = "buttonOrderReady";
buttonOrderReady.Size = new Size(157, 23);
buttonOrderReady.TabIndex = 4;
buttonOrderReady.Text = "Заказ готов";
buttonOrderReady.UseVisualStyleBackColor = true;
buttonOrderReady.Click += buttonOrderReady_Click;
//
// buttonIssuedOrder
//
buttonIssuedOrder.ImageAlign = ContentAlignment.MiddleRight;
buttonIssuedOrder.Location = new Point(1067, 129);
buttonIssuedOrder.Name = "buttonIssuedOrder";
buttonIssuedOrder.Size = new Size(157, 23);
buttonIssuedOrder.TabIndex = 5;
buttonIssuedOrder.Text = "Заказ выдан";
buttonIssuedOrder.UseVisualStyleBackColor = true;
buttonIssuedOrder.Click += buttonIssuedOrder_Click;
//
// buttonRef
//
buttonRef.ImageAlign = ContentAlignment.MiddleRight;
buttonRef.Location = new Point(1067, 158);
buttonRef.Name = "buttonRef";
buttonRef.Size = new Size(157, 23);
buttonRef.TabIndex = 6;
buttonRef.Text = "Обновить список";
buttonRef.UseVisualStyleBackColor = true;
buttonRef.Click += buttonRef_Click;
//
// FormMain
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(1236, 370);
Controls.Add(buttonRef);
Controls.Add(buttonIssuedOrder);
Controls.Add(buttonOrderReady);
Controls.Add(buttonTakeOrderInWork);
Controls.Add(buttonCreateOrder);
Controls.Add(dataGridView);
Controls.Add(menuStrip);
MainMenuStrip = menuStrip;
Name = "FormMain";
Text = "Ремонтные работы";
Load += FormMain_Load;
menuStrip.ResumeLayout(false);
menuStrip.PerformLayout();
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);
PerformLayout();
}
#endregion #endregion
private MenuStrip menuStrip; private MenuStrip menuStrip;
private ToolStripMenuItem refbooksToolStripMenuItem; private ToolStripMenuItem refbooksToolStripMenuItem;
private ToolStripMenuItem componentsToolStripMenuItem; private ToolStripMenuItem componentsToolStripMenuItem;
private ToolStripMenuItem JobTypeToolStripMenuItem; private ToolStripMenuItem JobTypeToolStripMenuItem;
private DataGridView dataGridView; private DataGridView dataGridView;
private Button buttonCreateOrder; private Button buttonCreateOrder;
private Button buttonTakeOrderInWork; private Button buttonTakeOrderInWork;
private Button buttonOrderReady; private Button buttonOrderReady;
private Button buttonIssuedOrder; private Button buttonIssuedOrder;
private Button buttonRef; private Button buttonRef;
} private ToolStripMenuItem отчетыToolStripMenuItem;
private ToolStripMenuItem listComponentsToolStripMenuItem;
private ToolStripMenuItem componentRepairsПоИзделиямToolStripMenuItem;
private ToolStripMenuItem OrdersToolStripMenuItem;
private ToolStripMenuItem ClientsToolStripMenuItem;
private ToolStripMenuItem ImplementersToolStripMenuItem;
private ToolStripMenuItem StartWorkingToolStripMenuItem;
private ToolStripMenuItem mailToolStripMenuItem;
private ToolStripMenuItem createBackUpToolStripMenuItem;
}
} }

View File

@ -150,10 +150,84 @@ namespace RenovationWorkView
} }
} }
private void buttonRef_Click(object sender, EventArgs e) private void buttonRef_Click(object sender, EventArgs e)
{ {
LoadData(); LoadData();
} }
}
}
private void listComponentsToolStripMenuItem_Click(object sender, EventArgs e)
{
using var dialog = new SaveFileDialog { Filter = "docx|*.docx" };
if (dialog.ShowDialog() == DialogResult.OK)
{
_reportLogic.SaveRepairsToWordFile(new ReportBindingModel
{
FileName = dialog.FileName
});
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
}
private void componentRepairsПоИзделиямToolStripMenuItem_Click(object sender, EventArgs e)
{
var form = DependencyManager.Instance.Resolve<FormReportRepairComponents>();
form.ShowDialog();
}
private void OrdersToolStripMenuItem_Click(object sender, EventArgs e)
{
var form = DependencyManager.Instance.Resolve<FormReportOrders>();
form.ShowDialog();
}
private void ClientsToolStripMenuItem_Click(object sender, EventArgs e)
{
var form = DependencyManager.Instance.Resolve<FormClients>();
form.ShowDialog();
}
private void ImplementersToolStripMenuItem_Click(object sender, EventArgs e)
{
var form = DependencyManager.Instance.Resolve<FormImplementers>();
form.ShowDialog();
}
private void StartWorkingToolStripMenuItem_Click_1(object sender, EventArgs e)
{
_workProcess.DoWork(DependencyManager.Instance.Resolve<IImplementerLogic>(), _orderLogic);
MessageBox.Show("Процесс обработки запущен", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private void mailToolStripMenuItem_Click(object sender, EventArgs e)
{
var form = DependencyManager.Instance.Resolve<FormMail>();
form.ShowDialog();
}
private void createBackUpToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
if (_backUpLogic != null)
{
var fbd = new FolderBrowserDialog();
if (fbd.ShowDialog() == DialogResult.OK)
{
_backUpLogic.CreateBackUp(new BackUpSaveBinidngModel
{
FolderName = fbd.SelectedPath
});
MessageBox.Show("Бекап создан", "Сообщение",
MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка создания бэкапа", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
}
}

View File

@ -30,19 +30,37 @@ namespace RenovationWorkView
option.SetMinimumLevel(LogLevel.Information); option.SetMinimumLevel(LogLevel.Information);
option.AddNLog("nlog.config"); option.AddNLog("nlog.config");
}); });
services.AddTransient<IComponentStorage, ComponentStorage>();
services.AddTransient<IOrderStorage, OrderStorage>(); DependencyManager.Instance.RegisterType<IClientLogic, ClientLogic>();
services.AddTransient<IRepairStorage, RepairStorage>(); DependencyManager.Instance.RegisterType<IComponentLogic, ComponentLogic>();
services.AddTransient<IComponentLogic, ComponentLogic>(); DependencyManager.Instance.RegisterType<IOrderLogic, OrderLogic>();
services.AddTransient<IOrderLogic, OrderLogic>(); DependencyManager.Instance.RegisterType<IRepairLogic, RepairLogic>();
services.AddTransient<IRepairLogic, RepairLogic>(); DependencyManager.Instance.RegisterType<IReportLogic, ReportLogic>();
services.AddTransient<FormMain>(); DependencyManager.Instance.RegisterType<IImplementerLogic, ImplementerLogic>();
services.AddTransient<FormComponent>(); DependencyManager.Instance.RegisterType<IMessageInfoLogic, MessageInfoLogic>();
services.AddTransient<FormComponents>(); DependencyManager.Instance.RegisterType<IBackUpLogic, BackUpLogic>();
services.AddTransient<FormCreateOrder>();
services.AddTransient<FormRepair>(); DependencyManager.Instance.RegisterType<AbstractSaveToWord, SaveToWord>();
services.AddTransient<FormRepairComponent>(); DependencyManager.Instance.RegisterType<AbstractSaveToExcel, SaveToExcel>();
services.AddTransient<FormRepairs>(); DependencyManager.Instance.RegisterType<AbstractSaveToPdf, SaveToPdf>();
} DependencyManager.Instance.RegisterType<AbstractMailWorker, MailKitWorker>(true);
}
DependencyManager.Instance.RegisterType<IWorkProcess, WorkModeling>();
DependencyManager.Instance.RegisterType<FormMain>();
DependencyManager.Instance.RegisterType<FormComponent>();
DependencyManager.Instance.RegisterType<FormComponents>();
DependencyManager.Instance.RegisterType<FormCreateOrder>();
DependencyManager.Instance.RegisterType<FormRepair>();
DependencyManager.Instance.RegisterType<FormRepairComponent>();
DependencyManager.Instance.RegisterType<FormRepairs>();
DependencyManager.Instance.RegisterType<FormReportOrders>();
DependencyManager.Instance.RegisterType<FormReportRepairComponents>();
DependencyManager.Instance.RegisterType<FormClients>();
DependencyManager.Instance.RegisterType<FormImplementers>();
DependencyManager.Instance.RegisterType<FormImplementer>();
DependencyManager.Instance.RegisterType<FormMail>();
}
private static void MailCheck(object obj) => DependencyManager.Instance.Resolve<AbstractMailWorker>()?.MailCheck();
}
} }

View File

@ -13,12 +13,18 @@ namespace RenovationWorkListImplement
public List<Component> Components { get; set; } public List<Component> Components { get; set; }
public List<Order> Orders { get; set; } public List<Order> Orders { get; set; }
public List<Repair> Repairs { get; set; } public List<Repair> Repairs { get; set; }
private DataListSingleton() public List<Client> Clients { get; set; }
public List<Implementer> Implementers { get; set; }
public List<MessageInfo> Messages { get; set; }
private DataListSingleton()
{ {
Components = new List<Component>(); Components = new List<Component>();
Orders = new List<Order>(); Orders = new List<Order>();
Repairs = new List<Repair>(); Repairs = new List<Repair>();
} Clients = new List<Client>();
Implementers = new List<Implementer>();
Messages = new List<MessageInfo>();
}
public static DataListSingleton GetInstance() public static DataListSingleton GetInstance()
{ {
if (_instance == null) if (_instance == null)