Compare commits
No commits in common. "Lab8" and "main" have entirely different histories.
@ -1,73 +0,0 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
|
||||||
# Visual Studio Version 17
|
|
||||||
VisualStudioVersion = 17.4.33213.308
|
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutomobilePlant", "AutomobilePlant\AutomobilePlant.csproj", "{970E66D6-3147-419D-98DC-9E05B10232B5}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutomobilePlantDataModels", "AutomobilePlantDataModels\AutomobilePlantDataModels.csproj", "{27B6E4A1-BB53-4AF6-AACA-099A40B64D60}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutomobilePlantContracts", "AutomobilePlantContracts\AutomobilePlantContracts.csproj", "{2F1D0A55-2722-48B4-87D1-0440E74D6E0A}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutomobilePlantBusinessLogic", "AutomobilePlantBusinessLogic\AutomobilePlantBusinessLogic.csproj", "{CC4E3C20-ABA4-4A54-B992-B68D39A1236E}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutomobilePlantListImplements", "AutomobilePlantListImplements\AutomobilePlantListImplements.csproj", "{B27736FF-39E9-4DEC-BCB4-35ACAF5ECEB9}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutomobilePlantFileImplement", "AutomobilePlantFileImplement\AutomobilePlantFileImplement.csproj", "{10818526-654C-4928-985F-9C02A2A02B15}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutomobilePlantDatabaseImplement", "AutomobilePlantDatabaseImplement\AutomobilePlantDatabaseImplement.csproj", "{6C1976A0-354A-4700-9CDA-3242782F5632}"
|
|
||||||
EndProject
|
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutomobilePlantRestApi", "AutomobilePlantRestApi\AutomobilePlantRestApi.csproj", "{CDF7D2AD-E6C5-4C51-9ECC-9CD678D922BF}"
|
|
||||||
EndProject
|
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutomobilePlantClientApp", "AutomobilePlantClientApp\AutomobilePlantClientApp.csproj", "{64B4EF20-2056-46B3-A009-E6DC5682492B}"
|
|
||||||
EndProject
|
|
||||||
Global
|
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
|
||||||
Debug|Any CPU = Debug|Any CPU
|
|
||||||
Release|Any CPU = Release|Any CPU
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
|
||||||
{970E66D6-3147-419D-98DC-9E05B10232B5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{970E66D6-3147-419D-98DC-9E05B10232B5}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{970E66D6-3147-419D-98DC-9E05B10232B5}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{970E66D6-3147-419D-98DC-9E05B10232B5}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{27B6E4A1-BB53-4AF6-AACA-099A40B64D60}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{27B6E4A1-BB53-4AF6-AACA-099A40B64D60}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{27B6E4A1-BB53-4AF6-AACA-099A40B64D60}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{27B6E4A1-BB53-4AF6-AACA-099A40B64D60}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{2F1D0A55-2722-48B4-87D1-0440E74D6E0A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{2F1D0A55-2722-48B4-87D1-0440E74D6E0A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{2F1D0A55-2722-48B4-87D1-0440E74D6E0A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{2F1D0A55-2722-48B4-87D1-0440E74D6E0A}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{CC4E3C20-ABA4-4A54-B992-B68D39A1236E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{CC4E3C20-ABA4-4A54-B992-B68D39A1236E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{CC4E3C20-ABA4-4A54-B992-B68D39A1236E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{CC4E3C20-ABA4-4A54-B992-B68D39A1236E}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{B27736FF-39E9-4DEC-BCB4-35ACAF5ECEB9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{B27736FF-39E9-4DEC-BCB4-35ACAF5ECEB9}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{B27736FF-39E9-4DEC-BCB4-35ACAF5ECEB9}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{B27736FF-39E9-4DEC-BCB4-35ACAF5ECEB9}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{10818526-654C-4928-985F-9C02A2A02B15}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{10818526-654C-4928-985F-9C02A2A02B15}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{10818526-654C-4928-985F-9C02A2A02B15}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{10818526-654C-4928-985F-9C02A2A02B15}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{6C1976A0-354A-4700-9CDA-3242782F5632}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{6C1976A0-354A-4700-9CDA-3242782F5632}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{6C1976A0-354A-4700-9CDA-3242782F5632}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{6C1976A0-354A-4700-9CDA-3242782F5632}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{CDF7D2AD-E6C5-4C51-9ECC-9CD678D922BF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{CDF7D2AD-E6C5-4C51-9ECC-9CD678D922BF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{CDF7D2AD-E6C5-4C51-9ECC-9CD678D922BF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{CDF7D2AD-E6C5-4C51-9ECC-9CD678D922BF}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{64B4EF20-2056-46B3-A009-E6DC5682492B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{64B4EF20-2056-46B3-A009-E6DC5682492B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{64B4EF20-2056-46B3-A009-E6DC5682492B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{64B4EF20-2056-46B3-A009-E6DC5682492B}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
|
||||||
HideSolutionNode = FALSE
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
|
||||||
SolutionGuid = {41F89D22-CD9D-4FAB-A7AA-A3DF6DA7078A}
|
|
||||||
EndGlobalSection
|
|
||||||
EndGlobal
|
|
@ -1,11 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<configuration>
|
|
||||||
<appSettings>
|
|
||||||
<add key="SmtpClientHost" value="smtp.gmail.com" />
|
|
||||||
<add key="SmtpClientPort" value="587" />
|
|
||||||
<add key="PopHost" value="pop.gmail.com" />
|
|
||||||
<add key="PopPort" value="995" />
|
|
||||||
<add key="MailLogin" value="mailforlab8@gmail.com" />
|
|
||||||
<add key="MailPassword" value="pvmu cnof aakc ckvd" />
|
|
||||||
</appSettings>
|
|
||||||
</configuration>
|
|
@ -1,36 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<OutputType>WinExe</OutputType>
|
|
||||||
<TargetFramework>net6.0-windows</TargetFramework>
|
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
<UseWindowsForms>true</UseWindowsForms>
|
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.3">
|
|
||||||
<PrivateAssets>all</PrivateAssets>
|
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
|
||||||
</PackageReference>
|
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
|
|
||||||
<PackageReference Include="NLog.Extensions.Logging" Version="5.2.1" />
|
|
||||||
<PackageReference Include="ReportViewerCore.WinForms" Version="15.1.17" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\AutomobilePlantBusinessLogic\AutomobilePlantBusinessLogic.csproj" />
|
|
||||||
<ProjectReference Include="..\AutomobilePlantContracts\AutomobilePlantContracts.csproj" />
|
|
||||||
<ProjectReference Include="..\AutomobilePlantDatabaseImplement\AutomobilePlantDatabaseImplement.csproj" />
|
|
||||||
<ProjectReference Include="..\AutomobilePlantDataModels\AutomobilePlantDataModels.csproj" />
|
|
||||||
<ProjectReference Include="..\AutomobilePlantFileImplement\AutomobilePlantFileImplement.csproj" />
|
|
||||||
<ProjectReference Include="..\AutomobilePlantListImplements\AutomobilePlantListImplements.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<None Update="ReportOrders.rdlc">
|
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
|
||||||
</None>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
@ -1,50 +0,0 @@
|
|||||||
using AutomobilePlantContracts.Attributes;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlant
|
|
||||||
{
|
|
||||||
public static class DataGridViewExtension
|
|
||||||
{
|
|
||||||
public static void FillAndConfigGrid<T>(this DataGridView grid, List<T>? data)
|
|
||||||
{
|
|
||||||
if (data == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
grid.DataSource = data;
|
|
||||||
var type = typeof(T);
|
|
||||||
var properties = type.GetProperties();
|
|
||||||
foreach (DataGridViewColumn column in grid.Columns)
|
|
||||||
{
|
|
||||||
var property = properties.FirstOrDefault(x => x.Name == column.Name);
|
|
||||||
if (property == null)
|
|
||||||
{
|
|
||||||
throw new InvalidOperationException($"В типе {type.Name} не найдено свойство с именем {column.Name}");
|
|
||||||
}
|
|
||||||
var attribute = property.GetCustomAttributes(typeof(ColumnAttribute), true)?.SingleOrDefault();
|
|
||||||
if (attribute == null)
|
|
||||||
{
|
|
||||||
throw new InvalidOperationException($"Не найден атрибут типа ColumnAttribute для свойства {property.Name}");
|
|
||||||
}
|
|
||||||
// ищем нужный нам атрибут
|
|
||||||
if (attribute is ColumnAttribute columnAttr)
|
|
||||||
{
|
|
||||||
column.HeaderText = columnAttr.Title;
|
|
||||||
column.Visible = columnAttr.Visible;
|
|
||||||
if (columnAttr.IsUseAutoSize)
|
|
||||||
{
|
|
||||||
column.AutoSizeMode = (DataGridViewAutoSizeColumnMode)Enum.Parse(typeof(DataGridViewAutoSizeColumnMode), columnAttr.GridViewAutoSize.ToString());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
column.Width = columnAttr.Width;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
232
AutomobilePlant/FormCar.Designer.cs
generated
232
AutomobilePlant/FormCar.Designer.cs
generated
@ -1,232 +0,0 @@
|
|||||||
namespace AutomobilePlant
|
|
||||||
{
|
|
||||||
partial class FormCar
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
this.labelName = new System.Windows.Forms.Label();
|
|
||||||
this.labelPrice = new System.Windows.Forms.Label();
|
|
||||||
this.textBoxName = new System.Windows.Forms.TextBox();
|
|
||||||
this.textBoxPrice = new System.Windows.Forms.TextBox();
|
|
||||||
this.groupBoxComponents = new System.Windows.Forms.GroupBox();
|
|
||||||
this.buttonUpdate = new System.Windows.Forms.Button();
|
|
||||||
this.buttonDelete = new System.Windows.Forms.Button();
|
|
||||||
this.buttonEdit = new System.Windows.Forms.Button();
|
|
||||||
this.buttonAdd = new System.Windows.Forms.Button();
|
|
||||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
|
||||||
this.ID = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
|
||||||
this.ColumnComponentName = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
|
||||||
this.ColumnCount = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
|
||||||
this.buttonSave = new System.Windows.Forms.Button();
|
|
||||||
this.buttonCancel = new System.Windows.Forms.Button();
|
|
||||||
this.groupBoxComponents.SuspendLayout();
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
|
||||||
this.SuspendLayout();
|
|
||||||
//
|
|
||||||
// labelName
|
|
||||||
//
|
|
||||||
this.labelName.AutoSize = true;
|
|
||||||
this.labelName.Location = new System.Drawing.Point(12, 9);
|
|
||||||
this.labelName.Name = "labelName";
|
|
||||||
this.labelName.Size = new System.Drawing.Size(80, 20);
|
|
||||||
this.labelName.TabIndex = 0;
|
|
||||||
this.labelName.Text = "Название:";
|
|
||||||
//
|
|
||||||
// labelPrice
|
|
||||||
//
|
|
||||||
this.labelPrice.AutoSize = true;
|
|
||||||
this.labelPrice.Location = new System.Drawing.Point(12, 45);
|
|
||||||
this.labelPrice.Name = "labelPrice";
|
|
||||||
this.labelPrice.Size = new System.Drawing.Size(86, 20);
|
|
||||||
this.labelPrice.TabIndex = 1;
|
|
||||||
this.labelPrice.Text = "Стоимость:";
|
|
||||||
//
|
|
||||||
// textBoxName
|
|
||||||
//
|
|
||||||
this.textBoxName.Location = new System.Drawing.Point(98, 6);
|
|
||||||
this.textBoxName.Name = "textBoxName";
|
|
||||||
this.textBoxName.Size = new System.Drawing.Size(315, 27);
|
|
||||||
this.textBoxName.TabIndex = 2;
|
|
||||||
//
|
|
||||||
// textBoxPrice
|
|
||||||
//
|
|
||||||
this.textBoxPrice.Location = new System.Drawing.Point(98, 39);
|
|
||||||
this.textBoxPrice.Name = "textBoxPrice";
|
|
||||||
this.textBoxPrice.Size = new System.Drawing.Size(157, 27);
|
|
||||||
this.textBoxPrice.TabIndex = 3;
|
|
||||||
//
|
|
||||||
// groupBoxComponents
|
|
||||||
//
|
|
||||||
this.groupBoxComponents.Controls.Add(this.buttonUpdate);
|
|
||||||
this.groupBoxComponents.Controls.Add(this.buttonDelete);
|
|
||||||
this.groupBoxComponents.Controls.Add(this.buttonEdit);
|
|
||||||
this.groupBoxComponents.Controls.Add(this.buttonAdd);
|
|
||||||
this.groupBoxComponents.Controls.Add(this.dataGridView);
|
|
||||||
this.groupBoxComponents.Location = new System.Drawing.Point(15, 83);
|
|
||||||
this.groupBoxComponents.Name = "groupBoxComponents";
|
|
||||||
this.groupBoxComponents.Size = new System.Drawing.Size(699, 275);
|
|
||||||
this.groupBoxComponents.TabIndex = 4;
|
|
||||||
this.groupBoxComponents.TabStop = false;
|
|
||||||
this.groupBoxComponents.Text = "Компоненты";
|
|
||||||
//
|
|
||||||
// buttonUpdate
|
|
||||||
//
|
|
||||||
this.buttonUpdate.Location = new System.Drawing.Point(521, 240);
|
|
||||||
this.buttonUpdate.Name = "buttonUpdate";
|
|
||||||
this.buttonUpdate.Size = new System.Drawing.Size(155, 29);
|
|
||||||
this.buttonUpdate.TabIndex = 4;
|
|
||||||
this.buttonUpdate.Text = "Обновить";
|
|
||||||
this.buttonUpdate.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonUpdate.Click += new System.EventHandler(this.ButtonUpdate_Click);
|
|
||||||
//
|
|
||||||
// buttonDelete
|
|
||||||
//
|
|
||||||
this.buttonDelete.Location = new System.Drawing.Point(521, 96);
|
|
||||||
this.buttonDelete.Name = "buttonDelete";
|
|
||||||
this.buttonDelete.Size = new System.Drawing.Size(155, 29);
|
|
||||||
this.buttonDelete.TabIndex = 3;
|
|
||||||
this.buttonDelete.Text = "Удалить";
|
|
||||||
this.buttonDelete.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonDelete.Click += new System.EventHandler(this.ButtonDelete_Click);
|
|
||||||
//
|
|
||||||
// buttonEdit
|
|
||||||
//
|
|
||||||
this.buttonEdit.Location = new System.Drawing.Point(521, 61);
|
|
||||||
this.buttonEdit.Name = "buttonEdit";
|
|
||||||
this.buttonEdit.Size = new System.Drawing.Size(155, 29);
|
|
||||||
this.buttonEdit.TabIndex = 2;
|
|
||||||
this.buttonEdit.Text = "Изменить";
|
|
||||||
this.buttonEdit.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonEdit.Click += new System.EventHandler(this.ButtonEdit_Click);
|
|
||||||
//
|
|
||||||
// buttonAdd
|
|
||||||
//
|
|
||||||
this.buttonAdd.Location = new System.Drawing.Point(521, 26);
|
|
||||||
this.buttonAdd.Name = "buttonAdd";
|
|
||||||
this.buttonAdd.Size = new System.Drawing.Size(155, 29);
|
|
||||||
this.buttonAdd.TabIndex = 1;
|
|
||||||
this.buttonAdd.Text = "Добавить";
|
|
||||||
this.buttonAdd.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
|
|
||||||
//
|
|
||||||
// dataGridView
|
|
||||||
//
|
|
||||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
|
||||||
this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
|
|
||||||
this.ID,
|
|
||||||
this.ColumnComponentName,
|
|
||||||
this.ColumnCount});
|
|
||||||
this.dataGridView.Location = new System.Drawing.Point(6, 26);
|
|
||||||
this.dataGridView.Name = "dataGridView";
|
|
||||||
this.dataGridView.RowHeadersWidth = 51;
|
|
||||||
this.dataGridView.RowTemplate.Height = 29;
|
|
||||||
this.dataGridView.Size = new System.Drawing.Size(490, 243);
|
|
||||||
this.dataGridView.TabIndex = 0;
|
|
||||||
//
|
|
||||||
// ID
|
|
||||||
//
|
|
||||||
this.ID.HeaderText = "ID";
|
|
||||||
this.ID.MinimumWidth = 6;
|
|
||||||
this.ID.Name = "ID";
|
|
||||||
this.ID.Visible = false;
|
|
||||||
this.ID.Width = 125;
|
|
||||||
//
|
|
||||||
// ColumnComponentName
|
|
||||||
//
|
|
||||||
this.ColumnComponentName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
|
|
||||||
this.ColumnComponentName.HeaderText = "Компонент";
|
|
||||||
this.ColumnComponentName.MinimumWidth = 6;
|
|
||||||
this.ColumnComponentName.Name = "ColumnComponentName";
|
|
||||||
this.ColumnComponentName.Resizable = System.Windows.Forms.DataGridViewTriState.True;
|
|
||||||
//
|
|
||||||
// ColumnCount
|
|
||||||
//
|
|
||||||
this.ColumnCount.HeaderText = "Количество";
|
|
||||||
this.ColumnCount.MinimumWidth = 6;
|
|
||||||
this.ColumnCount.Name = "ColumnCount";
|
|
||||||
this.ColumnCount.Width = 125;
|
|
||||||
//
|
|
||||||
// buttonSave
|
|
||||||
//
|
|
||||||
this.buttonSave.Location = new System.Drawing.Point(356, 379);
|
|
||||||
this.buttonSave.Name = "buttonSave";
|
|
||||||
this.buttonSave.Size = new System.Drawing.Size(155, 29);
|
|
||||||
this.buttonSave.TabIndex = 5;
|
|
||||||
this.buttonSave.Text = "Сохранить";
|
|
||||||
this.buttonSave.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
|
|
||||||
//
|
|
||||||
// buttonCancel
|
|
||||||
//
|
|
||||||
this.buttonCancel.Location = new System.Drawing.Point(536, 379);
|
|
||||||
this.buttonCancel.Name = "buttonCancel";
|
|
||||||
this.buttonCancel.Size = new System.Drawing.Size(155, 29);
|
|
||||||
this.buttonCancel.TabIndex = 6;
|
|
||||||
this.buttonCancel.Text = "Отмена";
|
|
||||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
|
||||||
//
|
|
||||||
// FormCar
|
|
||||||
//
|
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
this.ClientSize = new System.Drawing.Size(726, 427);
|
|
||||||
this.Controls.Add(this.buttonCancel);
|
|
||||||
this.Controls.Add(this.buttonSave);
|
|
||||||
this.Controls.Add(this.groupBoxComponents);
|
|
||||||
this.Controls.Add(this.textBoxPrice);
|
|
||||||
this.Controls.Add(this.textBoxName);
|
|
||||||
this.Controls.Add(this.labelPrice);
|
|
||||||
this.Controls.Add(this.labelName);
|
|
||||||
this.Name = "FormCar";
|
|
||||||
this.Text = "Автомобиль";
|
|
||||||
this.groupBoxComponents.ResumeLayout(false);
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
|
||||||
this.ResumeLayout(false);
|
|
||||||
this.PerformLayout();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private Label labelName;
|
|
||||||
private Label labelPrice;
|
|
||||||
private TextBox textBoxName;
|
|
||||||
private TextBox textBoxPrice;
|
|
||||||
private GroupBox groupBoxComponents;
|
|
||||||
private DataGridView dataGridView;
|
|
||||||
private DataGridViewTextBoxColumn ID;
|
|
||||||
private DataGridViewTextBoxColumn ColumnComponentName;
|
|
||||||
private DataGridViewTextBoxColumn ColumnCount;
|
|
||||||
private Button buttonUpdate;
|
|
||||||
private Button buttonDelete;
|
|
||||||
private Button buttonEdit;
|
|
||||||
private Button buttonAdd;
|
|
||||||
private Button buttonSave;
|
|
||||||
private Button buttonCancel;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,214 +0,0 @@
|
|||||||
using AutomobilePlantDataModels.Models;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Data;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
using AutomobilePlantContracts.BusinessLogicContracts;
|
|
||||||
using AutomobilePlantContracts.SearchModels;
|
|
||||||
using AutomobilePlantContracts.BindingModels;
|
|
||||||
using AutomobilePlantContracts.DI;
|
|
||||||
|
|
||||||
namespace AutomobilePlant
|
|
||||||
{
|
|
||||||
public partial class FormCar : Form
|
|
||||||
{
|
|
||||||
private readonly ILogger _logger;
|
|
||||||
private readonly ICarLogic _logic;
|
|
||||||
private int? _id;
|
|
||||||
private Dictionary<int, (IComponentModel, int)> _carComponents;
|
|
||||||
public int Id { set { _id = value; } }
|
|
||||||
|
|
||||||
public FormCar(ILogger<FormCar> logger, ICarLogic logic)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_logger = logger;
|
|
||||||
_logic = logic;
|
|
||||||
_carComponents = new Dictionary<int, (IComponentModel, int)>();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void FormCar_Load(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (_id.HasValue)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Загрузка автомобиля");
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var view = _logic.ReadElement(new CarSearchModel { Id = _id.Value });
|
|
||||||
if (view != null)
|
|
||||||
{
|
|
||||||
textBoxName.Text = view.CarName;
|
|
||||||
textBoxPrice.Text = view.Price.ToString();
|
|
||||||
_carComponents = view.CarComponents ?? new
|
|
||||||
Dictionary<int, (IComponentModel, int)>();
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка загрузки автомобиля");
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void LoadData()
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Загрузка компонентов автомобиля");
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (_carComponents != null)
|
|
||||||
{
|
|
||||||
dataGridView.Rows.Clear();
|
|
||||||
foreach (var cc in _carComponents)
|
|
||||||
{
|
|
||||||
dataGridView.Rows.Add(new object[] {
|
|
||||||
cc.Key,
|
|
||||||
cc.Value.Item1.ComponentName,
|
|
||||||
cc.Value.Item2
|
|
||||||
});
|
|
||||||
}
|
|
||||||
textBoxPrice.Text = CalcPrice().ToString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка загрузки компонентов автомобиля");
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private double CalcPrice()
|
|
||||||
{
|
|
||||||
double price = 0;
|
|
||||||
foreach (var elem in _carComponents)
|
|
||||||
{
|
|
||||||
price += ((elem.Value.Item1?.Cost ?? 0) * elem.Value.Item2);
|
|
||||||
}
|
|
||||||
return Math.Round(price * 1.1, 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
var form = DependencyManager.Instance.Resolve<FormCarComponent>();
|
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
if (form.ComponentModel == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Добавление нового компонента: { ComponentName}-{Count}", form.ComponentModel.ComponentName, form.Count);
|
|
||||||
if (_carComponents.ContainsKey(form.Id))
|
|
||||||
{
|
|
||||||
_carComponents[form.Id] = (form.ComponentModel, form.Count);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_carComponents.Add(form.Id, (form.ComponentModel, form.Count));
|
|
||||||
}
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonEdit_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
|
||||||
{
|
|
||||||
var form = DependencyManager.Instance.Resolve<FormCarComponent>();
|
|
||||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
|
|
||||||
form.Id = id;
|
|
||||||
form.Count = _carComponents[id].Item2;
|
|
||||||
|
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
if (form.ComponentModel == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Изменение компонента:{ ComponentName}- { Count}", form.ComponentModel.ComponentName, form.Count);
|
|
||||||
_carComponents[form.Id] = (form.ComponentModel, form.Count);
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonDelete_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
|
||||||
{
|
|
||||||
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Удаление компонента:{ ComponentName} - { Count}", dataGridView.SelectedRows[0].Cells[1].Value);
|
|
||||||
_carComponents?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value));
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonUpdate_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonSave_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(textBoxName.Text))
|
|
||||||
{
|
|
||||||
MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (string.IsNullOrEmpty(textBoxPrice.Text))
|
|
||||||
{
|
|
||||||
MessageBox.Show("Заполните цену", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (_carComponents == null || _carComponents.Count == 0)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Заполните компоненты", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Сохранение изделия");
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var model = new CarBindingModel
|
|
||||||
{
|
|
||||||
Id = _id ?? 0,
|
|
||||||
CarName = textBoxName.Text,
|
|
||||||
Price = Convert.ToDouble(textBoxPrice.Text),
|
|
||||||
CarComponents = _carComponents
|
|
||||||
};
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,60 +0,0 @@
|
|||||||
<root>
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
</root>
|
|
119
AutomobilePlant/FormCarComponent.Designer.cs
generated
119
AutomobilePlant/FormCarComponent.Designer.cs
generated
@ -1,119 +0,0 @@
|
|||||||
namespace AutomobilePlant
|
|
||||||
{
|
|
||||||
partial class FormCarComponent
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
this.labelComponent = new System.Windows.Forms.Label();
|
|
||||||
this.labelCount = new System.Windows.Forms.Label();
|
|
||||||
this.comboBoxComponent = new System.Windows.Forms.ComboBox();
|
|
||||||
this.textBoxCount = new System.Windows.Forms.TextBox();
|
|
||||||
this.buttonSave = new System.Windows.Forms.Button();
|
|
||||||
this.buttonCancel = new System.Windows.Forms.Button();
|
|
||||||
this.SuspendLayout();
|
|
||||||
//
|
|
||||||
// labelComponent
|
|
||||||
//
|
|
||||||
this.labelComponent.AutoSize = true;
|
|
||||||
this.labelComponent.Location = new System.Drawing.Point(25, 26);
|
|
||||||
this.labelComponent.Name = "labelComponent";
|
|
||||||
this.labelComponent.Size = new System.Drawing.Size(91, 20);
|
|
||||||
this.labelComponent.TabIndex = 0;
|
|
||||||
this.labelComponent.Text = "Компонент:";
|
|
||||||
//
|
|
||||||
// labelCount
|
|
||||||
//
|
|
||||||
this.labelCount.AutoSize = true;
|
|
||||||
this.labelCount.Location = new System.Drawing.Point(25, 74);
|
|
||||||
this.labelCount.Name = "labelCount";
|
|
||||||
this.labelCount.Size = new System.Drawing.Size(93, 20);
|
|
||||||
this.labelCount.TabIndex = 1;
|
|
||||||
this.labelCount.Text = "Количество:";
|
|
||||||
//
|
|
||||||
// comboBoxComponent
|
|
||||||
//
|
|
||||||
this.comboBoxComponent.FormattingEnabled = true;
|
|
||||||
this.comboBoxComponent.Location = new System.Drawing.Point(146, 26);
|
|
||||||
this.comboBoxComponent.Name = "comboBoxComponent";
|
|
||||||
this.comboBoxComponent.Size = new System.Drawing.Size(322, 28);
|
|
||||||
this.comboBoxComponent.TabIndex = 2;
|
|
||||||
//
|
|
||||||
// textBoxCount
|
|
||||||
//
|
|
||||||
this.textBoxCount.Location = new System.Drawing.Point(146, 71);
|
|
||||||
this.textBoxCount.Name = "textBoxCount";
|
|
||||||
this.textBoxCount.Size = new System.Drawing.Size(322, 27);
|
|
||||||
this.textBoxCount.TabIndex = 3;
|
|
||||||
//
|
|
||||||
// buttonSave
|
|
||||||
//
|
|
||||||
this.buttonSave.Location = new System.Drawing.Point(146, 115);
|
|
||||||
this.buttonSave.Name = "buttonSave";
|
|
||||||
this.buttonSave.Size = new System.Drawing.Size(143, 29);
|
|
||||||
this.buttonSave.TabIndex = 4;
|
|
||||||
this.buttonSave.Text = "Сохранить";
|
|
||||||
this.buttonSave.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
|
|
||||||
//
|
|
||||||
// buttonCancel
|
|
||||||
//
|
|
||||||
this.buttonCancel.Location = new System.Drawing.Point(325, 115);
|
|
||||||
this.buttonCancel.Name = "buttonCancel";
|
|
||||||
this.buttonCancel.Size = new System.Drawing.Size(143, 29);
|
|
||||||
this.buttonCancel.TabIndex = 5;
|
|
||||||
this.buttonCancel.Text = "Отмена";
|
|
||||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
|
||||||
//
|
|
||||||
// FormCarComponent
|
|
||||||
//
|
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
this.ClientSize = new System.Drawing.Size(491, 165);
|
|
||||||
this.Controls.Add(this.buttonCancel);
|
|
||||||
this.Controls.Add(this.buttonSave);
|
|
||||||
this.Controls.Add(this.textBoxCount);
|
|
||||||
this.Controls.Add(this.comboBoxComponent);
|
|
||||||
this.Controls.Add(this.labelCount);
|
|
||||||
this.Controls.Add(this.labelComponent);
|
|
||||||
this.Name = "FormCarComponent";
|
|
||||||
this.Text = "Компонент автомобиля";
|
|
||||||
this.ResumeLayout(false);
|
|
||||||
this.PerformLayout();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private Label labelComponent;
|
|
||||||
private Label labelCount;
|
|
||||||
private ComboBox comboBoxComponent;
|
|
||||||
private TextBox textBoxCount;
|
|
||||||
private Button buttonSave;
|
|
||||||
private Button buttonCancel;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,90 +0,0 @@
|
|||||||
using AutomobilePlantContracts.BusinessLogicContracts;
|
|
||||||
using AutomobilePlantContracts.ViewModels;
|
|
||||||
using AutomobilePlantDataModels.Models;
|
|
||||||
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 AutomobilePlant
|
|
||||||
{
|
|
||||||
public partial class FormCarComponent : Form
|
|
||||||
{
|
|
||||||
private readonly List<ComponentViewModel>? _list;
|
|
||||||
|
|
||||||
public int Id
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return Convert.ToInt32(comboBoxComponent.SelectedValue);
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
comboBoxComponent.SelectedValue = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public IComponentModel? ComponentModel
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (_list == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
foreach (var elem in _list)
|
|
||||||
{
|
|
||||||
if (elem.Id == Id)
|
|
||||||
{
|
|
||||||
return elem;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int Count
|
|
||||||
{
|
|
||||||
get { return Convert.ToInt32(textBoxCount.Text); }
|
|
||||||
set { textBoxCount.Text = value.ToString(); }
|
|
||||||
}
|
|
||||||
|
|
||||||
public FormCarComponent(IComponentLogic logic)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_list = logic.ReadList(null);
|
|
||||||
if (_list != null)
|
|
||||||
{
|
|
||||||
comboBoxComponent.DisplayMember = "ComponentName";
|
|
||||||
comboBoxComponent.ValueMember = "Id";
|
|
||||||
comboBoxComponent.DataSource = _list;
|
|
||||||
comboBoxComponent.SelectedItem = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void ButtonSave_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(textBoxCount.Text))
|
|
||||||
{
|
|
||||||
MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (comboBoxComponent.SelectedValue == null)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Выберите компонент", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
DialogResult = DialogResult.OK;
|
|
||||||
Close();
|
|
||||||
}
|
|
||||||
private void ButtonCancel_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
DialogResult = DialogResult.Cancel;
|
|
||||||
Close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,60 +0,0 @@
|
|||||||
<root>
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
</root>
|
|
115
AutomobilePlant/FormCars.Designer.cs
generated
115
AutomobilePlant/FormCars.Designer.cs
generated
@ -1,115 +0,0 @@
|
|||||||
namespace AutomobilePlant
|
|
||||||
{
|
|
||||||
partial class FormCars
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
|
||||||
this.buttonAdd = new System.Windows.Forms.Button();
|
|
||||||
this.buttonEdit = new System.Windows.Forms.Button();
|
|
||||||
this.buttonDelete = new System.Windows.Forms.Button();
|
|
||||||
this.buttonUpdate = new System.Windows.Forms.Button();
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
|
||||||
this.SuspendLayout();
|
|
||||||
//
|
|
||||||
// dataGridView
|
|
||||||
//
|
|
||||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
|
||||||
this.dataGridView.Location = new System.Drawing.Point(12, 12);
|
|
||||||
this.dataGridView.Name = "dataGridView";
|
|
||||||
this.dataGridView.RowHeadersWidth = 51;
|
|
||||||
this.dataGridView.RowTemplate.Height = 29;
|
|
||||||
this.dataGridView.Size = new System.Drawing.Size(507, 426);
|
|
||||||
this.dataGridView.TabIndex = 1;
|
|
||||||
//
|
|
||||||
// buttonAdd
|
|
||||||
//
|
|
||||||
this.buttonAdd.Location = new System.Drawing.Point(533, 12);
|
|
||||||
this.buttonAdd.Name = "buttonAdd";
|
|
||||||
this.buttonAdd.Size = new System.Drawing.Size(152, 29);
|
|
||||||
this.buttonAdd.TabIndex = 2;
|
|
||||||
this.buttonAdd.Text = "Добавить";
|
|
||||||
this.buttonAdd.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
|
|
||||||
//
|
|
||||||
// buttonEdit
|
|
||||||
//
|
|
||||||
this.buttonEdit.Location = new System.Drawing.Point(533, 47);
|
|
||||||
this.buttonEdit.Name = "buttonEdit";
|
|
||||||
this.buttonEdit.Size = new System.Drawing.Size(152, 29);
|
|
||||||
this.buttonEdit.TabIndex = 3;
|
|
||||||
this.buttonEdit.Text = "Изменить";
|
|
||||||
this.buttonEdit.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonEdit.Click += new System.EventHandler(this.ButtonEdit_Click);
|
|
||||||
//
|
|
||||||
// buttonDelete
|
|
||||||
//
|
|
||||||
this.buttonDelete.Location = new System.Drawing.Point(533, 82);
|
|
||||||
this.buttonDelete.Name = "buttonDelete";
|
|
||||||
this.buttonDelete.Size = new System.Drawing.Size(152, 29);
|
|
||||||
this.buttonDelete.TabIndex = 4;
|
|
||||||
this.buttonDelete.Text = "Удалить";
|
|
||||||
this.buttonDelete.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonDelete.Click += new System.EventHandler(this.ButtonDelete_Click);
|
|
||||||
//
|
|
||||||
// buttonUpdate
|
|
||||||
//
|
|
||||||
this.buttonUpdate.Location = new System.Drawing.Point(533, 409);
|
|
||||||
this.buttonUpdate.Name = "buttonUpdate";
|
|
||||||
this.buttonUpdate.Size = new System.Drawing.Size(152, 29);
|
|
||||||
this.buttonUpdate.TabIndex = 5;
|
|
||||||
this.buttonUpdate.Text = "Обновить";
|
|
||||||
this.buttonUpdate.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonUpdate.Click += new System.EventHandler(this.ButtonUpdate_Click);
|
|
||||||
//
|
|
||||||
// FormCars
|
|
||||||
//
|
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
this.ClientSize = new System.Drawing.Size(697, 450);
|
|
||||||
this.Controls.Add(this.buttonUpdate);
|
|
||||||
this.Controls.Add(this.buttonDelete);
|
|
||||||
this.Controls.Add(this.buttonEdit);
|
|
||||||
this.Controls.Add(this.buttonAdd);
|
|
||||||
this.Controls.Add(this.dataGridView);
|
|
||||||
this.Name = "FormCars";
|
|
||||||
this.Text = "Автомобили";
|
|
||||||
this.Load += new System.EventHandler(this.FormCars_Load);
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
|
||||||
this.ResumeLayout(false);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private DataGridView dataGridView;
|
|
||||||
private Button buttonAdd;
|
|
||||||
private Button buttonEdit;
|
|
||||||
private Button buttonDelete;
|
|
||||||
private Button buttonUpdate;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,103 +0,0 @@
|
|||||||
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 AutomobilePlantContracts.BusinessLogicContracts;
|
|
||||||
using AutomobilePlantContracts.SearchModels;
|
|
||||||
using AutomobilePlantContracts.BindingModels;
|
|
||||||
using AutomobilePlantContracts.DI;
|
|
||||||
|
|
||||||
namespace AutomobilePlant
|
|
||||||
{
|
|
||||||
public partial class FormCars : Form
|
|
||||||
{
|
|
||||||
private readonly ILogger _logger;
|
|
||||||
private readonly ICarLogic _logic;
|
|
||||||
public FormCars(ILogger<FormCars> logger, ICarLogic logic)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_logger = logger;
|
|
||||||
_logic = logic;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void FormCars_Load(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void LoadData()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
dataGridView.FillAndConfigGrid(_logic.ReadList(null));
|
|
||||||
_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 form = DependencyManager.Instance.Resolve<FormCar>();
|
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonEdit_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
|
||||||
{
|
|
||||||
var form = DependencyManager.Instance.Resolve<FormCar>();
|
|
||||||
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonDelete_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
|
||||||
{
|
|
||||||
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
|
||||||
{
|
|
||||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
|
||||||
_logger.LogInformation("Удаление автомобиля");
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (!_logic.Delete(new CarBindingModel
|
|
||||||
{
|
|
||||||
Id = id
|
|
||||||
}))
|
|
||||||
{
|
|
||||||
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
|
|
||||||
}
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка удаления автомобиля");
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonUpdate_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,60 +0,0 @@
|
|||||||
<root>
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
</root>
|
|
88
AutomobilePlant/FormClients.Designer.cs
generated
88
AutomobilePlant/FormClients.Designer.cs
generated
@ -1,88 +0,0 @@
|
|||||||
namespace AutomobilePlant
|
|
||||||
{
|
|
||||||
partial class FormClients
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
|
||||||
this.buttonDelete = new System.Windows.Forms.Button();
|
|
||||||
this.buttonUpdate = new System.Windows.Forms.Button();
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
|
||||||
this.SuspendLayout();
|
|
||||||
//
|
|
||||||
// dataGridView
|
|
||||||
//
|
|
||||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
|
||||||
this.dataGridView.Location = new System.Drawing.Point(12, 55);
|
|
||||||
this.dataGridView.Name = "dataGridView";
|
|
||||||
this.dataGridView.RowHeadersWidth = 51;
|
|
||||||
this.dataGridView.RowTemplate.Height = 29;
|
|
||||||
this.dataGridView.Size = new System.Drawing.Size(610, 383);
|
|
||||||
this.dataGridView.TabIndex = 0;
|
|
||||||
//
|
|
||||||
// buttonDelete
|
|
||||||
//
|
|
||||||
this.buttonDelete.Location = new System.Drawing.Point(352, 12);
|
|
||||||
this.buttonDelete.Name = "buttonDelete";
|
|
||||||
this.buttonDelete.Size = new System.Drawing.Size(270, 29);
|
|
||||||
this.buttonDelete.TabIndex = 1;
|
|
||||||
this.buttonDelete.Text = "Удалить выбранного клиента";
|
|
||||||
this.buttonDelete.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonDelete.Click += new System.EventHandler(this.buttonDelete_Click);
|
|
||||||
//
|
|
||||||
// buttonUpdate
|
|
||||||
//
|
|
||||||
this.buttonUpdate.Location = new System.Drawing.Point(228, 12);
|
|
||||||
this.buttonUpdate.Name = "buttonUpdate";
|
|
||||||
this.buttonUpdate.Size = new System.Drawing.Size(94, 29);
|
|
||||||
this.buttonUpdate.TabIndex = 2;
|
|
||||||
this.buttonUpdate.Text = "Обновить";
|
|
||||||
this.buttonUpdate.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonUpdate.Click += new System.EventHandler(this.buttonUpdate_Click);
|
|
||||||
//
|
|
||||||
// FormClients
|
|
||||||
//
|
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
this.ClientSize = new System.Drawing.Size(635, 450);
|
|
||||||
this.Controls.Add(this.buttonUpdate);
|
|
||||||
this.Controls.Add(this.buttonDelete);
|
|
||||||
this.Controls.Add(this.dataGridView);
|
|
||||||
this.Name = "FormClients";
|
|
||||||
this.Text = "Клиенты";
|
|
||||||
this.Load += new System.EventHandler(this.FormClients_Load);
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
|
||||||
this.ResumeLayout(false);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
private DataGridView dataGridView;
|
|
||||||
private Button buttonDelete;
|
|
||||||
private Button buttonUpdate;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,79 +0,0 @@
|
|||||||
using AutomobilePlantContracts.BindingModels;
|
|
||||||
using AutomobilePlantContracts.BusinessLogicContracts;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Data;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
namespace AutomobilePlant
|
|
||||||
{
|
|
||||||
public partial class FormClients : Form
|
|
||||||
{
|
|
||||||
private readonly ILogger _logger;
|
|
||||||
private readonly IClientLogic _logic;
|
|
||||||
public FormClients(ILogger<FormClients> logger, IClientLogic logic)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_logger = logger;
|
|
||||||
_logic = logic;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void FormClients_Load(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void LoadData()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
dataGridView.FillAndConfigGrid(_logic.ReadList(null));
|
|
||||||
_logger.LogInformation("Загрузка клиентов");
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка загрузки клиентов");
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buttonDelete_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
|
||||||
{
|
|
||||||
if (MessageBox.Show("Удалить клиента?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
|
||||||
{
|
|
||||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
|
||||||
_logger.LogInformation("Удаление клиента");
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (!_logic.Delete(new ClientBindingModel
|
|
||||||
{
|
|
||||||
Id = id
|
|
||||||
}))
|
|
||||||
{
|
|
||||||
throw new Exception("Ошибка при удалении клиента. Дополнительная информация в логах.");
|
|
||||||
}
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка удаления клиента");
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buttonUpdate_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,120 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<root>
|
|
||||||
<!--
|
|
||||||
Microsoft ResX Schema
|
|
||||||
|
|
||||||
Version 2.0
|
|
||||||
|
|
||||||
The primary goals of this format is to allow a simple XML format
|
|
||||||
that is mostly human readable. The generation and parsing of the
|
|
||||||
various data types are done through the TypeConverter classes
|
|
||||||
associated with the data types.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
... ado.net/XML headers & schema ...
|
|
||||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
|
||||||
<resheader name="version">2.0</resheader>
|
|
||||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
|
||||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
|
||||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
|
||||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
|
||||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
|
||||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
|
||||||
</data>
|
|
||||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
|
||||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
|
||||||
<comment>This is a comment</comment>
|
|
||||||
</data>
|
|
||||||
|
|
||||||
There are any number of "resheader" rows that contain simple
|
|
||||||
name/value pairs.
|
|
||||||
|
|
||||||
Each data row contains a name, and value. The row also contains a
|
|
||||||
type or mimetype. Type corresponds to a .NET class that support
|
|
||||||
text/value conversion through the TypeConverter architecture.
|
|
||||||
Classes that don't support this are serialized and stored with the
|
|
||||||
mimetype set.
|
|
||||||
|
|
||||||
The mimetype is used for serialized objects, and tells the
|
|
||||||
ResXResourceReader how to depersist the object. This is currently not
|
|
||||||
extensible. For a given mimetype the value must be set accordingly:
|
|
||||||
|
|
||||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
|
||||||
that the ResXResourceWriter will generate, however the reader can
|
|
||||||
read any of the formats listed below.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.binary.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.soap.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
|
||||||
value : The object must be serialized into a byte array
|
|
||||||
: using a System.ComponentModel.TypeConverter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
-->
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
</root>
|
|
118
AutomobilePlant/FormComponent.Designer.cs
generated
118
AutomobilePlant/FormComponent.Designer.cs
generated
@ -1,118 +0,0 @@
|
|||||||
namespace AutomobilePlant
|
|
||||||
{
|
|
||||||
partial class FormComponent
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
this.labelName = new System.Windows.Forms.Label();
|
|
||||||
this.labelPrice = new System.Windows.Forms.Label();
|
|
||||||
this.textBoxName = new System.Windows.Forms.TextBox();
|
|
||||||
this.textBoxCost = new System.Windows.Forms.TextBox();
|
|
||||||
this.buttonSave = new System.Windows.Forms.Button();
|
|
||||||
this.buttonCancel = new System.Windows.Forms.Button();
|
|
||||||
this.SuspendLayout();
|
|
||||||
//
|
|
||||||
// labelName
|
|
||||||
//
|
|
||||||
this.labelName.AutoSize = true;
|
|
||||||
this.labelName.Location = new System.Drawing.Point(27, 19);
|
|
||||||
this.labelName.Name = "labelName";
|
|
||||||
this.labelName.Size = new System.Drawing.Size(80, 20);
|
|
||||||
this.labelName.TabIndex = 0;
|
|
||||||
this.labelName.Text = "Название:";
|
|
||||||
//
|
|
||||||
// labelPrice
|
|
||||||
//
|
|
||||||
this.labelPrice.AutoSize = true;
|
|
||||||
this.labelPrice.Location = new System.Drawing.Point(27, 70);
|
|
||||||
this.labelPrice.Name = "labelPrice";
|
|
||||||
this.labelPrice.Size = new System.Drawing.Size(48, 20);
|
|
||||||
this.labelPrice.TabIndex = 1;
|
|
||||||
this.labelPrice.Text = "Цена:";
|
|
||||||
//
|
|
||||||
// textBoxName
|
|
||||||
//
|
|
||||||
this.textBoxName.Location = new System.Drawing.Point(113, 16);
|
|
||||||
this.textBoxName.Name = "textBoxName";
|
|
||||||
this.textBoxName.Size = new System.Drawing.Size(257, 27);
|
|
||||||
this.textBoxName.TabIndex = 2;
|
|
||||||
//
|
|
||||||
// textBoxCost
|
|
||||||
//
|
|
||||||
this.textBoxCost.Location = new System.Drawing.Point(113, 67);
|
|
||||||
this.textBoxCost.Name = "textBoxCost";
|
|
||||||
this.textBoxCost.Size = new System.Drawing.Size(257, 27);
|
|
||||||
this.textBoxCost.TabIndex = 3;
|
|
||||||
//
|
|
||||||
// buttonSave
|
|
||||||
//
|
|
||||||
this.buttonSave.Location = new System.Drawing.Point(176, 108);
|
|
||||||
this.buttonSave.Name = "buttonSave";
|
|
||||||
this.buttonSave.Size = new System.Drawing.Size(94, 29);
|
|
||||||
this.buttonSave.TabIndex = 4;
|
|
||||||
this.buttonSave.Text = "Сохранить";
|
|
||||||
this.buttonSave.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
|
|
||||||
//
|
|
||||||
// buttonCancel
|
|
||||||
//
|
|
||||||
this.buttonCancel.Location = new System.Drawing.Point(276, 108);
|
|
||||||
this.buttonCancel.Name = "buttonCancel";
|
|
||||||
this.buttonCancel.Size = new System.Drawing.Size(94, 29);
|
|
||||||
this.buttonCancel.TabIndex = 5;
|
|
||||||
this.buttonCancel.Text = "Отмена";
|
|
||||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
|
||||||
//
|
|
||||||
// FormComponent
|
|
||||||
//
|
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
this.ClientSize = new System.Drawing.Size(400, 149);
|
|
||||||
this.Controls.Add(this.buttonCancel);
|
|
||||||
this.Controls.Add(this.buttonSave);
|
|
||||||
this.Controls.Add(this.textBoxCost);
|
|
||||||
this.Controls.Add(this.textBoxName);
|
|
||||||
this.Controls.Add(this.labelPrice);
|
|
||||||
this.Controls.Add(this.labelName);
|
|
||||||
this.Name = "FormComponent";
|
|
||||||
this.Text = "Компонент";
|
|
||||||
this.ResumeLayout(false);
|
|
||||||
this.PerformLayout();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private Label labelName;
|
|
||||||
private Label labelPrice;
|
|
||||||
private TextBox textBoxName;
|
|
||||||
private TextBox textBoxCost;
|
|
||||||
private Button buttonSave;
|
|
||||||
private Button buttonCancel;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,93 +0,0 @@
|
|||||||
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 AutomobilePlantContracts.BusinessLogicContracts;
|
|
||||||
using AutomobilePlantContracts.BindingModels;
|
|
||||||
using AutomobilePlantContracts.SearchModels;
|
|
||||||
|
|
||||||
namespace AutomobilePlant
|
|
||||||
{
|
|
||||||
public partial class FormComponent : Form
|
|
||||||
{
|
|
||||||
private readonly ILogger _logger;
|
|
||||||
private readonly IComponentLogic _logic;
|
|
||||||
private int? _id;
|
|
||||||
public int Id { set { _id = value; } }
|
|
||||||
|
|
||||||
public FormComponent(ILogger<FormComponent> logger, IComponentLogic logic)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_logger = logger;
|
|
||||||
_logic = logic;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void FormComponent_Load(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (_id.HasValue)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Получение компонента");
|
|
||||||
var view = _logic.ReadElement(new ComponentSearchModel
|
|
||||||
{
|
|
||||||
Id = _id.Value
|
|
||||||
});
|
|
||||||
if (view != null)
|
|
||||||
{
|
|
||||||
textBoxName.Text = view.ComponentName;
|
|
||||||
textBoxCost.Text = view.Cost.ToString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Сохранение компонента");
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var model = new ComponentBindingModel
|
|
||||||
{
|
|
||||||
Id = _id ?? 0,
|
|
||||||
ComponentName = textBoxName.Text,
|
|
||||||
Cost = Convert.ToDouble(textBoxCost.Text)
|
|
||||||
};
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,60 +0,0 @@
|
|||||||
<root>
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
</root>
|
|
115
AutomobilePlant/FormComponents.Designer.cs
generated
115
AutomobilePlant/FormComponents.Designer.cs
generated
@ -1,115 +0,0 @@
|
|||||||
namespace AutomobilePlant
|
|
||||||
{
|
|
||||||
partial class FormComponents
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
|
||||||
this.buttonAdd = new System.Windows.Forms.Button();
|
|
||||||
this.buttonEdit = new System.Windows.Forms.Button();
|
|
||||||
this.buttonDelete = new System.Windows.Forms.Button();
|
|
||||||
this.buttonUpdate = new System.Windows.Forms.Button();
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
|
||||||
this.SuspendLayout();
|
|
||||||
//
|
|
||||||
// dataGridView
|
|
||||||
//
|
|
||||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
|
||||||
this.dataGridView.Location = new System.Drawing.Point(12, 12);
|
|
||||||
this.dataGridView.Name = "dataGridView";
|
|
||||||
this.dataGridView.RowHeadersWidth = 51;
|
|
||||||
this.dataGridView.RowTemplate.Height = 29;
|
|
||||||
this.dataGridView.Size = new System.Drawing.Size(599, 540);
|
|
||||||
this.dataGridView.TabIndex = 0;
|
|
||||||
//
|
|
||||||
// buttonAdd
|
|
||||||
//
|
|
||||||
this.buttonAdd.Location = new System.Drawing.Point(661, 12);
|
|
||||||
this.buttonAdd.Name = "buttonAdd";
|
|
||||||
this.buttonAdd.Size = new System.Drawing.Size(145, 55);
|
|
||||||
this.buttonAdd.TabIndex = 1;
|
|
||||||
this.buttonAdd.Text = "Добавить";
|
|
||||||
this.buttonAdd.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
|
|
||||||
//
|
|
||||||
// buttonEdit
|
|
||||||
//
|
|
||||||
this.buttonEdit.Location = new System.Drawing.Point(661, 100);
|
|
||||||
this.buttonEdit.Name = "buttonEdit";
|
|
||||||
this.buttonEdit.Size = new System.Drawing.Size(145, 52);
|
|
||||||
this.buttonEdit.TabIndex = 2;
|
|
||||||
this.buttonEdit.Text = "Изменить";
|
|
||||||
this.buttonEdit.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonEdit.Click += new System.EventHandler(this.ButtonEdit_Click);
|
|
||||||
//
|
|
||||||
// buttonDelete
|
|
||||||
//
|
|
||||||
this.buttonDelete.Location = new System.Drawing.Point(661, 186);
|
|
||||||
this.buttonDelete.Name = "buttonDelete";
|
|
||||||
this.buttonDelete.Size = new System.Drawing.Size(145, 52);
|
|
||||||
this.buttonDelete.TabIndex = 3;
|
|
||||||
this.buttonDelete.Text = "Удалить";
|
|
||||||
this.buttonDelete.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonDelete.Click += new System.EventHandler(this.ButtonDelete_Click);
|
|
||||||
//
|
|
||||||
// buttonUpdate
|
|
||||||
//
|
|
||||||
this.buttonUpdate.Location = new System.Drawing.Point(661, 273);
|
|
||||||
this.buttonUpdate.Name = "buttonUpdate";
|
|
||||||
this.buttonUpdate.Size = new System.Drawing.Size(145, 55);
|
|
||||||
this.buttonUpdate.TabIndex = 4;
|
|
||||||
this.buttonUpdate.Text = "Обновить";
|
|
||||||
this.buttonUpdate.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonUpdate.Click += new System.EventHandler(this.ButtonUpdate_Click);
|
|
||||||
//
|
|
||||||
// FormComponents
|
|
||||||
//
|
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
this.ClientSize = new System.Drawing.Size(843, 564);
|
|
||||||
this.Controls.Add(this.buttonUpdate);
|
|
||||||
this.Controls.Add(this.buttonDelete);
|
|
||||||
this.Controls.Add(this.buttonEdit);
|
|
||||||
this.Controls.Add(this.buttonAdd);
|
|
||||||
this.Controls.Add(this.dataGridView);
|
|
||||||
this.Name = "FormComponents";
|
|
||||||
this.Text = "Компоненты";
|
|
||||||
this.Load += new System.EventHandler(this.FormComponents_Load);
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
|
||||||
this.ResumeLayout(false);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private DataGridView dataGridView;
|
|
||||||
private Button buttonAdd;
|
|
||||||
private Button buttonEdit;
|
|
||||||
private Button buttonDelete;
|
|
||||||
private Button buttonUpdate;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,103 +0,0 @@
|
|||||||
using AutomobilePlantContracts.BindingModels;
|
|
||||||
using AutomobilePlantContracts.BusinessLogicContracts;
|
|
||||||
using AutomobilePlantContracts.DI;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Data;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
namespace AutomobilePlant
|
|
||||||
{
|
|
||||||
public partial class FormComponents : Form
|
|
||||||
{
|
|
||||||
private readonly ILogger _logger;
|
|
||||||
private readonly IComponentLogic _logic;
|
|
||||||
|
|
||||||
public FormComponents(ILogger<FormComponents> logger, IComponentLogic logic)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_logger = logger;
|
|
||||||
_logic = logic;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void FormComponents_Load(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void LoadData()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
dataGridView.FillAndConfigGrid(_logic.ReadList(null));
|
|
||||||
_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 form = DependencyManager.Instance.Resolve<FormComponent>();
|
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonEdit_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
|
||||||
{
|
|
||||||
var form = DependencyManager.Instance.Resolve<FormComponent>();
|
|
||||||
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonDelete_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
|
||||||
{
|
|
||||||
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
|
||||||
{
|
|
||||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
|
||||||
_logger.LogInformation("Удаление компонента");
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (!_logic.Delete(new ComponentBindingModel
|
|
||||||
{
|
|
||||||
Id = id
|
|
||||||
}))
|
|
||||||
{
|
|
||||||
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
|
|
||||||
}
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка удаления компонента");
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void ButtonUpdate_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,60 +0,0 @@
|
|||||||
<root>
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
</root>
|
|
167
AutomobilePlant/FormCreateOrder.Designer.cs
generated
167
AutomobilePlant/FormCreateOrder.Designer.cs
generated
@ -1,167 +0,0 @@
|
|||||||
namespace AutomobilePlant
|
|
||||||
{
|
|
||||||
partial class FormCreateOrder
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
this.labelName = new System.Windows.Forms.Label();
|
|
||||||
this.labelCount = new System.Windows.Forms.Label();
|
|
||||||
this.labelSum = new System.Windows.Forms.Label();
|
|
||||||
this.comboBoxCar = new System.Windows.Forms.ComboBox();
|
|
||||||
this.textBoxCount = new System.Windows.Forms.TextBox();
|
|
||||||
this.textBoxSum = new System.Windows.Forms.TextBox();
|
|
||||||
this.buttonSave = new System.Windows.Forms.Button();
|
|
||||||
this.buttonCancel = new System.Windows.Forms.Button();
|
|
||||||
this.labelClient = new System.Windows.Forms.Label();
|
|
||||||
this.comboBoxClient = new System.Windows.Forms.ComboBox();
|
|
||||||
this.SuspendLayout();
|
|
||||||
//
|
|
||||||
// labelName
|
|
||||||
//
|
|
||||||
this.labelName.AutoSize = true;
|
|
||||||
this.labelName.Location = new System.Drawing.Point(30, 20);
|
|
||||||
this.labelName.Name = "labelName";
|
|
||||||
this.labelName.Size = new System.Drawing.Size(99, 20);
|
|
||||||
this.labelName.TabIndex = 0;
|
|
||||||
this.labelName.Text = "Автомобиль:";
|
|
||||||
//
|
|
||||||
// labelCount
|
|
||||||
//
|
|
||||||
this.labelCount.AutoSize = true;
|
|
||||||
this.labelCount.Location = new System.Drawing.Point(30, 100);
|
|
||||||
this.labelCount.Name = "labelCount";
|
|
||||||
this.labelCount.Size = new System.Drawing.Size(93, 20);
|
|
||||||
this.labelCount.TabIndex = 1;
|
|
||||||
this.labelCount.Text = "Количество:";
|
|
||||||
//
|
|
||||||
// labelSum
|
|
||||||
//
|
|
||||||
this.labelSum.AutoSize = true;
|
|
||||||
this.labelSum.Location = new System.Drawing.Point(30, 138);
|
|
||||||
this.labelSum.Name = "labelSum";
|
|
||||||
this.labelSum.Size = new System.Drawing.Size(58, 20);
|
|
||||||
this.labelSum.TabIndex = 2;
|
|
||||||
this.labelSum.Text = "Сумма:";
|
|
||||||
//
|
|
||||||
// comboBoxCar
|
|
||||||
//
|
|
||||||
this.comboBoxCar.FormattingEnabled = true;
|
|
||||||
this.comboBoxCar.Location = new System.Drawing.Point(171, 20);
|
|
||||||
this.comboBoxCar.Name = "comboBoxCar";
|
|
||||||
this.comboBoxCar.Size = new System.Drawing.Size(262, 28);
|
|
||||||
this.comboBoxCar.TabIndex = 3;
|
|
||||||
this.comboBoxCar.SelectedIndexChanged += new System.EventHandler(this.ComboBoxCar_SelectedIndexChanged);
|
|
||||||
//
|
|
||||||
// textBoxCount
|
|
||||||
//
|
|
||||||
this.textBoxCount.Location = new System.Drawing.Point(171, 100);
|
|
||||||
this.textBoxCount.Name = "textBoxCount";
|
|
||||||
this.textBoxCount.Size = new System.Drawing.Size(262, 27);
|
|
||||||
this.textBoxCount.TabIndex = 4;
|
|
||||||
this.textBoxCount.TextChanged += new System.EventHandler(this.TextBoxCount_TextChanged);
|
|
||||||
//
|
|
||||||
// textBoxSum
|
|
||||||
//
|
|
||||||
this.textBoxSum.Location = new System.Drawing.Point(171, 135);
|
|
||||||
this.textBoxSum.Name = "textBoxSum";
|
|
||||||
this.textBoxSum.Size = new System.Drawing.Size(262, 27);
|
|
||||||
this.textBoxSum.TabIndex = 5;
|
|
||||||
//
|
|
||||||
// buttonSave
|
|
||||||
//
|
|
||||||
this.buttonSave.Location = new System.Drawing.Point(239, 171);
|
|
||||||
this.buttonSave.Name = "buttonSave";
|
|
||||||
this.buttonSave.Size = new System.Drawing.Size(94, 29);
|
|
||||||
this.buttonSave.TabIndex = 6;
|
|
||||||
this.buttonSave.Text = "Сохранить";
|
|
||||||
this.buttonSave.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
|
|
||||||
//
|
|
||||||
// buttonCancel
|
|
||||||
//
|
|
||||||
this.buttonCancel.Location = new System.Drawing.Point(339, 171);
|
|
||||||
this.buttonCancel.Name = "buttonCancel";
|
|
||||||
this.buttonCancel.Size = new System.Drawing.Size(94, 29);
|
|
||||||
this.buttonCancel.TabIndex = 7;
|
|
||||||
this.buttonCancel.Text = "Отмена";
|
|
||||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
|
||||||
//
|
|
||||||
// labelClient
|
|
||||||
//
|
|
||||||
this.labelClient.AutoSize = true;
|
|
||||||
this.labelClient.Location = new System.Drawing.Point(30, 61);
|
|
||||||
this.labelClient.Name = "labelClient";
|
|
||||||
this.labelClient.Size = new System.Drawing.Size(61, 20);
|
|
||||||
this.labelClient.TabIndex = 8;
|
|
||||||
this.labelClient.Text = "Клиент:";
|
|
||||||
//
|
|
||||||
// comboBoxClient
|
|
||||||
//
|
|
||||||
this.comboBoxClient.FormattingEnabled = true;
|
|
||||||
this.comboBoxClient.Location = new System.Drawing.Point(171, 61);
|
|
||||||
this.comboBoxClient.Name = "comboBoxClient";
|
|
||||||
this.comboBoxClient.Size = new System.Drawing.Size(262, 28);
|
|
||||||
this.comboBoxClient.TabIndex = 9;
|
|
||||||
//
|
|
||||||
// FormCreateOrder
|
|
||||||
//
|
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
this.ClientSize = new System.Drawing.Size(450, 212);
|
|
||||||
this.Controls.Add(this.comboBoxClient);
|
|
||||||
this.Controls.Add(this.labelClient);
|
|
||||||
this.Controls.Add(this.buttonCancel);
|
|
||||||
this.Controls.Add(this.buttonSave);
|
|
||||||
this.Controls.Add(this.textBoxSum);
|
|
||||||
this.Controls.Add(this.textBoxCount);
|
|
||||||
this.Controls.Add(this.comboBoxCar);
|
|
||||||
this.Controls.Add(this.labelSum);
|
|
||||||
this.Controls.Add(this.labelCount);
|
|
||||||
this.Controls.Add(this.labelName);
|
|
||||||
this.Name = "FormCreateOrder";
|
|
||||||
this.Text = "Создание заказа";
|
|
||||||
this.Load += new System.EventHandler(this.FormCreateOrder_Load);
|
|
||||||
this.ResumeLayout(false);
|
|
||||||
this.PerformLayout();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private Label labelName;
|
|
||||||
private Label labelCount;
|
|
||||||
private Label labelSum;
|
|
||||||
private ComboBox comboBoxCar;
|
|
||||||
private TextBox textBoxCount;
|
|
||||||
private TextBox textBoxSum;
|
|
||||||
private Button buttonSave;
|
|
||||||
private Button buttonCancel;
|
|
||||||
private Label labelClient;
|
|
||||||
private ComboBox comboBoxClient;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,156 +0,0 @@
|
|||||||
using AutomobilePlantContracts.BindingModels;
|
|
||||||
using AutomobilePlantContracts.BusinessLogicContracts;
|
|
||||||
using AutomobilePlantContracts.SearchModels;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Data;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
namespace AutomobilePlant
|
|
||||||
{
|
|
||||||
public partial class FormCreateOrder : Form
|
|
||||||
{
|
|
||||||
private readonly ILogger _logger;
|
|
||||||
private readonly ICarLogic _logicС;
|
|
||||||
private readonly IOrderLogic _logicO;
|
|
||||||
private readonly IClientLogic _logicClient;
|
|
||||||
|
|
||||||
public FormCreateOrder(ILogger<FormCreateOrder> logger, ICarLogic logicС, IOrderLogic logicO, IClientLogic logicClient)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_logger = logger;
|
|
||||||
_logicС = logicС;
|
|
||||||
_logicO = logicO;
|
|
||||||
_logicClient = logicClient;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void FormCreateOrder_Load(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Загрузка автомобилей для заказа");
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var list = _logicС.ReadList(null);
|
|
||||||
if (list != null)
|
|
||||||
{
|
|
||||||
comboBoxCar.DisplayMember = "CarName";
|
|
||||||
comboBoxCar.ValueMember = "Id";
|
|
||||||
comboBoxCar.DataSource = list;
|
|
||||||
comboBoxCar.SelectedItem = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка загрузки списка автомобилей");
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
|
|
||||||
_logger.LogInformation("Загрузка клиентов для заказа");
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var list = _logicClient.ReadList(null);
|
|
||||||
if (list != null)
|
|
||||||
{
|
|
||||||
comboBoxClient.DisplayMember = "ClientFIO";
|
|
||||||
comboBoxClient.ValueMember = "Id";
|
|
||||||
comboBoxClient.DataSource = list;
|
|
||||||
comboBoxClient.SelectedItem = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка загрузки списка клиентов");
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void CalcSum()
|
|
||||||
{
|
|
||||||
if (comboBoxCar.SelectedValue != null && !string.IsNullOrEmpty(textBoxCount.Text))
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
int id = Convert.ToInt32(comboBoxCar.SelectedValue);
|
|
||||||
var product = _logicС.ReadElement(new CarSearchModel
|
|
||||||
{
|
|
||||||
Id = id
|
|
||||||
});
|
|
||||||
int count = Convert.ToInt32(textBoxCount.Text);
|
|
||||||
textBoxSum.Text = Math.Round(count * (product?.Price ?? 0), 2).ToString();
|
|
||||||
_logger.LogInformation("Расчет суммы заказа");
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка расчета суммы заказа");
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
|
||||||
MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void TextBoxCount_TextChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
CalcSum();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ComboBoxCar_SelectedIndexChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
CalcSum();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonSave_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(textBoxCount.Text))
|
|
||||||
{
|
|
||||||
MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (comboBoxCar.SelectedValue == null)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Выберите автомобиль", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (comboBoxClient.SelectedValue == null)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Выберите клиента", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Создание заказа");
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var operationResult = _logicO.CreateOrder(new OrderBindingModel
|
|
||||||
{
|
|
||||||
CarId = Convert.ToInt32(comboBoxCar.SelectedValue),
|
|
||||||
ClientId = Convert.ToInt32(comboBoxClient.SelectedValue),
|
|
||||||
Count = Convert.ToInt32(textBoxCount.Text),
|
|
||||||
Sum = Convert.ToDouble(textBoxSum.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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,60 +0,0 @@
|
|||||||
<root>
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
</root>
|
|
167
AutomobilePlant/FormImplementer.Designer.cs
generated
167
AutomobilePlant/FormImplementer.Designer.cs
generated
@ -1,167 +0,0 @@
|
|||||||
namespace AutomobilePlant
|
|
||||||
{
|
|
||||||
partial class FormImplementer
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
this.labelFIO = new System.Windows.Forms.Label();
|
|
||||||
this.labelPassword = new System.Windows.Forms.Label();
|
|
||||||
this.labelWorkExp = new System.Windows.Forms.Label();
|
|
||||||
this.labelQualification = new System.Windows.Forms.Label();
|
|
||||||
this.textBoxFIO = new System.Windows.Forms.TextBox();
|
|
||||||
this.textBoxPassword = new System.Windows.Forms.TextBox();
|
|
||||||
this.numericUpDownWorkExp = new System.Windows.Forms.NumericUpDown();
|
|
||||||
this.numericUpDownQualification = new System.Windows.Forms.NumericUpDown();
|
|
||||||
this.buttonSave = new System.Windows.Forms.Button();
|
|
||||||
this.buttonCancel = new System.Windows.Forms.Button();
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownWorkExp)).BeginInit();
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownQualification)).BeginInit();
|
|
||||||
this.SuspendLayout();
|
|
||||||
//
|
|
||||||
// labelFIO
|
|
||||||
//
|
|
||||||
this.labelFIO.AutoSize = true;
|
|
||||||
this.labelFIO.Location = new System.Drawing.Point(24, 47);
|
|
||||||
this.labelFIO.Name = "labelFIO";
|
|
||||||
this.labelFIO.Size = new System.Drawing.Size(49, 20);
|
|
||||||
this.labelFIO.TabIndex = 0;
|
|
||||||
this.labelFIO.Text = "ФИО: ";
|
|
||||||
//
|
|
||||||
// labelPassword
|
|
||||||
//
|
|
||||||
this.labelPassword.AutoSize = true;
|
|
||||||
this.labelPassword.Location = new System.Drawing.Point(24, 92);
|
|
||||||
this.labelPassword.Name = "labelPassword";
|
|
||||||
this.labelPassword.Size = new System.Drawing.Size(65, 20);
|
|
||||||
this.labelPassword.TabIndex = 1;
|
|
||||||
this.labelPassword.Text = "Пароль:";
|
|
||||||
//
|
|
||||||
// labelWorkExp
|
|
||||||
//
|
|
||||||
this.labelWorkExp.AutoSize = true;
|
|
||||||
this.labelWorkExp.Location = new System.Drawing.Point(24, 134);
|
|
||||||
this.labelWorkExp.Name = "labelWorkExp";
|
|
||||||
this.labelWorkExp.Size = new System.Drawing.Size(102, 20);
|
|
||||||
this.labelWorkExp.TabIndex = 2;
|
|
||||||
this.labelWorkExp.Text = "Стаж работы:";
|
|
||||||
//
|
|
||||||
// labelQualification
|
|
||||||
//
|
|
||||||
this.labelQualification.AutoSize = true;
|
|
||||||
this.labelQualification.Location = new System.Drawing.Point(24, 177);
|
|
||||||
this.labelQualification.Name = "labelQualification";
|
|
||||||
this.labelQualification.Size = new System.Drawing.Size(114, 20);
|
|
||||||
this.labelQualification.TabIndex = 3;
|
|
||||||
this.labelQualification.Text = "Квалификация:";
|
|
||||||
//
|
|
||||||
// textBoxFIO
|
|
||||||
//
|
|
||||||
this.textBoxFIO.Location = new System.Drawing.Point(155, 47);
|
|
||||||
this.textBoxFIO.Name = "textBoxFIO";
|
|
||||||
this.textBoxFIO.Size = new System.Drawing.Size(371, 27);
|
|
||||||
this.textBoxFIO.TabIndex = 4;
|
|
||||||
//
|
|
||||||
// textBoxPassword
|
|
||||||
//
|
|
||||||
this.textBoxPassword.Location = new System.Drawing.Point(155, 85);
|
|
||||||
this.textBoxPassword.Name = "textBoxPassword";
|
|
||||||
this.textBoxPassword.Size = new System.Drawing.Size(182, 27);
|
|
||||||
this.textBoxPassword.TabIndex = 5;
|
|
||||||
//
|
|
||||||
// numericUpDownWorkExp
|
|
||||||
//
|
|
||||||
this.numericUpDownWorkExp.Location = new System.Drawing.Point(155, 132);
|
|
||||||
this.numericUpDownWorkExp.Name = "numericUpDownWorkExp";
|
|
||||||
this.numericUpDownWorkExp.Size = new System.Drawing.Size(182, 27);
|
|
||||||
this.numericUpDownWorkExp.TabIndex = 6;
|
|
||||||
//
|
|
||||||
// numericUpDownQualification
|
|
||||||
//
|
|
||||||
this.numericUpDownQualification.Location = new System.Drawing.Point(155, 175);
|
|
||||||
this.numericUpDownQualification.Name = "numericUpDownQualification";
|
|
||||||
this.numericUpDownQualification.Size = new System.Drawing.Size(182, 27);
|
|
||||||
this.numericUpDownQualification.TabIndex = 7;
|
|
||||||
//
|
|
||||||
// buttonSave
|
|
||||||
//
|
|
||||||
this.buttonSave.Location = new System.Drawing.Point(324, 233);
|
|
||||||
this.buttonSave.Name = "buttonSave";
|
|
||||||
this.buttonSave.Size = new System.Drawing.Size(103, 29);
|
|
||||||
this.buttonSave.TabIndex = 8;
|
|
||||||
this.buttonSave.Text = "Сохранить";
|
|
||||||
this.buttonSave.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonSave.Click += new System.EventHandler(this.buttonSave_Click);
|
|
||||||
//
|
|
||||||
// buttonCancel
|
|
||||||
//
|
|
||||||
this.buttonCancel.Location = new System.Drawing.Point(433, 233);
|
|
||||||
this.buttonCancel.Name = "buttonCancel";
|
|
||||||
this.buttonCancel.Size = new System.Drawing.Size(106, 29);
|
|
||||||
this.buttonCancel.TabIndex = 9;
|
|
||||||
this.buttonCancel.Text = "Отмена";
|
|
||||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
|
|
||||||
//
|
|
||||||
// FormImplementer
|
|
||||||
//
|
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
this.ClientSize = new System.Drawing.Size(551, 274);
|
|
||||||
this.Controls.Add(this.buttonCancel);
|
|
||||||
this.Controls.Add(this.buttonSave);
|
|
||||||
this.Controls.Add(this.numericUpDownQualification);
|
|
||||||
this.Controls.Add(this.numericUpDownWorkExp);
|
|
||||||
this.Controls.Add(this.textBoxPassword);
|
|
||||||
this.Controls.Add(this.textBoxFIO);
|
|
||||||
this.Controls.Add(this.labelQualification);
|
|
||||||
this.Controls.Add(this.labelWorkExp);
|
|
||||||
this.Controls.Add(this.labelPassword);
|
|
||||||
this.Controls.Add(this.labelFIO);
|
|
||||||
this.Name = "FormImplementer";
|
|
||||||
this.Text = "Исполнитель";
|
|
||||||
this.Load += new System.EventHandler(this.FormImplementer_Load);
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownWorkExp)).EndInit();
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownQualification)).EndInit();
|
|
||||||
this.ResumeLayout(false);
|
|
||||||
this.PerformLayout();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private Label labelFIO;
|
|
||||||
private Label labelPassword;
|
|
||||||
private Label labelWorkExp;
|
|
||||||
private Label labelQualification;
|
|
||||||
private TextBox textBoxFIO;
|
|
||||||
private TextBox textBoxPassword;
|
|
||||||
private NumericUpDown numericUpDownWorkExp;
|
|
||||||
private NumericUpDown numericUpDownQualification;
|
|
||||||
private Button buttonSave;
|
|
||||||
private Button buttonCancel;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,101 +0,0 @@
|
|||||||
using AutomobilePlantContracts.BindingModels;
|
|
||||||
using AutomobilePlantContracts.BusinessLogicContracts;
|
|
||||||
using AutomobilePlantContracts.SearchModels;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Data;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
namespace AutomobilePlant
|
|
||||||
{
|
|
||||||
public partial class FormImplementer : Form
|
|
||||||
{
|
|
||||||
private readonly ILogger _logger;
|
|
||||||
private readonly IImplementerLogic _logic;
|
|
||||||
private int? _id;
|
|
||||||
public int Id { set { _id = value; } }
|
|
||||||
public FormImplementer(ILogger<FormImplementer> logger, IImplementerLogic logic)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_logger = logger;
|
|
||||||
_logic = logic;
|
|
||||||
}
|
|
||||||
private void FormImplementer_Load(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (_id.HasValue)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Получение информации исполнителя");
|
|
||||||
var view = _logic.ReadElement(new ImplementerSearchModel
|
|
||||||
{
|
|
||||||
Id = _id.Value
|
|
||||||
});
|
|
||||||
if (view != null)
|
|
||||||
{
|
|
||||||
textBoxFIO.Text = view.ImplementerFIO;
|
|
||||||
textBoxPassword.Text = view.Password;
|
|
||||||
numericUpDownQualification.Value = view.Qualification;
|
|
||||||
numericUpDownWorkExp.Value = view.WorkExperience;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
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(textBoxPassword.Text))
|
|
||||||
{
|
|
||||||
MessageBox.Show("Заполните пароль", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (string.IsNullOrEmpty(textBoxFIO.Text))
|
|
||||||
{
|
|
||||||
MessageBox.Show("Заполните ФИО", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Сохранение исполнителя");
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var model = new ImplementerBindingModel
|
|
||||||
{
|
|
||||||
Id = _id ?? 0,
|
|
||||||
ImplementerFIO = textBoxFIO.Text,
|
|
||||||
Password = textBoxPassword.Text,
|
|
||||||
Qualification = (int)numericUpDownQualification.Value,
|
|
||||||
WorkExperience = (int)numericUpDownWorkExp.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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,120 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<root>
|
|
||||||
<!--
|
|
||||||
Microsoft ResX Schema
|
|
||||||
|
|
||||||
Version 2.0
|
|
||||||
|
|
||||||
The primary goals of this format is to allow a simple XML format
|
|
||||||
that is mostly human readable. The generation and parsing of the
|
|
||||||
various data types are done through the TypeConverter classes
|
|
||||||
associated with the data types.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
... ado.net/XML headers & schema ...
|
|
||||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
|
||||||
<resheader name="version">2.0</resheader>
|
|
||||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
|
||||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
|
||||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
|
||||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
|
||||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
|
||||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
|
||||||
</data>
|
|
||||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
|
||||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
|
||||||
<comment>This is a comment</comment>
|
|
||||||
</data>
|
|
||||||
|
|
||||||
There are any number of "resheader" rows that contain simple
|
|
||||||
name/value pairs.
|
|
||||||
|
|
||||||
Each data row contains a name, and value. The row also contains a
|
|
||||||
type or mimetype. Type corresponds to a .NET class that support
|
|
||||||
text/value conversion through the TypeConverter architecture.
|
|
||||||
Classes that don't support this are serialized and stored with the
|
|
||||||
mimetype set.
|
|
||||||
|
|
||||||
The mimetype is used for serialized objects, and tells the
|
|
||||||
ResXResourceReader how to depersist the object. This is currently not
|
|
||||||
extensible. For a given mimetype the value must be set accordingly:
|
|
||||||
|
|
||||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
|
||||||
that the ResXResourceWriter will generate, however the reader can
|
|
||||||
read any of the formats listed below.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.binary.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.soap.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
|
||||||
value : The object must be serialized into a byte array
|
|
||||||
: using a System.ComponentModel.TypeConverter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
-->
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
</root>
|
|
114
AutomobilePlant/FormImplementers.Designer.cs
generated
114
AutomobilePlant/FormImplementers.Designer.cs
generated
@ -1,114 +0,0 @@
|
|||||||
namespace AutomobilePlant
|
|
||||||
{
|
|
||||||
partial class FormImplementers
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
this.buttonCreate = new System.Windows.Forms.Button();
|
|
||||||
this.buttonEdit = new System.Windows.Forms.Button();
|
|
||||||
this.buttonDelete = new System.Windows.Forms.Button();
|
|
||||||
this.buttonRefresh = new System.Windows.Forms.Button();
|
|
||||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
|
||||||
this.SuspendLayout();
|
|
||||||
//
|
|
||||||
// buttonCreate
|
|
||||||
//
|
|
||||||
this.buttonCreate.Location = new System.Drawing.Point(667, 12);
|
|
||||||
this.buttonCreate.Name = "buttonCreate";
|
|
||||||
this.buttonCreate.Size = new System.Drawing.Size(121, 29);
|
|
||||||
this.buttonCreate.TabIndex = 0;
|
|
||||||
this.buttonCreate.Text = "Добавить";
|
|
||||||
this.buttonCreate.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonCreate.Click += new System.EventHandler(this.buttonCreate_Click);
|
|
||||||
//
|
|
||||||
// buttonEdit
|
|
||||||
//
|
|
||||||
this.buttonEdit.Location = new System.Drawing.Point(667, 47);
|
|
||||||
this.buttonEdit.Name = "buttonEdit";
|
|
||||||
this.buttonEdit.Size = new System.Drawing.Size(121, 29);
|
|
||||||
this.buttonEdit.TabIndex = 1;
|
|
||||||
this.buttonEdit.Text = "Изменить";
|
|
||||||
this.buttonEdit.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonEdit.Click += new System.EventHandler(this.buttonEdit_Click);
|
|
||||||
//
|
|
||||||
// buttonDelete
|
|
||||||
//
|
|
||||||
this.buttonDelete.Location = new System.Drawing.Point(667, 82);
|
|
||||||
this.buttonDelete.Name = "buttonDelete";
|
|
||||||
this.buttonDelete.Size = new System.Drawing.Size(121, 29);
|
|
||||||
this.buttonDelete.TabIndex = 2;
|
|
||||||
this.buttonDelete.Text = "Удалить";
|
|
||||||
this.buttonDelete.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonDelete.Click += new System.EventHandler(this.buttonDelete_Click);
|
|
||||||
//
|
|
||||||
// buttonRefresh
|
|
||||||
//
|
|
||||||
this.buttonRefresh.Location = new System.Drawing.Point(667, 117);
|
|
||||||
this.buttonRefresh.Name = "buttonRefresh";
|
|
||||||
this.buttonRefresh.Size = new System.Drawing.Size(121, 29);
|
|
||||||
this.buttonRefresh.TabIndex = 3;
|
|
||||||
this.buttonRefresh.Text = "Обновить";
|
|
||||||
this.buttonRefresh.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonRefresh.Click += new System.EventHandler(this.buttonRefresh_Click);
|
|
||||||
//
|
|
||||||
// dataGridView
|
|
||||||
//
|
|
||||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
|
||||||
this.dataGridView.Location = new System.Drawing.Point(12, 12);
|
|
||||||
this.dataGridView.Name = "dataGridView";
|
|
||||||
this.dataGridView.RowHeadersWidth = 51;
|
|
||||||
this.dataGridView.RowTemplate.Height = 29;
|
|
||||||
this.dataGridView.Size = new System.Drawing.Size(649, 426);
|
|
||||||
this.dataGridView.TabIndex = 4;
|
|
||||||
//
|
|
||||||
// FormImplementers
|
|
||||||
//
|
|
||||||
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.dataGridView);
|
|
||||||
this.Controls.Add(this.buttonRefresh);
|
|
||||||
this.Controls.Add(this.buttonDelete);
|
|
||||||
this.Controls.Add(this.buttonEdit);
|
|
||||||
this.Controls.Add(this.buttonCreate);
|
|
||||||
this.Name = "FormImplementers";
|
|
||||||
this.Text = "Исполнители";
|
|
||||||
this.Load += new System.EventHandler(this.FormImplementers_Load);
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
|
||||||
this.ResumeLayout(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private Button buttonCreate;
|
|
||||||
private Button buttonEdit;
|
|
||||||
private Button buttonDelete;
|
|
||||||
private Button buttonRefresh;
|
|
||||||
private DataGridView dataGridView;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,102 +0,0 @@
|
|||||||
using AutomobilePlantContracts.BindingModels;
|
|
||||||
using AutomobilePlantContracts.BusinessLogicContracts;
|
|
||||||
using AutomobilePlantContracts.DI;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Data;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
namespace AutomobilePlant
|
|
||||||
{
|
|
||||||
public partial class FormImplementers : Form
|
|
||||||
{
|
|
||||||
private readonly ILogger _logger;
|
|
||||||
private readonly IImplementerLogic _logic;
|
|
||||||
public FormImplementers(ILogger<FormImplementers> logger, IImplementerLogic logic)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_logger = logger;
|
|
||||||
_logic = logic;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void FormImplementers_Load(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
private void LoadData()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
dataGridView.FillAndConfigGrid(_logic.ReadList(null));
|
|
||||||
_logger.LogInformation("Загрузка исполнителей");
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка загрузки исполнителей");
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buttonCreate_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
var form = DependencyManager.Instance.Resolve<FormImplementer>();
|
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buttonEdit_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
|
||||||
{
|
|
||||||
var form = DependencyManager.Instance.Resolve<FormImplementer>();
|
|
||||||
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buttonDelete_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
|
||||||
{
|
|
||||||
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
|
||||||
{
|
|
||||||
int id =
|
|
||||||
Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
|
||||||
_logger.LogInformation("Удаление исполнителя");
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (!_logic.Delete(new ImplementerBindingModel
|
|
||||||
{
|
|
||||||
Id = id
|
|
||||||
}))
|
|
||||||
{
|
|
||||||
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
|
|
||||||
}
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка удаления исполнителя");
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buttonRefresh_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,120 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<root>
|
|
||||||
<!--
|
|
||||||
Microsoft ResX Schema
|
|
||||||
|
|
||||||
Version 2.0
|
|
||||||
|
|
||||||
The primary goals of this format is to allow a simple XML format
|
|
||||||
that is mostly human readable. The generation and parsing of the
|
|
||||||
various data types are done through the TypeConverter classes
|
|
||||||
associated with the data types.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
... ado.net/XML headers & schema ...
|
|
||||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
|
||||||
<resheader name="version">2.0</resheader>
|
|
||||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
|
||||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
|
||||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
|
||||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
|
||||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
|
||||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
|
||||||
</data>
|
|
||||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
|
||||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
|
||||||
<comment>This is a comment</comment>
|
|
||||||
</data>
|
|
||||||
|
|
||||||
There are any number of "resheader" rows that contain simple
|
|
||||||
name/value pairs.
|
|
||||||
|
|
||||||
Each data row contains a name, and value. The row also contains a
|
|
||||||
type or mimetype. Type corresponds to a .NET class that support
|
|
||||||
text/value conversion through the TypeConverter architecture.
|
|
||||||
Classes that don't support this are serialized and stored with the
|
|
||||||
mimetype set.
|
|
||||||
|
|
||||||
The mimetype is used for serialized objects, and tells the
|
|
||||||
ResXResourceReader how to depersist the object. This is currently not
|
|
||||||
extensible. For a given mimetype the value must be set accordingly:
|
|
||||||
|
|
||||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
|
||||||
that the ResXResourceWriter will generate, however the reader can
|
|
||||||
read any of the formats listed below.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.binary.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.soap.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
|
||||||
value : The object must be serialized into a byte array
|
|
||||||
: using a System.ComponentModel.TypeConverter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
-->
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
</root>
|
|
62
AutomobilePlant/FormMails.Designer.cs
generated
62
AutomobilePlant/FormMails.Designer.cs
generated
@ -1,62 +0,0 @@
|
|||||||
namespace AutomobilePlant
|
|
||||||
{
|
|
||||||
partial class FormMails
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
dataGridView = new DataGridView();
|
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
|
||||||
SuspendLayout();
|
|
||||||
//
|
|
||||||
// dataGridView
|
|
||||||
//
|
|
||||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
|
||||||
dataGridView.Location = new Point(12, 12);
|
|
||||||
dataGridView.Name = "dataGridView";
|
|
||||||
dataGridView.RowHeadersWidth = 51;
|
|
||||||
dataGridView.RowTemplate.Height = 29;
|
|
||||||
dataGridView.Size = new Size(776, 426);
|
|
||||||
dataGridView.TabIndex = 0;
|
|
||||||
//
|
|
||||||
// FormMails
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
|
||||||
ClientSize = new Size(800, 450);
|
|
||||||
Controls.Add(dataGridView);
|
|
||||||
Name = "FormMails";
|
|
||||||
Text = "Письма";
|
|
||||||
Load += FormMails_Load;
|
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
|
||||||
ResumeLayout(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private DataGridView dataGridView;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,42 +0,0 @@
|
|||||||
using AutomobilePlantContracts.BusinessLogicContracts;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Data;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
namespace AutomobilePlant
|
|
||||||
{
|
|
||||||
public partial class FormMails : Form
|
|
||||||
{
|
|
||||||
private readonly ILogger _logger;
|
|
||||||
private readonly IMessageInfoLogic _logic;
|
|
||||||
|
|
||||||
public FormMails(ILogger<FormMails> logger, IMessageInfoLogic logic)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_logger = logger;
|
|
||||||
_logic = logic;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void FormMails_Load(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
dataGridView.FillAndConfigGrid(_logic.ReadList(null));
|
|
||||||
_logger.LogInformation("Загрузка писем");
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка загрузки писем");
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
|
||||||
MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,120 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<root>
|
|
||||||
<!--
|
|
||||||
Microsoft ResX Schema
|
|
||||||
|
|
||||||
Version 2.0
|
|
||||||
|
|
||||||
The primary goals of this format is to allow a simple XML format
|
|
||||||
that is mostly human readable. The generation and parsing of the
|
|
||||||
various data types are done through the TypeConverter classes
|
|
||||||
associated with the data types.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
... ado.net/XML headers & schema ...
|
|
||||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
|
||||||
<resheader name="version">2.0</resheader>
|
|
||||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
|
||||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
|
||||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
|
||||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
|
||||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
|
||||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
|
||||||
</data>
|
|
||||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
|
||||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
|
||||||
<comment>This is a comment</comment>
|
|
||||||
</data>
|
|
||||||
|
|
||||||
There are any number of "resheader" rows that contain simple
|
|
||||||
name/value pairs.
|
|
||||||
|
|
||||||
Each data row contains a name, and value. The row also contains a
|
|
||||||
type or mimetype. Type corresponds to a .NET class that support
|
|
||||||
text/value conversion through the TypeConverter architecture.
|
|
||||||
Classes that don't support this are serialized and stored with the
|
|
||||||
mimetype set.
|
|
||||||
|
|
||||||
The mimetype is used for serialized objects, and tells the
|
|
||||||
ResXResourceReader how to depersist the object. This is currently not
|
|
||||||
extensible. For a given mimetype the value must be set accordingly:
|
|
||||||
|
|
||||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
|
||||||
that the ResXResourceWriter will generate, however the reader can
|
|
||||||
read any of the formats listed below.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.binary.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.soap.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
|
||||||
value : The object must be serialized into a byte array
|
|
||||||
: using a System.ComponentModel.TypeConverter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
-->
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
</root>
|
|
240
AutomobilePlant/FormMain.Designer.cs
generated
240
AutomobilePlant/FormMain.Designer.cs
generated
@ -1,240 +0,0 @@
|
|||||||
namespace AutomobilePlant
|
|
||||||
{
|
|
||||||
partial class FormMain
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
this.menuStrip = new System.Windows.Forms.MenuStrip();
|
|
||||||
this.справочникиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
|
||||||
this.компонентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
|
||||||
this.автомобилиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
|
||||||
this.клиентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
|
||||||
this.исполнителиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
|
||||||
this.письмаToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
|
||||||
this.отчетыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
|
||||||
this.списокАвтомобилейToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
|
||||||
this.компонентыПоАвтомобилямToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
|
||||||
this.списокЗаказовToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
|
||||||
this.запускРаботToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
|
||||||
this.создатьБэкапToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
|
||||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
|
||||||
this.buttonCreateOrder = new System.Windows.Forms.Button();
|
|
||||||
this.buttonSetToFinish = new System.Windows.Forms.Button();
|
|
||||||
this.buttonUpdate = new System.Windows.Forms.Button();
|
|
||||||
this.menuStrip.SuspendLayout();
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
|
||||||
this.SuspendLayout();
|
|
||||||
//
|
|
||||||
// menuStrip
|
|
||||||
//
|
|
||||||
this.menuStrip.ImageScalingSize = new System.Drawing.Size(20, 20);
|
|
||||||
this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
|
||||||
this.справочникиToolStripMenuItem,
|
|
||||||
this.отчетыToolStripMenuItem,
|
|
||||||
this.запускРаботToolStripMenuItem,
|
|
||||||
this.создатьБэкапToolStripMenuItem});
|
|
||||||
this.menuStrip.Location = new System.Drawing.Point(0, 0);
|
|
||||||
this.menuStrip.Name = "menuStrip";
|
|
||||||
this.menuStrip.Size = new System.Drawing.Size(1436, 28);
|
|
||||||
this.menuStrip.TabIndex = 0;
|
|
||||||
this.menuStrip.Text = "Справочники";
|
|
||||||
//
|
|
||||||
// справочникиToolStripMenuItem
|
|
||||||
//
|
|
||||||
this.справочникиToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
|
||||||
this.компонентыToolStripMenuItem,
|
|
||||||
this.автомобилиToolStripMenuItem,
|
|
||||||
this.клиентыToolStripMenuItem,
|
|
||||||
this.исполнителиToolStripMenuItem,
|
|
||||||
this.письмаToolStripMenuItem});
|
|
||||||
this.справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
|
|
||||||
this.справочникиToolStripMenuItem.Size = new System.Drawing.Size(117, 24);
|
|
||||||
this.справочникиToolStripMenuItem.Text = "Справочники";
|
|
||||||
//
|
|
||||||
// компонентыToolStripMenuItem
|
|
||||||
//
|
|
||||||
this.компонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem";
|
|
||||||
this.компонентыToolStripMenuItem.Size = new System.Drawing.Size(185, 26);
|
|
||||||
this.компонентыToolStripMenuItem.Text = "Компоненты";
|
|
||||||
this.компонентыToolStripMenuItem.Click += new System.EventHandler(this.компонентыToolStripMenuItem_Click);
|
|
||||||
//
|
|
||||||
// автомобилиToolStripMenuItem
|
|
||||||
//
|
|
||||||
this.автомобилиToolStripMenuItem.Name = "автомобилиToolStripMenuItem";
|
|
||||||
this.автомобилиToolStripMenuItem.Size = new System.Drawing.Size(185, 26);
|
|
||||||
this.автомобилиToolStripMenuItem.Text = "Автомобили";
|
|
||||||
this.автомобилиToolStripMenuItem.Click += new System.EventHandler(this.автомобилиToolStripMenuItem_Click);
|
|
||||||
//
|
|
||||||
// клиентыToolStripMenuItem
|
|
||||||
//
|
|
||||||
this.клиентыToolStripMenuItem.Name = "клиентыToolStripMenuItem";
|
|
||||||
this.клиентыToolStripMenuItem.Size = new System.Drawing.Size(185, 26);
|
|
||||||
this.клиентыToolStripMenuItem.Text = "Клиенты";
|
|
||||||
this.клиентыToolStripMenuItem.Click += new System.EventHandler(this.клиентыToolStripMenuItem_Click);
|
|
||||||
//
|
|
||||||
// исполнителиToolStripMenuItem
|
|
||||||
//
|
|
||||||
this.исполнителиToolStripMenuItem.Name = "исполнителиToolStripMenuItem";
|
|
||||||
this.исполнителиToolStripMenuItem.Size = new System.Drawing.Size(185, 26);
|
|
||||||
this.исполнителиToolStripMenuItem.Text = "Исполнители";
|
|
||||||
this.исполнителиToolStripMenuItem.Click += new System.EventHandler(this.исполнителиToolStripMenuItem_Click);
|
|
||||||
//
|
|
||||||
// письмаToolStripMenuItem
|
|
||||||
//
|
|
||||||
this.письмаToolStripMenuItem.Name = "письмаToolStripMenuItem";
|
|
||||||
this.письмаToolStripMenuItem.Size = new System.Drawing.Size(185, 26);
|
|
||||||
this.письмаToolStripMenuItem.Text = "Письма";
|
|
||||||
this.письмаToolStripMenuItem.Click += new System.EventHandler(this.письмаToolStripMenuItem_Click);
|
|
||||||
//
|
|
||||||
// отчетыToolStripMenuItem
|
|
||||||
//
|
|
||||||
this.отчетыToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
|
||||||
this.списокАвтомобилейToolStripMenuItem,
|
|
||||||
this.компонентыПоАвтомобилямToolStripMenuItem,
|
|
||||||
this.списокЗаказовToolStripMenuItem});
|
|
||||||
this.отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
|
|
||||||
this.отчетыToolStripMenuItem.Size = new System.Drawing.Size(73, 24);
|
|
||||||
this.отчетыToolStripMenuItem.Text = "Отчеты";
|
|
||||||
//
|
|
||||||
// списокАвтомобилейToolStripMenuItem
|
|
||||||
//
|
|
||||||
this.списокАвтомобилейToolStripMenuItem.Name = "списокАвтомобилейToolStripMenuItem";
|
|
||||||
this.списокАвтомобилейToolStripMenuItem.Size = new System.Drawing.Size(304, 26);
|
|
||||||
this.списокАвтомобилейToolStripMenuItem.Text = "Список автомобилей";
|
|
||||||
this.списокАвтомобилейToolStripMenuItem.Click += new System.EventHandler(this.списокАвтомобилейToolStripMenuItem_Click);
|
|
||||||
//
|
|
||||||
// компонентыПоАвтомобилямToolStripMenuItem
|
|
||||||
//
|
|
||||||
this.компонентыПоАвтомобилямToolStripMenuItem.Name = "компонентыПоАвтомобилямToolStripMenuItem";
|
|
||||||
this.компонентыПоАвтомобилямToolStripMenuItem.Size = new System.Drawing.Size(304, 26);
|
|
||||||
this.компонентыПоАвтомобилямToolStripMenuItem.Text = "Компоненты по автомобилям";
|
|
||||||
this.компонентыПоАвтомобилямToolStripMenuItem.Click += new System.EventHandler(this.компонентыПоАвтомобилямToolStripMenuItem_Click);
|
|
||||||
//
|
|
||||||
// списокЗаказовToolStripMenuItem
|
|
||||||
//
|
|
||||||
this.списокЗаказовToolStripMenuItem.Name = "списокЗаказовToolStripMenuItem";
|
|
||||||
this.списокЗаказовToolStripMenuItem.Size = new System.Drawing.Size(304, 26);
|
|
||||||
this.списокЗаказовToolStripMenuItem.Text = "Список заказов";
|
|
||||||
this.списокЗаказовToolStripMenuItem.Click += new System.EventHandler(this.списокЗаказовToolStripMenuItem_Click);
|
|
||||||
//
|
|
||||||
// запускРаботToolStripMenuItem
|
|
||||||
//
|
|
||||||
this.запускРаботToolStripMenuItem.Name = "запускРаботToolStripMenuItem";
|
|
||||||
this.запускРаботToolStripMenuItem.Size = new System.Drawing.Size(114, 24);
|
|
||||||
this.запускРаботToolStripMenuItem.Text = "Запуск работ";
|
|
||||||
this.запускРаботToolStripMenuItem.Click += new System.EventHandler(this.запускРаботToolStripMenuItem_Click);
|
|
||||||
//
|
|
||||||
// создатьБэкапToolStripMenuItem
|
|
||||||
//
|
|
||||||
this.создатьБэкапToolStripMenuItem.Name = "создатьБэкапToolStripMenuItem";
|
|
||||||
this.создатьБэкапToolStripMenuItem.Size = new System.Drawing.Size(122, 24);
|
|
||||||
this.создатьБэкапToolStripMenuItem.Text = "Создать бэкап";
|
|
||||||
this.создатьБэкапToolStripMenuItem.Click += new System.EventHandler(this.создатьБэкапToolStripMenuItem_Click);
|
|
||||||
//
|
|
||||||
// dataGridView
|
|
||||||
//
|
|
||||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
|
||||||
this.dataGridView.Location = new System.Drawing.Point(12, 31);
|
|
||||||
this.dataGridView.Name = "dataGridView";
|
|
||||||
this.dataGridView.RowHeadersWidth = 51;
|
|
||||||
this.dataGridView.RowTemplate.Height = 29;
|
|
||||||
this.dataGridView.Size = new System.Drawing.Size(1188, 407);
|
|
||||||
this.dataGridView.TabIndex = 1;
|
|
||||||
//
|
|
||||||
// buttonCreateOrder
|
|
||||||
//
|
|
||||||
this.buttonCreateOrder.Location = new System.Drawing.Point(1220, 42);
|
|
||||||
this.buttonCreateOrder.Name = "buttonCreateOrder";
|
|
||||||
this.buttonCreateOrder.Size = new System.Drawing.Size(194, 29);
|
|
||||||
this.buttonCreateOrder.TabIndex = 2;
|
|
||||||
this.buttonCreateOrder.Text = "Создать заказ";
|
|
||||||
this.buttonCreateOrder.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonCreateOrder.Click += new System.EventHandler(this.ButtonCreateOrder_Click);
|
|
||||||
//
|
|
||||||
// buttonSetToFinish
|
|
||||||
//
|
|
||||||
this.buttonSetToFinish.Location = new System.Drawing.Point(1220, 147);
|
|
||||||
this.buttonSetToFinish.Name = "buttonSetToFinish";
|
|
||||||
this.buttonSetToFinish.Size = new System.Drawing.Size(194, 29);
|
|
||||||
this.buttonSetToFinish.TabIndex = 5;
|
|
||||||
this.buttonSetToFinish.Text = "Заказ выдан";
|
|
||||||
this.buttonSetToFinish.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonSetToFinish.Click += new System.EventHandler(this.ButtonSetToFinish_Click);
|
|
||||||
//
|
|
||||||
// buttonUpdate
|
|
||||||
//
|
|
||||||
this.buttonUpdate.Location = new System.Drawing.Point(1220, 409);
|
|
||||||
this.buttonUpdate.Name = "buttonUpdate";
|
|
||||||
this.buttonUpdate.Size = new System.Drawing.Size(194, 29);
|
|
||||||
this.buttonUpdate.TabIndex = 6;
|
|
||||||
this.buttonUpdate.Text = "Обновить";
|
|
||||||
this.buttonUpdate.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonUpdate.Click += new System.EventHandler(this.ButtonUpdate_Click);
|
|
||||||
//
|
|
||||||
// FormMain
|
|
||||||
//
|
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
this.ClientSize = new System.Drawing.Size(1436, 450);
|
|
||||||
this.Controls.Add(this.buttonUpdate);
|
|
||||||
this.Controls.Add(this.buttonSetToFinish);
|
|
||||||
this.Controls.Add(this.buttonCreateOrder);
|
|
||||||
this.Controls.Add(this.dataGridView);
|
|
||||||
this.Controls.Add(this.menuStrip);
|
|
||||||
this.MainMenuStrip = this.menuStrip;
|
|
||||||
this.Name = "FormMain";
|
|
||||||
this.Text = "Автомобильный завод";
|
|
||||||
this.Load += new System.EventHandler(this.FormMain_Load);
|
|
||||||
this.menuStrip.ResumeLayout(false);
|
|
||||||
this.menuStrip.PerformLayout();
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
|
||||||
this.ResumeLayout(false);
|
|
||||||
this.PerformLayout();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private MenuStrip menuStrip;
|
|
||||||
private ToolStripMenuItem справочникиToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem компонентыToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem автомобилиToolStripMenuItem;
|
|
||||||
private DataGridView dataGridView;
|
|
||||||
private Button buttonCreateOrder;
|
|
||||||
private Button buttonSetToFinish;
|
|
||||||
private Button buttonUpdate;
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,179 +0,0 @@
|
|||||||
using AutomobilePlantBusinessLogic.BusinessLogics;
|
|
||||||
using AutomobilePlantContracts.BindingModels;
|
|
||||||
using AutomobilePlantContracts.BusinessLogicContracts;
|
|
||||||
using AutomobilePlantContracts.DI;
|
|
||||||
using AutomobilePlantDataModels.Enums;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Data;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
namespace AutomobilePlant
|
|
||||||
{
|
|
||||||
public partial class FormMain : Form
|
|
||||||
{
|
|
||||||
private readonly ILogger _logger;
|
|
||||||
private readonly IOrderLogic _orderLogic;
|
|
||||||
private readonly IReportLogic _reportLogic;
|
|
||||||
private readonly IWorkProcess _workProcess;
|
|
||||||
private readonly IBackUpLogic _backUpLogic;
|
|
||||||
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic, IReportLogic reportLogic, IWorkProcess workProcess, IBackUpLogic backUpLogic)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_logger = logger;
|
|
||||||
_orderLogic = orderLogic;
|
|
||||||
_reportLogic = reportLogic;
|
|
||||||
_workProcess = workProcess;
|
|
||||||
_backUpLogic = backUpLogic;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void FormMain_Load(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void LoadData()
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Загрузка заказов");
|
|
||||||
try
|
|
||||||
{
|
|
||||||
dataGridView.FillAndConfigGrid(_orderLogic.ReadList(null));
|
|
||||||
_logger.LogInformation("Загрузка заказов");
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка загрузки заказов");
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void компонентыToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
var form = DependencyManager.Instance.Resolve<FormComponents>();
|
|
||||||
form.ShowDialog();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void автомобилиToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
var form = DependencyManager.Instance.Resolve<FormCars>();
|
|
||||||
form.ShowDialog();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void клиентыToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
var form = DependencyManager.Instance.Resolve<FormClients>();
|
|
||||||
form.ShowDialog();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void исполнителиToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
var form = DependencyManager.Instance.Resolve<FormImplementers>();
|
|
||||||
form.ShowDialog();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void компонентыПоАвтомобилямToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
var form = DependencyManager.Instance.Resolve<FormReportCarComponents>();
|
|
||||||
form.ShowDialog();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void списокЗаказовToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
var form = DependencyManager.Instance.Resolve<FormReportOrder>();
|
|
||||||
form.ShowDialog();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void списокАвтомобилейToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
using var dialog = new SaveFileDialog { Filter = "docx|*.docx" };
|
|
||||||
if (dialog.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
_reportLogic.SaveCarsToWordFile(new ReportBindingModel
|
|
||||||
{
|
|
||||||
FileName = dialog.FileName
|
|
||||||
});
|
|
||||||
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonCreateOrder_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
var form = DependencyManager.Instance.Resolve<FormCreateOrder>();
|
|
||||||
form.ShowDialog();
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonSetToFinish_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("Ошибка при сохранении. Дополнительная информация в логах.");
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Заказ №{id} выдан", id);
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка отметки о выдачи заказа");
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonUpdate_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
LoadData();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void запускРаботToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
_workProcess.DoWork(DependencyManager.Instance.Resolve<IImplementerLogic>(), _orderLogic);
|
|
||||||
MessageBox.Show("Процесс обработки запущен", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void письмаToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
var form = DependencyManager.Instance.Resolve<FormMails>();
|
|
||||||
form.ShowDialog();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void создатьБэкапToolStripMenuItem_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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,66 +0,0 @@
|
|||||||
<root>
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<metadata name="menuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
|
||||||
<value>17, 17</value>
|
|
||||||
</metadata>
|
|
||||||
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
|
||||||
<value>60</value>
|
|
||||||
</metadata>
|
|
||||||
</root>
|
|
110
AutomobilePlant/FormReportCarComponents.Designer.cs
generated
110
AutomobilePlant/FormReportCarComponents.Designer.cs
generated
@ -1,110 +0,0 @@
|
|||||||
namespace AutomobilePlant
|
|
||||||
{
|
|
||||||
partial class FormReportCarComponents
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
|
||||||
this.buttonSaveToExcel = new System.Windows.Forms.Button();
|
|
||||||
this.Car = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
|
||||||
this.Component = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
|
||||||
this.Count = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
|
||||||
this.SuspendLayout();
|
|
||||||
//
|
|
||||||
// dataGridView
|
|
||||||
//
|
|
||||||
this.dataGridView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
|
||||||
| System.Windows.Forms.AnchorStyles.Left)
|
|
||||||
| System.Windows.Forms.AnchorStyles.Right)));
|
|
||||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
|
||||||
this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
|
|
||||||
this.Car,
|
|
||||||
this.Component,
|
|
||||||
this.Count});
|
|
||||||
this.dataGridView.Location = new System.Drawing.Point(12, 37);
|
|
||||||
this.dataGridView.Name = "dataGridView";
|
|
||||||
this.dataGridView.RowHeadersWidth = 51;
|
|
||||||
this.dataGridView.RowTemplate.Height = 29;
|
|
||||||
this.dataGridView.Size = new System.Drawing.Size(776, 401);
|
|
||||||
this.dataGridView.TabIndex = 0;
|
|
||||||
//
|
|
||||||
// buttonSaveToExcel
|
|
||||||
//
|
|
||||||
this.buttonSaveToExcel.Location = new System.Drawing.Point(12, 2);
|
|
||||||
this.buttonSaveToExcel.Name = "buttonSaveToExcel";
|
|
||||||
this.buttonSaveToExcel.Size = new System.Drawing.Size(220, 29);
|
|
||||||
this.buttonSaveToExcel.TabIndex = 1;
|
|
||||||
this.buttonSaveToExcel.Text = "Сохранить в Excel";
|
|
||||||
this.buttonSaveToExcel.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonSaveToExcel.Click += new System.EventHandler(this.buttonSaveToExcel_Click);
|
|
||||||
//
|
|
||||||
// Car
|
|
||||||
//
|
|
||||||
this.Car.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
|
|
||||||
this.Car.HeaderText = "Автомобиль";
|
|
||||||
this.Car.MinimumWidth = 6;
|
|
||||||
this.Car.Name = "Car";
|
|
||||||
//
|
|
||||||
// Component
|
|
||||||
//
|
|
||||||
this.Component.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
|
|
||||||
this.Component.HeaderText = "Компонент";
|
|
||||||
this.Component.MinimumWidth = 6;
|
|
||||||
this.Component.Name = "Component";
|
|
||||||
//
|
|
||||||
// Count
|
|
||||||
//
|
|
||||||
this.Count.HeaderText = "Количество";
|
|
||||||
this.Count.MinimumWidth = 6;
|
|
||||||
this.Count.Name = "Count";
|
|
||||||
this.Count.Width = 125;
|
|
||||||
//
|
|
||||||
// FormReportCarComponents
|
|
||||||
//
|
|
||||||
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.buttonSaveToExcel);
|
|
||||||
this.Controls.Add(this.dataGridView);
|
|
||||||
this.Name = "FormReportCarComponents";
|
|
||||||
this.Text = "Компоненты по автомобилям";
|
|
||||||
this.Load += new System.EventHandler(this.FormReportCarComponents_Load);
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
|
||||||
this.ResumeLayout(false);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private DataGridView dataGridView;
|
|
||||||
private Button buttonSaveToExcel;
|
|
||||||
private DataGridViewTextBoxColumn Car;
|
|
||||||
private DataGridViewTextBoxColumn Component;
|
|
||||||
private DataGridViewTextBoxColumn Count;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,85 +0,0 @@
|
|||||||
using AutomobilePlantContracts.BindingModels;
|
|
||||||
using AutomobilePlantContracts.BusinessLogicContracts;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Data;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
namespace AutomobilePlant
|
|
||||||
{
|
|
||||||
public partial class FormReportCarComponents : Form
|
|
||||||
{
|
|
||||||
private readonly ILogger _logger;
|
|
||||||
private readonly IReportLogic _logic;
|
|
||||||
|
|
||||||
public FormReportCarComponents(ILogger<FormReportCarComponents> logger, IReportLogic logic)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_logger = logger;
|
|
||||||
_logic = logic;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void FormReportCarComponents_Load(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var dict = _logic.GetCarComponents();
|
|
||||||
if (dict != null)
|
|
||||||
{
|
|
||||||
dataGridView.Rows.Clear();
|
|
||||||
foreach (var elem in dict)
|
|
||||||
{
|
|
||||||
dataGridView.Rows.Add(new object[] { elem.CarName, "", "" });
|
|
||||||
foreach (var listElem in elem.Components)
|
|
||||||
{
|
|
||||||
dataGridView.Rows.Add(new object[] { "", listElem.Item1, listElem.Item2 });
|
|
||||||
}
|
|
||||||
dataGridView.Rows.Add(new object[] { "Итого", "", elem.TotalCount });
|
|
||||||
dataGridView.Rows.Add(Array.Empty<object>());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_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.SaveCarComponentToExcelFile(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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,60 +0,0 @@
|
|||||||
<root>
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
</root>
|
|
130
AutomobilePlant/FormReportOrder.Designer.cs
generated
130
AutomobilePlant/FormReportOrder.Designer.cs
generated
@ -1,130 +0,0 @@
|
|||||||
namespace AutomobilePlant
|
|
||||||
{
|
|
||||||
partial class FormReportOrder
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
this.panel = new System.Windows.Forms.Panel();
|
|
||||||
this.buttonCreateToPdf = new System.Windows.Forms.Button();
|
|
||||||
this.buttonCreateReport = new System.Windows.Forms.Button();
|
|
||||||
this.label2 = new System.Windows.Forms.Label();
|
|
||||||
this.label1 = new System.Windows.Forms.Label();
|
|
||||||
this.dateTimePickerEnd = new System.Windows.Forms.DateTimePicker();
|
|
||||||
this.dateTimePickerStart = new System.Windows.Forms.DateTimePicker();
|
|
||||||
this.panel.SuspendLayout();
|
|
||||||
this.SuspendLayout();
|
|
||||||
//
|
|
||||||
// panel
|
|
||||||
//
|
|
||||||
this.panel.Controls.Add(this.buttonCreateToPdf);
|
|
||||||
this.panel.Controls.Add(this.buttonCreateReport);
|
|
||||||
this.panel.Controls.Add(this.label2);
|
|
||||||
this.panel.Controls.Add(this.label1);
|
|
||||||
this.panel.Controls.Add(this.dateTimePickerEnd);
|
|
||||||
this.panel.Controls.Add(this.dateTimePickerStart);
|
|
||||||
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(984, 69);
|
|
||||||
this.panel.TabIndex = 0;
|
|
||||||
//
|
|
||||||
// buttonCreateToPdf
|
|
||||||
//
|
|
||||||
this.buttonCreateToPdf.Location = new System.Drawing.Point(782, 39);
|
|
||||||
this.buttonCreateToPdf.Name = "buttonCreateToPdf";
|
|
||||||
this.buttonCreateToPdf.Size = new System.Drawing.Size(190, 27);
|
|
||||||
this.buttonCreateToPdf.TabIndex = 5;
|
|
||||||
this.buttonCreateToPdf.Text = "PDF";
|
|
||||||
this.buttonCreateToPdf.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonCreateToPdf.Click += new System.EventHandler(this.buttonCreateToPdf_Click);
|
|
||||||
//
|
|
||||||
// buttonCreateReport
|
|
||||||
//
|
|
||||||
this.buttonCreateReport.Location = new System.Drawing.Point(554, 39);
|
|
||||||
this.buttonCreateReport.Name = "buttonCreateReport";
|
|
||||||
this.buttonCreateReport.Size = new System.Drawing.Size(190, 27);
|
|
||||||
this.buttonCreateReport.TabIndex = 4;
|
|
||||||
this.buttonCreateReport.Text = "Сформировать";
|
|
||||||
this.buttonCreateReport.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonCreateReport.Click += new System.EventHandler(this.buttonCreateReport_Click);
|
|
||||||
//
|
|
||||||
// label2
|
|
||||||
//
|
|
||||||
this.label2.AutoSize = true;
|
|
||||||
this.label2.Location = new System.Drawing.Point(369, 9);
|
|
||||||
this.label2.Name = "label2";
|
|
||||||
this.label2.Size = new System.Drawing.Size(56, 20);
|
|
||||||
this.label2.TabIndex = 3;
|
|
||||||
this.label2.Text = "Конец:";
|
|
||||||
//
|
|
||||||
// label1
|
|
||||||
//
|
|
||||||
this.label1.AutoSize = true;
|
|
||||||
this.label1.Location = new System.Drawing.Point(87, 6);
|
|
||||||
this.label1.Name = "label1";
|
|
||||||
this.label1.Size = new System.Drawing.Size(64, 20);
|
|
||||||
this.label1.TabIndex = 2;
|
|
||||||
this.label1.Text = "Начало:";
|
|
||||||
//
|
|
||||||
// dateTimePickerEnd
|
|
||||||
//
|
|
||||||
this.dateTimePickerEnd.Location = new System.Drawing.Point(307, 39);
|
|
||||||
this.dateTimePickerEnd.Name = "dateTimePickerEnd";
|
|
||||||
this.dateTimePickerEnd.Size = new System.Drawing.Size(187, 27);
|
|
||||||
this.dateTimePickerEnd.TabIndex = 1;
|
|
||||||
//
|
|
||||||
// dateTimePickerStart
|
|
||||||
//
|
|
||||||
this.dateTimePickerStart.Location = new System.Drawing.Point(35, 39);
|
|
||||||
this.dateTimePickerStart.Name = "dateTimePickerStart";
|
|
||||||
this.dateTimePickerStart.Size = new System.Drawing.Size(187, 27);
|
|
||||||
this.dateTimePickerStart.TabIndex = 0;
|
|
||||||
//
|
|
||||||
// FormReportOrder
|
|
||||||
//
|
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
this.ClientSize = new System.Drawing.Size(984, 450);
|
|
||||||
this.Controls.Add(this.panel);
|
|
||||||
this.Name = "FormReportOrder";
|
|
||||||
this.Text = "Заказы";
|
|
||||||
this.panel.ResumeLayout(false);
|
|
||||||
this.panel.PerformLayout();
|
|
||||||
this.ResumeLayout(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private Panel panel;
|
|
||||||
private DateTimePicker dateTimePickerEnd;
|
|
||||||
private DateTimePicker dateTimePickerStart;
|
|
||||||
private Button buttonCreateToPdf;
|
|
||||||
private Button buttonCreateReport;
|
|
||||||
private Label label2;
|
|
||||||
private Label label1;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,101 +0,0 @@
|
|||||||
using AutomobilePlantContracts.BindingModels;
|
|
||||||
using AutomobilePlantContracts.BusinessLogicContracts;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using Microsoft.Reporting.WinForms;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Data;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
namespace AutomobilePlant
|
|
||||||
{
|
|
||||||
public partial class FormReportOrder : Form
|
|
||||||
{
|
|
||||||
private readonly ReportViewer reportViewer;
|
|
||||||
private readonly ILogger _logger;
|
|
||||||
private readonly IReportLogic _logic;
|
|
||||||
|
|
||||||
public FormReportOrder(ILogger<FormReportOrder> logger, IReportLogic logic)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_logger = logger;
|
|
||||||
_logic = logic;
|
|
||||||
reportViewer = new ReportViewer
|
|
||||||
{
|
|
||||||
Dock = DockStyle.Fill
|
|
||||||
};
|
|
||||||
reportViewer.LocalReport.LoadReportDefinition(new FileStream("ReportOrders.rdlc", FileMode.Open));
|
|
||||||
Controls.Clear();
|
|
||||||
Controls.Add(reportViewer);
|
|
||||||
Controls.Add(panel);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buttonCreateReport_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (dateTimePickerStart.Value.Date >= dateTimePickerEnd.Value.Date)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Дата начала должна быть меньше даты окончания", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var dataSource = _logic.GetOrders(new ReportBindingModel
|
|
||||||
{
|
|
||||||
DateFrom = dateTimePickerStart.Value,
|
|
||||||
DateTo = dateTimePickerEnd.Value
|
|
||||||
});
|
|
||||||
var source = new ReportDataSource("DataSetOrders", dataSource);
|
|
||||||
reportViewer.LocalReport.DataSources.Clear();
|
|
||||||
reportViewer.LocalReport.DataSources.Add(source);
|
|
||||||
var parameters = new[] { new ReportParameter("ReportParameterPeriod", $"c{dateTimePickerStart.Value.ToShortDateString()} по {dateTimePickerEnd.Value.ToShortDateString()}") };
|
|
||||||
reportViewer.LocalReport.SetParameters(parameters);
|
|
||||||
reportViewer.RefreshReport();
|
|
||||||
_logger.LogInformation("Загрузка списка заказов на период {From}-{ To}", dateTimePickerStart.Value.ToShortDateString(), dateTimePickerEnd.Value.ToShortDateString());
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка загрузки списка заказов на период");
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
|
||||||
MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buttonCreateToPdf_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (dateTimePickerStart.Value.Date >= dateTimePickerEnd.Value.Date)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Дата начала должна быть меньше даты окончания", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
using var dialog = new SaveFileDialog
|
|
||||||
{
|
|
||||||
Filter = "pdf|*.pdf"
|
|
||||||
};
|
|
||||||
if (dialog.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_logic.SaveOrdersToPdfFile(new ReportBindingModel
|
|
||||||
{
|
|
||||||
FileName = dialog.FileName,
|
|
||||||
DateFrom = dateTimePickerStart.Value,
|
|
||||||
DateTo = dateTimePickerEnd.Value
|
|
||||||
});
|
|
||||||
_logger.LogInformation("Сохранение списка заказов на период { From} -{ To}", dateTimePickerStart.Value.ToShortDateString(), dateTimePickerEnd.Value.ToShortDateString());
|
|
||||||
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка сохранения списка заказов на период");
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,120 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<root>
|
|
||||||
<!--
|
|
||||||
Microsoft ResX Schema
|
|
||||||
|
|
||||||
Version 2.0
|
|
||||||
|
|
||||||
The primary goals of this format is to allow a simple XML format
|
|
||||||
that is mostly human readable. The generation and parsing of the
|
|
||||||
various data types are done through the TypeConverter classes
|
|
||||||
associated with the data types.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
... ado.net/XML headers & schema ...
|
|
||||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
|
||||||
<resheader name="version">2.0</resheader>
|
|
||||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
|
||||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
|
||||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
|
||||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
|
||||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
|
||||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
|
||||||
</data>
|
|
||||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
|
||||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
|
||||||
<comment>This is a comment</comment>
|
|
||||||
</data>
|
|
||||||
|
|
||||||
There are any number of "resheader" rows that contain simple
|
|
||||||
name/value pairs.
|
|
||||||
|
|
||||||
Each data row contains a name, and value. The row also contains a
|
|
||||||
type or mimetype. Type corresponds to a .NET class that support
|
|
||||||
text/value conversion through the TypeConverter architecture.
|
|
||||||
Classes that don't support this are serialized and stored with the
|
|
||||||
mimetype set.
|
|
||||||
|
|
||||||
The mimetype is used for serialized objects, and tells the
|
|
||||||
ResXResourceReader how to depersist the object. This is currently not
|
|
||||||
extensible. For a given mimetype the value must be set accordingly:
|
|
||||||
|
|
||||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
|
||||||
that the ResXResourceWriter will generate, however the reader can
|
|
||||||
read any of the formats listed below.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.binary.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.soap.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
|
||||||
value : The object must be serialized into a byte array
|
|
||||||
: using a System.ComponentModel.TypeConverter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
-->
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
</root>
|
|
@ -1,90 +0,0 @@
|
|||||||
using AutomobilePlantBusinessLogic.BusinessLogics;
|
|
||||||
using AutomobilePlantBusinessLogic.MailWorker;
|
|
||||||
using AutomobilePlantBusinessLogic.OfficePackage;
|
|
||||||
using AutomobilePlantBusinessLogic.OfficePackage.Implements;
|
|
||||||
using AutomobilePlantContracts.BindingModels;
|
|
||||||
using AutomobilePlantContracts.BusinessLogicContracts;
|
|
||||||
using AutomobilePlantContracts.DI;
|
|
||||||
using AutomobilePlantContracts.StorageContracts;
|
|
||||||
using AutomobilePlantDatabaseImplement.Implements;
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using NLog.Extensions.Logging;
|
|
||||||
|
|
||||||
namespace AutomobilePlant
|
|
||||||
{
|
|
||||||
internal static class Program
|
|
||||||
{
|
|
||||||
[STAThread]
|
|
||||||
static void Main()
|
|
||||||
{
|
|
||||||
ApplicationConfiguration.Initialize();
|
|
||||||
InitDependency();
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var mailSender = DependencyManager.Instance.Resolve<AbstractMailWorker>();
|
|
||||||
mailSender?.MailConfig(new MailConfigBindingModel
|
|
||||||
{
|
|
||||||
MailLogin = System.Configuration.ConfigurationManager.AppSettings["MailLogin"] ?? string.Empty,
|
|
||||||
MailPassword = System.Configuration.ConfigurationManager.AppSettings["MailPassword"] ?? string.Empty,
|
|
||||||
SmtpClientHost = System.Configuration.ConfigurationManager.AppSettings["SmtpClientHost"] ?? string.Empty,
|
|
||||||
SmtpClientPort = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["SmtpClientPort"]),
|
|
||||||
PopHost = System.Configuration.ConfigurationManager.AppSettings["PopHost"] ?? string.Empty,
|
|
||||||
PopPort = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["PopPort"])
|
|
||||||
});
|
|
||||||
// Ñîçäàåì òàéìåð
|
|
||||||
var timer = new System.Threading.Timer(new TimerCallback(MailCheck!), null, 0, 100000);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
var logger = DependencyManager.Instance.Resolve<ILogger>();
|
|
||||||
logger?.LogError(ex, "Îøèáêà ðàáîòû ñ ïî÷òîé");
|
|
||||||
}
|
|
||||||
|
|
||||||
Application.Run(DependencyManager.Instance.Resolve<FormMain>());
|
|
||||||
}
|
|
||||||
private static void MailCheck(object obj) => DependencyManager.Instance.Resolve<AbstractMailWorker>()?.MailCheck();
|
|
||||||
|
|
||||||
private static void InitDependency()
|
|
||||||
{
|
|
||||||
DependencyManager.InitDependency();
|
|
||||||
|
|
||||||
DependencyManager.Instance.AddLogging(option =>
|
|
||||||
{
|
|
||||||
option.SetMinimumLevel(LogLevel.Information);
|
|
||||||
option.AddNLog("nlog.config");
|
|
||||||
});
|
|
||||||
|
|
||||||
DependencyManager.Instance.RegisterType<IComponentLogic, ComponentLogic>();
|
|
||||||
DependencyManager.Instance.RegisterType<IOrderLogic, OrderLogic>();
|
|
||||||
DependencyManager.Instance.RegisterType<ICarLogic, CarLogic>();
|
|
||||||
DependencyManager.Instance.RegisterType<IReportLogic, ReportLogic>();
|
|
||||||
DependencyManager.Instance.RegisterType<IClientLogic, ClientLogic>();
|
|
||||||
DependencyManager.Instance.RegisterType<IImplementerLogic, ImplementerLogic>();
|
|
||||||
DependencyManager.Instance.RegisterType<IWorkProcess, WorkModeling>();
|
|
||||||
DependencyManager.Instance.RegisterType<IMessageInfoLogic, MessageInfoLogic>();
|
|
||||||
DependencyManager.Instance.RegisterType<IBackUpLogic, BackUpLogic>();
|
|
||||||
|
|
||||||
DependencyManager.Instance.RegisterType<AbstractSaveToWord, SaveToWord>();
|
|
||||||
DependencyManager.Instance.RegisterType<AbstractSaveToExcel, SaveToExcel>();
|
|
||||||
DependencyManager.Instance.RegisterType<AbstractSaveToPdf, SaveToPdf>();
|
|
||||||
|
|
||||||
DependencyManager.Instance.RegisterType<AbstractMailWorker, MailKitWorker>(isSingle: true);
|
|
||||||
|
|
||||||
DependencyManager.Instance.RegisterType<FormMain>();
|
|
||||||
DependencyManager.Instance.RegisterType<FormComponent>();
|
|
||||||
DependencyManager.Instance.RegisterType<FormComponents>();
|
|
||||||
DependencyManager.Instance.RegisterType<FormCreateOrder>();
|
|
||||||
DependencyManager.Instance.RegisterType<FormCar>();
|
|
||||||
DependencyManager.Instance.RegisterType<FormCarComponent>();
|
|
||||||
DependencyManager.Instance.RegisterType<FormCars>();
|
|
||||||
DependencyManager.Instance.RegisterType<FormReportCarComponents>();
|
|
||||||
DependencyManager.Instance.RegisterType<FormReportOrder>();
|
|
||||||
DependencyManager.Instance.RegisterType<FormClients>();
|
|
||||||
DependencyManager.Instance.RegisterType<FormImplementers>();
|
|
||||||
DependencyManager.Instance.RegisterType<FormImplementer>();
|
|
||||||
DependencyManager.Instance.RegisterType<FormMails>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,12 +0,0 @@
|
|||||||
{
|
|
||||||
"profiles": {
|
|
||||||
"AutomobilePlant": {
|
|
||||||
"commandName": "Project",
|
|
||||||
"launchBrowser": true,
|
|
||||||
"environmentVariables": {
|
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
|
||||||
},
|
|
||||||
"applicationUrl": "https://localhost:53383;http://localhost:53391"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,600 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Report xmlns="http://schemas.microsoft.com/sqlserver/reporting/2016/01/reportdefinition" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
|
|
||||||
<AutoRefresh>0</AutoRefresh>
|
|
||||||
<DataSources>
|
|
||||||
<DataSource Name="AutomobilePlantContractsViewModels">
|
|
||||||
<ConnectionProperties>
|
|
||||||
<DataProvider>System.Data.DataSet</DataProvider>
|
|
||||||
<ConnectString>/* Local Connection */</ConnectString>
|
|
||||||
</ConnectionProperties>
|
|
||||||
<rd:DataSourceID>10791c83-cee8-4a38-bbd0-245fc17cefb3</rd:DataSourceID>
|
|
||||||
</DataSource>
|
|
||||||
</DataSources>
|
|
||||||
<DataSets>
|
|
||||||
<DataSet Name="DataSetOrders">
|
|
||||||
<Query>
|
|
||||||
<DataSourceName>AutomobilePlantContractsViewModels</DataSourceName>
|
|
||||||
<CommandText>/* Local Query */</CommandText>
|
|
||||||
</Query>
|
|
||||||
<Fields>
|
|
||||||
<Field Name="Id">
|
|
||||||
<DataField>Id</DataField>
|
|
||||||
<rd:TypeName>System.Int32</rd:TypeName>
|
|
||||||
</Field>
|
|
||||||
<Field Name="DateCreate">
|
|
||||||
<DataField>DateCreate</DataField>
|
|
||||||
<rd:TypeName>System.DateTime</rd:TypeName>
|
|
||||||
</Field>
|
|
||||||
<Field Name="CarName">
|
|
||||||
<DataField>CarName</DataField>
|
|
||||||
<rd:TypeName>System.String</rd:TypeName>
|
|
||||||
</Field>
|
|
||||||
<Field Name="Sum">
|
|
||||||
<DataField>Sum</DataField>
|
|
||||||
<rd:TypeName>System.Decimal</rd:TypeName>
|
|
||||||
</Field>
|
|
||||||
<Field Name="Status">
|
|
||||||
<DataField>Status</DataField>
|
|
||||||
<rd:TypeName>System.String</rd:TypeName>
|
|
||||||
</Field>
|
|
||||||
</Fields>
|
|
||||||
<rd:DataSetInfo>
|
|
||||||
<rd:DataSetName>AutomobilePlantContracts.ViewModels</rd:DataSetName>
|
|
||||||
<rd:TableName>ReportOrdersViewModel</rd:TableName>
|
|
||||||
<rd:ObjectDataSourceType>AutomobilePlantContracts.ViewModels.ReportOrdersViewModel, AutomobilePlantContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</rd:ObjectDataSourceType>
|
|
||||||
</rd:DataSetInfo>
|
|
||||||
</DataSet>
|
|
||||||
</DataSets>
|
|
||||||
<ReportSections>
|
|
||||||
<ReportSection>
|
|
||||||
<Body>
|
|
||||||
<ReportItems>
|
|
||||||
<Textbox Name="ReportParameterPeriod">
|
|
||||||
<CanGrow>true</CanGrow>
|
|
||||||
<KeepTogether>true</KeepTogether>
|
|
||||||
<Paragraphs>
|
|
||||||
<Paragraph>
|
|
||||||
<TextRuns>
|
|
||||||
<TextRun>
|
|
||||||
<Value>=Parameters!ReportParameterPeriod.Value</Value>
|
|
||||||
<Style>
|
|
||||||
<FontSize>14pt</FontSize>
|
|
||||||
<FontWeight>Bold</FontWeight>
|
|
||||||
</Style>
|
|
||||||
</TextRun>
|
|
||||||
</TextRuns>
|
|
||||||
<Style>
|
|
||||||
<TextAlign>Center</TextAlign>
|
|
||||||
</Style>
|
|
||||||
</Paragraph>
|
|
||||||
</Paragraphs>
|
|
||||||
<rd:DefaultName>ReportParameterPeriod</rd:DefaultName>
|
|
||||||
<Top>1cm</Top>
|
|
||||||
<Height>1cm</Height>
|
|
||||||
<Width>21cm</Width>
|
|
||||||
<Style>
|
|
||||||
<Border>
|
|
||||||
<Style>None</Style>
|
|
||||||
</Border>
|
|
||||||
<VerticalAlign>Middle</VerticalAlign>
|
|
||||||
<PaddingLeft>2pt</PaddingLeft>
|
|
||||||
<PaddingRight>2pt</PaddingRight>
|
|
||||||
<PaddingTop>2pt</PaddingTop>
|
|
||||||
<PaddingBottom>2pt</PaddingBottom>
|
|
||||||
</Style>
|
|
||||||
</Textbox>
|
|
||||||
<Textbox Name="TextboxTitle">
|
|
||||||
<CanGrow>true</CanGrow>
|
|
||||||
<KeepTogether>true</KeepTogether>
|
|
||||||
<Paragraphs>
|
|
||||||
<Paragraph>
|
|
||||||
<TextRuns>
|
|
||||||
<TextRun>
|
|
||||||
<Value>Заказы</Value>
|
|
||||||
<Style>
|
|
||||||
<FontSize>16pt</FontSize>
|
|
||||||
<FontWeight>Bold</FontWeight>
|
|
||||||
</Style>
|
|
||||||
</TextRun>
|
|
||||||
</TextRuns>
|
|
||||||
<Style>
|
|
||||||
<TextAlign>Center</TextAlign>
|
|
||||||
</Style>
|
|
||||||
</Paragraph>
|
|
||||||
</Paragraphs>
|
|
||||||
<Height>1cm</Height>
|
|
||||||
<Width>21cm</Width>
|
|
||||||
<ZIndex>1</ZIndex>
|
|
||||||
<Style>
|
|
||||||
<Border>
|
|
||||||
<Style>None</Style>
|
|
||||||
</Border>
|
|
||||||
<VerticalAlign>Middle</VerticalAlign>
|
|
||||||
<PaddingLeft>2pt</PaddingLeft>
|
|
||||||
<PaddingRight>2pt</PaddingRight>
|
|
||||||
<PaddingTop>2pt</PaddingTop>
|
|
||||||
<PaddingBottom>2pt</PaddingBottom>
|
|
||||||
</Style>
|
|
||||||
</Textbox>
|
|
||||||
<Tablix Name="Tablix1">
|
|
||||||
<TablixBody>
|
|
||||||
<TablixColumns>
|
|
||||||
<TablixColumn>
|
|
||||||
<Width>2.5cm</Width>
|
|
||||||
</TablixColumn>
|
|
||||||
<TablixColumn>
|
|
||||||
<Width>3.21438cm</Width>
|
|
||||||
</TablixColumn>
|
|
||||||
<TablixColumn>
|
|
||||||
<Width>8.23317cm</Width>
|
|
||||||
</TablixColumn>
|
|
||||||
<TablixColumn>
|
|
||||||
<Width>2.5cm</Width>
|
|
||||||
</TablixColumn>
|
|
||||||
<TablixColumn>
|
|
||||||
<Width>2.5cm</Width>
|
|
||||||
</TablixColumn>
|
|
||||||
</TablixColumns>
|
|
||||||
<TablixRows>
|
|
||||||
<TablixRow>
|
|
||||||
<Height>0.6cm</Height>
|
|
||||||
<TablixCells>
|
|
||||||
<TablixCell>
|
|
||||||
<CellContents>
|
|
||||||
<Textbox Name="Textbox5">
|
|
||||||
<CanGrow>true</CanGrow>
|
|
||||||
<KeepTogether>true</KeepTogether>
|
|
||||||
<Paragraphs>
|
|
||||||
<Paragraph>
|
|
||||||
<TextRuns>
|
|
||||||
<TextRun>
|
|
||||||
<Value>Номер</Value>
|
|
||||||
<Style>
|
|
||||||
<FontWeight>Bold</FontWeight>
|
|
||||||
</Style>
|
|
||||||
</TextRun>
|
|
||||||
</TextRuns>
|
|
||||||
<Style />
|
|
||||||
</Paragraph>
|
|
||||||
</Paragraphs>
|
|
||||||
<rd:DefaultName>Textbox5</rd:DefaultName>
|
|
||||||
<Style>
|
|
||||||
<Border>
|
|
||||||
<Color>LightGrey</Color>
|
|
||||||
<Style>Solid</Style>
|
|
||||||
</Border>
|
|
||||||
<PaddingLeft>2pt</PaddingLeft>
|
|
||||||
<PaddingRight>2pt</PaddingRight>
|
|
||||||
<PaddingTop>2pt</PaddingTop>
|
|
||||||
<PaddingBottom>2pt</PaddingBottom>
|
|
||||||
</Style>
|
|
||||||
</Textbox>
|
|
||||||
</CellContents>
|
|
||||||
</TablixCell>
|
|
||||||
<TablixCell>
|
|
||||||
<CellContents>
|
|
||||||
<Textbox Name="Textbox1">
|
|
||||||
<CanGrow>true</CanGrow>
|
|
||||||
<KeepTogether>true</KeepTogether>
|
|
||||||
<Paragraphs>
|
|
||||||
<Paragraph>
|
|
||||||
<TextRuns>
|
|
||||||
<TextRun>
|
|
||||||
<Value>Дата создания</Value>
|
|
||||||
<Style>
|
|
||||||
<FontWeight>Bold</FontWeight>
|
|
||||||
</Style>
|
|
||||||
</TextRun>
|
|
||||||
</TextRuns>
|
|
||||||
<Style />
|
|
||||||
</Paragraph>
|
|
||||||
</Paragraphs>
|
|
||||||
<rd:DefaultName>Textbox1</rd:DefaultName>
|
|
||||||
<Style>
|
|
||||||
<Border>
|
|
||||||
<Color>LightGrey</Color>
|
|
||||||
<Style>Solid</Style>
|
|
||||||
</Border>
|
|
||||||
<PaddingLeft>2pt</PaddingLeft>
|
|
||||||
<PaddingRight>2pt</PaddingRight>
|
|
||||||
<PaddingTop>2pt</PaddingTop>
|
|
||||||
<PaddingBottom>2pt</PaddingBottom>
|
|
||||||
</Style>
|
|
||||||
</Textbox>
|
|
||||||
</CellContents>
|
|
||||||
</TablixCell>
|
|
||||||
<TablixCell>
|
|
||||||
<CellContents>
|
|
||||||
<Textbox Name="Textbox3">
|
|
||||||
<CanGrow>true</CanGrow>
|
|
||||||
<KeepTogether>true</KeepTogether>
|
|
||||||
<Paragraphs>
|
|
||||||
<Paragraph>
|
|
||||||
<TextRuns>
|
|
||||||
<TextRun>
|
|
||||||
<Value>Автомобиль</Value>
|
|
||||||
<Style>
|
|
||||||
<FontWeight>Bold</FontWeight>
|
|
||||||
</Style>
|
|
||||||
</TextRun>
|
|
||||||
</TextRuns>
|
|
||||||
<Style />
|
|
||||||
</Paragraph>
|
|
||||||
</Paragraphs>
|
|
||||||
<rd:DefaultName>Textbox3</rd:DefaultName>
|
|
||||||
<Style>
|
|
||||||
<Border>
|
|
||||||
<Color>LightGrey</Color>
|
|
||||||
<Style>Solid</Style>
|
|
||||||
</Border>
|
|
||||||
<PaddingLeft>2pt</PaddingLeft>
|
|
||||||
<PaddingRight>2pt</PaddingRight>
|
|
||||||
<PaddingTop>2pt</PaddingTop>
|
|
||||||
<PaddingBottom>2pt</PaddingBottom>
|
|
||||||
</Style>
|
|
||||||
</Textbox>
|
|
||||||
</CellContents>
|
|
||||||
</TablixCell>
|
|
||||||
<TablixCell>
|
|
||||||
<CellContents>
|
|
||||||
<Textbox Name="Textbox7">
|
|
||||||
<CanGrow>true</CanGrow>
|
|
||||||
<KeepTogether>true</KeepTogether>
|
|
||||||
<Paragraphs>
|
|
||||||
<Paragraph>
|
|
||||||
<TextRuns>
|
|
||||||
<TextRun>
|
|
||||||
<Value>Сумма</Value>
|
|
||||||
<Style>
|
|
||||||
<FontWeight>Bold</FontWeight>
|
|
||||||
</Style>
|
|
||||||
</TextRun>
|
|
||||||
</TextRuns>
|
|
||||||
<Style />
|
|
||||||
</Paragraph>
|
|
||||||
</Paragraphs>
|
|
||||||
<rd:DefaultName>Textbox7</rd:DefaultName>
|
|
||||||
<Style>
|
|
||||||
<Border>
|
|
||||||
<Color>LightGrey</Color>
|
|
||||||
<Style>Solid</Style>
|
|
||||||
</Border>
|
|
||||||
<PaddingLeft>2pt</PaddingLeft>
|
|
||||||
<PaddingRight>2pt</PaddingRight>
|
|
||||||
<PaddingTop>2pt</PaddingTop>
|
|
||||||
<PaddingBottom>2pt</PaddingBottom>
|
|
||||||
</Style>
|
|
||||||
</Textbox>
|
|
||||||
</CellContents>
|
|
||||||
</TablixCell>
|
|
||||||
<TablixCell>
|
|
||||||
<CellContents>
|
|
||||||
<Textbox Name="Textbox2">
|
|
||||||
<CanGrow>true</CanGrow>
|
|
||||||
<KeepTogether>true</KeepTogether>
|
|
||||||
<Paragraphs>
|
|
||||||
<Paragraph>
|
|
||||||
<TextRuns>
|
|
||||||
<TextRun>
|
|
||||||
<Value>Статус</Value>
|
|
||||||
<Style>
|
|
||||||
<FontWeight>Bold</FontWeight>
|
|
||||||
</Style>
|
|
||||||
</TextRun>
|
|
||||||
</TextRuns>
|
|
||||||
<Style />
|
|
||||||
</Paragraph>
|
|
||||||
</Paragraphs>
|
|
||||||
<rd:DefaultName>Textbox2</rd:DefaultName>
|
|
||||||
<Style>
|
|
||||||
<Border>
|
|
||||||
<Color>LightGrey</Color>
|
|
||||||
<Style>Solid</Style>
|
|
||||||
</Border>
|
|
||||||
<PaddingLeft>2pt</PaddingLeft>
|
|
||||||
<PaddingRight>2pt</PaddingRight>
|
|
||||||
<PaddingTop>2pt</PaddingTop>
|
|
||||||
<PaddingBottom>2pt</PaddingBottom>
|
|
||||||
</Style>
|
|
||||||
</Textbox>
|
|
||||||
<rd:Selected>true</rd:Selected>
|
|
||||||
</CellContents>
|
|
||||||
</TablixCell>
|
|
||||||
</TablixCells>
|
|
||||||
</TablixRow>
|
|
||||||
<TablixRow>
|
|
||||||
<Height>0.6cm</Height>
|
|
||||||
<TablixCells>
|
|
||||||
<TablixCell>
|
|
||||||
<CellContents>
|
|
||||||
<Textbox Name="Id">
|
|
||||||
<CanGrow>true</CanGrow>
|
|
||||||
<KeepTogether>true</KeepTogether>
|
|
||||||
<Paragraphs>
|
|
||||||
<Paragraph>
|
|
||||||
<TextRuns>
|
|
||||||
<TextRun>
|
|
||||||
<Value>=Fields!Id.Value</Value>
|
|
||||||
<Style />
|
|
||||||
</TextRun>
|
|
||||||
</TextRuns>
|
|
||||||
<Style />
|
|
||||||
</Paragraph>
|
|
||||||
</Paragraphs>
|
|
||||||
<rd:DefaultName>Id</rd:DefaultName>
|
|
||||||
<Style>
|
|
||||||
<Border>
|
|
||||||
<Color>LightGrey</Color>
|
|
||||||
<Style>Solid</Style>
|
|
||||||
</Border>
|
|
||||||
<PaddingLeft>2pt</PaddingLeft>
|
|
||||||
<PaddingRight>2pt</PaddingRight>
|
|
||||||
<PaddingTop>2pt</PaddingTop>
|
|
||||||
<PaddingBottom>2pt</PaddingBottom>
|
|
||||||
</Style>
|
|
||||||
</Textbox>
|
|
||||||
</CellContents>
|
|
||||||
</TablixCell>
|
|
||||||
<TablixCell>
|
|
||||||
<CellContents>
|
|
||||||
<Textbox Name="DateCreate">
|
|
||||||
<CanGrow>true</CanGrow>
|
|
||||||
<KeepTogether>true</KeepTogether>
|
|
||||||
<Paragraphs>
|
|
||||||
<Paragraph>
|
|
||||||
<TextRuns>
|
|
||||||
<TextRun>
|
|
||||||
<Value>=Fields!DateCreate.Value</Value>
|
|
||||||
<Style>
|
|
||||||
<Format>d</Format>
|
|
||||||
</Style>
|
|
||||||
</TextRun>
|
|
||||||
</TextRuns>
|
|
||||||
<Style />
|
|
||||||
</Paragraph>
|
|
||||||
</Paragraphs>
|
|
||||||
<rd:DefaultName>DateCreate</rd:DefaultName>
|
|
||||||
<Style>
|
|
||||||
<Border>
|
|
||||||
<Color>LightGrey</Color>
|
|
||||||
<Style>Solid</Style>
|
|
||||||
</Border>
|
|
||||||
<PaddingLeft>2pt</PaddingLeft>
|
|
||||||
<PaddingRight>2pt</PaddingRight>
|
|
||||||
<PaddingTop>2pt</PaddingTop>
|
|
||||||
<PaddingBottom>2pt</PaddingBottom>
|
|
||||||
</Style>
|
|
||||||
</Textbox>
|
|
||||||
</CellContents>
|
|
||||||
</TablixCell>
|
|
||||||
<TablixCell>
|
|
||||||
<CellContents>
|
|
||||||
<Textbox Name="CarName">
|
|
||||||
<CanGrow>true</CanGrow>
|
|
||||||
<KeepTogether>true</KeepTogether>
|
|
||||||
<Paragraphs>
|
|
||||||
<Paragraph>
|
|
||||||
<TextRuns>
|
|
||||||
<TextRun>
|
|
||||||
<Value>=Fields!CarName.Value</Value>
|
|
||||||
<Style />
|
|
||||||
</TextRun>
|
|
||||||
</TextRuns>
|
|
||||||
<Style />
|
|
||||||
</Paragraph>
|
|
||||||
</Paragraphs>
|
|
||||||
<rd:DefaultName>CarName</rd:DefaultName>
|
|
||||||
<Style>
|
|
||||||
<Border>
|
|
||||||
<Color>LightGrey</Color>
|
|
||||||
<Style>Solid</Style>
|
|
||||||
</Border>
|
|
||||||
<PaddingLeft>2pt</PaddingLeft>
|
|
||||||
<PaddingRight>2pt</PaddingRight>
|
|
||||||
<PaddingTop>2pt</PaddingTop>
|
|
||||||
<PaddingBottom>2pt</PaddingBottom>
|
|
||||||
</Style>
|
|
||||||
</Textbox>
|
|
||||||
</CellContents>
|
|
||||||
</TablixCell>
|
|
||||||
<TablixCell>
|
|
||||||
<CellContents>
|
|
||||||
<Textbox Name="Sum">
|
|
||||||
<CanGrow>true</CanGrow>
|
|
||||||
<KeepTogether>true</KeepTogether>
|
|
||||||
<Paragraphs>
|
|
||||||
<Paragraph>
|
|
||||||
<TextRuns>
|
|
||||||
<TextRun>
|
|
||||||
<Value>=Fields!Sum.Value</Value>
|
|
||||||
<Style />
|
|
||||||
</TextRun>
|
|
||||||
</TextRuns>
|
|
||||||
<Style />
|
|
||||||
</Paragraph>
|
|
||||||
</Paragraphs>
|
|
||||||
<rd:DefaultName>Sum</rd:DefaultName>
|
|
||||||
<Style>
|
|
||||||
<Border>
|
|
||||||
<Color>LightGrey</Color>
|
|
||||||
<Style>Solid</Style>
|
|
||||||
</Border>
|
|
||||||
<PaddingLeft>2pt</PaddingLeft>
|
|
||||||
<PaddingRight>2pt</PaddingRight>
|
|
||||||
<PaddingTop>2pt</PaddingTop>
|
|
||||||
<PaddingBottom>2pt</PaddingBottom>
|
|
||||||
</Style>
|
|
||||||
</Textbox>
|
|
||||||
</CellContents>
|
|
||||||
</TablixCell>
|
|
||||||
<TablixCell>
|
|
||||||
<CellContents>
|
|
||||||
<Textbox Name="Status">
|
|
||||||
<CanGrow>true</CanGrow>
|
|
||||||
<KeepTogether>true</KeepTogether>
|
|
||||||
<Paragraphs>
|
|
||||||
<Paragraph>
|
|
||||||
<TextRuns>
|
|
||||||
<TextRun>
|
|
||||||
<Value>=Fields!Status.Value</Value>
|
|
||||||
<Style />
|
|
||||||
</TextRun>
|
|
||||||
</TextRuns>
|
|
||||||
<Style />
|
|
||||||
</Paragraph>
|
|
||||||
</Paragraphs>
|
|
||||||
<rd:DefaultName>Status</rd:DefaultName>
|
|
||||||
<Style>
|
|
||||||
<Border>
|
|
||||||
<Color>LightGrey</Color>
|
|
||||||
<Style>Solid</Style>
|
|
||||||
</Border>
|
|
||||||
<PaddingLeft>2pt</PaddingLeft>
|
|
||||||
<PaddingRight>2pt</PaddingRight>
|
|
||||||
<PaddingTop>2pt</PaddingTop>
|
|
||||||
<PaddingBottom>2pt</PaddingBottom>
|
|
||||||
</Style>
|
|
||||||
</Textbox>
|
|
||||||
</CellContents>
|
|
||||||
</TablixCell>
|
|
||||||
</TablixCells>
|
|
||||||
</TablixRow>
|
|
||||||
</TablixRows>
|
|
||||||
</TablixBody>
|
|
||||||
<TablixColumnHierarchy>
|
|
||||||
<TablixMembers>
|
|
||||||
<TablixMember />
|
|
||||||
<TablixMember />
|
|
||||||
<TablixMember />
|
|
||||||
<TablixMember />
|
|
||||||
<TablixMember />
|
|
||||||
</TablixMembers>
|
|
||||||
</TablixColumnHierarchy>
|
|
||||||
<TablixRowHierarchy>
|
|
||||||
<TablixMembers>
|
|
||||||
<TablixMember>
|
|
||||||
<KeepWithGroup>After</KeepWithGroup>
|
|
||||||
</TablixMember>
|
|
||||||
<TablixMember>
|
|
||||||
<Group Name="Подробности" />
|
|
||||||
</TablixMember>
|
|
||||||
</TablixMembers>
|
|
||||||
</TablixRowHierarchy>
|
|
||||||
<DataSetName>DataSetOrders</DataSetName>
|
|
||||||
<Top>2.48391cm</Top>
|
|
||||||
<Left>0.55245cm</Left>
|
|
||||||
<Height>1.2cm</Height>
|
|
||||||
<Width>18.94755cm</Width>
|
|
||||||
<ZIndex>2</ZIndex>
|
|
||||||
<Style>
|
|
||||||
<Border>
|
|
||||||
<Style>Double</Style>
|
|
||||||
</Border>
|
|
||||||
</Style>
|
|
||||||
</Tablix>
|
|
||||||
<Textbox Name="TextboxTotalSum">
|
|
||||||
<CanGrow>true</CanGrow>
|
|
||||||
<KeepTogether>true</KeepTogether>
|
|
||||||
<Paragraphs>
|
|
||||||
<Paragraph>
|
|
||||||
<TextRuns>
|
|
||||||
<TextRun>
|
|
||||||
<Value>Итого:</Value>
|
|
||||||
<Style>
|
|
||||||
<FontWeight>Bold</FontWeight>
|
|
||||||
</Style>
|
|
||||||
</TextRun>
|
|
||||||
</TextRuns>
|
|
||||||
<Style>
|
|
||||||
<TextAlign>Right</TextAlign>
|
|
||||||
</Style>
|
|
||||||
</Paragraph>
|
|
||||||
</Paragraphs>
|
|
||||||
<Top>4cm</Top>
|
|
||||||
<Left>12cm</Left>
|
|
||||||
<Height>0.6cm</Height>
|
|
||||||
<Width>2.5cm</Width>
|
|
||||||
<ZIndex>3</ZIndex>
|
|
||||||
<Style>
|
|
||||||
<Border>
|
|
||||||
<Style>None</Style>
|
|
||||||
</Border>
|
|
||||||
<PaddingLeft>2pt</PaddingLeft>
|
|
||||||
<PaddingRight>2pt</PaddingRight>
|
|
||||||
<PaddingTop>2pt</PaddingTop>
|
|
||||||
<PaddingBottom>2pt</PaddingBottom>
|
|
||||||
</Style>
|
|
||||||
</Textbox>
|
|
||||||
<Textbox Name="SumTotal">
|
|
||||||
<CanGrow>true</CanGrow>
|
|
||||||
<KeepTogether>true</KeepTogether>
|
|
||||||
<Paragraphs>
|
|
||||||
<Paragraph>
|
|
||||||
<TextRuns>
|
|
||||||
<TextRun>
|
|
||||||
<Value>=Sum(Fields!Sum.Value, "DataSetOrders")</Value>
|
|
||||||
<Style>
|
|
||||||
<FontWeight>Bold</FontWeight>
|
|
||||||
</Style>
|
|
||||||
</TextRun>
|
|
||||||
</TextRuns>
|
|
||||||
<Style>
|
|
||||||
<TextAlign>Right</TextAlign>
|
|
||||||
</Style>
|
|
||||||
</Paragraph>
|
|
||||||
</Paragraphs>
|
|
||||||
<Top>4cm</Top>
|
|
||||||
<Left>14.5cm</Left>
|
|
||||||
<Height>0.6cm</Height>
|
|
||||||
<Width>2.5cm</Width>
|
|
||||||
<ZIndex>4</ZIndex>
|
|
||||||
<Style>
|
|
||||||
<Border>
|
|
||||||
<Style>None</Style>
|
|
||||||
</Border>
|
|
||||||
<PaddingLeft>2pt</PaddingLeft>
|
|
||||||
<PaddingRight>2pt</PaddingRight>
|
|
||||||
<PaddingTop>2pt</PaddingTop>
|
|
||||||
<PaddingBottom>2pt</PaddingBottom>
|
|
||||||
</Style>
|
|
||||||
</Textbox>
|
|
||||||
</ReportItems>
|
|
||||||
<Height>5.72875cm</Height>
|
|
||||||
<Style />
|
|
||||||
</Body>
|
|
||||||
<Width>21cm</Width>
|
|
||||||
<Page>
|
|
||||||
<PageHeight>29.7cm</PageHeight>
|
|
||||||
<PageWidth>21cm</PageWidth>
|
|
||||||
<LeftMargin>2cm</LeftMargin>
|
|
||||||
<RightMargin>2cm</RightMargin>
|
|
||||||
<TopMargin>2cm</TopMargin>
|
|
||||||
<BottomMargin>2cm</BottomMargin>
|
|
||||||
<ColumnSpacing>0.13cm</ColumnSpacing>
|
|
||||||
<Style />
|
|
||||||
</Page>
|
|
||||||
</ReportSection>
|
|
||||||
</ReportSections>
|
|
||||||
<ReportParameters>
|
|
||||||
<ReportParameter Name="ReportParameterPeriod">
|
|
||||||
<DataType>String</DataType>
|
|
||||||
<Nullable>true</Nullable>
|
|
||||||
<Prompt>ReportParameter1</Prompt>
|
|
||||||
</ReportParameter>
|
|
||||||
</ReportParameters>
|
|
||||||
<ReportParametersLayout>
|
|
||||||
<GridLayoutDefinition>
|
|
||||||
<NumberOfColumns>4</NumberOfColumns>
|
|
||||||
<NumberOfRows>2</NumberOfRows>
|
|
||||||
<CellDefinitions>
|
|
||||||
<CellDefinition>
|
|
||||||
<ColumnIndex>0</ColumnIndex>
|
|
||||||
<RowIndex>0</RowIndex>
|
|
||||||
<ParameterName>ReportParameterPeriod</ParameterName>
|
|
||||||
</CellDefinition>
|
|
||||||
</CellDefinitions>
|
|
||||||
</GridLayoutDefinition>
|
|
||||||
</ReportParametersLayout>
|
|
||||||
<rd:ReportUnitType>Cm</rd:ReportUnitType>
|
|
||||||
<rd:ReportID>2de0031a-4d17-449d-922d-d9fc54572312</rd:ReportID>
|
|
||||||
</Report>
|
|
@ -1,20 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="DocumentFormat.OpenXml" Version="2.19.0" />
|
|
||||||
<PackageReference Include="MailKit" Version="4.0.0" />
|
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
|
|
||||||
<PackageReference Include="PDFsharp-MigraDoc-GDI" Version="1.50.5147" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\AutomobilePlantContracts\AutomobilePlantContracts.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
@ -1,100 +0,0 @@
|
|||||||
using AutomobilePlantContracts.BindingModels;
|
|
||||||
using AutomobilePlantContracts.BusinessLogicContracts;
|
|
||||||
using AutomobilePlantContracts.StorageContracts;
|
|
||||||
using AutomobilePlantDataModels;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO.Compression;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Runtime.Serialization.Json;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantBusinessLogic.BusinessLogics
|
|
||||||
{
|
|
||||||
public class BackUpLogic : IBackUpLogic
|
|
||||||
{
|
|
||||||
private readonly ILogger _logger;
|
|
||||||
private readonly IBackUpInfo _backUpInfo;
|
|
||||||
public BackUpLogic(ILogger<BackUpLogic> logger, IBackUpInfo backUpInfo)
|
|
||||||
{
|
|
||||||
_logger = logger;
|
|
||||||
_backUpInfo = backUpInfo;
|
|
||||||
}
|
|
||||||
public void CreateBackUp(BackUpSaveBinidngModel model)
|
|
||||||
{
|
|
||||||
if (_backUpInfo == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_logger.LogDebug("Clear folder");
|
|
||||||
// зачистка папки и удаление старого архива
|
|
||||||
var dirInfo = new DirectoryInfo(model.FolderName);
|
|
||||||
if (dirInfo.Exists)
|
|
||||||
{
|
|
||||||
foreach (var file in dirInfo.GetFiles())
|
|
||||||
{
|
|
||||||
file.Delete();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_logger.LogDebug("Delete archive");
|
|
||||||
string fileName = $"{model.FolderName}.zip";
|
|
||||||
if (File.Exists(fileName))
|
|
||||||
{
|
|
||||||
File.Delete(fileName);
|
|
||||||
}
|
|
||||||
// берем метод для сохранения
|
|
||||||
_logger.LogDebug("Get assembly");
|
|
||||||
var typeIId = typeof(IId);
|
|
||||||
var assembly = typeIId.Assembly;
|
|
||||||
if (assembly == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("Сборка не найдена", nameof(assembly));
|
|
||||||
}
|
|
||||||
var types = assembly.GetTypes();
|
|
||||||
var method = GetType().GetMethod("SaveToFile", BindingFlags.NonPublic | BindingFlags.Instance);
|
|
||||||
_logger.LogDebug("Find {count} types", types.Length);
|
|
||||||
foreach (var type in types)
|
|
||||||
{
|
|
||||||
if (type.IsInterface && type.GetInterface(typeIId.Name) != null)
|
|
||||||
{
|
|
||||||
var modelType = _backUpInfo.GetTypeByModelInterface(type.Name);
|
|
||||||
if (modelType == null)
|
|
||||||
{
|
|
||||||
throw new InvalidOperationException($"Не найден класс - модель для {type.Name}");
|
|
||||||
}
|
|
||||||
_logger.LogDebug("Call SaveToFile method for {name} type", type.Name);
|
|
||||||
// вызываем метод на выполнение
|
|
||||||
method?.MakeGenericMethod(modelType).Invoke(this, new
|
|
||||||
object[] { model.FolderName });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_logger.LogDebug("Create zip and remove folder");
|
|
||||||
// архивируем
|
|
||||||
ZipFile.CreateFromDirectory(model.FolderName, fileName);
|
|
||||||
// удаляем папку
|
|
||||||
dirInfo.Delete(true);
|
|
||||||
}
|
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void SaveToFile<T>(string folderName) where T : class, new()
|
|
||||||
{
|
|
||||||
var records = _backUpInfo.GetList<T>();
|
|
||||||
if (records == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("{type} type get null list", typeof(T).Name);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var jsonFormatter = new DataContractJsonSerializer(typeof(List<T>));
|
|
||||||
using var fs = new FileStream(string.Format("{0}/{1}.json", folderName, typeof(T).Name), FileMode.OpenOrCreate);
|
|
||||||
jsonFormatter.WriteObject(fs, records);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,119 +0,0 @@
|
|||||||
using AutomobilePlantContracts.BusinessLogicContracts;
|
|
||||||
using AutomobilePlantContracts.StorageContracts;
|
|
||||||
using AutomobilePlantContracts.BindingModels;
|
|
||||||
using AutomobilePlantContracts.SearchModels;
|
|
||||||
using AutomobilePlantContracts.ViewModels;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantBusinessLogic.BusinessLogics
|
|
||||||
{
|
|
||||||
public class CarLogic : ICarLogic
|
|
||||||
{
|
|
||||||
private readonly ILogger _logger;
|
|
||||||
private readonly ICarStorage _carStorage;
|
|
||||||
|
|
||||||
public CarLogic(ILogger<CarLogic> logger, ICarStorage carStorage)
|
|
||||||
{
|
|
||||||
_logger = logger;
|
|
||||||
_carStorage = carStorage;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Create(CarBindingModel model)
|
|
||||||
{
|
|
||||||
CheckModel(model);
|
|
||||||
if (_carStorage.Insert(model) == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Insert operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Delete(CarBindingModel model)
|
|
||||||
{
|
|
||||||
CheckModel(model, false);
|
|
||||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
|
||||||
if (_carStorage.Delete(model) == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Delete operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Update(CarBindingModel model)
|
|
||||||
{
|
|
||||||
CheckModel(model);
|
|
||||||
if (_carStorage.Update(model) == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Update operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CarViewModel? ReadElement(CarSearchModel model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(model));
|
|
||||||
}
|
|
||||||
_logger.LogInformation("ReadElement. CarName:{CarName}.Id:{ Id}", model.CarName, model.Id);
|
|
||||||
var element = _carStorage.GetElement(model);
|
|
||||||
if (element == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("ReadElement element not found");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
|
||||||
return element;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<CarViewModel>? ReadList(CarSearchModel? model)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("ReadList. CarName:{CarName}.Id:{ Id}", model?.CarName, model?.Id);
|
|
||||||
var list = model == null ? _carStorage.GetFullList() : _carStorage.GetFilteredList(model);
|
|
||||||
if (list == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("ReadList return null list");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void CheckModel(CarBindingModel model, bool withParams = true)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(model));
|
|
||||||
}
|
|
||||||
if (!withParams)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (string.IsNullOrEmpty(model.CarName))
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("Нет названия авто", nameof(model.CarName));
|
|
||||||
}
|
|
||||||
if (model.Price <= 0)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("Стоимость авто должна быть больше 0", nameof(model.Price));
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Car. CarName:{CarName}.Price:{ Price}. Id: { Id}", model.CarName, model.Price, model.Id);
|
|
||||||
var element = _carStorage.GetElement(new CarSearchModel
|
|
||||||
{
|
|
||||||
CarName = model.CarName
|
|
||||||
});
|
|
||||||
if (element != null && element.Id != model.Id)
|
|
||||||
{
|
|
||||||
throw new InvalidOperationException("Авто с таким названием уже есть");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,126 +0,0 @@
|
|||||||
using AutomobilePlantContracts.BindingModels;
|
|
||||||
using AutomobilePlantContracts.BusinessLogicContracts;
|
|
||||||
using AutomobilePlantContracts.SearchModels;
|
|
||||||
using AutomobilePlantContracts.StorageContracts;
|
|
||||||
using AutomobilePlantContracts.ViewModels;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Text.RegularExpressions;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantBusinessLogic.BusinessLogics
|
|
||||||
{
|
|
||||||
public class ClientLogic : IClientLogic
|
|
||||||
{
|
|
||||||
private readonly ILogger _logger;
|
|
||||||
private readonly IClientStorage _clientStorage;
|
|
||||||
public ClientLogic(ILogger<ClientLogic> logger, IClientStorage clientStorage)
|
|
||||||
{
|
|
||||||
_logger = logger;
|
|
||||||
_clientStorage = clientStorage;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Create(ClientBindingModel model)
|
|
||||||
{
|
|
||||||
CheckModel(model);
|
|
||||||
if (_clientStorage.Insert(model) == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Insert operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
public bool Update(ClientBindingModel model)
|
|
||||||
{
|
|
||||||
CheckModel(model);
|
|
||||||
if (_clientStorage.Update(model) == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Update operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Delete(ClientBindingModel model)
|
|
||||||
{
|
|
||||||
CheckModel(model, false);
|
|
||||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
|
||||||
if (_clientStorage.Delete(model) == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Delete operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ClientViewModel? ReadElement(ClientSearchModel model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(model));
|
|
||||||
}
|
|
||||||
_logger.LogInformation("ReadElement. Email:{Email}.Id:{ Id}", model.Email, model.Id);
|
|
||||||
var element = _clientStorage.GetElement(model);
|
|
||||||
if (element == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("ReadElement element not found");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
|
||||||
return element;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<ClientViewModel>? ReadList(ClientSearchModel? model)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("ReadList. Email:{Email}.Id:{ Id} ", model?.Email, model?.Id);
|
|
||||||
var list = (model == null) ? _clientStorage.GetFullList() : _clientStorage.GetFilteredList(model);
|
|
||||||
if (list == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("ReadList return null list");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void CheckModel(ClientBindingModel model, bool withParams = true)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(model));
|
|
||||||
}
|
|
||||||
if (!withParams)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (string.IsNullOrEmpty(model.ClientFIO))
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("Нет ФИО клиента", nameof(model.ClientFIO));
|
|
||||||
}
|
|
||||||
if (string.IsNullOrEmpty(model.Email))
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("Нет логина(почты) клиента", nameof(model.Email));
|
|
||||||
}
|
|
||||||
if (!Regex.IsMatch(model.Email, @"^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$"))
|
|
||||||
{
|
|
||||||
throw new ArgumentException("Некорретно введен email клиента", nameof(model.Email));
|
|
||||||
}
|
|
||||||
if (!Regex.IsMatch(model.Password, @"^(?=.*\d)(?=.*\W)(?=.*[^\d\s]).+$"))
|
|
||||||
{
|
|
||||||
throw new ArgumentException("Некорректно введен пароль клиента", nameof(model.Password));
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Client. Id: {Id}, FIO: {fio}, email: {email}", model.Id, model.ClientFIO, model.Email);
|
|
||||||
var element = _clientStorage.GetElement(new ClientSearchModel
|
|
||||||
{
|
|
||||||
Email = model.Email,
|
|
||||||
});
|
|
||||||
if (element != null && element.Id != model.Id)
|
|
||||||
{
|
|
||||||
throw new InvalidOperationException("Клиент с таким логином(почтой) уже есть");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,119 +0,0 @@
|
|||||||
using AutomobilePlantContracts.BindingModels;
|
|
||||||
using AutomobilePlantContracts.BusinessLogicContracts;
|
|
||||||
using AutomobilePlantContracts.SearchModels;
|
|
||||||
using AutomobilePlantContracts.StorageContracts;
|
|
||||||
using AutomobilePlantContracts.ViewModels;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantBusinessLogic.BusinessLogics
|
|
||||||
{
|
|
||||||
public class ComponentLogic : IComponentLogic
|
|
||||||
{
|
|
||||||
private readonly ILogger _logger;
|
|
||||||
private readonly IComponentStorage _componentStorage;
|
|
||||||
|
|
||||||
public ComponentLogic(ILogger<ComponentLogic> logger, IComponentStorage componentStorage)
|
|
||||||
{
|
|
||||||
_logger = logger;
|
|
||||||
_componentStorage = componentStorage;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Create(ComponentBindingModel model)
|
|
||||||
{
|
|
||||||
CheckModel(model);
|
|
||||||
if (_componentStorage.Insert(model) == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Insert operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Update(ComponentBindingModel model)
|
|
||||||
{
|
|
||||||
CheckModel(model);
|
|
||||||
if (_componentStorage.Update(model) == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Update operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Delete(ComponentBindingModel model)
|
|
||||||
{
|
|
||||||
CheckModel(model, false);
|
|
||||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
|
||||||
if (_componentStorage.Delete(model) == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Delete operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<ComponentViewModel>? ReadList(ComponentSearchModel? model)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("ReadList. ComponentName:{ComponentName}.Id:{ Id}", model?.ComponentName, model?.Id);
|
|
||||||
var list = model == null ? _componentStorage.GetFullList() : _componentStorage.GetFilteredList(model);
|
|
||||||
if (list == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("ReadList return null list");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ComponentViewModel? ReadElement(ComponentSearchModel model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(model));
|
|
||||||
}
|
|
||||||
_logger.LogInformation("ReadElement. ComponentName:{ComponentName}.Id:{ Id}", model.ComponentName, model.Id);
|
|
||||||
var element = _componentStorage.GetElement(model);
|
|
||||||
if (element == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("ReadElement element not found");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
|
||||||
return element;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void CheckModel(ComponentBindingModel model, bool withParams = true)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(model));
|
|
||||||
}
|
|
||||||
if (!withParams)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (string.IsNullOrEmpty(model.ComponentName))
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("Нет названия компонента", nameof(model.ComponentName));
|
|
||||||
}
|
|
||||||
if (model.Cost <= 0)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("Цена компонента должна быть больше 0", nameof(model.Cost));
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Component. ComponentName:{ComponentName}.Cost:{ Cost}. Id: { Id}", model.ComponentName, model.Cost, model.Id);
|
|
||||||
var element = _componentStorage.GetElement(new ComponentSearchModel
|
|
||||||
{
|
|
||||||
ComponentName = model.ComponentName
|
|
||||||
});
|
|
||||||
if (element != null && element.Id != model.Id)
|
|
||||||
{
|
|
||||||
throw new InvalidOperationException("Компонент с таким названием уже есть");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,126 +0,0 @@
|
|||||||
using AutomobilePlantContracts.BindingModels;
|
|
||||||
using AutomobilePlantContracts.BusinessLogicContracts;
|
|
||||||
using AutomobilePlantContracts.SearchModels;
|
|
||||||
using AutomobilePlantContracts.StorageContracts;
|
|
||||||
using AutomobilePlantContracts.ViewModels;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantBusinessLogic.BusinessLogics
|
|
||||||
{
|
|
||||||
public class ImplementerLogic : IImplementerLogic
|
|
||||||
{
|
|
||||||
private readonly ILogger _logger;
|
|
||||||
private readonly IImplementerStorage _implementerStorage;
|
|
||||||
public ImplementerLogic(ILogger<ImplementerLogic> logger, IImplementerStorage implementerStorage)
|
|
||||||
{
|
|
||||||
_logger = logger;
|
|
||||||
_implementerStorage = implementerStorage;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Create(ImplementerBindingModel model)
|
|
||||||
{
|
|
||||||
CheckModel(model);
|
|
||||||
if (_implementerStorage.Insert(model) == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Insert operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Update(ImplementerBindingModel model)
|
|
||||||
{
|
|
||||||
CheckModel(model);
|
|
||||||
if (_implementerStorage.Update(model) == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Update operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Delete(ImplementerBindingModel model)
|
|
||||||
{
|
|
||||||
CheckModel(model, false);
|
|
||||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
|
||||||
if (_implementerStorage.Delete(model) == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Delete operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ImplementerViewModel? ReadElement(ImplementerSearchModel model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(model));
|
|
||||||
}
|
|
||||||
_logger.LogInformation("ReadElement. FIO:{FIO}.Id:{ Id}", model.ImplementerFIO, model.Id);
|
|
||||||
var element = _implementerStorage.GetElement(model);
|
|
||||||
if (element == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("ReadElement element not found");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
|
||||||
return element;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<ImplementerViewModel>? ReadList(ImplementerSearchModel? model)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("ReadList. FIO:{FIO}.Id:{ Id} ", model?.ImplementerFIO, model?.Id);
|
|
||||||
var list = (model == null) ? _implementerStorage.GetFullList() : _implementerStorage.GetFilteredList(model);
|
|
||||||
if (list == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("ReadList return null list");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void CheckModel(ImplementerBindingModel model, bool withParams = true)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(model));
|
|
||||||
}
|
|
||||||
if (!withParams)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (model.WorkExperience < 0)
|
|
||||||
{
|
|
||||||
throw new ArgumentException("Стаж работы не может быть меньше нуля", nameof(model.WorkExperience));
|
|
||||||
}
|
|
||||||
if (model.Qualification < 0)
|
|
||||||
{
|
|
||||||
throw new ArgumentException("Квалификация не должна быть меньше нуля", nameof(model.Qualification));
|
|
||||||
}
|
|
||||||
if (string.IsNullOrEmpty(model.Password))
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("Нет пароля исполнителя", nameof(model.ImplementerFIO));
|
|
||||||
}
|
|
||||||
if (string.IsNullOrEmpty(model.ImplementerFIO))
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("Нет ФИО исполнителя", nameof(model.ImplementerFIO));
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Implementer. Id: {Id}, FIO: {FIO}", model.Id, model.ImplementerFIO);
|
|
||||||
var element = _implementerStorage.GetElement(new ImplementerSearchModel
|
|
||||||
{
|
|
||||||
ImplementerFIO = model.ImplementerFIO,
|
|
||||||
});
|
|
||||||
if (element != null && element.Id != model.Id)
|
|
||||||
{
|
|
||||||
throw new InvalidOperationException("Исполнитель с таким ФИО уже есть");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,48 +0,0 @@
|
|||||||
using AutomobilePlantContracts.BindingModels;
|
|
||||||
using AutomobilePlantContracts.BusinessLogicContracts;
|
|
||||||
using AutomobilePlantContracts.SearchModels;
|
|
||||||
using AutomobilePlantContracts.StorageContracts;
|
|
||||||
using AutomobilePlantContracts.ViewModels;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantBusinessLogic.BusinessLogics
|
|
||||||
{
|
|
||||||
public class MessageInfoLogic : IMessageInfoLogic
|
|
||||||
{
|
|
||||||
private readonly ILogger _logger;
|
|
||||||
private readonly IMessageInfoStorage _messageInfoStorage;
|
|
||||||
public MessageInfoLogic(ILogger<MessageInfoLogic> logger, IMessageInfoStorage MessageInfoStorage)
|
|
||||||
{
|
|
||||||
_logger = logger;
|
|
||||||
_messageInfoStorage = MessageInfoStorage;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Create(MessageInfoBindingModel model)
|
|
||||||
{
|
|
||||||
if (_messageInfoStorage.Insert(model) == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Insert operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<MessageInfoViewModel>? ReadList(MessageInfoSearchModel? model)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("ReadList. MessageId:{MessageId}.ClientId:{ClientId} ", model?.MessageId, model?.ClientId);
|
|
||||||
var list = (model == null) ? _messageInfoStorage.GetFullList() : _messageInfoStorage.GetFilteredList(model);
|
|
||||||
if (list == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("ReadList return null list");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,187 +0,0 @@
|
|||||||
using AutomobilePlantBusinessLogic.MailWorker;
|
|
||||||
using AutomobilePlantContracts.BindingModels;
|
|
||||||
using AutomobilePlantContracts.BusinessLogicContracts;
|
|
||||||
using AutomobilePlantContracts.SearchModels;
|
|
||||||
using AutomobilePlantContracts.StorageContracts;
|
|
||||||
using AutomobilePlantContracts.ViewModels;
|
|
||||||
using AutomobilePlantDataModels.Enums;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantBusinessLogic.BusinessLogics
|
|
||||||
{
|
|
||||||
public class OrderLogic : IOrderLogic
|
|
||||||
{
|
|
||||||
private readonly ILogger _logger;
|
|
||||||
private readonly IOrderStorage _orderStorage;
|
|
||||||
private readonly AbstractMailWorker _mailWorker;
|
|
||||||
private readonly IClientLogic _clientLogic;
|
|
||||||
|
|
||||||
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage, AbstractMailWorker mailWorker, IClientLogic clientLogic)
|
|
||||||
{
|
|
||||||
_logger = logger;
|
|
||||||
_orderStorage = orderStorage;
|
|
||||||
_mailWorker = mailWorker;
|
|
||||||
_clientLogic = clientLogic;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool CreateOrder(OrderBindingModel model)
|
|
||||||
{
|
|
||||||
CheckModel(model);
|
|
||||||
if (model.Status != OrderStatus.Неизвестен)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Insert operation failed. Order status incorrect.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
model.Status = OrderStatus.Принят;
|
|
||||||
var result = _orderStorage.Insert(model);
|
|
||||||
if (result == null)
|
|
||||||
{
|
|
||||||
model.Status = OrderStatus.Неизвестен;
|
|
||||||
_logger.LogWarning("Insert operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
SendOrderStatusMail(result.ClientId, $"Новый заказ создан. Номер заказа #{result.Id}", $"Заказ #{result.Id} от {result.DateCreate} на сумму {result.Sum:0.00} принят");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool StatusUpdate(OrderBindingModel rawModel, OrderStatus newStatus)
|
|
||||||
{
|
|
||||||
var viewModel = _orderStorage.GetElement(new OrderSearchModel
|
|
||||||
{
|
|
||||||
Id = rawModel.Id
|
|
||||||
});
|
|
||||||
|
|
||||||
if (viewModel == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Order model not found");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
OrderBindingModel model = new OrderBindingModel
|
|
||||||
{
|
|
||||||
Id = viewModel.Id,
|
|
||||||
CarId = viewModel.CarId,
|
|
||||||
Status = viewModel.Status,
|
|
||||||
DateCreate = viewModel.DateCreate,
|
|
||||||
DateImplement = viewModel.DateImplement,
|
|
||||||
Count = viewModel.Count,
|
|
||||||
Sum = viewModel.Sum,
|
|
||||||
ImplementerId = viewModel.ImplementerId
|
|
||||||
};
|
|
||||||
|
|
||||||
if (rawModel.ImplementerId.HasValue)
|
|
||||||
{
|
|
||||||
model.ImplementerId = rawModel.ImplementerId;
|
|
||||||
}
|
|
||||||
|
|
||||||
CheckModel(model, false);
|
|
||||||
if (model.Status + 1 != newStatus)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Status update to " + newStatus.ToString() + " operation failed. Order status incorrect.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
model.Status = newStatus;
|
|
||||||
if (model.Status == OrderStatus.Выдан) model.DateImplement = DateTime.Now;
|
|
||||||
var result = _orderStorage.Update(model);
|
|
||||||
if (result == null)
|
|
||||||
{
|
|
||||||
model.Status--;
|
|
||||||
_logger.LogWarning("Update operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
SendOrderStatusMail(result.ClientId, $"Изменен статус заказа #{result.Id}", $"Заказ #{result.Id} изменен статус на {result.Status}");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool TakeOrderInWork(OrderBindingModel model)
|
|
||||||
{
|
|
||||||
return StatusUpdate(model, OrderStatus.Выполняется);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool DeliveryOrder(OrderBindingModel model)
|
|
||||||
{
|
|
||||||
return StatusUpdate(model, OrderStatus.Готов);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool FinishOrder(OrderBindingModel model)
|
|
||||||
{
|
|
||||||
return StatusUpdate(model, OrderStatus.Выдан);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Order. OrderID:{Id}", model?.Id);
|
|
||||||
var list = model == null ? _orderStorage.GetFullList() : _orderStorage.GetFilteredList(model);
|
|
||||||
if (list == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("ReadList return null list");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OrderViewModel? ReadElement(OrderSearchModel model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(model));
|
|
||||||
}
|
|
||||||
_logger.LogInformation("ReadElement. Id:{ Id}", model.Id);
|
|
||||||
var element = _orderStorage.GetElement(model);
|
|
||||||
if (element == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("ReadElement element not found");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
|
||||||
return element;
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool SendOrderStatusMail(int clientId, string subject, string text)
|
|
||||||
{
|
|
||||||
var client = _clientLogic.ReadElement(new() { Id = clientId });
|
|
||||||
if (client == null)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
_mailWorker.MailSendAsync(new()
|
|
||||||
{
|
|
||||||
MailAddress = client.Email,
|
|
||||||
Subject = subject,
|
|
||||||
Text = text
|
|
||||||
});
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void CheckModel(OrderBindingModel model, bool withParams = true)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(model));
|
|
||||||
}
|
|
||||||
if (!withParams)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (model.CarId < 0)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("Некорректный идентификатор авто", nameof(model.CarId));
|
|
||||||
}
|
|
||||||
if (model.Count <= 0)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("Количество авто в заказе должно быть больше 0", nameof(model.Count));
|
|
||||||
}
|
|
||||||
if (model.Sum <= 0)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("Сумма заказа должна быть больше 0", nameof(model.Sum));
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Order. OrderID:{Id}.Sum:{ Sum}. CarId: { CarId}", model.Id, model.Sum, model.CarId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,107 +0,0 @@
|
|||||||
using AutomobilePlantBusinessLogic.OfficePackage.HelperModels;
|
|
||||||
using AutomobilePlantBusinessLogic.OfficePackage;
|
|
||||||
using AutomobilePlantContracts.BindingModels;
|
|
||||||
using AutomobilePlantContracts.BusinessLogicContracts;
|
|
||||||
using AutomobilePlantContracts.SearchModels;
|
|
||||||
using AutomobilePlantContracts.StorageContracts;
|
|
||||||
using AutomobilePlantContracts.ViewModels;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantBusinessLogic.BusinessLogics
|
|
||||||
{
|
|
||||||
public class ReportLogic : IReportLogic
|
|
||||||
{
|
|
||||||
private readonly IComponentStorage _componentStorage;
|
|
||||||
private readonly ICarStorage _carStorage;
|
|
||||||
private readonly IOrderStorage _orderStorage;
|
|
||||||
private readonly AbstractSaveToExcel _saveToExcel;
|
|
||||||
private readonly AbstractSaveToWord _saveToWord;
|
|
||||||
private readonly AbstractSaveToPdf _saveToPdf;
|
|
||||||
public ReportLogic(ICarStorage carStorage, IComponentStorage componentStorage, IOrderStorage orderStorage, AbstractSaveToExcel saveToExcel, AbstractSaveToWord saveToWord, AbstractSaveToPdf saveToPdf)
|
|
||||||
{
|
|
||||||
_carStorage = carStorage;
|
|
||||||
_componentStorage = componentStorage;
|
|
||||||
_orderStorage = orderStorage;
|
|
||||||
_saveToExcel = saveToExcel;
|
|
||||||
_saveToWord = saveToWord;
|
|
||||||
_saveToPdf = saveToPdf;
|
|
||||||
}
|
|
||||||
/// Получение списка компонент с указанием, в каких изделиях используются
|
|
||||||
public List<ReportCarComponentViewModel> GetCarComponents()
|
|
||||||
{
|
|
||||||
var cars = _carStorage.GetFullList();
|
|
||||||
var list = new List<ReportCarComponentViewModel>();
|
|
||||||
foreach (var car in cars)
|
|
||||||
{
|
|
||||||
var record = new ReportCarComponentViewModel
|
|
||||||
{
|
|
||||||
CarName = car.CarName,
|
|
||||||
Components = new List<(string Component, int Count)>(),
|
|
||||||
TotalCount = 0
|
|
||||||
};
|
|
||||||
foreach (var component in car.CarComponents.Values)
|
|
||||||
{
|
|
||||||
record.Components.Add((component.Item1.ComponentName, component.Item2));
|
|
||||||
record.TotalCount += component.Item2;
|
|
||||||
}
|
|
||||||
list.Add(record);
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
/// Получение списка заказов за определенный период
|
|
||||||
public List<ReportOrdersViewModel> GetOrders(ReportBindingModel model)
|
|
||||||
{
|
|
||||||
return _orderStorage.GetFilteredList(new OrderSearchModel
|
|
||||||
{
|
|
||||||
DateFrom = model.DateFrom,
|
|
||||||
DateTo = model.DateTo
|
|
||||||
})
|
|
||||||
.Select(x => new ReportOrdersViewModel
|
|
||||||
{
|
|
||||||
Id = x.Id,
|
|
||||||
DateCreate = x.DateCreate,
|
|
||||||
CarName = x.CarName,
|
|
||||||
Sum = x.Sum,
|
|
||||||
Status = x.Status.ToString(),
|
|
||||||
})
|
|
||||||
.ToList();
|
|
||||||
}
|
|
||||||
/// Сохранение компонент в файл-Word
|
|
||||||
public void SaveCarsToWordFile(ReportBindingModel model)
|
|
||||||
{
|
|
||||||
_saveToWord.CreateDoc(new WordInfo
|
|
||||||
{
|
|
||||||
FileName = model.FileName,
|
|
||||||
Title = "Список автомобилей",
|
|
||||||
Cars = _carStorage.GetFullList()
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/// Сохранение компонент с указаеним продуктов в файл-Excel
|
|
||||||
public void SaveCarComponentToExcelFile(ReportBindingModel model)
|
|
||||||
{
|
|
||||||
_saveToExcel.CreateReport(new ExcelInfo
|
|
||||||
{
|
|
||||||
FileName = model.FileName,
|
|
||||||
Title = "Список автомобилей",
|
|
||||||
CarComponents = GetCarComponents()
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/// Сохранение заказов в файл-Pdf
|
|
||||||
public void SaveOrdersToPdfFile(ReportBindingModel model)
|
|
||||||
{
|
|
||||||
_saveToPdf.CreateDoc(new PdfInfo
|
|
||||||
{
|
|
||||||
FileName = model.FileName,
|
|
||||||
Title = "Список заказов",
|
|
||||||
DateFrom = model.DateFrom!.Value,
|
|
||||||
DateTo = model.DateTo!.Value,
|
|
||||||
Orders = GetOrders(model)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,142 +0,0 @@
|
|||||||
using AutomobilePlantContracts.BindingModels;
|
|
||||||
using AutomobilePlantContracts.BusinessLogicContracts;
|
|
||||||
using AutomobilePlantContracts.SearchModels;
|
|
||||||
using AutomobilePlantContracts.ViewModels;
|
|
||||||
using AutomobilePlantDataModels.Enums;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantBusinessLogic.BusinessLogics
|
|
||||||
{
|
|
||||||
public class WorkModeling : IWorkProcess
|
|
||||||
{
|
|
||||||
private readonly ILogger _logger;
|
|
||||||
|
|
||||||
private readonly Random _rnd;
|
|
||||||
|
|
||||||
private IOrderLogic? _orderLogic;
|
|
||||||
|
|
||||||
public WorkModeling(ILogger<WorkModeling> logger)
|
|
||||||
{
|
|
||||||
_logger = logger;
|
|
||||||
_rnd = new Random(1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void DoWork(IImplementerLogic implementerLogic, IOrderLogic orderLogic)
|
|
||||||
{
|
|
||||||
_orderLogic = orderLogic;
|
|
||||||
var implementers = implementerLogic.ReadList(null);
|
|
||||||
if (implementers == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("DoWork. Implementers is null");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var orders = _orderLogic.ReadList(new OrderSearchModel { Status = OrderStatus.Принят });
|
|
||||||
if (orders == null || orders.Count == 0)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("DoWork. Orders is null or empty");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_logger.LogDebug("DoWork for {Count} orders", orders.Count);
|
|
||||||
foreach (var implementer in implementers)
|
|
||||||
{
|
|
||||||
Task.Run(() => WorkerWorkAsync(implementer, orders));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task WorkerWorkAsync(ImplementerViewModel implementer, List<OrderViewModel> orders)
|
|
||||||
{
|
|
||||||
if (_orderLogic == null || implementer == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
await RunOrderInWork(implementer);
|
|
||||||
|
|
||||||
await Task.Run(() =>
|
|
||||||
{
|
|
||||||
foreach (var order in orders)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_logger.LogDebug("DoWork. Worker {Id} try get order {Order}", implementer.Id, order.Id);
|
|
||||||
// пытаемся назначить заказ на исполнителя
|
|
||||||
if (_orderLogic.TakeOrderInWork(new OrderBindingModel
|
|
||||||
{
|
|
||||||
Id = order.Id,
|
|
||||||
ImplementerId = implementer.Id
|
|
||||||
}))
|
|
||||||
{
|
|
||||||
// делаем работу
|
|
||||||
Thread.Sleep(implementer.WorkExperience * _rnd.Next(100, 1000) * order.Count);
|
|
||||||
_logger.LogDebug("DoWork. Worker {Id} finish order {Order}", implementer.Id, order.Id);
|
|
||||||
_orderLogic.DeliveryOrder(new OrderBindingModel
|
|
||||||
{
|
|
||||||
Id = order.Id,
|
|
||||||
ImplementerId = implementer.Id
|
|
||||||
});
|
|
||||||
// отдыхаем
|
|
||||||
Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
// кто-то мог уже перехватить заказ, игнорируем ошибку
|
|
||||||
catch (InvalidOperationException ex)
|
|
||||||
{
|
|
||||||
_logger.LogWarning(ex, "Error try get work");
|
|
||||||
}
|
|
||||||
// заканчиваем выполнение имитации в случае иной ошибки
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Error while do work");
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task RunOrderInWork(ImplementerViewModel implementer)
|
|
||||||
{
|
|
||||||
if (_orderLogic == null || implementer == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var runOrder = await Task.Run(() => _orderLogic.ReadElement(new OrderSearchModel
|
|
||||||
{
|
|
||||||
ImplementerId = implementer.Id,
|
|
||||||
Status = OrderStatus.Выполняется
|
|
||||||
}));
|
|
||||||
if (runOrder == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_logger.LogDebug("DoWork. Worker {Id} back to order {Order}", implementer.Id, runOrder.Id);
|
|
||||||
// доделываем работу
|
|
||||||
Thread.Sleep(implementer.WorkExperience * _rnd.Next(100, 300) * runOrder.Count);
|
|
||||||
_logger.LogDebug("DoWork. Worker {Id} finish order {Order}", implementer.Id, runOrder.Id);
|
|
||||||
_orderLogic.DeliveryOrder(new OrderBindingModel
|
|
||||||
{
|
|
||||||
Id = runOrder.Id
|
|
||||||
});
|
|
||||||
// отдыхаем
|
|
||||||
Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100));
|
|
||||||
}
|
|
||||||
// заказа может не быть, просто игнорируем ошибку
|
|
||||||
catch (InvalidOperationException ex)
|
|
||||||
{
|
|
||||||
_logger.LogWarning(ex, "Error try get work");
|
|
||||||
}
|
|
||||||
// а может возникнуть иная ошибка, тогда просто заканчиваем выполнение имитации
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Error while do work");
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,82 +0,0 @@
|
|||||||
using AutomobilePlantContracts.BindingModels;
|
|
||||||
using AutomobilePlantContracts.BusinessLogicContracts;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantBusinessLogic.MailWorker
|
|
||||||
{
|
|
||||||
public abstract class AbstractMailWorker
|
|
||||||
{
|
|
||||||
protected string _mailLogin = string.Empty;
|
|
||||||
protected string _mailPassword = string.Empty;
|
|
||||||
protected string _smtpClientHost = string.Empty;
|
|
||||||
protected int _smtpClientPort;
|
|
||||||
protected string _popHost = string.Empty;
|
|
||||||
protected int _popPort;
|
|
||||||
private readonly IMessageInfoLogic _messageInfoLogic;
|
|
||||||
private readonly IClientLogic _clientLogic;
|
|
||||||
private readonly ILogger _logger;
|
|
||||||
public AbstractMailWorker(ILogger<AbstractMailWorker> logger, IMessageInfoLogic messageInfoLogic, IClientLogic clientLogic)
|
|
||||||
{
|
|
||||||
_logger = logger;
|
|
||||||
_messageInfoLogic = messageInfoLogic;
|
|
||||||
_clientLogic = clientLogic;
|
|
||||||
}
|
|
||||||
public void MailConfig(MailConfigBindingModel config)
|
|
||||||
{
|
|
||||||
_mailLogin = config.MailLogin;
|
|
||||||
_mailPassword = config.MailPassword;
|
|
||||||
_smtpClientHost = config.SmtpClientHost;
|
|
||||||
_smtpClientPort = config.SmtpClientPort;
|
|
||||||
_popHost = config.PopHost;
|
|
||||||
_popPort = config.PopPort;
|
|
||||||
_logger.LogDebug("Config: {login}, {password}, {clientHost},{ clientPOrt}, { popHost}, { popPort}", _mailLogin, _mailPassword, _smtpClientHost, _smtpClientPort, _popHost, _popPort);
|
|
||||||
}
|
|
||||||
public async void MailSendAsync(MailSendInfoBindingModel info)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(_mailLogin) || string.IsNullOrEmpty(_mailPassword))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (string.IsNullOrEmpty(_smtpClientHost) || _smtpClientPort == 0)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (string.IsNullOrEmpty(info.MailAddress) || string.IsNullOrEmpty(info.Subject) || string.IsNullOrEmpty(info.Text))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_logger.LogDebug("Send Mail: {To}, {Subject}", info.MailAddress, info.Subject);
|
|
||||||
await SendMailAsync(info);
|
|
||||||
}
|
|
||||||
public async void MailCheck()
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(_mailLogin) || string.IsNullOrEmpty(_mailPassword))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (string.IsNullOrEmpty(_popHost) || _popPort == 0)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (_messageInfoLogic == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var list = await ReceiveMailAsync();
|
|
||||||
_logger.LogDebug("Check Mail: {Count} new mails", list.Count);
|
|
||||||
foreach (var mail in list)
|
|
||||||
{
|
|
||||||
mail.ClientId = _clientLogic.ReadElement(new() { Email = mail.SenderName })?.Id;
|
|
||||||
_messageInfoLogic.Create(mail);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
protected abstract Task SendMailAsync(MailSendInfoBindingModel info);
|
|
||||||
protected abstract Task<List<MessageInfoBindingModel>>
|
|
||||||
ReceiveMailAsync();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,79 +0,0 @@
|
|||||||
using AutomobilePlantContracts.BindingModels;
|
|
||||||
using AutomobilePlantContracts.BusinessLogicContracts;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Net.Mail;
|
|
||||||
using System.Net;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using MailKit.Net.Pop3;
|
|
||||||
using MailKit.Security;
|
|
||||||
|
|
||||||
namespace AutomobilePlantBusinessLogic.MailWorker
|
|
||||||
{
|
|
||||||
public class MailKitWorker : AbstractMailWorker
|
|
||||||
{
|
|
||||||
public MailKitWorker(ILogger<MailKitWorker> logger, IMessageInfoLogic messageInfoLogic, IClientLogic clientLogic) : base(logger, messageInfoLogic, clientLogic) { }
|
|
||||||
protected override async Task SendMailAsync(MailSendInfoBindingModel info)
|
|
||||||
{
|
|
||||||
using var objMailMessage = new MailMessage();
|
|
||||||
using var objSmtpClient = new SmtpClient(_smtpClientHost, _smtpClientPort);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
objMailMessage.From = new MailAddress(_mailLogin);
|
|
||||||
objMailMessage.To.Add(new MailAddress(info.MailAddress));
|
|
||||||
objMailMessage.Subject = info.Subject;
|
|
||||||
objMailMessage.Body = info.Text;
|
|
||||||
objMailMessage.SubjectEncoding = Encoding.UTF8;
|
|
||||||
objMailMessage.BodyEncoding = Encoding.UTF8;
|
|
||||||
objSmtpClient.UseDefaultCredentials = false;
|
|
||||||
objSmtpClient.EnableSsl = true;
|
|
||||||
objSmtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
|
|
||||||
objSmtpClient.Credentials = new NetworkCredential(_mailLogin, _mailPassword);
|
|
||||||
await Task.Run(() => objSmtpClient.Send(objMailMessage));
|
|
||||||
}
|
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
protected override async Task<List<MessageInfoBindingModel>>
|
|
||||||
ReceiveMailAsync()
|
|
||||||
{
|
|
||||||
var list = new List<MessageInfoBindingModel>();
|
|
||||||
using var client = new Pop3Client();
|
|
||||||
await Task.Run(() =>
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
client.Connect(_popHost, _popPort, SecureSocketOptions.SslOnConnect);
|
|
||||||
client.Authenticate(_mailLogin, _mailPassword);
|
|
||||||
for (int i = 0; i < client.Count; i++)
|
|
||||||
{
|
|
||||||
var message = client.GetMessage(i);
|
|
||||||
foreach (var mail in message.From.Mailboxes)
|
|
||||||
{
|
|
||||||
list.Add(new MessageInfoBindingModel
|
|
||||||
{
|
|
||||||
DateDelivery = message.Date.DateTime,
|
|
||||||
MessageId = message.MessageId,
|
|
||||||
SenderName = mail.Address,
|
|
||||||
Subject = message.Subject,
|
|
||||||
Body = message.TextBody
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (MailKit.Security.AuthenticationException)
|
|
||||||
{ }
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
client.Disconnect(true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,85 +0,0 @@
|
|||||||
using AutomobilePlantBusinessLogic.OfficePackage.HelperEnums;
|
|
||||||
using AutomobilePlantBusinessLogic.OfficePackage.HelperModels;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantBusinessLogic.OfficePackage
|
|
||||||
{
|
|
||||||
public abstract class AbstractSaveToExcel
|
|
||||||
{
|
|
||||||
/// Создание отчета
|
|
||||||
public void CreateReport(ExcelInfo info)
|
|
||||||
{
|
|
||||||
CreateExcel(info);
|
|
||||||
InsertCellInWorksheet(new ExcelCellParameters
|
|
||||||
{
|
|
||||||
ColumnName = "A",
|
|
||||||
RowIndex = 1,
|
|
||||||
Text = info.Title,
|
|
||||||
StyleInfo = ExcelStyleInfoType.Title
|
|
||||||
});
|
|
||||||
MergeCells(new ExcelMergeParameters
|
|
||||||
{
|
|
||||||
CellFromName = "A1",
|
|
||||||
CellToName = "C1"
|
|
||||||
});
|
|
||||||
uint rowIndex = 2;
|
|
||||||
foreach (var pc in info.CarComponents)
|
|
||||||
{
|
|
||||||
InsertCellInWorksheet(new ExcelCellParameters
|
|
||||||
{
|
|
||||||
ColumnName = "A",
|
|
||||||
RowIndex = rowIndex,
|
|
||||||
Text = pc.CarName,
|
|
||||||
StyleInfo = ExcelStyleInfoType.Text
|
|
||||||
});
|
|
||||||
rowIndex++;
|
|
||||||
foreach (var (Component, Count) in pc.Components)
|
|
||||||
{
|
|
||||||
InsertCellInWorksheet(new ExcelCellParameters
|
|
||||||
{
|
|
||||||
ColumnName = "B",
|
|
||||||
RowIndex = rowIndex,
|
|
||||||
Text = Component,
|
|
||||||
StyleInfo = ExcelStyleInfoType.TextWithBorder
|
|
||||||
});
|
|
||||||
InsertCellInWorksheet(new ExcelCellParameters
|
|
||||||
{
|
|
||||||
ColumnName = "C",
|
|
||||||
RowIndex = rowIndex,
|
|
||||||
Text = Count.ToString(),
|
|
||||||
StyleInfo = ExcelStyleInfoType.TextWithBorder
|
|
||||||
});
|
|
||||||
rowIndex++;
|
|
||||||
}
|
|
||||||
InsertCellInWorksheet(new ExcelCellParameters
|
|
||||||
{
|
|
||||||
ColumnName = "A",
|
|
||||||
RowIndex = rowIndex,
|
|
||||||
Text = "Итого",
|
|
||||||
StyleInfo = ExcelStyleInfoType.Text
|
|
||||||
});
|
|
||||||
InsertCellInWorksheet(new ExcelCellParameters
|
|
||||||
{
|
|
||||||
ColumnName = "C",
|
|
||||||
RowIndex = rowIndex,
|
|
||||||
Text = pc.TotalCount.ToString(),
|
|
||||||
StyleInfo = ExcelStyleInfoType.Text
|
|
||||||
});
|
|
||||||
rowIndex++;
|
|
||||||
}
|
|
||||||
SaveExcel(info);
|
|
||||||
}
|
|
||||||
/// Создание excel-файла
|
|
||||||
protected abstract void CreateExcel(ExcelInfo info);
|
|
||||||
/// Добавляем новую ячейку в лист
|
|
||||||
protected abstract void InsertCellInWorksheet(ExcelCellParameters excelParams);
|
|
||||||
/// Объединение ячеек
|
|
||||||
protected abstract void MergeCells(ExcelMergeParameters excelParams);
|
|
||||||
/// Сохранение файла
|
|
||||||
protected abstract void SaveExcel(ExcelInfo info);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,63 +0,0 @@
|
|||||||
using AutomobilePlantBusinessLogic.OfficePackage.HelperEnums;
|
|
||||||
using AutomobilePlantBusinessLogic.OfficePackage.HelperModels;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantBusinessLogic.OfficePackage
|
|
||||||
{
|
|
||||||
public abstract class AbstractSaveToPdf
|
|
||||||
{
|
|
||||||
public void CreateDoc(PdfInfo info)
|
|
||||||
{
|
|
||||||
CreatePdf(info);
|
|
||||||
CreateParagraph(new PdfParagraph
|
|
||||||
{
|
|
||||||
Text = info.Title,
|
|
||||||
Style = "NormalTitle",
|
|
||||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
|
||||||
});
|
|
||||||
CreateParagraph(new PdfParagraph
|
|
||||||
{
|
|
||||||
Text = $"с{info.DateFrom.ToShortDateString()} по {info.DateTo.ToShortDateString()}",
|
|
||||||
Style = "Normal",
|
|
||||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
|
||||||
});
|
|
||||||
CreateTable(new List<string> { "2cm", "3cm", "6cm", "3cm", "4cm" });
|
|
||||||
CreateRow(new PdfRowParameters
|
|
||||||
{
|
|
||||||
Texts = new List<string> { "Номер", "Дата заказа", "Автомобиль", "Сумма", "Статус"},
|
|
||||||
Style = "NormalTitle",
|
|
||||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
|
||||||
});
|
|
||||||
foreach (var order in info.Orders)
|
|
||||||
{
|
|
||||||
CreateRow(new PdfRowParameters
|
|
||||||
{
|
|
||||||
Texts = new List<string> { order.Id.ToString(), order.DateCreate.ToShortDateString(), order.CarName, order.Sum.ToString(), order.Status},
|
|
||||||
Style = "Normal",
|
|
||||||
ParagraphAlignment = PdfParagraphAlignmentType.Left
|
|
||||||
});
|
|
||||||
}
|
|
||||||
CreateParagraph(new PdfParagraph
|
|
||||||
{
|
|
||||||
Text = $"Итого: {info.Orders.Sum(x => x.Sum)}\t",
|
|
||||||
Style = "Normal",
|
|
||||||
ParagraphAlignment = PdfParagraphAlignmentType.Right
|
|
||||||
});
|
|
||||||
SavePdf(info);
|
|
||||||
}
|
|
||||||
/// Создание pdf-файла
|
|
||||||
protected abstract void CreatePdf(PdfInfo info);
|
|
||||||
/// Создание параграфа с текстом
|
|
||||||
protected abstract void CreateParagraph(PdfParagraph paragraph);
|
|
||||||
/// Создание таблицы
|
|
||||||
protected abstract void CreateTable(List<string> columns);
|
|
||||||
/// Создание и заполнение строки
|
|
||||||
protected abstract void CreateRow(PdfRowParameters rowParameters);
|
|
||||||
/// Сохранение файла
|
|
||||||
protected abstract void SavePdf(PdfInfo info);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,48 +0,0 @@
|
|||||||
using AutomobilePlantBusinessLogic.OfficePackage.HelperEnums;
|
|
||||||
using AutomobilePlantBusinessLogic.OfficePackage.HelperModels;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantBusinessLogic.OfficePackage
|
|
||||||
{
|
|
||||||
public abstract class AbstractSaveToWord
|
|
||||||
{
|
|
||||||
public void CreateDoc(WordInfo info)
|
|
||||||
{
|
|
||||||
CreateWord(info);
|
|
||||||
CreateParagraph(new WordParagraph
|
|
||||||
{
|
|
||||||
Texts = new List<(string, WordTextProperties)> { (info.Title, new WordTextProperties { Bold = true, Size = "24", }) },
|
|
||||||
TextProperties = new WordTextProperties
|
|
||||||
{
|
|
||||||
Size = "24",
|
|
||||||
JustificationType = WordJustificationType.Center
|
|
||||||
}
|
|
||||||
});
|
|
||||||
foreach (var car in info.Cars)
|
|
||||||
{
|
|
||||||
CreateParagraph(new WordParagraph
|
|
||||||
{
|
|
||||||
Texts = new List<(string, WordTextProperties)>
|
|
||||||
{(car.CarName + " - ", new WordTextProperties { Size = "24", Bold = true}),
|
|
||||||
(car.Price.ToString(), new WordTextProperties { Size = "24", })},
|
|
||||||
TextProperties = new WordTextProperties
|
|
||||||
{
|
|
||||||
Size = "24",
|
|
||||||
JustificationType = WordJustificationType.Both
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
SaveWord(info);
|
|
||||||
}
|
|
||||||
/// Создание doc-файла
|
|
||||||
protected abstract void CreateWord(WordInfo info);
|
|
||||||
/// Создание абзаца с текстом
|
|
||||||
protected abstract void CreateParagraph(WordParagraph paragraph);
|
|
||||||
/// Сохранение файла
|
|
||||||
protected abstract void SaveWord(WordInfo info);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantBusinessLogic.OfficePackage.HelperEnums
|
|
||||||
{
|
|
||||||
public enum ExcelStyleInfoType
|
|
||||||
{
|
|
||||||
Title,
|
|
||||||
Text,
|
|
||||||
TextWithBorder
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantBusinessLogic.OfficePackage.HelperEnums
|
|
||||||
{
|
|
||||||
public enum PdfParagraphAlignmentType
|
|
||||||
{
|
|
||||||
Center,
|
|
||||||
Left,
|
|
||||||
Right
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,14 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantBusinessLogic.OfficePackage.HelperEnums
|
|
||||||
{
|
|
||||||
public enum WordJustificationType
|
|
||||||
{
|
|
||||||
Center,
|
|
||||||
Both
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,18 +0,0 @@
|
|||||||
using AutomobilePlantBusinessLogic.OfficePackage.HelperEnums;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantBusinessLogic.OfficePackage.HelperModels
|
|
||||||
{
|
|
||||||
public class ExcelCellParameters
|
|
||||||
{
|
|
||||||
public string ColumnName { get; set; } = string.Empty;
|
|
||||||
public uint RowIndex { get; set; }
|
|
||||||
public string Text { get; set; } = string.Empty;
|
|
||||||
public string CellReference => $"{ColumnName}{RowIndex}";
|
|
||||||
public ExcelStyleInfoType StyleInfo { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,16 +0,0 @@
|
|||||||
using AutomobilePlantContracts.ViewModels;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantBusinessLogic.OfficePackage.HelperModels
|
|
||||||
{
|
|
||||||
public class ExcelInfo
|
|
||||||
{
|
|
||||||
public string FileName { get; set; } = string.Empty;
|
|
||||||
public string Title { get; set; } = string.Empty;
|
|
||||||
public List<ReportCarComponentViewModel> CarComponents { get; set; } = new();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantBusinessLogic.OfficePackage.HelperModels
|
|
||||||
{
|
|
||||||
public class ExcelMergeParameters
|
|
||||||
{
|
|
||||||
public string CellFromName { get; set; } = string.Empty;
|
|
||||||
public string CellToName { get; set; } = string.Empty;
|
|
||||||
public string Merge => $"{CellFromName}:{CellToName}";
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,18 +0,0 @@
|
|||||||
using AutomobilePlantContracts.ViewModels;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantBusinessLogic.OfficePackage.HelperModels
|
|
||||||
{
|
|
||||||
public class PdfInfo
|
|
||||||
{
|
|
||||||
public string FileName { get; set; } = string.Empty;
|
|
||||||
public string Title { get; set; } = string.Empty;
|
|
||||||
public DateTime DateFrom { get; set; }
|
|
||||||
public DateTime DateTo { get; set; }
|
|
||||||
public List<ReportOrdersViewModel> Orders { get; set; } = new();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,16 +0,0 @@
|
|||||||
using AutomobilePlantBusinessLogic.OfficePackage.HelperEnums;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantBusinessLogic.OfficePackage.HelperModels
|
|
||||||
{
|
|
||||||
public class PdfParagraph
|
|
||||||
{
|
|
||||||
public string Text { get; set; } = string.Empty;
|
|
||||||
public string Style { get; set; } = string.Empty;
|
|
||||||
public PdfParagraphAlignmentType ParagraphAlignment { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,16 +0,0 @@
|
|||||||
using AutomobilePlantBusinessLogic.OfficePackage.HelperEnums;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantBusinessLogic.OfficePackage.HelperModels
|
|
||||||
{
|
|
||||||
public class PdfRowParameters
|
|
||||||
{
|
|
||||||
public List<string> Texts { get; set; } = new();
|
|
||||||
public string Style { get; set; } = string.Empty;
|
|
||||||
public PdfParagraphAlignmentType ParagraphAlignment { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,16 +0,0 @@
|
|||||||
using AutomobilePlantContracts.ViewModels;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantBusinessLogic.OfficePackage.HelperModels
|
|
||||||
{
|
|
||||||
public class WordInfo
|
|
||||||
{
|
|
||||||
public string FileName { get; set; } = string.Empty;
|
|
||||||
public string Title { get; set; } = string.Empty;
|
|
||||||
public List<CarViewModel> Cars { get; set; } = new();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,14 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantBusinessLogic.OfficePackage.HelperModels
|
|
||||||
{
|
|
||||||
public class WordParagraph
|
|
||||||
{
|
|
||||||
public List<(string, WordTextProperties)> Texts { get; set; } = new();
|
|
||||||
public WordTextProperties? TextProperties { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,16 +0,0 @@
|
|||||||
using AutomobilePlantBusinessLogic.OfficePackage.HelperEnums;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantBusinessLogic.OfficePackage.HelperModels
|
|
||||||
{
|
|
||||||
public class WordTextProperties
|
|
||||||
{
|
|
||||||
public string Size { get; set; } = string.Empty;
|
|
||||||
public bool Bold { get; set; }
|
|
||||||
public WordJustificationType JustificationType { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,312 +0,0 @@
|
|||||||
using AutomobilePlantBusinessLogic.OfficePackage.HelperEnums;
|
|
||||||
using AutomobilePlantBusinessLogic.OfficePackage.HelperModels;
|
|
||||||
using DocumentFormat.OpenXml;
|
|
||||||
using DocumentFormat.OpenXml.Office2010.Excel;
|
|
||||||
using DocumentFormat.OpenXml.Office2013.Excel;
|
|
||||||
using DocumentFormat.OpenXml.Packaging;
|
|
||||||
using DocumentFormat.OpenXml.Spreadsheet;
|
|
||||||
|
|
||||||
namespace AutomobilePlantBusinessLogic.OfficePackage.Implements
|
|
||||||
{
|
|
||||||
public class SaveToExcel : AbstractSaveToExcel
|
|
||||||
{
|
|
||||||
private SpreadsheetDocument? _spreadsheetDocument;
|
|
||||||
private SharedStringTablePart? _shareStringPart;
|
|
||||||
private Worksheet? _worksheet;
|
|
||||||
|
|
||||||
/// Настройка стилей для файла
|
|
||||||
private static void CreateStyles(WorkbookPart workbookpart)
|
|
||||||
{
|
|
||||||
var sp = workbookpart.AddNewPart<WorkbookStylesPart>();
|
|
||||||
sp.Stylesheet = new Stylesheet();
|
|
||||||
var fonts = new Fonts() { Count = 2U, KnownFonts = true };
|
|
||||||
var fontUsual = new Font();
|
|
||||||
fontUsual.Append(new FontSize() { Val = 12D });
|
|
||||||
fontUsual.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color()
|
|
||||||
{ Theme = 1U });
|
|
||||||
fontUsual.Append(new FontName() { Val = "Times New Roman" });
|
|
||||||
fontUsual.Append(new FontFamilyNumbering() { Val = 2 });
|
|
||||||
fontUsual.Append(new FontScheme() { Val = FontSchemeValues.Minor });
|
|
||||||
var fontTitle = new Font();
|
|
||||||
fontTitle.Append(new Bold());
|
|
||||||
fontTitle.Append(new FontSize() { Val = 14D });
|
|
||||||
fontTitle.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color()
|
|
||||||
{ Theme = 1U });
|
|
||||||
fontTitle.Append(new FontName() { Val = "Times New Roman" });
|
|
||||||
fontTitle.Append(new FontFamilyNumbering() { Val = 2 });
|
|
||||||
fontTitle.Append(new FontScheme() { Val = FontSchemeValues.Minor });
|
|
||||||
fonts.Append(fontUsual);
|
|
||||||
fonts.Append(fontTitle);
|
|
||||||
var fills = new Fills() { Count = 2U };
|
|
||||||
var fill1 = new Fill();
|
|
||||||
fill1.Append(new PatternFill() { PatternType = PatternValues.None }); var fill2 = new Fill();
|
|
||||||
fill2.Append(new PatternFill()
|
|
||||||
{
|
|
||||||
PatternType = PatternValues.Gray125
|
|
||||||
});
|
|
||||||
fills.Append(fill1);
|
|
||||||
fills.Append(fill2);
|
|
||||||
var borders = new Borders() { Count = 2U };
|
|
||||||
var borderNoBorder = new Border();
|
|
||||||
borderNoBorder.Append(new LeftBorder());
|
|
||||||
borderNoBorder.Append(new RightBorder());
|
|
||||||
borderNoBorder.Append(new TopBorder());
|
|
||||||
borderNoBorder.Append(new BottomBorder());
|
|
||||||
borderNoBorder.Append(new DiagonalBorder());
|
|
||||||
var borderThin = new Border();
|
|
||||||
var leftBorder = new LeftBorder() { Style = BorderStyleValues.Thin };
|
|
||||||
leftBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color()
|
|
||||||
{ Indexed = 64U });
|
|
||||||
var rightBorder = new RightBorder()
|
|
||||||
{
|
|
||||||
Style = BorderStyleValues.Thin
|
|
||||||
};
|
|
||||||
rightBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color()
|
|
||||||
{ Indexed = 64U });
|
|
||||||
var topBorder = new TopBorder() { Style = BorderStyleValues.Thin };
|
|
||||||
topBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color()
|
|
||||||
{ Indexed = 64U });
|
|
||||||
var bottomBorder = new BottomBorder()
|
|
||||||
{
|
|
||||||
Style = BorderStyleValues.Thin
|
|
||||||
};
|
|
||||||
bottomBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color()
|
|
||||||
{ Indexed = 64U });
|
|
||||||
borderThin.Append(leftBorder);
|
|
||||||
borderThin.Append(rightBorder);
|
|
||||||
borderThin.Append(topBorder);
|
|
||||||
borderThin.Append(bottomBorder);
|
|
||||||
borderThin.Append(new DiagonalBorder());
|
|
||||||
borders.Append(borderNoBorder);
|
|
||||||
borders.Append(borderThin);
|
|
||||||
var cellStyleFormats = new CellStyleFormats() { Count = 1U };
|
|
||||||
var cellFormatStyle = new CellFormat()
|
|
||||||
{
|
|
||||||
NumberFormatId = 0U,
|
|
||||||
FontId = 0U,
|
|
||||||
FillId = 0U,
|
|
||||||
BorderId = 0U
|
|
||||||
};
|
|
||||||
cellStyleFormats.Append(cellFormatStyle);
|
|
||||||
var cellFormats = new CellFormats() { Count = 3U };
|
|
||||||
var cellFormatFont = new CellFormat()
|
|
||||||
{
|
|
||||||
NumberFormatId = 0U,
|
|
||||||
FontId = 0U,
|
|
||||||
FillId = 0U,
|
|
||||||
BorderId = 0U,
|
|
||||||
FormatId = 0U,
|
|
||||||
ApplyFont = true
|
|
||||||
};
|
|
||||||
var cellFormatFontAndBorder = new CellFormat()
|
|
||||||
{
|
|
||||||
NumberFormatId = 0U,
|
|
||||||
FontId = 0U,
|
|
||||||
FillId = 0U,
|
|
||||||
BorderId = 1U,
|
|
||||||
FormatId = 0U,
|
|
||||||
ApplyFont = true,
|
|
||||||
ApplyBorder = true
|
|
||||||
};
|
|
||||||
var cellFormatTitle = new CellFormat()
|
|
||||||
{
|
|
||||||
NumberFormatId = 0U,
|
|
||||||
FontId = 1U,
|
|
||||||
FillId = 0U,
|
|
||||||
BorderId = 0U,
|
|
||||||
FormatId = 0U,
|
|
||||||
Alignment = new Alignment()
|
|
||||||
{
|
|
||||||
Vertical = VerticalAlignmentValues.Center,
|
|
||||||
WrapText = true,
|
|
||||||
Horizontal = HorizontalAlignmentValues.Center
|
|
||||||
},
|
|
||||||
ApplyFont = true
|
|
||||||
};
|
|
||||||
cellFormats.Append(cellFormatFont);
|
|
||||||
cellFormats.Append(cellFormatFontAndBorder);
|
|
||||||
cellFormats.Append(cellFormatTitle); var cellStyles = new CellStyles() { Count = 1U };
|
|
||||||
cellStyles.Append(new CellStyle()
|
|
||||||
{
|
|
||||||
Name = "Normal",
|
|
||||||
FormatId = 0U,
|
|
||||||
BuiltinId = 0U
|
|
||||||
});
|
|
||||||
var differentialFormats = new DocumentFormat.OpenXml.Office2013.Excel.DifferentialFormats()
|
|
||||||
{ Count = 0U };
|
|
||||||
|
|
||||||
var tableStyles = new TableStyles()
|
|
||||||
{
|
|
||||||
Count = 0U,
|
|
||||||
DefaultTableStyle = "TableStyleMedium2",
|
|
||||||
DefaultPivotStyle = "PivotStyleLight16"
|
|
||||||
};
|
|
||||||
var stylesheetExtensionList = new StylesheetExtensionList();
|
|
||||||
var stylesheetExtension1 = new StylesheetExtension()
|
|
||||||
{
|
|
||||||
Uri = "{EB79DEF2-80B8-43e5-95BD-54CBDDF9020C}"
|
|
||||||
};
|
|
||||||
stylesheetExtension1.AddNamespaceDeclaration("x14", "http://schemas.microsoft.com/office/spreadsheetml/2009/9/main");
|
|
||||||
stylesheetExtension1.Append(new SlicerStyles()
|
|
||||||
{
|
|
||||||
DefaultSlicerStyle = "SlicerStyleLight1"
|
|
||||||
});
|
|
||||||
var stylesheetExtension2 = new StylesheetExtension()
|
|
||||||
{
|
|
||||||
Uri = "{9260A510-F301-46a8-8635-F512D64BE5F5}"
|
|
||||||
};
|
|
||||||
stylesheetExtension2.AddNamespaceDeclaration("x15", "http://schemas.microsoft.com/office/spreadsheetml/2010/11/main");
|
|
||||||
stylesheetExtension2.Append(new TimelineStyles()
|
|
||||||
{
|
|
||||||
DefaultTimelineStyle = "TimeSlicerStyleLight1"
|
|
||||||
});
|
|
||||||
stylesheetExtensionList.Append(stylesheetExtension1);
|
|
||||||
stylesheetExtensionList.Append(stylesheetExtension2);
|
|
||||||
sp.Stylesheet.Append(fonts);
|
|
||||||
sp.Stylesheet.Append(fills);
|
|
||||||
sp.Stylesheet.Append(borders);
|
|
||||||
sp.Stylesheet.Append(cellStyleFormats);
|
|
||||||
sp.Stylesheet.Append(cellFormats);
|
|
||||||
sp.Stylesheet.Append(cellStyles);
|
|
||||||
sp.Stylesheet.Append(differentialFormats);
|
|
||||||
sp.Stylesheet.Append(tableStyles);
|
|
||||||
sp.Stylesheet.Append(stylesheetExtensionList);
|
|
||||||
}
|
|
||||||
/// Получение номера стиля из типа
|
|
||||||
private static uint GetStyleValue(ExcelStyleInfoType styleInfo)
|
|
||||||
{
|
|
||||||
return styleInfo switch
|
|
||||||
{
|
|
||||||
ExcelStyleInfoType.Title => 2U,
|
|
||||||
ExcelStyleInfoType.TextWithBorder => 1U,
|
|
||||||
ExcelStyleInfoType.Text => 0U,
|
|
||||||
_ => 0U,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
protected override void CreateExcel(ExcelInfo info)
|
|
||||||
{
|
|
||||||
_spreadsheetDocument = SpreadsheetDocument.Create(info.FileName,
|
|
||||||
SpreadsheetDocumentType.Workbook);
|
|
||||||
// Создаем книгу (в ней хранятся листы)
|
|
||||||
var workbookpart = _spreadsheetDocument.AddWorkbookPart();
|
|
||||||
workbookpart.Workbook = new Workbook(); CreateStyles(workbookpart);
|
|
||||||
// Получаем/создаем хранилище текстов для книги
|
|
||||||
_shareStringPart = _spreadsheetDocument.WorkbookPart!.GetPartsOfType<SharedStringTablePart>().Any()
|
|
||||||
?
|
|
||||||
_spreadsheetDocument.WorkbookPart.GetPartsOfType<SharedStringTablePart>().First()
|
|
||||||
:
|
|
||||||
_spreadsheetDocument.WorkbookPart.AddNewPart<SharedStringTablePart>();
|
|
||||||
// Создаем SharedStringTable, если его нет
|
|
||||||
if (_shareStringPart.SharedStringTable == null)
|
|
||||||
{
|
|
||||||
_shareStringPart.SharedStringTable = new SharedStringTable();
|
|
||||||
}
|
|
||||||
// Создаем лист в книгу
|
|
||||||
var worksheetPart = workbookpart.AddNewPart<WorksheetPart>();
|
|
||||||
worksheetPart.Worksheet = new Worksheet(new SheetData());
|
|
||||||
// Добавляем лист в книгу
|
|
||||||
var sheets = _spreadsheetDocument.WorkbookPart.Workbook.AppendChild(new Sheets());
|
|
||||||
var sheet = new Sheet()
|
|
||||||
{
|
|
||||||
Id = _spreadsheetDocument.WorkbookPart.GetIdOfPart(worksheetPart),
|
|
||||||
SheetId = 1,
|
|
||||||
Name = "Лист"
|
|
||||||
};
|
|
||||||
sheets.Append(sheet);
|
|
||||||
_worksheet = worksheetPart.Worksheet;
|
|
||||||
}
|
|
||||||
protected override void InsertCellInWorksheet(ExcelCellParameters excelParams)
|
|
||||||
{
|
|
||||||
if (_worksheet == null || _shareStringPart == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var sheetData = _worksheet.GetFirstChild<SheetData>();
|
|
||||||
if (sheetData == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// Ищем строку, либо добавляем ее
|
|
||||||
Row row;
|
|
||||||
if (sheetData.Elements<Row>().Where(r => r.RowIndex! == excelParams.RowIndex).Any())
|
|
||||||
{
|
|
||||||
row = sheetData.Elements<Row>().Where(r => r.RowIndex! == excelParams.RowIndex).First();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
row = new Row() { RowIndex = excelParams.RowIndex };
|
|
||||||
sheetData.Append(row);
|
|
||||||
}
|
|
||||||
// Ищем нужную ячейку
|
|
||||||
Cell cell;
|
|
||||||
if (row.Elements<Cell>().Where(c => c.CellReference!.Value == excelParams.CellReference).Any())
|
|
||||||
{
|
|
||||||
cell = row.Elements<Cell>().Where(c => c.CellReference!.Value == excelParams.CellReference).First();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Все ячейки должны быть последовательно друг за другом расположены
|
|
||||||
// нужно определить, после какой вставлять
|
|
||||||
Cell? refCell = null;
|
|
||||||
foreach (Cell rowCell in row.Elements<Cell>())
|
|
||||||
{
|
|
||||||
if (string.Compare(rowCell.CellReference!.Value, excelParams.CellReference, true) > 0)
|
|
||||||
{
|
|
||||||
refCell = rowCell;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var newCell = new Cell()
|
|
||||||
{
|
|
||||||
CellReference = excelParams.CellReference
|
|
||||||
};
|
|
||||||
row.InsertBefore(newCell, refCell);
|
|
||||||
cell = newCell;
|
|
||||||
}
|
|
||||||
// вставляем новый текст
|
|
||||||
_shareStringPart.SharedStringTable.AppendChild(new SharedStringItem(new Text(excelParams.Text)));
|
|
||||||
_shareStringPart.SharedStringTable.Save();
|
|
||||||
cell.CellValue = new CellValue((_shareStringPart.SharedStringTable.Elements<SharedStringItem>().Count() - 1).ToString());
|
|
||||||
cell.DataType = new EnumValue<CellValues>(CellValues.SharedString);
|
|
||||||
cell.StyleIndex = GetStyleValue(excelParams.StyleInfo);
|
|
||||||
}
|
|
||||||
protected override void MergeCells(ExcelMergeParameters excelParams)
|
|
||||||
{
|
|
||||||
if (_worksheet == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
MergeCells mergeCells;
|
|
||||||
if (_worksheet.Elements<MergeCells>().Any())
|
|
||||||
{
|
|
||||||
mergeCells = _worksheet.Elements<MergeCells>().First();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mergeCells = new MergeCells();
|
|
||||||
if (_worksheet.Elements<CustomSheetView>().Any())
|
|
||||||
{
|
|
||||||
_worksheet.InsertAfter(mergeCells, _worksheet.Elements<CustomSheetView>().First());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_worksheet.InsertAfter(mergeCells, _worksheet.Elements<SheetData>().First());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var mergeCell = new MergeCell()
|
|
||||||
{
|
|
||||||
Reference = new StringValue(excelParams.Merge)
|
|
||||||
};
|
|
||||||
mergeCells.Append(mergeCell);
|
|
||||||
}
|
|
||||||
protected override void SaveExcel(ExcelInfo info)
|
|
||||||
{
|
|
||||||
if (_spreadsheetDocument == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_spreadsheetDocument.WorkbookPart!.Workbook.Save();
|
|
||||||
_spreadsheetDocument.Close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,96 +0,0 @@
|
|||||||
using AutomobilePlantBusinessLogic.OfficePackage.HelperEnums;
|
|
||||||
using AutomobilePlantBusinessLogic.OfficePackage.HelperModels;
|
|
||||||
using MigraDoc.DocumentObjectModel;
|
|
||||||
using MigraDoc.Rendering;
|
|
||||||
using MigraDoc.DocumentObjectModel.Tables;
|
|
||||||
|
|
||||||
namespace AutomobilePlantBusinessLogic.OfficePackage.Implements
|
|
||||||
{
|
|
||||||
public class SaveToPdf : AbstractSaveToPdf
|
|
||||||
{
|
|
||||||
private Document? _document;
|
|
||||||
private Section? _section;
|
|
||||||
private Table? _table;
|
|
||||||
private static ParagraphAlignment
|
|
||||||
GetParagraphAlignment(PdfParagraphAlignmentType type)
|
|
||||||
{
|
|
||||||
return type switch
|
|
||||||
{
|
|
||||||
PdfParagraphAlignmentType.Center => ParagraphAlignment.Center,
|
|
||||||
PdfParagraphAlignmentType.Left => ParagraphAlignment.Left,
|
|
||||||
PdfParagraphAlignmentType.Right => ParagraphAlignment.Right,
|
|
||||||
_ => ParagraphAlignment.Justify,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
/// Создание стилей для документа
|
|
||||||
private static void DefineStyles(Document document)
|
|
||||||
{
|
|
||||||
var style = document.Styles["Normal"];
|
|
||||||
style.Font.Name = "Times New Roman";
|
|
||||||
style.Font.Size = 14;
|
|
||||||
style = document.Styles.AddStyle("NormalTitle", "Normal");
|
|
||||||
style.Font.Bold = true;
|
|
||||||
}
|
|
||||||
protected override void CreatePdf(PdfInfo info)
|
|
||||||
{
|
|
||||||
_document = new Document();
|
|
||||||
DefineStyles(_document);
|
|
||||||
_section = _document.AddSection();
|
|
||||||
}
|
|
||||||
protected override void CreateParagraph(PdfParagraph pdfParagraph)
|
|
||||||
{
|
|
||||||
if (_section == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var paragraph = _section.AddParagraph(pdfParagraph.Text);
|
|
||||||
paragraph.Format.SpaceAfter = "1cm";
|
|
||||||
paragraph.Format.Alignment = GetParagraphAlignment(pdfParagraph.ParagraphAlignment);
|
|
||||||
paragraph.Style = pdfParagraph.Style;
|
|
||||||
}
|
|
||||||
protected override void CreateTable(List<string> columns)
|
|
||||||
{
|
|
||||||
if (_document == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_table = _document.LastSection.AddTable();
|
|
||||||
foreach (var elem in columns)
|
|
||||||
{
|
|
||||||
_table.AddColumn(elem);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
protected override void CreateRow(PdfRowParameters rowParameters)
|
|
||||||
{
|
|
||||||
if (_table == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var row = _table.AddRow();
|
|
||||||
for (int i = 0; i < rowParameters.Texts.Count; ++i)
|
|
||||||
{
|
|
||||||
row.Cells[i].AddParagraph(rowParameters.Texts[i]);
|
|
||||||
if (!string.IsNullOrEmpty(rowParameters.Style))
|
|
||||||
{
|
|
||||||
row.Cells[i].Style = rowParameters.Style;
|
|
||||||
}
|
|
||||||
Unit borderWidth = 0.5;
|
|
||||||
row.Cells[i].Borders.Left.Width = borderWidth;
|
|
||||||
row.Cells[i].Borders.Right.Width = borderWidth;
|
|
||||||
row.Cells[i].Borders.Top.Width = borderWidth;
|
|
||||||
row.Cells[i].Borders.Bottom.Width = borderWidth;
|
|
||||||
row.Cells[i].Format.Alignment = GetParagraphAlignment(rowParameters.ParagraphAlignment);
|
|
||||||
row.Cells[i].VerticalAlignment = VerticalAlignment.Center;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
protected override void SavePdf(PdfInfo info)
|
|
||||||
{
|
|
||||||
var renderer = new PdfDocumentRenderer(true)
|
|
||||||
{
|
|
||||||
Document = _document
|
|
||||||
};
|
|
||||||
renderer.RenderDocument();
|
|
||||||
renderer.PdfDocument.Save(info.FileName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,120 +0,0 @@
|
|||||||
using AutomobilePlantBusinessLogic.OfficePackage.HelperEnums;
|
|
||||||
using AutomobilePlantBusinessLogic.OfficePackage.HelperModels;
|
|
||||||
using DocumentFormat.OpenXml.Packaging;
|
|
||||||
using DocumentFormat.OpenXml.Wordprocessing;
|
|
||||||
using DocumentFormat.OpenXml;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AutomobilePlantBusinessLogic.OfficePackage.Implements
|
|
||||||
{
|
|
||||||
public class SaveToWord : AbstractSaveToWord
|
|
||||||
{
|
|
||||||
private WordprocessingDocument? _wordDocument;
|
|
||||||
private Body? _docBody;
|
|
||||||
|
|
||||||
/// Получение типа выравнивания
|
|
||||||
private static JustificationValues
|
|
||||||
GetJustificationValues(WordJustificationType type)
|
|
||||||
{
|
|
||||||
return type switch
|
|
||||||
{
|
|
||||||
WordJustificationType.Both => JustificationValues.Both,
|
|
||||||
WordJustificationType.Center => JustificationValues.Center,
|
|
||||||
_ => JustificationValues.Left,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Настройки страницы
|
|
||||||
private static SectionProperties CreateSectionProperties()
|
|
||||||
{
|
|
||||||
var properties = new SectionProperties();
|
|
||||||
var pageSize = new PageSize
|
|
||||||
{
|
|
||||||
Orient = PageOrientationValues.Portrait
|
|
||||||
};
|
|
||||||
properties.AppendChild(pageSize);
|
|
||||||
return properties;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Задание форматирования для абзаца
|
|
||||||
private static ParagraphProperties?
|
|
||||||
CreateParagraphProperties(WordTextProperties? paragraphProperties)
|
|
||||||
{
|
|
||||||
if (paragraphProperties == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
var properties = new ParagraphProperties();
|
|
||||||
properties.AppendChild(new Justification()
|
|
||||||
{
|
|
||||||
Val = GetJustificationValues(paragraphProperties.JustificationType)
|
|
||||||
});
|
|
||||||
properties.AppendChild(new SpacingBetweenLines
|
|
||||||
{
|
|
||||||
LineRule = LineSpacingRuleValues.Auto
|
|
||||||
});
|
|
||||||
properties.AppendChild(new Indentation());
|
|
||||||
var paragraphMarkRunProperties = new ParagraphMarkRunProperties();
|
|
||||||
if (!string.IsNullOrEmpty(paragraphProperties.Size))
|
|
||||||
{
|
|
||||||
paragraphMarkRunProperties.AppendChild(new FontSize
|
|
||||||
{
|
|
||||||
Val =
|
|
||||||
paragraphProperties.Size
|
|
||||||
});
|
|
||||||
}
|
|
||||||
properties.AppendChild(paragraphMarkRunProperties);
|
|
||||||
return properties;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void CreateWord(WordInfo info)
|
|
||||||
{
|
|
||||||
_wordDocument = WordprocessingDocument.Create(info.FileName, WordprocessingDocumentType.Document);
|
|
||||||
MainDocumentPart mainPart = _wordDocument.AddMainDocumentPart();
|
|
||||||
mainPart.Document = new Document();
|
|
||||||
_docBody = mainPart.Document.AppendChild(new Body());
|
|
||||||
}
|
|
||||||
protected override void CreateParagraph(WordParagraph paragraph)
|
|
||||||
{
|
|
||||||
if (_docBody == null || paragraph == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var docParagraph = new Paragraph();
|
|
||||||
|
|
||||||
docParagraph.AppendChild(CreateParagraphProperties(paragraph.TextProperties));
|
|
||||||
foreach (var run in paragraph.Texts)
|
|
||||||
{
|
|
||||||
var docRun = new Run();
|
|
||||||
var properties = new RunProperties();
|
|
||||||
properties.AppendChild(new FontSize { Val = run.Item2.Size });
|
|
||||||
if (run.Item2.Bold)
|
|
||||||
{
|
|
||||||
properties.AppendChild(new Bold());
|
|
||||||
}
|
|
||||||
docRun.AppendChild(properties);
|
|
||||||
docRun.AppendChild(new Text
|
|
||||||
{
|
|
||||||
Text = run.Item1,
|
|
||||||
Space = SpaceProcessingModeValues.Preserve
|
|
||||||
});
|
|
||||||
docParagraph.AppendChild(docRun);
|
|
||||||
}
|
|
||||||
_docBody.AppendChild(docParagraph);
|
|
||||||
}
|
|
||||||
protected override void SaveWord(WordInfo info)
|
|
||||||
{
|
|
||||||
if (_docBody == null || _wordDocument == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_docBody.AppendChild(CreateSectionProperties());
|
|
||||||
_wordDocument.MainDocumentPart!.Document.Save();
|
|
||||||
_wordDocument.Close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,12 +0,0 @@
|
|||||||
{
|
|
||||||
"profiles": {
|
|
||||||
"AutomobilePlantBusinessLogic": {
|
|
||||||
"commandName": "Project",
|
|
||||||
"launchBrowser": true,
|
|
||||||
"environmentVariables": {
|
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
|
||||||
},
|
|
||||||
"applicationUrl": "https://localhost:53386;http://localhost:53392"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,45 +0,0 @@
|
|||||||
using AutomobilePlantContracts.ViewModels;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using System.Net.Http.Headers;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
|
|
||||||
namespace AutomobilePlantClientApp
|
|
||||||
{
|
|
||||||
public static class APIClient
|
|
||||||
{
|
|
||||||
private static readonly HttpClient _client = new();
|
|
||||||
public static ClientViewModel? Client { get; set; } = null;
|
|
||||||
public static void Connect(IConfiguration configuration)
|
|
||||||
{
|
|
||||||
_client.BaseAddress = new Uri(configuration["IPAddress"]);
|
|
||||||
_client.DefaultRequestHeaders.Accept.Clear();
|
|
||||||
_client.DefaultRequestHeaders.Accept.Add(new
|
|
||||||
MediaTypeWithQualityHeaderValue("application/json"));
|
|
||||||
}
|
|
||||||
public static T? GetRequest<T>(string requestUrl)
|
|
||||||
{
|
|
||||||
var response = _client.GetAsync(requestUrl);
|
|
||||||
var result = response.Result.Content.ReadAsStringAsync().Result;
|
|
||||||
if (response.Result.IsSuccessStatusCode)
|
|
||||||
{
|
|
||||||
return JsonConvert.DeserializeObject<T>(result);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new Exception(result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public static void PostRequest<T>(string requestUrl, T model)
|
|
||||||
{
|
|
||||||
var json = JsonConvert.SerializeObject(model);
|
|
||||||
var data = new StringContent(json, Encoding.UTF8, "application/json");
|
|
||||||
var response = _client.PostAsync(requestUrl, data);
|
|
||||||
var result = response.Result.Content.ReadAsStringAsync().Result;
|
|
||||||
if (!response.Result.IsSuccessStatusCode)
|
|
||||||
{
|
|
||||||
throw new Exception(result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,24 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\AutomobilePlantContracts\AutomobilePlantContracts.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Content Update="Views\Home\Mails.cshtml">
|
|
||||||
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
|
|
||||||
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
|
||||||
</Content>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
@ -1,148 +0,0 @@
|
|||||||
using AutomobilePlantClientApp.Models;
|
|
||||||
using AutomobilePlantContracts.BindingModels;
|
|
||||||
using AutomobilePlantContracts.ViewModels;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using System.Diagnostics;
|
|
||||||
|
|
||||||
namespace AutomobilePlantClientApp.Controllers
|
|
||||||
{
|
|
||||||
public class HomeController : Controller
|
|
||||||
{
|
|
||||||
private readonly ILogger<HomeController> _logger;
|
|
||||||
public HomeController(ILogger<HomeController> logger)
|
|
||||||
{
|
|
||||||
_logger = logger;
|
|
||||||
}
|
|
||||||
public IActionResult Index()
|
|
||||||
{
|
|
||||||
if (APIClient.Client == null)
|
|
||||||
{
|
|
||||||
return Redirect("~/Home/Enter");
|
|
||||||
}
|
|
||||||
return View(APIClient.GetRequest<List<OrderViewModel>>($"api/main/getorders?clientId={APIClient.Client.Id}"));
|
|
||||||
}
|
|
||||||
[HttpGet]
|
|
||||||
public IActionResult Privacy()
|
|
||||||
{
|
|
||||||
if (APIClient.Client == null)
|
|
||||||
{
|
|
||||||
return Redirect("~/Home/Enter");
|
|
||||||
}
|
|
||||||
return View(APIClient.Client);
|
|
||||||
}
|
|
||||||
[HttpPost]
|
|
||||||
public void Privacy(string login, string password, string fio)
|
|
||||||
{
|
|
||||||
if (APIClient.Client == null)
|
|
||||||
{
|
|
||||||
throw new Exception("Вход только авторизованным");
|
|
||||||
}
|
|
||||||
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(fio))
|
|
||||||
{
|
|
||||||
throw new Exception("Введите логин, пароль и ФИО");
|
|
||||||
}
|
|
||||||
APIClient.PostRequest("api/client/updatedata", new
|
|
||||||
ClientBindingModel
|
|
||||||
{
|
|
||||||
Id = APIClient.Client.Id,
|
|
||||||
ClientFIO = fio,
|
|
||||||
Email = login,
|
|
||||||
Password = password
|
|
||||||
});
|
|
||||||
APIClient.Client.ClientFIO = fio;
|
|
||||||
APIClient.Client.Email = login;
|
|
||||||
APIClient.Client.Password = password;
|
|
||||||
Response.Redirect("Index");
|
|
||||||
}
|
|
||||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
|
||||||
public IActionResult Error()
|
|
||||||
{
|
|
||||||
return View(new ErrorViewModel
|
|
||||||
{
|
|
||||||
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier
|
|
||||||
});
|
|
||||||
}
|
|
||||||
[HttpGet]
|
|
||||||
public IActionResult Enter()
|
|
||||||
{
|
|
||||||
return View();
|
|
||||||
}
|
|
||||||
[HttpPost]
|
|
||||||
public void Enter(string login, string password)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password))
|
|
||||||
{
|
|
||||||
throw new Exception("Введите логин и пароль");
|
|
||||||
}
|
|
||||||
APIClient.Client = APIClient.GetRequest<ClientViewModel>($"api/client/login?login={login}&password={password}");
|
|
||||||
if (APIClient.Client == null)
|
|
||||||
{
|
|
||||||
throw new Exception("Неверный логин/пароль");
|
|
||||||
}
|
|
||||||
Response.Redirect("Index");
|
|
||||||
}
|
|
||||||
[HttpGet]
|
|
||||||
public IActionResult Register()
|
|
||||||
{
|
|
||||||
return View();
|
|
||||||
}
|
|
||||||
[HttpPost]
|
|
||||||
public void Register(string login, string password, string fio)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(fio))
|
|
||||||
{
|
|
||||||
throw new Exception("Введите логин, пароль и ФИО");
|
|
||||||
}
|
|
||||||
APIClient.PostRequest("api/client/register", new ClientBindingModel
|
|
||||||
{
|
|
||||||
ClientFIO = fio,
|
|
||||||
Email = login,
|
|
||||||
Password = password
|
|
||||||
});
|
|
||||||
Response.Redirect("Enter");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
[HttpGet]
|
|
||||||
public IActionResult Create()
|
|
||||||
{
|
|
||||||
ViewBag.Cars = APIClient.GetRequest<List<CarViewModel>>("api/main/getcarlist");
|
|
||||||
return View();
|
|
||||||
}
|
|
||||||
[HttpPost]
|
|
||||||
public void Create(int car, int count)
|
|
||||||
{
|
|
||||||
if (APIClient.Client == null)
|
|
||||||
{
|
|
||||||
throw new Exception("Вход только авторизованным");
|
|
||||||
}
|
|
||||||
if (count <= 0)
|
|
||||||
{
|
|
||||||
throw new Exception("Количество и сумма должны быть больше 0");
|
|
||||||
}
|
|
||||||
APIClient.PostRequest("api/main/createorder", new OrderBindingModel
|
|
||||||
{
|
|
||||||
ClientId = APIClient.Client.Id,
|
|
||||||
CarId = car,
|
|
||||||
Count = count,
|
|
||||||
Sum = Calc(count, car)
|
|
||||||
});
|
|
||||||
Response.Redirect("Index");
|
|
||||||
}
|
|
||||||
[HttpPost]
|
|
||||||
public double Calc(int count, int car)
|
|
||||||
{
|
|
||||||
var c = APIClient.GetRequest<CarViewModel>($"api/main/getcar?carId={car}");
|
|
||||||
return count * (c?.Price ?? 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet]
|
|
||||||
public IActionResult Mails()
|
|
||||||
{
|
|
||||||
if (APIClient.Client == null)
|
|
||||||
{
|
|
||||||
return Redirect("~/Home/Enter");
|
|
||||||
}
|
|
||||||
return View(APIClient.GetRequest<List<MessageInfoViewModel>>($"api/client/getmessages?clientId={APIClient.Client.Id}"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,9 +0,0 @@
|
|||||||
namespace AutomobilePlantClientApp.Models
|
|
||||||
{
|
|
||||||
public class ErrorViewModel
|
|
||||||
{
|
|
||||||
public string? RequestId { get; set; }
|
|
||||||
|
|
||||||
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,30 +0,0 @@
|
|||||||
using AutomobilePlantClientApp;
|
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
|
||||||
|
|
||||||
// Add services to the container.
|
|
||||||
builder.Services.AddControllersWithViews();
|
|
||||||
|
|
||||||
var app = builder.Build();
|
|
||||||
APIClient.Connect(builder.Configuration);
|
|
||||||
|
|
||||||
// Configure the HTTP request pipeline.
|
|
||||||
if (!app.Environment.IsDevelopment())
|
|
||||||
{
|
|
||||||
app.UseExceptionHandler("/Home/Error");
|
|
||||||
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
|
|
||||||
app.UseHsts();
|
|
||||||
}
|
|
||||||
|
|
||||||
app.UseHttpsRedirection();
|
|
||||||
app.UseStaticFiles();
|
|
||||||
|
|
||||||
app.UseRouting();
|
|
||||||
|
|
||||||
app.UseAuthorization();
|
|
||||||
|
|
||||||
app.MapControllerRoute(
|
|
||||||
name: "default",
|
|
||||||
pattern: "{controller=Home}/{action=Index}/{id?}");
|
|
||||||
|
|
||||||
app.Run();
|
|
@ -1,28 +0,0 @@
|
|||||||
{
|
|
||||||
"iisSettings": {
|
|
||||||
"windowsAuthentication": false,
|
|
||||||
"anonymousAuthentication": true,
|
|
||||||
"iisExpress": {
|
|
||||||
"applicationUrl": "http://localhost:44270",
|
|
||||||
"sslPort": 44370
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"profiles": {
|
|
||||||
"AutomobilePlantClientApp": {
|
|
||||||
"commandName": "Project",
|
|
||||||
"dotnetRunMessages": true,
|
|
||||||
"launchBrowser": true,
|
|
||||||
"applicationUrl": "https://localhost:7042;http://localhost:5188",
|
|
||||||
"environmentVariables": {
|
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"IIS Express": {
|
|
||||||
"commandName": "IISExpress",
|
|
||||||
"launchBrowser": true,
|
|
||||||
"environmentVariables": {
|
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,55 +0,0 @@
|
|||||||
@{
|
|
||||||
ViewData["Title"] = "Create";
|
|
||||||
}
|
|
||||||
<div class="text-center">
|
|
||||||
<h2 class="display-4">Создание заказа</h2>
|
|
||||||
</div>
|
|
||||||
<form method="post">
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-4">Автомобиль:</div>
|
|
||||||
<div class="col-8">
|
|
||||||
<select id="car" name="car" class="form-control" asp-items="@(new SelectList(@ViewBag.Cars,"Id", "CarName"))"></select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-4">Количество:</div>
|
|
||||||
<div class="col-8">
|
|
||||||
<input type="text" name="count" id="count" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-4">Сумма:</div>
|
|
||||||
<div class="col-8">
|
|
||||||
<input type="text" id="sum" name="sum" readonly />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-8"></div>
|
|
||||||
<div class="col-4">
|
|
||||||
<input type="submit" value="Создать" class="btn
|
|
||||||
btn-primary" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
<script>
|
|
||||||
$('#car').on('change', function () {
|
|
||||||
check();
|
|
||||||
});
|
|
||||||
$('#count').on('change', function () {
|
|
||||||
check();
|
|
||||||
});
|
|
||||||
function check() {
|
|
||||||
var count = $('#count').val();
|
|
||||||
var car = $('#car').val();
|
|
||||||
if (count && car) {
|
|
||||||
$.ajax({
|
|
||||||
method: "POST",
|
|
||||||
url: "/Home/Calc",
|
|
||||||
data: { count: count, car: car },
|
|
||||||
success: function (result) {
|
|
||||||
$("#sum").val(result);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
}
|
|
||||||
</script>
|
|
@ -1,20 +0,0 @@
|
|||||||
@{
|
|
||||||
ViewData["Title"] = "Enter";
|
|
||||||
}
|
|
||||||
<div class="text-center">
|
|
||||||
<h2 class="display-4">Вход в приложение</h2>
|
|
||||||
</div>
|
|
||||||
<form method="post">
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-4">Логин:</div>
|
|
||||||
<div class="col-8"><input type="text" name="login" /></div>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-4">Пароль:</div>
|
|
||||||
<div class="col-8"><input type="password" name="password" /></div>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-8"></div>
|
|
||||||
<div class="col-4"><input type="submit" value="Вход" class="btn btnprimary" /></div>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
@ -1,75 +0,0 @@
|
|||||||
@using AutomobilePlantContracts.ViewModels
|
|
||||||
@model List<OrderViewModel>
|
|
||||||
@{
|
|
||||||
ViewData["Title"] = "Home Page";
|
|
||||||
}
|
|
||||||
<div class="text-center">
|
|
||||||
<h1 class="display-4">Заказы</h1>
|
|
||||||
</div>
|
|
||||||
<div class="text-center">
|
|
||||||
@{
|
|
||||||
if (Model == null)
|
|
||||||
{
|
|
||||||
<h3 class="display-4">Авторизируйтесь</h3>
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
<p>
|
|
||||||
<a asp-action="Create">Создать заказ</a>
|
|
||||||
</p>
|
|
||||||
<table class="table">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>
|
|
||||||
Номер
|
|
||||||
</th>
|
|
||||||
<th>
|
|
||||||
Автомобиль
|
|
||||||
</th>
|
|
||||||
<th>
|
|
||||||
Дата создания
|
|
||||||
</th>
|
|
||||||
<th>
|
|
||||||
Количество
|
|
||||||
</th>
|
|
||||||
<th>
|
|
||||||
Сумма
|
|
||||||
</th>
|
|
||||||
<th>
|
|
||||||
Статус
|
|
||||||
</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
@foreach (var item in Model)
|
|
||||||
{
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
@Html.DisplayFor(modelItem =>
|
|
||||||
item.Id)
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
@Html.DisplayFor(modelItem =>
|
|
||||||
item.CarName)
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
@Html.DisplayFor(modelItem =>
|
|
||||||
item.DateCreate)
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
@Html.DisplayFor(modelItem =>
|
|
||||||
item.Count)
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
@Html.DisplayFor(modelItem =>
|
|
||||||
item.Sum)
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
@Html.DisplayFor(modelItem =>
|
|
||||||
item.Status)
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
}
|
|
||||||
</div>
|
|
@ -1,54 +0,0 @@
|
|||||||
@using AutomobilePlantContracts.ViewModels
|
|
||||||
|
|
||||||
@model List<MessageInfoViewModel>
|
|
||||||
|
|
||||||
@{
|
|
||||||
ViewData["Title"] = "Mails";
|
|
||||||
}
|
|
||||||
|
|
||||||
<div class="text-center">
|
|
||||||
<h1 class="display-4">Письма</h1>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<div class="text-center">
|
|
||||||
@{
|
|
||||||
if (Model == null)
|
|
||||||
{
|
|
||||||
<h3 class="display-4">Авторизируйтесь</h3>
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
<table class="table">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>
|
|
||||||
Дата письма
|
|
||||||
</th>
|
|
||||||
<th>
|
|
||||||
Заголовок
|
|
||||||
</th>
|
|
||||||
<th>
|
|
||||||
Текст
|
|
||||||
</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
@foreach (var item in Model)
|
|
||||||
{
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
@Html.DisplayFor(modelItem => item.DateDelivery)
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
@Html.DisplayFor(modelItem => item.Subject)
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
@Html.DisplayFor(modelItem => item.Body)
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
}
|
|
||||||
</div>
|
|
@ -1,30 +0,0 @@
|
|||||||
@using AutomobilePlantContracts.ViewModels
|
|
||||||
@model ClientViewModel
|
|
||||||
@{
|
|
||||||
ViewData["Title"] = "Privacy Policy";
|
|
||||||
}
|
|
||||||
<div class="text-center">
|
|
||||||
<h2 class="display-4">Личные данные</h2>
|
|
||||||
</div>
|
|
||||||
<form method="post">
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-4">Логин:</div>
|
|
||||||
<div class="col-8"><input type="text" name="login"
|
|
||||||
value="@Model.Email"/></div>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-4">Пароль:</div>
|
|
||||||
<div class="col-8"><input type="password" name="password"
|
|
||||||
value="@Model.Password"/></div>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-4">ФИО:</div>
|
|
||||||
<div class="col-8"><input type="text" name="fio"
|
|
||||||
value="@Model.ClientFIO"/></div>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-8"></div>
|
|
||||||
<div class="col-4"><input type="submit" value="Сохранить" class="btn
|
|
||||||
btn-primary" /></div>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
@ -1,26 +0,0 @@
|
|||||||
@{
|
|
||||||
ViewData["Title"] = "Register";
|
|
||||||
}
|
|
||||||
<div class="text-center">
|
|
||||||
<h2 class="display-4">Регистрация</h2>
|
|
||||||
</div>
|
|
||||||
<form method="post">
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-4">Логин:</div>
|
|
||||||
<div class="col-8"><input type="text" name="login" /></div>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-4">Пароль:</div>
|
|
||||||
<div class="col-8"><input type="password" name="password" /></div>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-4">ФИО:</div><div class="col-8"><input type="text" name="fio" /></div>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-8"></div>
|
|
||||||
<div class="col-4">
|
|
||||||
<input type="submit" value="Регистрация"
|
|
||||||
class="btn btn-primary" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
@ -1,25 +0,0 @@
|
|||||||
@model ErrorViewModel
|
|
||||||
@{
|
|
||||||
ViewData["Title"] = "Error";
|
|
||||||
}
|
|
||||||
|
|
||||||
<h1 class="text-danger">Error.</h1>
|
|
||||||
<h2 class="text-danger">An error occurred while processing your request.</h2>
|
|
||||||
|
|
||||||
@if (Model.ShowRequestId)
|
|
||||||
{
|
|
||||||
<p>
|
|
||||||
<strong>Request ID:</strong> <code>@Model.RequestId</code>
|
|
||||||
</p>
|
|
||||||
}
|
|
||||||
|
|
||||||
<h3>Development Mode</h3>
|
|
||||||
<p>
|
|
||||||
Swapping to <strong>Development</strong> environment will display more detailed information about the error that occurred.
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
|
|
||||||
It can result in displaying sensitive information from exceptions to end users.
|
|
||||||
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
|
|
||||||
and restarting the app.
|
|
||||||
</p>
|
|
@ -1,57 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
||||||
<title>@ViewData["Title"] - AutomobilePlantClientApp</title>
|
|
||||||
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
|
|
||||||
<link rel="stylesheet" href="~/css/site.css" />
|
|
||||||
<script src="~/lib/jquery/dist/jquery.min.js"></script>
|
|
||||||
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
|
|
||||||
<script src="~/js/site.js" asp-append-version="true"></script>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<header>
|
|
||||||
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bgwhite border-bottom box-shadow mb-3">
|
|
||||||
<div class="container">
|
|
||||||
<a class="navbar-brand" asp-area="" asp-controller="Home" aspaction="Index">Автомобильный Завод</a>
|
|
||||||
<button class="navbar-toggler" type="button" datatoggle="collapse" data-target=".navbar-collapse" ariacontrols="navbarSupportedContent"
|
|
||||||
aria-expanded="false" aria-label="Toggle navigation">
|
|
||||||
<span class="navbar-toggler-icon"></span>
|
|
||||||
</button>
|
|
||||||
<div class="navbar-collapse collapse d-sm-inline-flex flex-smrow-reverse">
|
|
||||||
<ul class="navbar-nav flex-grow-1">
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Index">Заказы</a>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Privacy">Личные данные</a>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Mails">Письма</a>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Enter">Вход</a>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Register">Регистрация</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
</header>
|
|
||||||
<div class="container">
|
|
||||||
<main role="main" class="pb-3">
|
|
||||||
@RenderBody()
|
|
||||||
</main>
|
|
||||||
</div>
|
|
||||||
<footer class="border-top footer text-muted">
|
|
||||||
<div class="container">
|
|
||||||
© 2023 - Автомобильный завод - <a asp-area="" aspcontroller="Home" asp-action="Privacy">Личные данные</a>
|
|
||||||
</div>
|
|
||||||
</footer>
|
|
||||||
<script src="~/js/site.js" asp-append-version="true"></script>
|
|
||||||
@RenderSection("Scripts", required: false)
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,48 +0,0 @@
|
|||||||
/* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification
|
|
||||||
for details on configuring this project to bundle and minify static web assets. */
|
|
||||||
|
|
||||||
a.navbar-brand {
|
|
||||||
white-space: normal;
|
|
||||||
text-align: center;
|
|
||||||
word-break: break-all;
|
|
||||||
}
|
|
||||||
|
|
||||||
a {
|
|
||||||
color: #0077cc;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-primary {
|
|
||||||
color: #fff;
|
|
||||||
background-color: #1b6ec2;
|
|
||||||
border-color: #1861ac;
|
|
||||||
}
|
|
||||||
|
|
||||||
.nav-pills .nav-link.active, .nav-pills .show > .nav-link {
|
|
||||||
color: #fff;
|
|
||||||
background-color: #1b6ec2;
|
|
||||||
border-color: #1861ac;
|
|
||||||
}
|
|
||||||
|
|
||||||
.border-top {
|
|
||||||
border-top: 1px solid #e5e5e5;
|
|
||||||
}
|
|
||||||
.border-bottom {
|
|
||||||
border-bottom: 1px solid #e5e5e5;
|
|
||||||
}
|
|
||||||
|
|
||||||
.box-shadow {
|
|
||||||
box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05);
|
|
||||||
}
|
|
||||||
|
|
||||||
button.accept-policy {
|
|
||||||
font-size: 1rem;
|
|
||||||
line-height: inherit;
|
|
||||||
}
|
|
||||||
|
|
||||||
.footer {
|
|
||||||
position: absolute;
|
|
||||||
bottom: 0;
|
|
||||||
width: 100%;
|
|
||||||
white-space: nowrap;
|
|
||||||
line-height: 60px;
|
|
||||||
}
|
|
@ -1,2 +0,0 @@
|
|||||||
<script src="~/lib/jquery-validation/dist/jquery.validate.min.js"></script>
|
|
||||||
<script src="~/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.min.js"></script>
|
|
@ -1,3 +0,0 @@
|
|||||||
@using AutomobilePlantClientApp
|
|
||||||
@using AutomobilePlantClientApp.Models
|
|
||||||
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
|
|
@ -1,3 +0,0 @@
|
|||||||
@{
|
|
||||||
Layout = "_Layout";
|
|
||||||
}
|
|
@ -1,8 +0,0 @@
|
|||||||
{
|
|
||||||
"Logging": {
|
|
||||||
"LogLevel": {
|
|
||||||
"Default": "Information",
|
|
||||||
"Microsoft.AspNetCore": "Warning"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,10 +0,0 @@
|
|||||||
{
|
|
||||||
"Logging": {
|
|
||||||
"LogLevel": {
|
|
||||||
"Default": "Information",
|
|
||||||
"Microsoft.AspNetCore": "Warning"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"AllowedHosts": "*",
|
|
||||||
"IPAddress": "http://localhost:5137/"
|
|
||||||
}
|
|
@ -1,18 +0,0 @@
|
|||||||
html {
|
|
||||||
font-size: 14px;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (min-width: 768px) {
|
|
||||||
html {
|
|
||||||
font-size: 16px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
html {
|
|
||||||
position: relative;
|
|
||||||
min-height: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
body {
|
|
||||||
margin-bottom: 60px;
|
|
||||||
}
|
|
Binary file not shown.
Before Width: | Height: | Size: 5.3 KiB |
@ -1,4 +0,0 @@
|
|||||||
// Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification
|
|
||||||
// for details on configuring this project to bundle and minify static web assets.
|
|
||||||
|
|
||||||
// Write your JavaScript code.
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user