Compare commits
2 Commits
main
...
laboratory
Author | SHA1 | Date | |
---|---|---|---|
|
6cad9b0137 | ||
|
a5932ab678 |
55
Lab 4/Belianin_4/Belianin_4.sln
Normal file
55
Lab 4/Belianin_4/Belianin_4.sln
Normal file
@ -0,0 +1,55 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.9.34728.123
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DesktopWithMyVisualComponents", "DesktopWithMyVisualComponents\DesktopWithMyVisualComponents.csproj", "{D784BAED-C48F-46F2-A6A0-BBD6CE599A59}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EnterpriseContracts", "EnterpriseContracts\EnterpriseContracts.csproj", "{B07E9BAB-F7E0-4191-A9A5-FECA4127F6FF}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EnterpriseDataBaseImplement", "EnterpriseDataBaseImplement\EnterpriseDataBaseImplement.csproj", "{D4FEF8DA-7060-4BF5-BB44-E5676DAE83E9}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EnterpriseBusinessLogic", "EnterpriseBusinessLogic\EnterpriseBusinessLogic.csproj", "{80D54561-34CE-4DE8-BF20-30A38B393D4B}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PluginsConventionLibrary", "PluginsConventionLibrary\PluginsConventionLibrary.csproj", "{29708637-6FE2-482A-8960-C5A73EBD9F10}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DesktopWithPlugins", "DesktopWithPlugins\DesktopWithPlugins.csproj", "{A2976F63-6DFE-4434-8AB3-7036C8598CA8}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{D784BAED-C48F-46F2-A6A0-BBD6CE599A59}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{D784BAED-C48F-46F2-A6A0-BBD6CE599A59}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D784BAED-C48F-46F2-A6A0-BBD6CE599A59}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D784BAED-C48F-46F2-A6A0-BBD6CE599A59}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{B07E9BAB-F7E0-4191-A9A5-FECA4127F6FF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{B07E9BAB-F7E0-4191-A9A5-FECA4127F6FF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{B07E9BAB-F7E0-4191-A9A5-FECA4127F6FF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{B07E9BAB-F7E0-4191-A9A5-FECA4127F6FF}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{D4FEF8DA-7060-4BF5-BB44-E5676DAE83E9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{D4FEF8DA-7060-4BF5-BB44-E5676DAE83E9}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D4FEF8DA-7060-4BF5-BB44-E5676DAE83E9}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D4FEF8DA-7060-4BF5-BB44-E5676DAE83E9}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{80D54561-34CE-4DE8-BF20-30A38B393D4B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{80D54561-34CE-4DE8-BF20-30A38B393D4B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{80D54561-34CE-4DE8-BF20-30A38B393D4B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{80D54561-34CE-4DE8-BF20-30A38B393D4B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{29708637-6FE2-482A-8960-C5A73EBD9F10}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{29708637-6FE2-482A-8960-C5A73EBD9F10}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{29708637-6FE2-482A-8960-C5A73EBD9F10}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{29708637-6FE2-482A-8960-C5A73EBD9F10}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{A2976F63-6DFE-4434-8AB3-7036C8598CA8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{A2976F63-6DFE-4434-8AB3-7036C8598CA8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{A2976F63-6DFE-4434-8AB3-7036C8598CA8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{A2976F63-6DFE-4434-8AB3-7036C8598CA8}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {26502496-F9AE-4E02-986A-76FD9595E9AE}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
@ -0,0 +1,35 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net6.0-windows7.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="BarsukovComponents" Version="1.0.0" />
|
||||
<PackageReference Include="BelianinComponents" Version="1.0.0" />
|
||||
<PackageReference Include="KryukovLib" Version="1.0.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Analyzers" Version="7.0.13" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.13">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.13" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.13">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Unity" Version="5.11.10" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\EnterpriseBusinessLogic\EnterpriseBusinessLogic.csproj" />
|
||||
<ProjectReference Include="..\EnterpriseContracts\EnterpriseContracts.csproj" />
|
||||
<ProjectReference Include="..\EnterpriseDataBaseImplement\EnterpriseDataBaseImplement.csproj" />
|
||||
<ProjectReference Include="..\PluginsConventionLibrary\PluginsConventionLibrary.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
189
Lab 4/Belianin_4/DesktopWithMyVisualComponents/FormEmployee.Designer.cs
generated
Normal file
189
Lab 4/Belianin_4/DesktopWithMyVisualComponents/FormEmployee.Designer.cs
generated
Normal file
@ -0,0 +1,189 @@
|
||||
namespace DesktopWithMyVisualComponents
|
||||
{
|
||||
partial class FormEmployee
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
labelFIO = new Label();
|
||||
textBoxFIO = new TextBox();
|
||||
labelPhoneNumber = new Label();
|
||||
barsukovTextBoxPhoneNumber = new BarsukovComponents.VisualComponents.CustomTextBox();
|
||||
labelSkill = new Label();
|
||||
customSelectedCheckedListBoxProperty = new BelianinComponents.CustomSelectedCheckedListBoxProperty();
|
||||
buttonPhoto = new Button();
|
||||
buttonSave = new Button();
|
||||
buttonCancelAdd = new Button();
|
||||
pictureBoxPhoto = new PictureBox();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxPhoto).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// labelFIO
|
||||
//
|
||||
labelFIO.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||
labelFIO.AutoSize = true;
|
||||
labelFIO.Location = new Point(30, 10);
|
||||
labelFIO.Name = "labelFIO";
|
||||
labelFIO.Size = new Size(45, 20);
|
||||
labelFIO.TabIndex = 0;
|
||||
labelFIO.Text = "ФИО:";
|
||||
//
|
||||
// textBoxFIO
|
||||
//
|
||||
textBoxFIO.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||
textBoxFIO.Location = new Point(35, 34);
|
||||
textBoxFIO.Margin = new Padding(3, 4, 3, 4);
|
||||
textBoxFIO.Name = "textBoxFIO";
|
||||
textBoxFIO.Size = new Size(493, 27);
|
||||
textBoxFIO.TabIndex = 1;
|
||||
//
|
||||
// labelPhoneNumber
|
||||
//
|
||||
labelPhoneNumber.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||
labelPhoneNumber.AutoSize = true;
|
||||
labelPhoneNumber.Location = new Point(242, 98);
|
||||
labelPhoneNumber.Name = "labelPhoneNumber";
|
||||
labelPhoneNumber.Size = new Size(130, 20);
|
||||
labelPhoneNumber.TabIndex = 2;
|
||||
labelPhoneNumber.Text = "Номер телефона:";
|
||||
//
|
||||
// barsukovTextBoxPhoneNumber
|
||||
//
|
||||
barsukovTextBoxPhoneNumber.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||
barsukovTextBoxPhoneNumber.BorderStyle = BorderStyle.FixedSingle;
|
||||
barsukovTextBoxPhoneNumber.Location = new Point(242, 122);
|
||||
barsukovTextBoxPhoneNumber.Margin = new Padding(3, 4, 3, 4);
|
||||
barsukovTextBoxPhoneNumber.Name = "barsukovTextBoxPhoneNumber";
|
||||
barsukovTextBoxPhoneNumber.numberPattern = "";
|
||||
barsukovTextBoxPhoneNumber.Size = new Size(275, 81);
|
||||
barsukovTextBoxPhoneNumber.TabIndex = 3;
|
||||
barsukovTextBoxPhoneNumber.textBoxNumber = "";
|
||||
barsukovTextBoxPhoneNumber.Enter += barsukovTextBoxPhoneNumber_Enter;
|
||||
//
|
||||
// labelSkill
|
||||
//
|
||||
labelSkill.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||
labelSkill.AutoSize = true;
|
||||
labelSkill.Location = new Point(35, 65);
|
||||
labelSkill.Name = "labelSkill";
|
||||
labelSkill.Size = new Size(57, 20);
|
||||
labelSkill.TabIndex = 4;
|
||||
labelSkill.Text = "Навык:";
|
||||
//
|
||||
// customSelectedCheckedListBoxProperty
|
||||
//
|
||||
customSelectedCheckedListBoxProperty.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||
customSelectedCheckedListBoxProperty.Location = new Point(34, 84);
|
||||
customSelectedCheckedListBoxProperty.Margin = new Padding(3, 4, 3, 4);
|
||||
customSelectedCheckedListBoxProperty.Name = "customSelectedCheckedListBoxProperty";
|
||||
customSelectedCheckedListBoxProperty.SelectedElement = "";
|
||||
customSelectedCheckedListBoxProperty.Size = new Size(202, 207);
|
||||
customSelectedCheckedListBoxProperty.TabIndex = 5;
|
||||
//
|
||||
// buttonPhoto
|
||||
//
|
||||
buttonPhoto.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||
buttonPhoto.Location = new Point(35, 615);
|
||||
buttonPhoto.Margin = new Padding(3, 4, 3, 4);
|
||||
buttonPhoto.Name = "buttonPhoto";
|
||||
buttonPhoto.Size = new Size(494, 48);
|
||||
buttonPhoto.TabIndex = 6;
|
||||
buttonPhoto.Text = "Загрузить фото";
|
||||
buttonPhoto.UseVisualStyleBackColor = true;
|
||||
buttonPhoto.Click += buttonPhoto_Click;
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonSave.Location = new Point(309, 671);
|
||||
buttonSave.Margin = new Padding(3, 4, 3, 4);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(101, 41);
|
||||
buttonSave.TabIndex = 7;
|
||||
buttonSave.Text = "Сохранить";
|
||||
buttonSave.UseVisualStyleBackColor = true;
|
||||
buttonSave.Click += buttonSave_Click;
|
||||
//
|
||||
// buttonCancelAdd
|
||||
//
|
||||
buttonCancelAdd.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonCancelAdd.Location = new Point(427, 671);
|
||||
buttonCancelAdd.Margin = new Padding(3, 4, 3, 4);
|
||||
buttonCancelAdd.Name = "buttonCancelAdd";
|
||||
buttonCancelAdd.Size = new Size(102, 41);
|
||||
buttonCancelAdd.TabIndex = 8;
|
||||
buttonCancelAdd.Text = "Отмена";
|
||||
buttonCancelAdd.UseVisualStyleBackColor = true;
|
||||
buttonCancelAdd.Click += buttonCancelAdd_Click;
|
||||
//
|
||||
// pictureBoxPhoto
|
||||
//
|
||||
pictureBoxPhoto.Location = new Point(35, 281);
|
||||
pictureBoxPhoto.Margin = new Padding(3, 4, 3, 4);
|
||||
pictureBoxPhoto.Name = "pictureBoxPhoto";
|
||||
pictureBoxPhoto.Size = new Size(493, 327);
|
||||
pictureBoxPhoto.TabIndex = 9;
|
||||
pictureBoxPhoto.TabStop = false;
|
||||
//
|
||||
// FormEmployee
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(559, 717);
|
||||
Controls.Add(pictureBoxPhoto);
|
||||
Controls.Add(buttonCancelAdd);
|
||||
Controls.Add(buttonSave);
|
||||
Controls.Add(buttonPhoto);
|
||||
Controls.Add(customSelectedCheckedListBoxProperty);
|
||||
Controls.Add(labelSkill);
|
||||
Controls.Add(barsukovTextBoxPhoneNumber);
|
||||
Controls.Add(labelPhoneNumber);
|
||||
Controls.Add(textBoxFIO);
|
||||
Controls.Add(labelFIO);
|
||||
KeyPreview = true;
|
||||
Margin = new Padding(3, 4, 3, 4);
|
||||
Name = "FormEmployee";
|
||||
Text = "Сотрудник";
|
||||
Load += FormEmployee_Load;
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxPhoto).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label labelFIO;
|
||||
private TextBox textBoxFIO;
|
||||
private Label labelPhoneNumber;
|
||||
private BarsukovComponents.VisualComponents.CustomTextBox barsukovTextBoxPhoneNumber;
|
||||
private Label labelSkill;
|
||||
private BelianinComponents.CustomSelectedCheckedListBoxProperty customSelectedCheckedListBoxProperty;
|
||||
private Button buttonPhoto;
|
||||
private Button buttonSave;
|
||||
private Button buttonCancelAdd;
|
||||
private PictureBox pictureBoxPhoto;
|
||||
}
|
||||
}
|
148
Lab 4/Belianin_4/DesktopWithMyVisualComponents/FormEmployee.cs
Normal file
148
Lab 4/Belianin_4/DesktopWithMyVisualComponents/FormEmployee.cs
Normal file
@ -0,0 +1,148 @@
|
||||
using EnterpriseContracts.BindingModels;
|
||||
using EnterpriseContracts.BusinessLogicContracts;
|
||||
using EnterpriseContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DesktopWithMyVisualComponents
|
||||
{
|
||||
public partial class FormEmployee : Form
|
||||
{
|
||||
public int Id { set { id = value; } }
|
||||
|
||||
private readonly IEmployeeLogic _logic;
|
||||
|
||||
private readonly ISkillLogic _logicS;
|
||||
|
||||
private string image = null;
|
||||
|
||||
private int? id;
|
||||
|
||||
public FormEmployee(IEmployeeLogic logic, ISkillLogic logicS)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logic = logic;
|
||||
_logicS = logicS;
|
||||
}
|
||||
|
||||
private void barsukovTextBoxPhoneNumber_Enter(object sender, EventArgs e)
|
||||
{
|
||||
ToolTip tt = new ToolTip();
|
||||
|
||||
// Формат записи телефона
|
||||
tt.Show("X-XXX-XX-XX", barsukovTextBoxPhoneNumber, 30, -20, 1000);
|
||||
}
|
||||
|
||||
private void FormEmployee_Load(object sender, EventArgs e)
|
||||
{
|
||||
barsukovTextBoxPhoneNumber.numberPattern = @"^\d{1}-\d{3}-\d{2}-\d{2}$";
|
||||
List<SkillViewModel> viewS = _logicS.Read(null);
|
||||
|
||||
if (viewS != null)
|
||||
{
|
||||
foreach (SkillViewModel skill in viewS)
|
||||
{
|
||||
customSelectedCheckedListBoxProperty.Items.Add(skill.Name);
|
||||
}
|
||||
}
|
||||
|
||||
if (id.HasValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
EmployeeViewModel view = _logic.Read(new EmployeeBindingModel { Id = id.Value })?[0];
|
||||
|
||||
if (view != null)
|
||||
{
|
||||
textBoxFIO.Text = view.FIO;
|
||||
barsukovTextBoxPhoneNumber.textBoxNumber = view.PhoneNumber;
|
||||
customSelectedCheckedListBoxProperty.SelectedElement = view.Skill;
|
||||
|
||||
pictureBoxPhoto.Image = StringToImage(view.Photo);
|
||||
image = view.Photo;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Image StringToImage(string bytes)
|
||||
{
|
||||
byte[] arrayimg = Convert.FromBase64String(bytes);
|
||||
Image imageStr = Image.FromStream(new MemoryStream(arrayimg));
|
||||
|
||||
return imageStr;
|
||||
}
|
||||
|
||||
private string ImageToString(Image image)
|
||||
{
|
||||
using (var ms = new MemoryStream())
|
||||
{
|
||||
image.Save(ms, image.RawFormat);
|
||||
byte[] imageBytes = ms.ToArray();
|
||||
|
||||
// Convert byte[] to Base64 String
|
||||
string base64String = Convert.ToBase64String(imageBytes);
|
||||
return base64String;
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
List<SkillViewModel> viewS = _logicS.Read(null);
|
||||
|
||||
try
|
||||
{
|
||||
_logic.CreateOrUpdate(new EmployeeBindingModel
|
||||
{
|
||||
Id = id,
|
||||
FIO = textBoxFIO.Text,
|
||||
Photo = image,
|
||||
Skill = customSelectedCheckedListBoxProperty.SelectedElement,
|
||||
PhoneNumber = barsukovTextBoxPhoneNumber.textBoxNumber,
|
||||
});
|
||||
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
DialogResult = DialogResult.OK;
|
||||
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonCancelAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void buttonPhoto_Click(object sender, EventArgs e)
|
||||
{
|
||||
var dialog = new OpenFileDialog();
|
||||
|
||||
dialog.Title = "Выберите изображение";
|
||||
dialog.Filter = "jpg files (*.jpg)|*.jpg";
|
||||
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
var image_new = new Bitmap(dialog.FileName);
|
||||
pictureBoxPhoto.Image = image_new;
|
||||
image = ImageToString(image_new);
|
||||
}
|
||||
|
||||
dialog.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
120
Lab 4/Belianin_4/DesktopWithMyVisualComponents/FormEmployee.resx
Normal file
120
Lab 4/Belianin_4/DesktopWithMyVisualComponents/FormEmployee.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?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>
|
183
Lab 4/Belianin_4/DesktopWithMyVisualComponents/FormMain.Designer.cs
generated
Normal file
183
Lab 4/Belianin_4/DesktopWithMyVisualComponents/FormMain.Designer.cs
generated
Normal file
@ -0,0 +1,183 @@
|
||||
namespace DesktopWithMyVisualComponents
|
||||
{
|
||||
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()
|
||||
{
|
||||
components = new System.ComponentModel.Container();
|
||||
menuStrip = new MenuStrip();
|
||||
справочникиToolStripMenuItem = new ToolStripMenuItem();
|
||||
навыкиToolStripMenuItem = new ToolStripMenuItem();
|
||||
действияToolStripMenuItem = new ToolStripMenuItem();
|
||||
добавитьToolStripMenuItem = new ToolStripMenuItem();
|
||||
изменитьToolStripMenuItem = new ToolStripMenuItem();
|
||||
удалитьToolStripMenuItem = new ToolStripMenuItem();
|
||||
документыToolStripMenuItem = new ToolStripMenuItem();
|
||||
wordСФотоToolStripMenuItem = new ToolStripMenuItem();
|
||||
pdfТаблицаToolStripMenuItem = new ToolStripMenuItem();
|
||||
excelГистограммаToolStripMenuItem = new ToolStripMenuItem();
|
||||
wordWithImages = new BelianinComponents.WordWithImages(components);
|
||||
componentTableToPdf = new BarsukovComponents.NotVisualComponents.PdfTable(components);
|
||||
krykovItemTable = new KryukovLib.CustomDataGridView();
|
||||
excelGistogram = new KryukovLib.ExcelGistogram(components);
|
||||
menuStrip.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// menuStrip
|
||||
//
|
||||
menuStrip.ImageScalingSize = new Size(20, 20);
|
||||
menuStrip.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, действияToolStripMenuItem, документыToolStripMenuItem });
|
||||
menuStrip.Location = new Point(0, 0);
|
||||
menuStrip.Name = "menuStrip";
|
||||
menuStrip.Padding = new Padding(7, 3, 0, 3);
|
||||
menuStrip.Size = new Size(661, 30);
|
||||
menuStrip.TabIndex = 0;
|
||||
menuStrip.Text = "menuStrip";
|
||||
//
|
||||
// справочникиToolStripMenuItem
|
||||
//
|
||||
справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { навыкиToolStripMenuItem });
|
||||
справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
|
||||
справочникиToolStripMenuItem.Size = new Size(117, 24);
|
||||
справочникиToolStripMenuItem.Text = "Справочники";
|
||||
//
|
||||
// навыкиToolStripMenuItem
|
||||
//
|
||||
навыкиToolStripMenuItem.Name = "навыкиToolStripMenuItem";
|
||||
навыкиToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.I;
|
||||
навыкиToolStripMenuItem.Size = new Size(146, 26);
|
||||
навыкиToolStripMenuItem.Text = "Навыки";
|
||||
навыкиToolStripMenuItem.Click += навыкиToolStripMenuItem_Click;
|
||||
//
|
||||
// действияToolStripMenuItem
|
||||
//
|
||||
действияToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { добавитьToolStripMenuItem, изменитьToolStripMenuItem, удалитьToolStripMenuItem });
|
||||
действияToolStripMenuItem.Name = "действияToolStripMenuItem";
|
||||
действияToolStripMenuItem.Size = new Size(88, 24);
|
||||
действияToolStripMenuItem.Text = "Действия";
|
||||
//
|
||||
// добавитьToolStripMenuItem
|
||||
//
|
||||
добавитьToolStripMenuItem.Name = "добавитьToolStripMenuItem";
|
||||
добавитьToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.A;
|
||||
добавитьToolStripMenuItem.Size = new Size(213, 26);
|
||||
добавитьToolStripMenuItem.Text = "Добавить";
|
||||
добавитьToolStripMenuItem.Click += добавитьToolStripMenuItem_Click;
|
||||
//
|
||||
// изменитьToolStripMenuItem
|
||||
//
|
||||
изменитьToolStripMenuItem.Name = "изменитьToolStripMenuItem";
|
||||
изменитьToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.U;
|
||||
изменитьToolStripMenuItem.Size = new Size(213, 26);
|
||||
изменитьToolStripMenuItem.Text = "Изменить";
|
||||
изменитьToolStripMenuItem.Click += изменитьToolStripMenuItem_Click;
|
||||
//
|
||||
// удалитьToolStripMenuItem
|
||||
//
|
||||
удалитьToolStripMenuItem.Name = "удалитьToolStripMenuItem";
|
||||
удалитьToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.D;
|
||||
удалитьToolStripMenuItem.Size = new Size(213, 26);
|
||||
удалитьToolStripMenuItem.Text = "Удалить";
|
||||
удалитьToolStripMenuItem.Click += удалитьToolStripMenuItem_Click;
|
||||
//
|
||||
// документыToolStripMenuItem
|
||||
//
|
||||
документыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { wordСФотоToolStripMenuItem, pdfТаблицаToolStripMenuItem, excelГистограммаToolStripMenuItem });
|
||||
документыToolStripMenuItem.Name = "документыToolStripMenuItem";
|
||||
документыToolStripMenuItem.Size = new Size(101, 24);
|
||||
документыToolStripMenuItem.Text = "Документы";
|
||||
//
|
||||
// wordСФотоToolStripMenuItem
|
||||
//
|
||||
wordСФотоToolStripMenuItem.Name = "wordСФотоToolStripMenuItem";
|
||||
wordСФотоToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.S;
|
||||
wordСФотоToolStripMenuItem.Size = new Size(271, 26);
|
||||
wordСФотоToolStripMenuItem.Text = "Word с фото";
|
||||
wordСФотоToolStripMenuItem.Click += wordСФотоToolStripMenuItem_Click;
|
||||
//
|
||||
// pdfТаблицаToolStripMenuItem
|
||||
//
|
||||
pdfТаблицаToolStripMenuItem.Name = "pdfТаблицаToolStripMenuItem";
|
||||
pdfТаблицаToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.T;
|
||||
pdfТаблицаToolStripMenuItem.Size = new Size(271, 26);
|
||||
pdfТаблицаToolStripMenuItem.Text = "Pdf таблица";
|
||||
pdfТаблицаToolStripMenuItem.Click += pdfТаблицаToolStripMenuItem_Click;
|
||||
//
|
||||
// excelГистограммаToolStripMenuItem
|
||||
//
|
||||
excelГистограммаToolStripMenuItem.Name = "excelГистограммаToolStripMenuItem";
|
||||
excelГистограммаToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.C;
|
||||
excelГистограммаToolStripMenuItem.Size = new Size(271, 26);
|
||||
excelГистограммаToolStripMenuItem.Text = "Excel гистограмма";
|
||||
excelГистограммаToolStripMenuItem.Click += excelГистограммаToolStripMenuItem_Click;
|
||||
//
|
||||
// krykovItemTable
|
||||
//
|
||||
krykovItemTable.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||
krykovItemTable.Location = new Point(14, 36);
|
||||
krykovItemTable.Margin = new Padding(3, 5, 3, 5);
|
||||
krykovItemTable.Name = "krykovItemTable";
|
||||
krykovItemTable.Size = new Size(630, 477);
|
||||
krykovItemTable.TabIndex = 2;
|
||||
//
|
||||
// FormMain
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(661, 529);
|
||||
Controls.Add(krykovItemTable);
|
||||
Controls.Add(menuStrip);
|
||||
MainMenuStrip = menuStrip;
|
||||
Margin = new Padding(3, 4, 3, 4);
|
||||
Name = "FormMain";
|
||||
Text = "Главная";
|
||||
Load += FormMain_Load;
|
||||
menuStrip.ResumeLayout(false);
|
||||
menuStrip.PerformLayout();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private MenuStrip menuStrip;
|
||||
private ToolStripMenuItem справочникиToolStripMenuItem;
|
||||
private ToolStripMenuItem навыкиToolStripMenuItem;
|
||||
private ToolStripMenuItem действияToolStripMenuItem;
|
||||
private ToolStripMenuItem добавитьToolStripMenuItem;
|
||||
private ToolStripMenuItem изменитьToolStripMenuItem;
|
||||
private ToolStripMenuItem удалитьToolStripMenuItem;
|
||||
private ToolStripMenuItem документыToolStripMenuItem;
|
||||
private ToolStripMenuItem wordСФотоToolStripMenuItem;
|
||||
private ToolStripMenuItem pdfТаблицаToolStripMenuItem;
|
||||
private ToolStripMenuItem excelГистограммаToolStripMenuItem;
|
||||
private BelianinComponents.WordWithImages wordWithImages;
|
||||
private BarsukovComponents.NotVisualComponents.PdfTable componentTableToPdf;
|
||||
private KryukovLib.CustomDataGridView krykovItemTable;
|
||||
private KryukovLib.ExcelGistogram excelGistogram;
|
||||
}
|
||||
}
|
246
Lab 4/Belianin_4/DesktopWithMyVisualComponents/FormMain.cs
Normal file
246
Lab 4/Belianin_4/DesktopWithMyVisualComponents/FormMain.cs
Normal file
@ -0,0 +1,246 @@
|
||||
using BelianinComponents;
|
||||
using BelianinComponents.Models;
|
||||
using EnterpriseContracts.BindingModels;
|
||||
using EnterpriseContracts.BusinessLogicContracts;
|
||||
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 EnterpriseContracts.ViewModels;
|
||||
using EnterpriseDataBaseImplement.Models;
|
||||
using Unity;
|
||||
using BarsukovComponents.NotVisualComponents.Configs;
|
||||
|
||||
namespace DesktopWithMyVisualComponents
|
||||
{
|
||||
public partial class FormMain : Form
|
||||
{
|
||||
private readonly IEmployeeLogic _employeeLogic;
|
||||
|
||||
private readonly ISkillLogic _skillLogic;
|
||||
|
||||
// Конструктор
|
||||
public FormMain(IEmployeeLogic employeeLogic, ISkillLogic skillLogic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_employeeLogic = employeeLogic;
|
||||
|
||||
krykovItemTable.ConfigColumn(new()
|
||||
{
|
||||
ColumnsCount = 4,
|
||||
NameColumn = new string[] { "Id", "ФИО", "Навык", "Номер телефона" },
|
||||
Width = new int[] { 10, 150, 250, 200 },
|
||||
Visible = new bool[] { false, true, true, true },
|
||||
PropertiesObject = new string[] { "Id", "FIO", "Skill", "PhoneNumber" }
|
||||
});
|
||||
|
||||
_skillLogic = skillLogic;
|
||||
}
|
||||
|
||||
private void FormMain_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
try
|
||||
{
|
||||
krykovItemTable.ClearDataGrid();
|
||||
// Поиск записей в бд
|
||||
var list = _employeeLogic.Read(null);
|
||||
|
||||
if (list != null)
|
||||
{
|
||||
for (int j = 0; j < list.Count; j++)
|
||||
{
|
||||
krykovItemTable.AddItem(list[j], j);
|
||||
krykovItemTable.Update();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void добавитьToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var form = Program.Container.Resolve<FormEmployee>();
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
|
||||
private void изменитьToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var form = Program.Container.Resolve<FormEmployee>();
|
||||
|
||||
form.Id = Convert.ToInt32(krykovItemTable.GetSelectedObjectInRow<Employee>().Id);
|
||||
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
|
||||
private void удалитьToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (MessageBox.Show("Удалить запись", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
int id = Convert.ToInt32(krykovItemTable.GetSelectedObjectInRow<Employee>().Id);
|
||||
|
||||
try
|
||||
{
|
||||
_employeeLogic.Delete(new EmployeeBindingModel { Id = id });
|
||||
krykovItemTable.ClearDataGrid();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
|
||||
private void навыкиToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var form = Program.Container.Resolve<FormSkill>();
|
||||
|
||||
form.ShowDialog();
|
||||
}
|
||||
|
||||
private byte[] StringToImage(string bytes)
|
||||
{
|
||||
byte[] arrayimg = Convert.FromBase64String(bytes);
|
||||
|
||||
return arrayimg;
|
||||
}
|
||||
|
||||
private void wordСФотоToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
string fileName = "";
|
||||
|
||||
using (var dialog = new SaveFileDialog { Filter = "docx|*.docx" })
|
||||
{
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
fileName = dialog.FileName.ToString();
|
||||
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
var list = _employeeLogic.Read(null);
|
||||
|
||||
var list_images = new List<byte[]>();
|
||||
|
||||
foreach (var item in list)
|
||||
{
|
||||
var img = StringToImage(item.Photo);
|
||||
list_images.Add(img);
|
||||
}
|
||||
|
||||
wordWithImages.CreateDoc(new WordWithImageConfig
|
||||
{
|
||||
FilePath = fileName,
|
||||
Header = "Фотографии:",
|
||||
Images = list_images
|
||||
});
|
||||
}
|
||||
|
||||
private void pdfТаблицаToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
string fileName = "";
|
||||
|
||||
using (var dialog = new SaveFileDialog { Filter = "pdf|*.pdf" })
|
||||
{
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
fileName = dialog.FileName.ToString();
|
||||
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
|
||||
// Вызов метода CreateTable
|
||||
componentTableToPdf.CreateDoc(new ComponentTableToPdfConfig<EmployeeViewModel>
|
||||
{
|
||||
// Путь к файлу
|
||||
FilePath = fileName,
|
||||
// Заголовок таблицы
|
||||
Header = "Таблица с сотрудниками",
|
||||
UseUnion = true,
|
||||
// Информация о колонках
|
||||
ColumnsRowsWidth = new List<(int, int)> { (20, 0), (20, 0), (20, 0), (20, 0) },
|
||||
// Объединённые ячейки
|
||||
ColumnUnion = new List<(int StartIndex, int Count)> { (2, 2) },
|
||||
|
||||
Headers = new List<(int ColumnIndex, int RowIndex, string Header, string PropertyName)>()
|
||||
{
|
||||
(0, 0, "Идент.", "Id"),
|
||||
(1, 0, "ФИО", "FIO"),
|
||||
(2, 0, "Работа", ""),
|
||||
(2, 1, "Номер телефона", "PhoneNumber"),
|
||||
(3, 1, "Навык", "Skill")
|
||||
},
|
||||
|
||||
// Данные для таблицы
|
||||
Data = _employeeLogic.Read(null)
|
||||
});
|
||||
}
|
||||
|
||||
private void excelГистограммаToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
string fileName = "";
|
||||
|
||||
using (var dialog = new SaveFileDialog { Filter = "xlsx|*.xlsx" })
|
||||
{
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
fileName = dialog.FileName.ToString();
|
||||
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
|
||||
var list2D = new List<(string Date, double Value)>();
|
||||
|
||||
var emps = _employeeLogic.Read(null);
|
||||
var skills = _skillLogic.Read(null);
|
||||
|
||||
foreach (var skill in skills)
|
||||
{
|
||||
double count = 0;
|
||||
|
||||
foreach (var emp in emps)
|
||||
{
|
||||
if (skill.Name.Equals(emp.Skill))
|
||||
{
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
var elem = (skill.Name, count);
|
||||
list2D.Add(elem);
|
||||
}
|
||||
|
||||
excelGistogram.CreateDoc(new()
|
||||
{
|
||||
FilePath = fileName,
|
||||
Header = "Chart",
|
||||
ChartTitle = "BarChart",
|
||||
LegendLocation = KryukovLib.Models.Location.Top,
|
||||
Data = new Dictionary<string, List<(string Date, double Value)>>
|
||||
{
|
||||
{ "Series 1", list2D }
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
132
Lab 4/Belianin_4/DesktopWithMyVisualComponents/FormMain.resx
Normal file
132
Lab 4/Belianin_4/DesktopWithMyVisualComponents/FormMain.resx
Normal file
@ -0,0 +1,132 @@
|
||||
<?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>
|
||||
<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="wordWithImages.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>508, 17</value>
|
||||
</metadata>
|
||||
<metadata name="componentTableToPdf.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>145, 17</value>
|
||||
</metadata>
|
||||
<metadata name="excelGistogram.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>349, 17</value>
|
||||
</metadata>
|
||||
</root>
|
69
Lab 4/Belianin_4/DesktopWithMyVisualComponents/FormSkill.Designer.cs
generated
Normal file
69
Lab 4/Belianin_4/DesktopWithMyVisualComponents/FormSkill.Designer.cs
generated
Normal file
@ -0,0 +1,69 @@
|
||||
namespace DesktopWithMyVisualComponents
|
||||
{
|
||||
partial class FormSkill
|
||||
{
|
||||
/// <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.AllowUserToAddRows = false;
|
||||
dataGridView.AllowUserToDeleteRows = false;
|
||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView.Location = new Point(14, 16);
|
||||
dataGridView.Margin = new Padding(3, 4, 3, 4);
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.RowHeadersWidth = 51;
|
||||
dataGridView.RowTemplate.Height = 25;
|
||||
dataGridView.Size = new Size(282, 200);
|
||||
dataGridView.TabIndex = 0;
|
||||
dataGridView.CellEndEdit += dataGridView_CellEndEdit;
|
||||
dataGridView.KeyDown += dataGridView_KeyDown;
|
||||
//
|
||||
// FormSkill
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(310, 240);
|
||||
Controls.Add(dataGridView);
|
||||
KeyPreview = true;
|
||||
Margin = new Padding(3, 4, 3, 4);
|
||||
Name = "FormSkill";
|
||||
Text = "Навыки";
|
||||
Load += FormSkill_Load;
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView dataGridView;
|
||||
}
|
||||
}
|
145
Lab 4/Belianin_4/DesktopWithMyVisualComponents/FormSkill.cs
Normal file
145
Lab 4/Belianin_4/DesktopWithMyVisualComponents/FormSkill.cs
Normal file
@ -0,0 +1,145 @@
|
||||
using EnterpriseContracts.BindingModels;
|
||||
using EnterpriseContracts.BusinessLogicContracts;
|
||||
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 DesktopWithMyVisualComponents
|
||||
{
|
||||
public partial class FormSkill : Form
|
||||
{
|
||||
private readonly ISkillLogic _skillLogic;
|
||||
|
||||
BindingList<SkillBindingModel> list;
|
||||
|
||||
public FormSkill(ISkillLogic skillLogic)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_skillLogic = skillLogic;
|
||||
dataGridView.AllowUserToDeleteRows = true;
|
||||
list = new BindingList<SkillBindingModel>();
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
try
|
||||
{
|
||||
var list1 = _skillLogic.Read(null);
|
||||
list.Clear();
|
||||
|
||||
foreach (var item in list1)
|
||||
{
|
||||
list.Add(new SkillBindingModel
|
||||
{
|
||||
Id = item.Id,
|
||||
Name = item.Name,
|
||||
});
|
||||
}
|
||||
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns[0].Visible = false;
|
||||
dataGridView.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void FormSkill_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void dataGridView_CellEndEdit(object sender, DataGridViewCellEventArgs e)
|
||||
{
|
||||
var typeName = (string)dataGridView.CurrentRow.Cells[1].Value;
|
||||
|
||||
if (!string.IsNullOrEmpty(typeName))
|
||||
{
|
||||
if (dataGridView.CurrentRow.Cells[0].Value != null)
|
||||
{
|
||||
_skillLogic.CreateOrUpdate(new SkillBindingModel()
|
||||
{
|
||||
Id = Convert.ToInt32(dataGridView.CurrentRow.Cells[0].Value),
|
||||
Name = (string)dataGridView.CurrentRow.Cells[1].EditedFormattedValue
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
_skillLogic.CreateOrUpdate(new SkillBindingModel()
|
||||
{
|
||||
Name = (string)dataGridView.CurrentRow.Cells[1].EditedFormattedValue
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Введена пустая строка", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void dataGridView_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.KeyData == Keys.Insert)
|
||||
{
|
||||
if (dataGridView.Rows.Count == 0)
|
||||
{
|
||||
list.Add(new SkillBindingModel());
|
||||
dataGridView.DataSource = new List<SkillBindingModel>(list);
|
||||
dataGridView.CurrentCell = dataGridView.Rows[0].Cells[1];
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (dataGridView.Rows[dataGridView.Rows.Count - 1].Cells[1].Value != null)
|
||||
{
|
||||
list.Add(new SkillBindingModel());
|
||||
dataGridView.DataSource = new List<SkillBindingModel>(list);
|
||||
dataGridView.CurrentCell = dataGridView.Rows[dataGridView.Rows.Count - 1].Cells[1];
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (e.KeyData == Keys.Delete)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
|
||||
try
|
||||
{
|
||||
if (!_skillLogic.Delete(new SkillBindingModel() { Id = id }))
|
||||
{
|
||||
throw new Exception("Ошибка при удалении");
|
||||
}
|
||||
|
||||
dataGridView.Rows.RemoveAt(dataGridView.SelectedRows[0].Index);
|
||||
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
120
Lab 4/Belianin_4/DesktopWithMyVisualComponents/FormSkill.resx
Normal file
120
Lab 4/Belianin_4/DesktopWithMyVisualComponents/FormSkill.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?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>
|
@ -0,0 +1,286 @@
|
||||
using BarsukovComponents.NotVisualComponents.Configs;
|
||||
using BelianinComponents.Models;
|
||||
using BelianinComponents;
|
||||
using EnterpriseBusinessLogic.BusinessLogics;
|
||||
using EnterpriseContracts.BindingModels;
|
||||
using EnterpriseContracts.BusinessLogicContracts;
|
||||
using EnterpriseContracts.ViewModels;
|
||||
using KryukovLib;
|
||||
using PluginsConventionLibrary.Plugins;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using PluginsConventionLibrary;
|
||||
using BarsukovComponents.NotVisualComponents;
|
||||
|
||||
namespace DesktopWithMyVisualComponents
|
||||
{
|
||||
public class PluginsConvention : IPluginsConvention
|
||||
{
|
||||
private CustomDataGridView krykovItemTable;
|
||||
|
||||
private readonly IEmployeeLogic _employeeLogic;
|
||||
|
||||
private readonly ISkillLogic _skillLogic;
|
||||
|
||||
public PluginsConvention()
|
||||
{
|
||||
_employeeLogic = new EmployeeLogic();
|
||||
_skillLogic = new SkillLogic();
|
||||
|
||||
krykovItemTable = new CustomDataGridView();
|
||||
var menu = new ContextMenuStrip();
|
||||
|
||||
var skillMenuItem = new ToolStripMenuItem("Формы");
|
||||
menu.Items.Add(skillMenuItem);
|
||||
|
||||
skillMenuItem.Click += (sender, e) =>
|
||||
{
|
||||
var formSkill = new FormSkill(_skillLogic);
|
||||
formSkill.ShowDialog();
|
||||
};
|
||||
|
||||
krykovItemTable.ContextMenuStrip = menu;
|
||||
ReloadData();
|
||||
}
|
||||
|
||||
/// Название плагина
|
||||
string IPluginsConvention.PluginName => PluginName();
|
||||
public string PluginName()
|
||||
{
|
||||
return "Сотрудники";
|
||||
}
|
||||
|
||||
public UserControl GetControl => krykovItemTable;
|
||||
|
||||
PluginsConventionElement IPluginsConvention.GetElement => GetElement();
|
||||
|
||||
public PluginsConventionElement GetElement()
|
||||
{
|
||||
var employee = krykovItemTable.GetSelectedObjectInRow<MainPluginConventionElement>(); ;
|
||||
MainPluginConventionElement element = null;
|
||||
|
||||
if (krykovItemTable != null)
|
||||
{
|
||||
element = new MainPluginConventionElement
|
||||
{
|
||||
Id = employee.Id,
|
||||
FIO = employee.FIO,
|
||||
PhoneNumber = employee.PhoneNumber,
|
||||
Photo = employee.Photo,
|
||||
Skill = employee.Skill,
|
||||
};
|
||||
}
|
||||
|
||||
return (new PluginsConventionElement { Id = element.Id });
|
||||
}
|
||||
|
||||
public Form GetForm(PluginsConventionElement element)
|
||||
{
|
||||
var formEmployee = new FormEmployee(_employeeLogic, _skillLogic);
|
||||
|
||||
if (element != null)
|
||||
{
|
||||
formEmployee.Id = element.Id;
|
||||
}
|
||||
|
||||
return formEmployee;
|
||||
}
|
||||
|
||||
public bool DeleteElement(PluginsConventionElement element)
|
||||
{
|
||||
try
|
||||
{
|
||||
_employeeLogic.Delete(new EmployeeBindingModel { Id = element.Id });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void ReloadData()
|
||||
{
|
||||
krykovItemTable.ClearDataGrid();
|
||||
krykovItemTable.ClearDataGrid();
|
||||
|
||||
krykovItemTable.ConfigColumn(new()
|
||||
{
|
||||
ColumnsCount = 4,
|
||||
NameColumn = new string[] { "Id", "ФИО", "Навык", "Номер телефона" },
|
||||
Width = new int[] { 10, 150, 250, 200 },
|
||||
Visible = new bool[] { false, true, true, true },
|
||||
PropertiesObject = new string[] { "Id", "FIO", "Skill", "PhoneNumber" }
|
||||
});
|
||||
|
||||
var list = _employeeLogic.Read(null);
|
||||
|
||||
if (list != null)
|
||||
{
|
||||
for (int j = 0; j < list.Count; j++)
|
||||
{
|
||||
krykovItemTable.AddItem(list[j], j);
|
||||
krykovItemTable.Update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private byte[] StringToImage(string bytes)
|
||||
{
|
||||
byte[] arrayimg = Convert.FromBase64String(bytes);
|
||||
return arrayimg;
|
||||
}
|
||||
|
||||
public bool CreateSimpleDocument(PluginsConventionSaveDocument saveDocument)
|
||||
{
|
||||
try
|
||||
{
|
||||
string fileName = "";
|
||||
|
||||
using (var dialog = new SaveFileDialog { Filter = "docx|*.docx" })
|
||||
{
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
fileName = dialog.FileName.ToString();
|
||||
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
|
||||
var list = _employeeLogic.Read(null);
|
||||
var list_images = new List<byte[]>();
|
||||
|
||||
foreach (var item in list)
|
||||
{
|
||||
var img = StringToImage(item.Photo);
|
||||
list_images.Add(img);
|
||||
}
|
||||
|
||||
WordWithImages wordWithImages = new WordWithImages();
|
||||
wordWithImages.CreateDoc(new WordWithImageConfig
|
||||
{
|
||||
FilePath = fileName,
|
||||
Header = "Фотографии:",
|
||||
Images = list_images
|
||||
});
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool CreateTableDocument(PluginsConventionSaveDocument saveDocument)
|
||||
{
|
||||
try
|
||||
{
|
||||
string fileName = "";
|
||||
|
||||
using (var dialog = new SaveFileDialog { Filter = "pdf|*.pdf" })
|
||||
{
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
fileName = dialog.FileName.ToString();
|
||||
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
|
||||
PdfTable componentTableToPdf = new PdfTable();
|
||||
componentTableToPdf.CreateDoc(new ComponentTableToPdfConfig<EmployeeViewModel>
|
||||
{
|
||||
FilePath = fileName,
|
||||
Header = "Таблица с сотрудниками",
|
||||
UseUnion = true,
|
||||
ColumnsRowsWidth = new List<(int, int)> { (20, 0), (20, 0), (20, 0), (20, 0) },
|
||||
ColumnUnion = new List<(int StartIndex, int Count)> { (2, 2) },
|
||||
|
||||
Headers = new List<(int ColumnIndex, int RowIndex, string Header, string PropertyName)>
|
||||
{
|
||||
(0, 0, "Идент.", "Id"),
|
||||
(1, 0, "ФИО", "FIO"),
|
||||
(2, 0, "Работа", ""),
|
||||
(2, 1, "Номер телефона", "PhoneNumber"),
|
||||
(3, 1, "Навык", "Skill")
|
||||
},
|
||||
|
||||
Data = _employeeLogic.Read(null)
|
||||
});
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool CreateChartDocument(PluginsConventionSaveDocument saveDocument)
|
||||
{
|
||||
try
|
||||
{
|
||||
string fileName = "";
|
||||
|
||||
using (var dialog = new SaveFileDialog { Filter = "xlsx|*.xlsx" })
|
||||
{
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
fileName = dialog.FileName.ToString();
|
||||
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
|
||||
var list2D = new List<(string Date, double Value)>();
|
||||
|
||||
var emps = _employeeLogic.Read(null);
|
||||
var skills = _skillLogic.Read(null);
|
||||
|
||||
foreach (var skill in skills)
|
||||
{
|
||||
double count = 0;
|
||||
|
||||
foreach (var emp in emps)
|
||||
{
|
||||
if (skill.Name.Equals(emp.Skill))
|
||||
{
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
var elem = (skill.Name, count);
|
||||
list2D.Add(elem);
|
||||
}
|
||||
|
||||
ExcelGistogram excelGistogram = new ExcelGistogram();
|
||||
|
||||
excelGistogram.CreateDoc(new()
|
||||
{
|
||||
FilePath = fileName,
|
||||
Header = "Chart",
|
||||
ChartTitle = "BarChart",
|
||||
LegendLocation = KryukovLib.Models.Location.Top,
|
||||
Data = new Dictionary<string, List<(string Date, double Value)>> {
|
||||
{ "Series 1", list2D }
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public Form GetThesaurus()
|
||||
{
|
||||
return new FormSkill(_skillLogic);
|
||||
}
|
||||
}
|
||||
}
|
50
Lab 4/Belianin_4/DesktopWithMyVisualComponents/Program.cs
Normal file
50
Lab 4/Belianin_4/DesktopWithMyVisualComponents/Program.cs
Normal file
@ -0,0 +1,50 @@
|
||||
using EnterpriseBusinessLogic.BusinessLogics;
|
||||
using EnterpriseContracts.BusinessLogicContracts;
|
||||
using EnterpriseContracts.StorageContracts;
|
||||
using EnterpriseDataBaseImplement.Implements;
|
||||
using Unity;
|
||||
using Unity.Lifetime;
|
||||
|
||||
namespace DesktopWithMyVisualComponents
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
private static IUnityContainer container = null;
|
||||
|
||||
public static IUnityContainer Container
|
||||
{
|
||||
get
|
||||
{
|
||||
if (container == null)
|
||||
{
|
||||
container = BuildUnityContainer();
|
||||
}
|
||||
return container;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
Application.SetHighDpiMode(HighDpiMode.SystemAware);
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.Run(Container.Resolve<FormMain>());
|
||||
}
|
||||
private static IUnityContainer BuildUnityContainer()
|
||||
{
|
||||
var currentContainer = new UnityContainer();
|
||||
|
||||
currentContainer.RegisterType<IEmployeeStorage, EmployeeStorage>(new HierarchicalLifetimeManager());
|
||||
currentContainer.RegisterType<ISkillStorage, SkillStorage>(new HierarchicalLifetimeManager());
|
||||
|
||||
currentContainer.RegisterType<IEmployeeLogic, EmployeeLogic>(new HierarchicalLifetimeManager());
|
||||
currentContainer.RegisterType<ISkillLogic, SkillLogic>(new HierarchicalLifetimeManager());
|
||||
|
||||
return currentContainer;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
<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>
|
||||
<ProjectReference Include="..\DesktopWithMyVisualComponents\DesktopWithMyVisualComponents.csproj" />
|
||||
<ProjectReference Include="..\EnterpriseContracts\EnterpriseContracts.csproj" />
|
||||
<ProjectReference Include="..\PluginsConventionLibrary\PluginsConventionLibrary.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Update="FormMain.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
184
Lab 4/Belianin_4/DesktopWithPlugins/FormMain.Designer.cs
generated
Normal file
184
Lab 4/Belianin_4/DesktopWithPlugins/FormMain.Designer.cs
generated
Normal file
@ -0,0 +1,184 @@
|
||||
namespace DesktopWithPlugins
|
||||
{
|
||||
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.ControlsStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.ActionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.DocsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.SimpleDocToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.TableDocToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.ChartDocToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.panelControl = new System.Windows.Forms.Panel();
|
||||
this.ThesaurusToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.AddElementToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.UpdElementToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.DelElementToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.menuStrip.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// menuStrip
|
||||
//
|
||||
this.menuStrip.Items.AddRange(new
|
||||
System.Windows.Forms.ToolStripItem[] {
|
||||
this.ControlsStripMenuItem,
|
||||
this.ActionsToolStripMenuItem,
|
||||
this.DocsToolStripMenuItem});
|
||||
this.menuStrip.Location = new System.Drawing.Point(0, 0);
|
||||
this.menuStrip.Name = "menuStrip";
|
||||
this.menuStrip.Size = new System.Drawing.Size(800, 24);
|
||||
this.menuStrip.TabIndex = 0;
|
||||
this.menuStrip.Text = "Меню";
|
||||
//
|
||||
// ControlsStripMenuItem
|
||||
//
|
||||
this.ControlsStripMenuItem.Name = "ControlsStripMenuItem";
|
||||
this.ControlsStripMenuItem.Size = new System.Drawing.Size(94, 20);
|
||||
this.ControlsStripMenuItem.Text = "Компоненты";
|
||||
//
|
||||
// ActionsToolStripMenuItem
|
||||
//
|
||||
this.ActionsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.ThesaurusToolStripMenuItem,
|
||||
this.AddElementToolStripMenuItem,
|
||||
this.UpdElementToolStripMenuItem,
|
||||
this.DelElementToolStripMenuItem});
|
||||
this.ActionsToolStripMenuItem.Name = "ActionsToolStripMenuItem";
|
||||
this.ActionsToolStripMenuItem.Size = new System.Drawing.Size(70, 20);
|
||||
this.ActionsToolStripMenuItem.Text = "Действия";
|
||||
//
|
||||
// DocsToolStripMenuItem
|
||||
//
|
||||
this.DocsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.SimpleDocToolStripMenuItem,
|
||||
this.TableDocToolStripMenuItem,
|
||||
this.ChartDocToolStripMenuItem});
|
||||
this.DocsToolStripMenuItem.Name = "DocsToolStripMenuItem";
|
||||
this.DocsToolStripMenuItem.Size = new System.Drawing.Size(82, 20);
|
||||
this.DocsToolStripMenuItem.Text = "Документы";
|
||||
//
|
||||
// SimpleDocToolStripMenuItem
|
||||
//
|
||||
this.SimpleDocToolStripMenuItem.Name = "SimpleDocToolStripMenuItem";
|
||||
this.SimpleDocToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.S)));
|
||||
this.SimpleDocToolStripMenuItem.Size = new System.Drawing.Size(233, 22);
|
||||
this.SimpleDocToolStripMenuItem.Text = "Простой документ";
|
||||
this.SimpleDocToolStripMenuItem.Click += new System.EventHandler(this.SimpleDocToolStripMenuItem_Click);
|
||||
//
|
||||
// TableDocToolStripMenuItem
|
||||
//
|
||||
this.TableDocToolStripMenuItem.Name = "TableDocToolStripMenuItem";
|
||||
this.TableDocToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.T)));
|
||||
this.TableDocToolStripMenuItem.Size = new System.Drawing.Size(233, 22);
|
||||
this.TableDocToolStripMenuItem.Text = "Документ с таблицей";
|
||||
this.TableDocToolStripMenuItem.Click += new System.EventHandler(this.TableDocToolStripMenuItem_Click);
|
||||
//
|
||||
// ChartDocToolStripMenuItem
|
||||
//
|
||||
this.ChartDocToolStripMenuItem.Name = "ChartDocToolStripMenuItem";
|
||||
this.ChartDocToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.C)));
|
||||
this.ChartDocToolStripMenuItem.Size = new System.Drawing.Size(233, 22);
|
||||
this.ChartDocToolStripMenuItem.Text = "Диаграмма";
|
||||
this.ChartDocToolStripMenuItem.Click += new System.EventHandler(this.ChartDocToolStripMenuItem_Click);
|
||||
//
|
||||
// panelControl
|
||||
//
|
||||
this.panelControl.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.panelControl.Location = new System.Drawing.Point(0, 24);
|
||||
this.panelControl.Name = "panelControl";
|
||||
this.panelControl.Size = new System.Drawing.Size(800, 426);
|
||||
this.panelControl.TabIndex = 1;
|
||||
//
|
||||
// ThesaurusToolStripMenuItem
|
||||
//
|
||||
this.ThesaurusToolStripMenuItem.Name = "ThesaurusToolStripMenuItem";
|
||||
this.ThesaurusToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.I)));
|
||||
this.ThesaurusToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||
this.ThesaurusToolStripMenuItem.Text = "Справочник";
|
||||
this.ThesaurusToolStripMenuItem.Click += new System.EventHandler(this.ThesaurusToolStripMenuItem_Click);
|
||||
//
|
||||
// AddElementToolStripMenuItem
|
||||
//
|
||||
this.AddElementToolStripMenuItem.Name = "AddElementToolStripMenuItem";
|
||||
this.AddElementToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.A)));
|
||||
this.AddElementToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||
this.AddElementToolStripMenuItem.Text = "Добавить";
|
||||
this.AddElementToolStripMenuItem.Click += new System.EventHandler(this.AddElementToolStripMenuItem_Click);
|
||||
//
|
||||
// UpdElementToolStripMenuItem
|
||||
//
|
||||
this.UpdElementToolStripMenuItem.Name = "UpdElementToolStripMenuItem";
|
||||
this.UpdElementToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.U)));
|
||||
this.UpdElementToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||
this.UpdElementToolStripMenuItem.Text = "Изменить";
|
||||
this.UpdElementToolStripMenuItem.Click += new System.EventHandler(this.UpdElementToolStripMenuItem_Click);
|
||||
//
|
||||
// DelElementToolStripMenuItem
|
||||
//
|
||||
this.DelElementToolStripMenuItem.Name = "DelElementToolStripMenuItem";
|
||||
this.DelElementToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.D)));
|
||||
this.DelElementToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||
this.DelElementToolStripMenuItem.Text = "Удалить";
|
||||
this.DelElementToolStripMenuItem.Click += new System.EventHandler(this.DelElementToolStripMenuItem_Click);
|
||||
//
|
||||
// FormMain
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Controls.Add(this.panelControl);
|
||||
this.Controls.Add(this.menuStrip);
|
||||
this.MainMenuStrip = this.menuStrip;
|
||||
this.Name = "FormMain";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "Главная форма";
|
||||
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
|
||||
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.FormMain_KeyDown);
|
||||
this.menuStrip.ResumeLayout(false);
|
||||
this.menuStrip.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.MenuStrip menuStrip;
|
||||
private System.Windows.Forms.ToolStripMenuItem ControlsStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem DocsToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem SimpleDocToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem TableDocToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem ChartDocToolStripMenuItem;
|
||||
private System.Windows.Forms.Panel panelControl;
|
||||
private System.Windows.Forms.ToolStripMenuItem ActionsToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem ThesaurusToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem AddElementToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem UpdElementToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem DelElementToolStripMenuItem;
|
||||
}
|
||||
}
|
245
Lab 4/Belianin_4/DesktopWithPlugins/FormMain.cs
Normal file
245
Lab 4/Belianin_4/DesktopWithPlugins/FormMain.cs
Normal file
@ -0,0 +1,245 @@
|
||||
using BelianinComponents;
|
||||
using BelianinComponents.Models;
|
||||
using EnterpriseContracts.BindingModels;
|
||||
using EnterpriseContracts.BusinessLogicContracts;
|
||||
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 System.Reflection;
|
||||
using PluginsConventionLibrary.Plugins;
|
||||
|
||||
namespace DesktopWithPlugins
|
||||
{
|
||||
public partial class FormMain : Form
|
||||
{
|
||||
private readonly Dictionary<string, IPluginsConvention> _plugins;
|
||||
|
||||
private string _selectedPlugin;
|
||||
|
||||
public FormMain()
|
||||
{
|
||||
InitializeComponent();
|
||||
_plugins = LoadPlugins();
|
||||
|
||||
_selectedPlugin = string.Empty;
|
||||
}
|
||||
|
||||
// Загрузка плагинов
|
||||
private Dictionary<string, IPluginsConvention> LoadPlugins()
|
||||
{
|
||||
var plugins = new Dictionary<string, IPluginsConvention>();
|
||||
|
||||
// Ищем в директории плагины, указан путь к каталогу
|
||||
string pluginsDir = Directory.GetParent(Directory.GetCurrentDirectory())!.Parent!.Parent!.FullName + "\\plugins";
|
||||
|
||||
// Получает файлы dll
|
||||
string[] dllFiles = Directory.GetFiles(pluginsDir, "*.dll", SearchOption.AllDirectories);
|
||||
|
||||
foreach (string dllFile in dllFiles)
|
||||
{
|
||||
try
|
||||
{
|
||||
/// Загрузка каждого dll
|
||||
Assembly assembly = Assembly.LoadFrom(dllFile);
|
||||
Type[] types = assembly.GetTypes();
|
||||
|
||||
foreach (var type in types)
|
||||
{
|
||||
// Поиск классов, которые реализуют интерфейс плагина
|
||||
if (typeof(IPluginsConvention).IsAssignableFrom(type) && !type.IsInterface)
|
||||
{
|
||||
var plugin = (IPluginsConvention)Activator.CreateInstance(type)!;
|
||||
plugins.Add(plugin.PluginName, plugin);
|
||||
CreateToolStripMenuItem(plugin.PluginName);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"Ошибка при загрузке сборки {dllFile}: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
return plugins;
|
||||
}
|
||||
|
||||
/// Создать ToolStripMenuItem для плагина (создание элементов меню)
|
||||
private void CreateToolStripMenuItem(string pluginName)
|
||||
{
|
||||
var menuItem = new ToolStripMenuItem(pluginName);
|
||||
menuItem.Click += (object? sender, EventArgs e) =>
|
||||
{
|
||||
_selectedPlugin = pluginName;
|
||||
|
||||
// Начало обработки выбранногоо плагина
|
||||
IPluginsConvention plugin = _plugins![pluginName];
|
||||
|
||||
// Get Control возвращает пользовательский элемент
|
||||
UserControl userControl = plugin.GetControl;
|
||||
|
||||
if (userControl != null)
|
||||
{
|
||||
// panelControl добавляет контейнер на котором происходит отображение интерфейса
|
||||
panelControl.Controls.Clear();
|
||||
plugin.ReloadData();
|
||||
userControl.Dock = DockStyle.Fill;
|
||||
panelControl.Controls.Add(userControl);
|
||||
}
|
||||
};
|
||||
|
||||
ControlsStripMenuItem.DropDownItems.Add(menuItem);
|
||||
}
|
||||
|
||||
private void FormMain_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (!e.Control)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
switch (e.KeyCode)
|
||||
{
|
||||
case Keys.I:
|
||||
ShowThesaurus();
|
||||
break;
|
||||
case Keys.A:
|
||||
AddNewElement();
|
||||
break;
|
||||
case Keys.U:
|
||||
UpdateElement();
|
||||
break;
|
||||
case Keys.D:
|
||||
DeleteElement();
|
||||
break;
|
||||
case Keys.S:
|
||||
CreateSimpleDoc();
|
||||
break;
|
||||
case Keys.T:
|
||||
CreateTableDoc();
|
||||
break;
|
||||
case Keys.C:
|
||||
CreateChartDoc();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/// Отобразить форму для работы со справочником
|
||||
private void ShowThesaurus()
|
||||
{
|
||||
_plugins[_selectedPlugin].GetThesaurus()?.Show();
|
||||
}
|
||||
|
||||
private void AddNewElement()
|
||||
{
|
||||
var form = _plugins[_selectedPlugin].GetForm(null);
|
||||
|
||||
if (form != null && form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
_plugins[_selectedPlugin].ReloadData();
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateElement()
|
||||
{
|
||||
var element = _plugins[_selectedPlugin].GetElement;
|
||||
|
||||
if (element == null)
|
||||
{
|
||||
MessageBox.Show("Нет выбранного элемента", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
var form = _plugins[_selectedPlugin].GetForm(element);
|
||||
if (form != null && form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
_plugins[_selectedPlugin].ReloadData();
|
||||
}
|
||||
}
|
||||
|
||||
private void DeleteElement()
|
||||
{
|
||||
if (MessageBox.Show("Удалить выбранный элемент", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var element = _plugins[_selectedPlugin].GetElement;
|
||||
|
||||
if (element == null)
|
||||
{
|
||||
MessageBox.Show("Нет выбранного элемента", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (_plugins[_selectedPlugin].DeleteElement(element))
|
||||
{
|
||||
_plugins[_selectedPlugin].ReloadData();
|
||||
}
|
||||
}
|
||||
|
||||
/// Создать простой документ
|
||||
private void CreateSimpleDoc()
|
||||
{
|
||||
if (_plugins[_selectedPlugin].CreateSimpleDocument(new PluginsConventionSaveDocument()))
|
||||
{
|
||||
MessageBox.Show("Документ сохранен", "Создание документа", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Ошибка при создании документа", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
/// Создать документ с настраиваемой таблицей
|
||||
private void CreateTableDoc()
|
||||
{
|
||||
if (_plugins[_selectedPlugin].CreateTableDocument(new PluginsConventionSaveDocument()))
|
||||
{
|
||||
MessageBox.Show("Документ сохранен", "Создание документа", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Ошибка при создании документа", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
/// Создать документ с диаграммой
|
||||
private void CreateChartDoc()
|
||||
{
|
||||
if (_plugins[_selectedPlugin].CreateChartDocument(new PluginsConventionSaveDocument()))
|
||||
{
|
||||
MessageBox.Show("Документ сохранен", "Создание документа", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Ошибка при создании документа", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
/// Отобразить форму для работы со справочником
|
||||
private void ThesaurusToolStripMenuItem_Click(object sender, EventArgs e) => ShowThesaurus();
|
||||
|
||||
/// Создать элемент
|
||||
private void AddElementToolStripMenuItem_Click(object sender, EventArgs e) => AddNewElement();
|
||||
|
||||
/// Редактировать элемент
|
||||
private void UpdElementToolStripMenuItem_Click(object sender, EventArgs e) => UpdateElement();
|
||||
|
||||
/// Удалить элемент
|
||||
private void DelElementToolStripMenuItem_Click(object sender, EventArgs e) => DeleteElement();
|
||||
|
||||
/// Создать простой документ
|
||||
private void SimpleDocToolStripMenuItem_Click(object sender, EventArgs e) => CreateSimpleDoc();
|
||||
|
||||
/// Создать документ с настраиваемой таблицей
|
||||
private void TableDocToolStripMenuItem_Click(object sender, EventArgs e) => CreateTableDoc();
|
||||
|
||||
/// Создать документ с диаграммой
|
||||
private void ChartDocToolStripMenuItem_Click(object sender, EventArgs e) => CreateChartDoc();
|
||||
}
|
||||
}
|
69
Lab 4/Belianin_4/DesktopWithPlugins/FormMain.resx
Normal file
69
Lab 4/Belianin_4/DesktopWithPlugins/FormMain.resx
Normal file
@ -0,0 +1,69 @@
|
||||
<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="wordWithImages.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="wordWithTable.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>161, 17</value>
|
||||
</metadata>
|
||||
<metadata name="wordWithDiagram.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>295, 17</value>
|
||||
</metadata>
|
||||
</root>
|
24
Lab 4/Belianin_4/DesktopWithPlugins/Program.cs
Normal file
24
Lab 4/Belianin_4/DesktopWithPlugins/Program.cs
Normal file
@ -0,0 +1,24 @@
|
||||
using EnterpriseBusinessLogic.BusinessLogics;
|
||||
using EnterpriseContracts.BusinessLogicContracts;
|
||||
using EnterpriseContracts.StorageContracts;
|
||||
using EnterpriseDataBaseImplement.Implements;
|
||||
using Unity;
|
||||
using Unity.Lifetime;
|
||||
|
||||
namespace DesktopWithPlugins
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
// To customize application configuration such as set high DPI settings or default font,
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
ApplicationConfiguration.Initialize();
|
||||
Application.Run(new FormMain());
|
||||
}
|
||||
}
|
||||
}
|
BIN
Lab 4/Belianin_4/DesktopWithPlugins/plugins/Azure.Core.dll
Normal file
BIN
Lab 4/Belianin_4/DesktopWithPlugins/plugins/Azure.Core.dll
Normal file
Binary file not shown.
BIN
Lab 4/Belianin_4/DesktopWithPlugins/plugins/Azure.Identity.dll
Normal file
BIN
Lab 4/Belianin_4/DesktopWithPlugins/plugins/Azure.Identity.dll
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Lab 4/Belianin_4/DesktopWithPlugins/plugins/Humanizer.dll
Normal file
BIN
Lab 4/Belianin_4/DesktopWithPlugins/plugins/Humanizer.dll
Normal file
Binary file not shown.
BIN
Lab 4/Belianin_4/DesktopWithPlugins/plugins/KryukovLib.dll
Normal file
BIN
Lab 4/Belianin_4/DesktopWithPlugins/plugins/KryukovLib.dll
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Lab 4/Belianin_4/DesktopWithPlugins/plugins/PdfSharp-gdi.dll
Normal file
BIN
Lab 4/Belianin_4/DesktopWithPlugins/plugins/PdfSharp-gdi.dll
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Lab 4/Belianin_4/DesktopWithPlugins/plugins/PdfSharp.System.dll
Normal file
BIN
Lab 4/Belianin_4/DesktopWithPlugins/plugins/PdfSharp.System.dll
Normal file
Binary file not shown.
BIN
Lab 4/Belianin_4/DesktopWithPlugins/plugins/PdfSharp.WPFonts.dll
Normal file
BIN
Lab 4/Belianin_4/DesktopWithPlugins/plugins/PdfSharp.WPFonts.dll
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Lab 4/Belianin_4/DesktopWithPlugins/plugins/System.Text.Json.dll
Normal file
BIN
Lab 4/Belianin_4/DesktopWithPlugins/plugins/System.Text.Json.dll
Normal file
Binary file not shown.
Binary file not shown.
BIN
Lab 4/Belianin_4/DesktopWithPlugins/plugins/Unity.Container.dll
Normal file
BIN
Lab 4/Belianin_4/DesktopWithPlugins/plugins/Unity.Container.dll
Normal file
Binary file not shown.
@ -0,0 +1,89 @@
|
||||
using EnterpriseContracts.BindingModels;
|
||||
using EnterpriseContracts.BusinessLogicContracts;
|
||||
using EnterpriseContracts.StorageContracts;
|
||||
using EnterpriseContracts.ViewModels;
|
||||
using EnterpriseDataBaseImplement.Implements;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace EnterpriseBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class EmployeeLogic : IEmployeeLogic
|
||||
{
|
||||
private readonly IEmployeeStorage _employeeStorage;
|
||||
|
||||
public EmployeeLogic()
|
||||
{
|
||||
_employeeStorage = new EmployeeStorage();
|
||||
}
|
||||
|
||||
public EmployeeLogic(IEmployeeStorage employeeStorage)
|
||||
{
|
||||
_employeeStorage = employeeStorage;
|
||||
}
|
||||
|
||||
// Создание и обновление записи о работнике
|
||||
public void CreateOrUpdate(EmployeeBindingModel model)
|
||||
{
|
||||
var element = _employeeStorage.GetElement(new EmployeeBindingModel
|
||||
{
|
||||
FIO = model.FIO
|
||||
});
|
||||
|
||||
if (element != null && element.Id != model.Id)
|
||||
{
|
||||
throw new Exception("Сотрудник с таким именем уже существует");
|
||||
}
|
||||
|
||||
// Если уже создан, то обновляем, иначе создаём
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
_employeeStorage.Update(model);
|
||||
}
|
||||
else
|
||||
{
|
||||
_employeeStorage.Insert(model);
|
||||
}
|
||||
}
|
||||
|
||||
// Удаление записи о работнике
|
||||
public void Delete(EmployeeBindingModel model)
|
||||
{
|
||||
var element = _employeeStorage.GetElement(new EmployeeBindingModel
|
||||
{
|
||||
Id = model.Id
|
||||
});
|
||||
|
||||
if (element == null)
|
||||
{
|
||||
throw new Exception("Сотрудник не найден");
|
||||
}
|
||||
|
||||
_employeeStorage.Delete(model);
|
||||
}
|
||||
|
||||
// Чтение записей о работнике
|
||||
public List<EmployeeViewModel> Read(EmployeeBindingModel model)
|
||||
{
|
||||
// Если неконкретная запись, то выводим все
|
||||
if (model == null)
|
||||
{
|
||||
return _employeeStorage.GetFullList();
|
||||
}
|
||||
|
||||
// Если конкретная запись о навыке
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
return new List<EmployeeViewModel>
|
||||
{
|
||||
_employeeStorage.GetElement(model)
|
||||
};
|
||||
}
|
||||
|
||||
return _employeeStorage.GetFullList();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,95 @@
|
||||
using EnterpriseContracts.BindingModels;
|
||||
using EnterpriseContracts.BusinessLogicContracts;
|
||||
using EnterpriseContracts.StorageContracts;
|
||||
using EnterpriseContracts.ViewModels;
|
||||
using EnterpriseDataBaseImplement.Implements;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace EnterpriseBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class SkillLogic : ISkillLogic
|
||||
{
|
||||
private readonly ISkillStorage _skillStorage;
|
||||
|
||||
public SkillLogic()
|
||||
{
|
||||
_skillStorage = new SkillStorage();
|
||||
}
|
||||
|
||||
public SkillLogic(ISkillStorage skillStorage)
|
||||
{
|
||||
_skillStorage = skillStorage;
|
||||
}
|
||||
|
||||
// Создание и обновление записи о навыке
|
||||
public void CreateOrUpdate(SkillBindingModel model)
|
||||
{
|
||||
var element = _skillStorage.GetElement(
|
||||
new SkillBindingModel
|
||||
{
|
||||
Name = model.Name
|
||||
});
|
||||
|
||||
if (element != null && element.Id != model.Id)
|
||||
{
|
||||
throw new Exception("Такой навык уже существует");
|
||||
}
|
||||
|
||||
// Если уже создан, то обновляем, иначе создаём
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
_skillStorage.Update(model);
|
||||
}
|
||||
else
|
||||
{
|
||||
_skillStorage.Insert(model);
|
||||
}
|
||||
}
|
||||
|
||||
// Удаление записи о навыке
|
||||
public bool Delete(SkillBindingModel model)
|
||||
{
|
||||
var element = _skillStorage.GetElement(new SkillBindingModel
|
||||
{
|
||||
Id = model.Id
|
||||
});
|
||||
|
||||
if (element == null)
|
||||
{
|
||||
throw new Exception("Навык не найден");
|
||||
}
|
||||
|
||||
if (_skillStorage.Delete(model) == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Чтение записей о навыках
|
||||
public List<SkillViewModel> Read(SkillBindingModel model)
|
||||
{
|
||||
// Если неконкретная запись, то выводим все
|
||||
if (model == null)
|
||||
{
|
||||
return _skillStorage.GetFullList();
|
||||
}
|
||||
|
||||
// Если конкретная запись о навыке
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
return new List<SkillViewModel>
|
||||
{
|
||||
_skillStorage.GetElement(model)
|
||||
};
|
||||
}
|
||||
|
||||
return _skillStorage.GetFilteredList(model);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\EnterpriseContracts\EnterpriseContracts.csproj" />
|
||||
<ProjectReference Include="..\EnterpriseDataBaseImplement\EnterpriseDataBaseImplement.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace EnterpriseContracts.BindingModels
|
||||
{
|
||||
public class EmployeeBindingModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
|
||||
public string Skill { get; set; }
|
||||
|
||||
public string Photo { get; set; }
|
||||
|
||||
public string FIO { get; set; }
|
||||
|
||||
public string PhoneNumber { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace EnterpriseContracts.BindingModels
|
||||
{
|
||||
public class SkillBindingModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
using EnterpriseContracts.BindingModels;
|
||||
using EnterpriseContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace EnterpriseContracts.BusinessLogicContracts
|
||||
{
|
||||
public interface IEmployeeLogic
|
||||
{
|
||||
List<EmployeeViewModel> Read(EmployeeBindingModel model);
|
||||
|
||||
void CreateOrUpdate(EmployeeBindingModel model);
|
||||
|
||||
void Delete(EmployeeBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
using EnterpriseContracts.BindingModels;
|
||||
using EnterpriseContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace EnterpriseContracts.BusinessLogicContracts
|
||||
{
|
||||
public interface ISkillLogic
|
||||
{
|
||||
List<SkillViewModel> Read(SkillBindingModel model);
|
||||
|
||||
void CreateOrUpdate(SkillBindingModel model);
|
||||
|
||||
bool Delete(SkillBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
@ -0,0 +1,25 @@
|
||||
using EnterpriseContracts.BindingModels;
|
||||
using EnterpriseContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace EnterpriseContracts.StorageContracts
|
||||
{
|
||||
public interface IEmployeeStorage
|
||||
{
|
||||
List<EmployeeViewModel> GetFullList();
|
||||
|
||||
List<EmployeeViewModel> GetFilteredList(EmployeeBindingModel model);
|
||||
|
||||
EmployeeViewModel GetElement(EmployeeBindingModel model);
|
||||
|
||||
void Insert(EmployeeBindingModel model);
|
||||
|
||||
void Update(EmployeeBindingModel model);
|
||||
|
||||
void Delete(EmployeeBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
using EnterpriseContracts.BindingModels;
|
||||
using EnterpriseContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace EnterpriseContracts.StorageContracts
|
||||
{
|
||||
public interface ISkillStorage
|
||||
{
|
||||
List<SkillViewModel> GetFullList();
|
||||
|
||||
List<SkillViewModel> GetFilteredList(SkillBindingModel model);
|
||||
|
||||
SkillViewModel GetElement(SkillBindingModel model);
|
||||
|
||||
void Insert(SkillBindingModel model);
|
||||
|
||||
void Update(SkillBindingModel model);
|
||||
|
||||
bool Delete(SkillBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace EnterpriseContracts.ViewModels
|
||||
{
|
||||
public class EmployeeViewModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
|
||||
[DisplayName("Навык")]
|
||||
public string Skill { get; set; }
|
||||
|
||||
// [DisplayName("Фото")]
|
||||
public string Photo { get; set; }
|
||||
|
||||
[DisplayName("ФИО")]
|
||||
public string FIO { get; set; }
|
||||
|
||||
[DisplayName("Номер телефона")]
|
||||
public string PhoneNumber { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace EnterpriseContracts.ViewModels
|
||||
{
|
||||
public class SkillViewModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
using EnterpriseDataBaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace EnterpriseDataBaseImplement
|
||||
{
|
||||
public class EnterpriseDataBase : DbContext
|
||||
{
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
if (optionsBuilder.IsConfigured == false)
|
||||
{
|
||||
optionsBuilder.UseSqlServer(@"Data Source=localhost\SQLEXPRESS;Initial Catalog=EnterpriseDataBase;Integrated Security=True;MultipleActiveResultSets=True; TrustServerCertificate=True");
|
||||
}
|
||||
|
||||
base.OnConfiguring(optionsBuilder);
|
||||
}
|
||||
|
||||
public virtual DbSet<Employee> Employees { set; get; }
|
||||
|
||||
public virtual DbSet<Skill> Skills { set; get; }
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.11" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Analyzers" Version="7.0.11" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.11">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.11" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.11">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\EnterpriseContracts\EnterpriseContracts.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -0,0 +1,136 @@
|
||||
using EnterpriseContracts.BindingModels;
|
||||
using EnterpriseContracts.StorageContracts;
|
||||
using EnterpriseContracts.ViewModels;
|
||||
using EnterpriseDataBaseImplement.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace EnterpriseDataBaseImplement.Implements
|
||||
{
|
||||
public class EmployeeStorage : IEmployeeStorage
|
||||
{
|
||||
// Создание работника
|
||||
private static Employee CreateModel(EmployeeBindingModel model, Employee employee)
|
||||
{
|
||||
employee.FIO = model.FIO;
|
||||
employee.Skill = model.Skill;
|
||||
employee.PhoneNumber = model.PhoneNumber;
|
||||
employee.Photo = model.Photo;
|
||||
|
||||
return employee;
|
||||
}
|
||||
|
||||
private static EmployeeViewModel CreateModel(Employee employee)
|
||||
{
|
||||
return new EmployeeViewModel
|
||||
{
|
||||
Id = employee.Id,
|
||||
FIO = employee.FIO,
|
||||
Photo = employee.Photo,
|
||||
PhoneNumber = employee.PhoneNumber,
|
||||
Skill = employee.Skill
|
||||
};
|
||||
}
|
||||
|
||||
// Добавление работника
|
||||
public void Insert(EmployeeBindingModel model)
|
||||
{
|
||||
var context = new EnterpriseDataBase();
|
||||
var transaction = context.Database.BeginTransaction();
|
||||
|
||||
try
|
||||
{
|
||||
context.Employees.Add(CreateModel(model, new Employee()));
|
||||
context.SaveChanges();
|
||||
transaction.Commit();
|
||||
}
|
||||
catch
|
||||
{
|
||||
transaction.Rollback();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
// Обновление данных о работнике
|
||||
public void Update(EmployeeBindingModel model)
|
||||
{
|
||||
var context = new EnterpriseDataBase();
|
||||
var transaction = context.Database.BeginTransaction();
|
||||
|
||||
try
|
||||
{
|
||||
var employee = context.Employees.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
|
||||
if (employee == null)
|
||||
{
|
||||
throw new Exception("Сотрудник не найден");
|
||||
}
|
||||
|
||||
CreateModel(model, employee);
|
||||
context.SaveChanges();
|
||||
transaction.Commit();
|
||||
}
|
||||
catch
|
||||
{
|
||||
transaction.Rollback();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public void Delete(EmployeeBindingModel model)
|
||||
{
|
||||
var context = new EnterpriseDataBase();
|
||||
var employee = context.Employees.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
|
||||
if (employee != null)
|
||||
{
|
||||
context.Employees.Remove(employee);
|
||||
context.SaveChanges();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Сотрудник не найден");
|
||||
}
|
||||
}
|
||||
|
||||
// Получение записи о работнике
|
||||
public EmployeeViewModel GetElement(EmployeeBindingModel model)
|
||||
{
|
||||
// Если пусто
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
using var context = new EnterpriseDataBase();
|
||||
|
||||
var employee = context.Employees.ToList()
|
||||
.FirstOrDefault(rec => rec.FIO == model.FIO || rec.Id == model.Id);
|
||||
|
||||
return employee != null ? CreateModel(employee) : null;
|
||||
}
|
||||
|
||||
// Получение отфильтрованного списка
|
||||
public List<EmployeeViewModel> GetFilteredList(EmployeeBindingModel model)
|
||||
{
|
||||
var context = new EnterpriseDataBase();
|
||||
|
||||
return context.Employees
|
||||
.Where(employee => employee.FIO.Contains(model.FIO) && employee.Skill.Contains(model.Skill))
|
||||
.ToList().Select(CreateModel).ToList();
|
||||
}
|
||||
|
||||
// Получение всех записей
|
||||
public List<EmployeeViewModel> GetFullList()
|
||||
{
|
||||
using (var context = new EnterpriseDataBase())
|
||||
{
|
||||
return context.Employees.ToList()
|
||||
.Select(CreateModel).ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,133 @@
|
||||
using EnterpriseContracts.BindingModels;
|
||||
using EnterpriseContracts.StorageContracts;
|
||||
using EnterpriseContracts.ViewModels;
|
||||
using EnterpriseDataBaseImplement.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace EnterpriseDataBaseImplement.Implements
|
||||
{
|
||||
public class SkillStorage : ISkillStorage
|
||||
{
|
||||
// Создание навыка
|
||||
private static Skill CreateModel(SkillBindingModel model, Skill skill)
|
||||
{
|
||||
skill.Name = model.Name;
|
||||
return skill;
|
||||
}
|
||||
|
||||
private static SkillViewModel CreateModel(Skill skill)
|
||||
{
|
||||
return new SkillViewModel
|
||||
{
|
||||
Id = skill.Id,
|
||||
Name = skill.Name
|
||||
};
|
||||
}
|
||||
|
||||
// Добавление навыка
|
||||
public void Insert(SkillBindingModel model)
|
||||
{
|
||||
var context = new EnterpriseDataBase();
|
||||
var transaction = context.Database.BeginTransaction();
|
||||
|
||||
try
|
||||
{
|
||||
context.Skills.Add(CreateModel(model, new Skill()));
|
||||
context.SaveChanges();
|
||||
transaction.Commit();
|
||||
}
|
||||
catch
|
||||
{
|
||||
transaction.Rollback();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
// Обновление навыка
|
||||
public void Update(SkillBindingModel model)
|
||||
{
|
||||
var context = new EnterpriseDataBase();
|
||||
var transaction = context.Database.BeginTransaction();
|
||||
|
||||
try
|
||||
{
|
||||
var skill = context.Skills.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
|
||||
// Навык не найден -> исключение
|
||||
if (skill == null)
|
||||
{
|
||||
throw new Exception("Навык не найден :(");
|
||||
}
|
||||
|
||||
CreateModel(model, skill);
|
||||
context.SaveChanges();
|
||||
transaction.Commit();
|
||||
}
|
||||
catch
|
||||
{
|
||||
transaction.Rollback();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
// Удаление навыка
|
||||
public bool Delete(SkillBindingModel model)
|
||||
{
|
||||
var context = new EnterpriseDataBase();
|
||||
var skill = context.Skills.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
|
||||
if (skill != null)
|
||||
{
|
||||
context.Skills.Remove(skill);
|
||||
context.SaveChanges();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Навык не найден");
|
||||
}
|
||||
}
|
||||
|
||||
// Получение записи о навыке
|
||||
public SkillViewModel GetElement(SkillBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
using var context = new EnterpriseDataBase();
|
||||
|
||||
var skill = context.Skills.ToList().FirstOrDefault(rec => rec.Id == model.Id || rec.Name == model.Name);
|
||||
|
||||
return skill != null ? CreateModel(skill) : null;
|
||||
}
|
||||
|
||||
// Получение фильтрованного списка
|
||||
public List<SkillViewModel> GetFilteredList(SkillBindingModel model)
|
||||
{
|
||||
// Если пусто
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var context = new EnterpriseDataBase();
|
||||
|
||||
return context.Skills.Where(rec => rec.Name.Contains(model.Name))
|
||||
.Select(CreateModel).ToList();
|
||||
}
|
||||
|
||||
// Получение всего списка навыков
|
||||
public List<SkillViewModel> GetFullList()
|
||||
{
|
||||
using var context = new EnterpriseDataBase();
|
||||
|
||||
return context.Skills.Select(CreateModel).ToList();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace EnterpriseDataBaseImplement.Models
|
||||
{
|
||||
public class Employee
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public string Skill { get; set; }
|
||||
|
||||
[Required]
|
||||
public string Photo { get; set; }
|
||||
|
||||
[Required]
|
||||
public string FIO { get; set; }
|
||||
|
||||
[Required]
|
||||
public string PhoneNumber { get; set; }
|
||||
}
|
||||
}
|
17
Lab 4/Belianin_4/EnterpriseDataBaseImplement/Models/Skill.cs
Normal file
17
Lab 4/Belianin_4/EnterpriseDataBaseImplement/Models/Skill.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace EnterpriseDataBaseImplement.Models
|
||||
{
|
||||
public class Skill
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public string Name { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PluginsConventionLibrary.Plugins
|
||||
{
|
||||
public interface IPluginsConvention
|
||||
{
|
||||
/// Название плагина
|
||||
string PluginName { get; }
|
||||
|
||||
/// Получение контрола для вывода набора данных
|
||||
UserControl GetControl { get; }
|
||||
|
||||
/// Получение элемента, выбранного в контроле
|
||||
PluginsConventionElement GetElement { get; }
|
||||
|
||||
/// Получение формы для создания/редактирования объекта
|
||||
Form GetForm(PluginsConventionElement element);
|
||||
|
||||
/// Получение формы для работы со справочником
|
||||
Form GetThesaurus();
|
||||
|
||||
/// Удаление элемента
|
||||
bool DeleteElement(PluginsConventionElement element);
|
||||
|
||||
/// Обновление набора данных в контроле
|
||||
void ReloadData();
|
||||
|
||||
/// Создание простого документа
|
||||
bool CreateSimpleDocument(PluginsConventionSaveDocument saveDocument);
|
||||
|
||||
/// Создание простого документа (таблицы)
|
||||
bool CreateTableDocument(PluginsConventionSaveDocument saveDocument);
|
||||
|
||||
/// Создание простого документа (диаграммы)
|
||||
bool CreateChartDocument(PluginsConventionSaveDocument saveDocument);
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
using PluginsConventionLibrary.Plugins;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PluginsConventionLibrary
|
||||
{
|
||||
public class MainPluginConventionElement : PluginsConventionElement
|
||||
{
|
||||
public string Skill { get; set; }
|
||||
|
||||
public string Photo { get; set; }
|
||||
|
||||
public string FIO { get; set; }
|
||||
|
||||
public string PhoneNumber { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PluginsConventionLibrary.Plugins
|
||||
{
|
||||
// Класс для передачи объекта на форму и удаления
|
||||
public class PluginsConventionElement
|
||||
{
|
||||
// Глобальный уникальный идентификатор
|
||||
public int Id { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PluginsConventionLibrary.Plugins
|
||||
{
|
||||
public class PluginsConventionSaveDocument
|
||||
{
|
||||
public string FileName { get; set; }
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user