Compare commits

..

33 Commits
main ... Laba3

Author SHA1 Message Date
cc06a1a703 fgd 2024-12-23 08:29:44 +04:00
5c8d21f228 r 2024-12-23 08:07:59 +04:00
2af45433fa asd 2024-12-23 07:34:02 +04:00
05e69af98d s 2024-12-22 22:40:07 +04:00
d2d9219957 Скоректироваль 2024-12-22 21:47:25 +04:00
0d7216a9a0 Для красоты 2024-12-22 21:36:43 +04:00
71e7a114de Чутка подправил 2024-12-22 21:22:33 +04:00
df2cdb9c0e ААААААААААААААААААААААААААААААААААААаа 2024-12-16 22:14:44 +04:00
718ef76f20 Много шагов 2024-12-16 21:10:06 +04:00
2ccb3f1956 Merge branch 'Laba2' into Laba3 2024-12-14 20:20:44 +04:00
43d383e34a Хнык... 2024-12-14 20:19:56 +04:00
c8356c5d02 АААААА х2 2024-12-14 20:06:15 +04:00
fe2dc84b65 АААА 2024-12-14 19:59:45 +04:00
ab55cec4ef ААААААА 2024-12-14 19:59:25 +04:00
d8e396a649 Дичь 2024-12-14 19:57:12 +04:00
9214fd3879 Продолжение цепочки исправлений 2024-12-14 19:50:07 +04:00
6c11146c7e Добавил зависимость сотрудника к типу работы 2024-12-14 19:47:23 +04:00
e3edb20bb8 Ужс 2024-12-14 19:11:02 +04:00
37f7893c03 Merge branch 'Laba2' into Laba3 2024-12-14 17:34:30 +04:00
9cc5412c9e Чуть-чуть переделал кое-гже 2024-12-14 17:33:45 +04:00
3870a8c0f7 Сделал справочники, недоделал штуку побольшеб 2024-12-14 17:31:22 +04:00
410b1f42ab Усе 2024-12-07 22:19:48 +04:00
46f953858d Merge branch 'Laba1' into Laba2 2024-12-07 22:04:05 +04:00
90437340b3 Поймаль ошибку 2024-12-07 22:02:38 +04:00
c5b53aac84 Исправление формыы работы с проектами 2024-12-07 22:01:43 +04:00
2bb556bc3f Что-то было сделано 2024-12-07 21:24:10 +04:00
44c4998db1 Merge branch 'Laba1' into Laba2 2024-11-24 23:35:15 +04:00
57651f249a Исправление недачетов в операциях 2024-11-24 23:10:15 +04:00
cd79ab9f26 Реализация сущностей 2024-11-24 23:08:46 +04:00
736b16822b Доделал. Отправляю... 2024-11-16 19:20:12 +04:00
d5a10abe57 Доработка оп 1 лабе 2024-11-13 10:49:04 +04:00
8e14ffaef6 Добавление форм по учету времени 2024-11-12 16:17:11 +04:00
68715a92d9 1 лаба усе 2024-11-12 15:38:39 +04:00
89 changed files with 7579 additions and 77 deletions

View File

@ -9,4 +9,47 @@
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<None Remove="Reports\WordBuilder.cs~RF53e3db5.TMP" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Dapper" Version="2.1.35" />
<PackageReference Include="DocumentFormat.OpenXml" Version="3.1.1" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Npgsql" Version="9.0.1" />
<PackageReference Include="PdfSharp.MigraDoc.Standard" Version="1.51.15" />
<PackageReference Include="Serilog" Version="4.0.2" />
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.4" />
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
<PackageReference Include="System.Data.SqlClient" Version="4.9.0" />
<PackageReference Include="Unity" Version="5.11.10" />
<PackageReference Include="Unity.Microsoft.Logging" Version="5.11.1" />
</ItemGroup>
<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Update="appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

View File

@ -0,0 +1,21 @@

namespace Accounting_Time_It_Company.Entities;
public class Client
{
public int Id { get; private set; }
public string NameClient { get; private set; } = string.Empty;
public string Phone { get; private set; } = string.Empty;
public static Client CreateEntity(int id, string nameClaent, string phone)
{
return new Client
{
Id = id,
NameClient = nameClaent,
Phone = phone
};
}
}

View File

@ -0,0 +1,27 @@

namespace Accounting_Time_It_Company.Entities;
public class Employee
{
public int Id { get; private set; }
public int PostId { get; private set; }
public string Name { get; private set; } = string.Empty;
public string Phone { get; private set; } = string.Empty;
public float Allowance { get; private set; }
public static Employee CreateEntity(int id, int postId, string name, string phone, float allowance)
{
return new Employee
{
Id = id,
PostId = postId,
Name = name,
Phone = phone,
Allowance = allowance,
};
}
}

View File

@ -0,0 +1,9 @@
namespace Accounting_Time_It_Company.Entities.Enums;
public enum TypePost
{
None = 0,
Developer = 1,
Manager = 2,
Director = 3
}

View File

@ -0,0 +1,14 @@

namespace Accounting_Time_It_Company.Entities.Enums;
[Flags]
public enum TypeProduct
{
None = 0,
Development = 1,
Suppurt = 2,
Supervision = 4
}

View File

@ -0,0 +1,25 @@
using Accounting_Time_It_Company.Entities.Enums;
namespace Accounting_Time_It_Company.Entities;
public class Post
{
public int Id { get; private set; }
public TypePost NamePost { get; private set; }
public string LevelPost { get; private set; } = string.Empty;
public int Wage { get; private set; }
public static Post CreateEntity(int id, TypePost namePost, string levelPost, int wage)
{
return new Post
{
Id = id,
NamePost = namePost,
LevelPost = levelPost,
Wage = wage
};
}
}

View File

@ -0,0 +1,25 @@
using Accounting_Time_It_Company.Entities.Enums;
namespace Accounting_Time_It_Company.Entities;
public class Product
{
public int Id { get; private set; }
public int ClientId { get; private set; }
public string Name { get; private set; } = string.Empty;
public TypeProduct Type { get; private set; }
public static Product CreateEntity(int id, int clientId, string name, TypeProduct type)
{
return new Product
{
Id = id,
ClientId = clientId,
Name = name,
Type = type
};
}
}

View File

@ -0,0 +1,17 @@

using Accounting_Time_It_Company.Entities.Enums;
namespace Accounting_Time_It_Company.Entities;
public class TempWorkTime
{
public int Id { get; private set; }
public int ProductId { get; private set; }
public int DirectorId { get; private set; }
public string Description { get; private set; } = string.Empty;
public int AllowanceForJob { get; private set; }
public DateTime Date { get; private set; }
public int EmployeeId { get; private set; }
public int Hours { get; private set; }
public TypePost NamePost { get; private set; }
}

View File

@ -0,0 +1,53 @@

namespace Accounting_Time_It_Company.Entities;
public class TypeJob
{
public int Id { get; private set; }
public int ProductId { get; private set; }
public int DirectorId { get; private set; }
public string Description { get; private set; } = string.Empty;
public int AllowanceForJob { get; private set; }
public DateTime Date { get; private set; }
public IEnumerable<WorkTime> WorkTimesDevelop { get; private set; } = [];
public IEnumerable<WorkTime> WorkTimesManager { get; private set; } = [];
public static TypeJob CreateOperation(int id, int productId, int directorId, string discription, int allowanceForJob,
IEnumerable<WorkTime> workTimesDevelop, IEnumerable<WorkTime> workTimesManager)
{
return new TypeJob
{
Id = id,
ProductId = productId,
DirectorId = directorId,
Description = discription,
AllowanceForJob = allowanceForJob,
Date = DateTime.Now,
WorkTimesDevelop = workTimesDevelop,
WorkTimesManager = workTimesManager
};
}
public static TypeJob CreateOperation(TempWorkTime tempWorkTime,
IEnumerable<WorkTime> workTimesDevelop, IEnumerable<WorkTime> workTimesManager)
{
return new TypeJob
{
Id = tempWorkTime.Id,
ProductId = tempWorkTime.ProductId,
DirectorId = tempWorkTime.DirectorId,
Description = tempWorkTime.Description,
AllowanceForJob = tempWorkTime.AllowanceForJob,
Date = tempWorkTime.Date,
WorkTimesDevelop = workTimesDevelop,
WorkTimesManager = workTimesManager
};
}
}

View File

@ -0,0 +1,26 @@

namespace Accounting_Time_It_Company.Entities;
public class Vacation
{
public int Id { get; private set; }
public int DirectorId { get; private set; }
public int EmployeeId { get; private set; }
public DateTime StartDate { get; private set; }
public DateTime EndDate { get; private set; }
public static Vacation CreateOpeartion(int id, int directorId, int employeeId, DateTime startDate, DateTime endDate)
{
return new Vacation
{
Id = id,
DirectorId = directorId,
EmployeeId = employeeId,
StartDate = startDate,
EndDate = endDate
};
}
}

View File

@ -0,0 +1,21 @@

namespace Accounting_Time_It_Company.Entities;
public class WorkTime
{
public int Id { get; private set; }
public int EmployeeId { get; private set; }
public int Hours { get; private set; }
public static WorkTime CreateElement(int id, int employeeId, int hours)
{
return new WorkTime
{
Id = id,
EmployeeId = employeeId,
Hours = hours
};
}
}

View File

@ -1,39 +0,0 @@
namespace Accounting_Time_It_Company
{
partial class Form1
{
/// <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.components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Text = "Form1";
}
#endregion
}
}

View File

@ -1,10 +0,0 @@
namespace Accounting_Time_It_Company
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}

View File

@ -0,0 +1,179 @@
namespace Accounting_Time_It_Company
{
partial class FormCompany
{
/// <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()
{
menuStrip1 = new MenuStrip();
directorysToolStripMenuItem = new ToolStripMenuItem();
PostsToolStripMenuItem = new ToolStripMenuItem();
ClientsToolStripMenuItem = new ToolStripMenuItem();
ProductsToolStripMenuItem = new ToolStripMenuItem();
EmployeesToolStripMenuItem = new ToolStripMenuItem();
operationsToolStripMenuItem = new ToolStripMenuItem();
vacationsToolStripMenuItem = new ToolStripMenuItem();
typeJobsРаботуToolStripMenuItem = new ToolStripMenuItem();
reportsToolStripMenuItem = new ToolStripMenuItem();
DirectoryReportToolStripMenuItem = new ToolStripMenuItem();
WorkAndCheelEmpToolStripMenuItem = new ToolStripMenuItem();
VacatiobEmpToolStripMenuItem = new ToolStripMenuItem();
menuStrip1.SuspendLayout();
SuspendLayout();
//
// menuStrip1
//
menuStrip1.ImageScalingSize = new Size(20, 20);
menuStrip1.Items.AddRange(new ToolStripItem[] { directorysToolStripMenuItem, operationsToolStripMenuItem, reportsToolStripMenuItem });
menuStrip1.Location = new Point(0, 0);
menuStrip1.Name = "menuStrip1";
menuStrip1.Size = new Size(877, 28);
menuStrip1.TabIndex = 0;
menuStrip1.Text = "menuStrip";
//
// directorysToolStripMenuItem
//
directorysToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { PostsToolStripMenuItem, ClientsToolStripMenuItem, ProductsToolStripMenuItem, EmployeesToolStripMenuItem });
directorysToolStripMenuItem.Name = "directorysToolStripMenuItem";
directorysToolStripMenuItem.Size = new Size(117, 24);
directorysToolStripMenuItem.Text = "Справочники";
//
// PostsToolStripMenuItem
//
PostsToolStripMenuItem.Name = "PostsToolStripMenuItem";
PostsToolStripMenuItem.Size = new Size(170, 26);
PostsToolStripMenuItem.Text = "Должности";
PostsToolStripMenuItem.Click += PostsToolStripMenuItem_Click;
//
// ClientsToolStripMenuItem
//
ClientsToolStripMenuItem.Name = "ClientsToolStripMenuItem";
ClientsToolStripMenuItem.Size = new Size(170, 26);
ClientsToolStripMenuItem.Text = "Клиенты";
ClientsToolStripMenuItem.Click += ClientsToolStripMenuItem_Click;
//
// ProductsToolStripMenuItem
//
ProductsToolStripMenuItem.Name = "ProductsToolStripMenuItem";
ProductsToolStripMenuItem.Size = new Size(170, 26);
ProductsToolStripMenuItem.Text = "Проекты";
ProductsToolStripMenuItem.Click += ProductsToolStripMenuItem_Click;
//
// EmployeesToolStripMenuItem
//
EmployeesToolStripMenuItem.Name = "EmployeesToolStripMenuItem";
EmployeesToolStripMenuItem.Size = new Size(170, 26);
EmployeesToolStripMenuItem.Text = "Работник";
EmployeesToolStripMenuItem.Click += EmployeesToolStripMenuItem_Click;
//
// operationsToolStripMenuItem
//
operationsToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { vacationsToolStripMenuItem, typeJobsРаботуToolStripMenuItem });
operationsToolStripMenuItem.Name = "operationsToolStripMenuItem";
operationsToolStripMenuItem.Size = new Size(95, 24);
operationsToolStripMenuItem.Text = "Операции";
//
// vacationsToolStripMenuItem
//
vacationsToolStripMenuItem.Name = "vacationsToolStripMenuItem";
vacationsToolStripMenuItem.Size = new Size(227, 26);
vacationsToolStripMenuItem.Text = "Отправить в отпуск";
vacationsToolStripMenuItem.Click += VacationsToolStripMenuItem_Click;
//
// typeJobsРаботуToolStripMenuItem
//
typeJobsРаботуToolStripMenuItem.Name = "typeJobsРаботуToolStripMenuItem";
typeJobsРаботуToolStripMenuItem.Size = new Size(227, 26);
typeJobsРаботуToolStripMenuItem.Text = "Добавит работу";
typeJobsРаботуToolStripMenuItem.Click += TypeJobsToolStripMenuItem_Click;
//
// reportsToolStripMenuItem
//
reportsToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { DirectoryReportToolStripMenuItem, WorkAndCheelEmpToolStripMenuItem, VacatiobEmpToolStripMenuItem });
reportsToolStripMenuItem.Name = "reportsToolStripMenuItem";
reportsToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.W;
reportsToolStripMenuItem.Size = new Size(73, 24);
reportsToolStripMenuItem.Text = "Отчеты";
//
// DirectoryReportToolStripMenuItem
//
DirectoryReportToolStripMenuItem.Name = "DirectoryReportToolStripMenuItem";
DirectoryReportToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.W;
DirectoryReportToolStripMenuItem.Size = new Size(350, 26);
DirectoryReportToolStripMenuItem.Text = "Документ со справочниками";
DirectoryReportToolStripMenuItem.Click += DirectoryReportToolStripMenuItem_Click;
//
// WorkAndCheelEmpToolStripMenuItem
//
WorkAndCheelEmpToolStripMenuItem.Name = "WorkAndCheelEmpToolStripMenuItem";
WorkAndCheelEmpToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.E;
WorkAndCheelEmpToolStripMenuItem.Size = new Size(350, 26);
WorkAndCheelEmpToolStripMenuItem.Text = "Работа и отдых сотрудников";
WorkAndCheelEmpToolStripMenuItem.Click += WorkAndCheelEmpToolStripMenuItem_Click;
//
// VacatiobEmpToolStripMenuItem
//
VacatiobEmpToolStripMenuItem.Name = "VacatiobEmpToolStripMenuItem";
VacatiobEmpToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.P;
VacatiobEmpToolStripMenuItem.Size = new Size(350, 26);
VacatiobEmpToolStripMenuItem.Text = "Отпуска работников";
VacatiobEmpToolStripMenuItem.Click += VacatiobEmpToolStripMenuItem_Click;
//
// FormCompany
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
BackgroundImage = Properties.Resources.BG;
BackgroundImageLayout = ImageLayout.Stretch;
ClientSize = new Size(877, 482);
Controls.Add(menuStrip1);
MainMenuStrip = menuStrip1;
Name = "FormCompany";
StartPosition = FormStartPosition.CenterScreen;
Text = "IT Компания";
menuStrip1.ResumeLayout(false);
menuStrip1.PerformLayout();
ResumeLayout(false);
PerformLayout();
}
#endregion
private MenuStrip menuStrip1;
private ToolStripMenuItem directorysToolStripMenuItem;
private ToolStripMenuItem PostsToolStripMenuItem;
private ToolStripMenuItem ClientsToolStripMenuItem;
private ToolStripMenuItem ProductsToolStripMenuItem;
private ToolStripMenuItem operationsToolStripMenuItem;
private ToolStripMenuItem vacationsToolStripMenuItem;
private ToolStripMenuItem typeJobsРаботуToolStripMenuItem;
private ToolStripMenuItem reportsToolStripMenuItem;
private ToolStripMenuItem EmployeesToolStripMenuItem;
private ToolStripMenuItem DirectoryReportToolStripMenuItem;
private ToolStripMenuItem WorkAndCheelEmpToolStripMenuItem;
private ToolStripMenuItem VacatiobEmpToolStripMenuItem;
}
}

View File

@ -0,0 +1,134 @@
using Accounting_Time_It_Company.Forms;
using Accounting_Time_It_Company.Reports;
using Unity;
namespace Accounting_Time_It_Company
{
public partial class FormCompany : Form
{
private readonly IUnityContainer _container;
public FormCompany(IUnityContainer container)
{
InitializeComponent();
_container = container ?? throw new ArgumentNullException(nameof(container));
}
private void PostsToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormPosts>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ClientsToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormClients>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ProductsToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormProducts>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void EmployeesToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormEmployees>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void VacationsToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormVacations>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void TypeJobsToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormTypeJobs>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void DirectoryReportToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormDirectoryReport>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void WorkAndCheelEmpToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormEmployeeReport>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void VacatiobEmpToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormVacationEmployeeDistributionReport>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}

View File

@ -0,0 +1,123 @@
<?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="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

View File

@ -0,0 +1,119 @@
namespace Accounting_Time_It_Company.Forms
{
partial class FormClient
{
/// <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()
{
labelName = new Label();
textBoxName = new TextBox();
labelPhone = new Label();
buttonSave = new Button();
buttonCansle = new Button();
maskedTextBoxPhone = new MaskedTextBox();
SuspendLayout();
//
// labelName
//
labelName.AutoSize = true;
labelName.Location = new Point(12, 28);
labelName.Name = "labelName";
labelName.Size = new Size(42, 20);
labelName.TabIndex = 0;
labelName.Text = "Имя:";
//
// textBoxName
//
textBoxName.Location = new Point(95, 25);
textBoxName.Name = "textBoxName";
textBoxName.Size = new Size(203, 27);
textBoxName.TabIndex = 1;
//
// labelPhone
//
labelPhone.AutoSize = true;
labelPhone.Location = new Point(12, 83);
labelPhone.Name = "labelPhone";
labelPhone.Size = new Size(72, 20);
labelPhone.TabIndex = 2;
labelPhone.Text = "Телефон:";
//
// buttonSave
//
buttonSave.Location = new Point(95, 181);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(94, 29);
buttonSave.TabIndex = 4;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += ButtonSave_Click;
//
// buttonCansle
//
buttonCansle.Location = new Point(204, 181);
buttonCansle.Name = "buttonCansle";
buttonCansle.Size = new Size(94, 29);
buttonCansle.TabIndex = 5;
buttonCansle.Text = "Отмена";
buttonCansle.UseVisualStyleBackColor = true;
buttonCansle.Click += ButtonCansle_Click;
//
// maskedTextBoxPhone
//
maskedTextBoxPhone.Location = new Point(95, 80);
maskedTextBoxPhone.Mask = "000 000 0000";
maskedTextBoxPhone.Name = "maskedTextBoxPhone";
maskedTextBoxPhone.Size = new Size(203, 27);
maskedTextBoxPhone.TabIndex = 6;
//
// FormClient
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(310, 239);
Controls.Add(maskedTextBoxPhone);
Controls.Add(buttonCansle);
Controls.Add(buttonSave);
Controls.Add(labelPhone);
Controls.Add(textBoxName);
Controls.Add(labelName);
Name = "FormClient";
StartPosition = FormStartPosition.CenterParent;
Text = "Клиент";
ResumeLayout(false);
PerformLayout();
}
#endregion
private Label labelName;
private TextBox textBoxName;
private Label labelPhone;
private Button buttonSave;
private Button buttonCansle;
private MaskedTextBox maskedTextBoxPhone;
}
}

View File

@ -0,0 +1,72 @@
using Accounting_Time_It_Company.Entities;
using Accounting_Time_It_Company.Repositories;
namespace Accounting_Time_It_Company.Forms
{
public partial class FormClient : Form
{
private readonly IClientRepositories _clientRepositories;
private int? _clientId;
public int Id
{
set
{
try
{
var client = _clientRepositories.ReadClientById(value);
if (client == null)
{
throw new InvalidDataException(nameof(client));
}
textBoxName.Text = client.NameClient;
maskedTextBoxPhone.Text = client.Phone.ToString();
_clientId = value;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при получении двнных", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
}
public FormClient(IClientRepositories clientRepositories)
{
InitializeComponent();
_clientRepositories = clientRepositories ?? throw new ArgumentNullException(nameof(clientRepositories));
}
private void ButtonSave_Click(object sender, EventArgs e)
{
try
{
if (string.IsNullOrWhiteSpace(textBoxName.Text) ||
string.IsNullOrWhiteSpace(maskedTextBoxPhone.Text))
{
throw new Exception("Имеются незаполненные поля");
}
if (_clientId.HasValue)
{
_clientRepositories.UpdateClient(CreateClient(_clientId.Value));
}
else
{
_clientRepositories.CreateClient(CreateClient(0));
}
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonCansle_Click(object sender, EventArgs e) => Close();
private Client CreateClient(int id) => Client.CreateEntity(id, textBoxName.Text, maskedTextBoxPhone.Text);
}
}

View File

@ -1,17 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
<!--
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
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>
@ -26,36 +26,36 @@
<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
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
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
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
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
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
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
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->

View File

@ -0,0 +1,127 @@
namespace Accounting_Time_It_Company.Forms
{
partial class FormClients
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
panel1 = new Panel();
buttonDelete = new Button();
buttonUpdate = new Button();
buttonAdd = new Button();
dataGridViewData = new DataGridView();
panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit();
SuspendLayout();
//
// panel1
//
panel1.Controls.Add(buttonDelete);
panel1.Controls.Add(buttonUpdate);
panel1.Controls.Add(buttonAdd);
panel1.Dock = DockStyle.Right;
panel1.Location = new Point(686, 0);
panel1.Name = "panel1";
panel1.Size = new Size(114, 450);
panel1.TabIndex = 0;
//
// buttonDelete
//
buttonDelete.BackgroundImage = Properties.Resources.Delete;
buttonDelete.BackgroundImageLayout = ImageLayout.Stretch;
buttonDelete.Location = new Point(8, 280);
buttonDelete.Name = "buttonDelete";
buttonDelete.Size = new Size(94, 94);
buttonDelete.TabIndex = 2;
buttonDelete.UseVisualStyleBackColor = true;
buttonDelete.Click += ButtonDelete_Click;
//
// buttonUpdate
//
buttonUpdate.BackgroundImage = Properties.Resources.Update;
buttonUpdate.BackgroundImageLayout = ImageLayout.Stretch;
buttonUpdate.Location = new Point(8, 167);
buttonUpdate.Name = "buttonUpdate";
buttonUpdate.Size = new Size(94, 94);
buttonUpdate.TabIndex = 1;
buttonUpdate.UseVisualStyleBackColor = true;
buttonUpdate.Click += ButtonUpdate_Click;
//
// buttonAdd
//
buttonAdd.BackgroundImage = Properties.Resources.Add;
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
buttonAdd.Location = new Point(8, 59);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(94, 94);
buttonAdd.TabIndex = 0;
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += ButtonAdd_Click;
//
// dataGridViewData
//
dataGridViewData.AllowUserToAddRows = false;
dataGridViewData.AllowUserToDeleteRows = false;
dataGridViewData.AllowUserToResizeColumns = false;
dataGridViewData.AllowUserToResizeRows = false;
dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridViewData.Dock = DockStyle.Fill;
dataGridViewData.Location = new Point(0, 0);
dataGridViewData.MultiSelect = false;
dataGridViewData.Name = "dataGridViewData";
dataGridViewData.ReadOnly = true;
dataGridViewData.RowHeadersVisible = false;
dataGridViewData.RowHeadersWidth = 51;
dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridViewData.Size = new Size(686, 450);
dataGridViewData.TabIndex = 1;
//
// FormClients
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450);
Controls.Add(dataGridViewData);
Controls.Add(panel1);
Name = "FormClients";
StartPosition = FormStartPosition.CenterParent;
Text = "Клиенты";
Load += FormClients_Load;
panel1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
ResumeLayout(false);
}
#endregion
private Panel panel1;
private Button buttonDelete;
private Button buttonUpdate;
private Button buttonAdd;
private DataGridView dataGridViewData;
}
}

View File

@ -0,0 +1,98 @@
using Accounting_Time_It_Company.Repositories;
using Unity;
namespace Accounting_Time_It_Company.Forms
{
public partial class FormClients : Form
{
private readonly IUnityContainer _container;
private readonly IClientRepositories _clientRepositories;
public FormClients(IUnityContainer container, IClientRepositories clientRepositories)
{
InitializeComponent();
_container = container ?? throw new ArgumentNullException(nameof(container));
_clientRepositories = clientRepositories ?? throw new ArgumentNullException(nameof(clientRepositories));
}
private void FormClients_Load(object sender, EventArgs e)
{
try
{
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonAdd_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormClient>().ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonUpdate_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectedRow(out var findId))
{
return;
}
try
{
var form = _container.Resolve<FormClient>();
form.Id = findId;
form.ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonDelete_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectedRow(out var findId))
{
return;
}
if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes)
{
return;
}
try
{
_clientRepositories.DeleteClient(findId);
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void LoadList() => dataGridViewData.DataSource = _clientRepositories.ReadClients();
private bool TryGetIdentifierFromSelectedRow(out int id)
{
id = 0;
if (dataGridViewData.SelectedRows.Count < 1)
{
MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
id = Convert.ToInt32(dataGridViewData.SelectedRows[0].Cells["Id"].Value);
return true;
}
}
}

View 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>

View File

@ -0,0 +1,112 @@
namespace Accounting_Time_It_Company.Forms
{
partial class FormDirectoryReport
{
/// <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()
{
checkBoxClients = new CheckBox();
checkBoxEmployees = new CheckBox();
checkBoxPosts = new CheckBox();
buttonBuild = new Button();
checkBoxProducts = new CheckBox();
SuspendLayout();
//
// checkBoxClients
//
checkBoxClients.AutoSize = true;
checkBoxClients.Location = new Point(42, 12);
checkBoxClients.Name = "checkBoxClients";
checkBoxClients.Size = new Size(91, 24);
checkBoxClients.TabIndex = 0;
checkBoxClients.Text = "Клиенты";
checkBoxClients.UseVisualStyleBackColor = true;
//
// checkBoxEmployees
//
checkBoxEmployees.AutoSize = true;
checkBoxEmployees.Location = new Point(42, 42);
checkBoxEmployees.Name = "checkBoxEmployees";
checkBoxEmployees.Size = new Size(104, 24);
checkBoxEmployees.TabIndex = 1;
checkBoxEmployees.Text = "Работника";
checkBoxEmployees.UseVisualStyleBackColor = true;
//
// checkBoxPosts
//
checkBoxPosts.AutoSize = true;
checkBoxPosts.Location = new Point(42, 72);
checkBoxPosts.Name = "checkBoxPosts";
checkBoxPosts.Size = new Size(109, 24);
checkBoxPosts.TabIndex = 2;
checkBoxPosts.Text = "Должности";
checkBoxPosts.UseVisualStyleBackColor = true;
//
// buttonBuild
//
buttonBuild.Location = new Point(173, 54);
buttonBuild.Name = "buttonBuild";
buttonBuild.Size = new Size(128, 29);
buttonBuild.TabIndex = 3;
buttonBuild.Text = "Сформировать";
buttonBuild.UseVisualStyleBackColor = true;
buttonBuild.Click += ButtonBuild_Click;
//
// checkBoxProducts
//
checkBoxProducts.AutoSize = true;
checkBoxProducts.Location = new Point(42, 102);
checkBoxProducts.Name = "checkBoxProducts";
checkBoxProducts.Size = new Size(92, 24);
checkBoxProducts.TabIndex = 4;
checkBoxProducts.Text = "Проекты";
checkBoxProducts.UseVisualStyleBackColor = true;
//
// FormDirectoryReport
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(313, 148);
Controls.Add(checkBoxProducts);
Controls.Add(buttonBuild);
Controls.Add(checkBoxPosts);
Controls.Add(checkBoxEmployees);
Controls.Add(checkBoxClients);
Name = "FormDirectoryReport";
Text = "FormDirectoryReport";
ResumeLayout(false);
PerformLayout();
}
#endregion
private CheckBox checkBoxClients;
private CheckBox checkBoxEmployees;
private CheckBox checkBoxPosts;
private Button buttonBuild;
private CheckBox checkBoxProducts;
}
}

View File

@ -0,0 +1,52 @@
using Accounting_Time_It_Company.Reports;
using Unity;
namespace Accounting_Time_It_Company.Forms;
public partial class FormDirectoryReport : Form
{
private readonly IUnityContainer _container;
public FormDirectoryReport(IUnityContainer container)
{
InitializeComponent();
_container = container ?? throw new ArgumentNullException(nameof(container));
}
private void ButtonBuild_Click(object sender, EventArgs e)
{
try
{
if (!checkBoxClients.Checked && !checkBoxEmployees.Checked
&& !checkBoxPosts.Checked && !checkBoxProducts.Checked)
{
throw new Exception("Не выбран ни один справочник для выгрузки");
}
var sfd = new SaveFileDialog()
{
Filter = "Docx Files | *.docx"
};
if (sfd.ShowDialog() != DialogResult.OK)
{
throw new Exception("Не выбран файла для отчета");
}
if (_container.Resolve<DocReport>().CreateDoc(sfd.FileName, checkBoxClients.Checked,
checkBoxEmployees.Checked, checkBoxPosts.Checked, checkBoxProducts.Checked))
{
MessageBox.Show("Документ сформирован", "Формирование документа",
MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MessageBox.Show("Возникли ошибки при формировании документа.Подробности в логах", "Формирование документа",
MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при создании отчета",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}

View 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>

View File

@ -0,0 +1,169 @@
namespace Accounting_Time_It_Company.Forms
{
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()
{
maskedTextBoxPhone = new MaskedTextBox();
buttonCansle = new Button();
buttonSave = new Button();
labelPhone = new Label();
textBoxName = new TextBox();
labelName = new Label();
labelPost = new Label();
labelAllowance = new Label();
comboBoxPost = new ComboBox();
numericUpDownAllowance = new NumericUpDown();
((System.ComponentModel.ISupportInitialize)numericUpDownAllowance).BeginInit();
SuspendLayout();
//
// maskedTextBoxPhone
//
maskedTextBoxPhone.Location = new Point(107, 84);
maskedTextBoxPhone.Mask = "000 000 0000";
maskedTextBoxPhone.Name = "maskedTextBoxPhone";
maskedTextBoxPhone.Size = new Size(205, 27);
maskedTextBoxPhone.TabIndex = 12;
//
// buttonCansle
//
buttonCansle.Location = new Point(218, 242);
buttonCansle.Name = "buttonCansle";
buttonCansle.Size = new Size(94, 29);
buttonCansle.TabIndex = 11;
buttonCansle.Text = "Отмена";
buttonCansle.UseVisualStyleBackColor = true;
buttonCansle.Click += ButtonCansle_Click;
//
// buttonSave
//
buttonSave.Location = new Point(109, 242);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(94, 29);
buttonSave.TabIndex = 10;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += ButtonSave_Click;
//
// labelPhone
//
labelPhone.AutoSize = true;
labelPhone.Location = new Point(14, 87);
labelPhone.Name = "labelPhone";
labelPhone.Size = new Size(72, 20);
labelPhone.TabIndex = 9;
labelPhone.Text = "Телефон:";
//
// textBoxName
//
textBoxName.Location = new Point(107, 28);
textBoxName.Name = "textBoxName";
textBoxName.Size = new Size(205, 27);
textBoxName.TabIndex = 8;
//
// labelName
//
labelName.AutoSize = true;
labelName.Location = new Point(14, 31);
labelName.Name = "labelName";
labelName.Size = new Size(42, 20);
labelName.TabIndex = 7;
labelName.Text = "Имя:";
//
// labelPost
//
labelPost.AutoSize = true;
labelPost.Location = new Point(14, 139);
labelPost.Name = "labelPost";
labelPost.Size = new Size(89, 20);
labelPost.TabIndex = 13;
labelPost.Text = "Должность:";
//
// labelAllowance
//
labelAllowance.AutoSize = true;
labelAllowance.Location = new Point(14, 189);
labelAllowance.Name = "labelAllowance";
labelAllowance.Size = new Size(79, 20);
labelAllowance.TabIndex = 14;
labelAllowance.Text = "Надбавка:";
//
// comboBoxPost
//
comboBoxPost.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxPost.FormattingEnabled = true;
comboBoxPost.Location = new Point(107, 136);
comboBoxPost.Name = "comboBoxPost";
comboBoxPost.Size = new Size(205, 28);
comboBoxPost.TabIndex = 15;
//
// numericUpDownAllowance
//
numericUpDownAllowance.DecimalPlaces = 2;
numericUpDownAllowance.Location = new Point(107, 187);
numericUpDownAllowance.Maximum = new decimal(new int[] { 1, 0, 0, 0 });
numericUpDownAllowance.Name = "numericUpDownAllowance";
numericUpDownAllowance.Size = new Size(205, 27);
numericUpDownAllowance.TabIndex = 16;
//
// FormEmployee
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(349, 303);
Controls.Add(numericUpDownAllowance);
Controls.Add(comboBoxPost);
Controls.Add(labelAllowance);
Controls.Add(labelPost);
Controls.Add(maskedTextBoxPhone);
Controls.Add(buttonCansle);
Controls.Add(buttonSave);
Controls.Add(labelPhone);
Controls.Add(textBoxName);
Controls.Add(labelName);
Name = "FormEmployee";
StartPosition = FormStartPosition.CenterParent;
Text = "Работник";
((System.ComponentModel.ISupportInitialize)numericUpDownAllowance).EndInit();
ResumeLayout(false);
PerformLayout();
}
#endregion
private MaskedTextBox maskedTextBoxPhone;
private Button buttonCansle;
private Button buttonSave;
private Label labelPhone;
private TextBox textBoxName;
private Label labelName;
private Label labelPost;
private Label labelAllowance;
private ComboBox comboBoxPost;
private NumericUpDown numericUpDownAllowance;
}
}

View File

@ -0,0 +1,80 @@
using Accounting_Time_It_Company.Entities;
using Accounting_Time_It_Company.Repositories;
namespace Accounting_Time_It_Company.Forms
{
public partial class FormEmployee : Form
{
private readonly IEmployeeRepositories _employeeRepositories;
private int? _employeeId;
public int Id
{
set
{
try
{
var employee = _employeeRepositories.ReadEmployeeById(value);
if (employee == null)
{
throw new InvalidDataException(nameof(employee));
}
textBoxName.Text = employee.Name;
maskedTextBoxPhone.Text = employee.Phone.ToString();
comboBoxPost.SelectedValue = employee.PostId;
labelAllowance.Text = employee.Allowance.ToString();
_employeeId = value;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при получении двнных", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
}
public FormEmployee(IEmployeeRepositories employeeRepositories, IPostRepositories postRepositories)
{
InitializeComponent();
_employeeRepositories = employeeRepositories ?? throw new ArgumentNullException(nameof(employeeRepositories));
comboBoxPost.DataSource = postRepositories.ReadPosts();
comboBoxPost.DisplayMember = "NamePost";
comboBoxPost.ValueMember = "Id";
}
private void ButtonSave_Click(object sender, EventArgs e)
{
try
{
if (string.IsNullOrWhiteSpace(textBoxName.Text) ||
string.IsNullOrWhiteSpace(maskedTextBoxPhone.Text) ||
comboBoxPost.SelectedIndex < 0)
{
throw new Exception("Имеются незаполненные поля");
}
if (_employeeId.HasValue)
{
_employeeRepositories.UpdateEmployee(CreateEmployee(_employeeId.Value));
}
else
{
_employeeRepositories.CreateEmployee(CreateEmployee(0));
}
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonCansle_Click(object sender, EventArgs e) => Close();
private Employee CreateEmployee(int id) => Employee.CreateEntity(id, (int)comboBoxPost.SelectedValue!, textBoxName.Text,
maskedTextBoxPhone.Text, (float)numericUpDownAllowance.Value);
}
}

View 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>

View File

@ -0,0 +1,162 @@
namespace Accounting_Time_It_Company.Forms
{
partial class FormEmployeeReport
{
/// <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()
{
buttonPath = new Button();
buttonBuild = new Button();
comboBoxEmployee = new ComboBox();
dateTimePickerEndDate = new DateTimePicker();
dateTimePickerStartDate = new DateTimePicker();
textBoxPath = new TextBox();
labelEmployee = new Label();
labelStartDate = new Label();
labelEndDate = new Label();
labelPath = new Label();
SuspendLayout();
//
// buttonPath
//
buttonPath.Location = new Point(275, 39);
buttonPath.Name = "buttonPath";
buttonPath.Size = new Size(29, 29);
buttonPath.TabIndex = 0;
buttonPath.Text = "...";
buttonPath.UseVisualStyleBackColor = true;
buttonPath.Click += ButtonPath_Click;
//
// buttonBuild
//
buttonBuild.Location = new Point(112, 193);
buttonBuild.Name = "buttonBuild";
buttonBuild.Size = new Size(125, 29);
buttonBuild.TabIndex = 1;
buttonBuild.Text = "Сформировать";
buttonBuild.UseVisualStyleBackColor = true;
buttonBuild.Click += ButtonBuild_Click;
//
// comboBoxEmployee
//
comboBoxEmployee.FormattingEnabled = true;
comboBoxEmployee.Location = new Point(144, 74);
comboBoxEmployee.Name = "comboBoxEmployee";
comboBoxEmployee.Size = new Size(160, 28);
comboBoxEmployee.TabIndex = 2;
//
// dateTimePickerEndDate
//
dateTimePickerEndDate.Location = new Point(144, 150);
dateTimePickerEndDate.Name = "dateTimePickerEndDate";
dateTimePickerEndDate.Size = new Size(160, 27);
dateTimePickerEndDate.TabIndex = 3;
//
// dateTimePickerStartDate
//
dateTimePickerStartDate.Location = new Point(144, 112);
dateTimePickerStartDate.Name = "dateTimePickerStartDate";
dateTimePickerStartDate.Size = new Size(160, 27);
dateTimePickerStartDate.TabIndex = 4;
//
// textBoxPath
//
textBoxPath.Location = new Point(144, 41);
textBoxPath.Name = "textBoxPath";
textBoxPath.Size = new Size(125, 27);
textBoxPath.TabIndex = 5;
//
// labelEmployee
//
labelEmployee.AutoSize = true;
labelEmployee.Location = new Point(12, 79);
labelEmployee.Name = "labelEmployee";
labelEmployee.Size = new Size(74, 20);
labelEmployee.TabIndex = 6;
labelEmployee.Text = "Работник";
//
// labelStartDate
//
labelStartDate.AutoSize = true;
labelStartDate.Location = new Point(12, 114);
labelStartDate.Name = "labelStartDate";
labelStartDate.Size = new Size(28, 20);
labelStartDate.TabIndex = 7;
labelStartDate.Text = "С -";
//
// labelEndDate
//
labelEndDate.AutoSize = true;
labelEndDate.Location = new Point(12, 152);
labelEndDate.Name = "labelEndDate";
labelEndDate.Size = new Size(43, 20);
labelEndDate.TabIndex = 8;
labelEndDate.Text = "По - ";
//
// labelPath
//
labelPath.AutoSize = true;
labelPath.Location = new Point(12, 41);
labelPath.Name = "labelPath";
labelPath.Size = new Size(109, 20);
labelPath.TabIndex = 9;
labelPath.Text = "Путь до файла";
//
// FormEmployeeReport
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(380, 248);
Controls.Add(labelPath);
Controls.Add(labelEndDate);
Controls.Add(labelStartDate);
Controls.Add(labelEmployee);
Controls.Add(textBoxPath);
Controls.Add(dateTimePickerStartDate);
Controls.Add(dateTimePickerEndDate);
Controls.Add(comboBoxEmployee);
Controls.Add(buttonBuild);
Controls.Add(buttonPath);
Name = "FormEmployeeReport";
Text = "FormEmployeeReport";
ResumeLayout(false);
PerformLayout();
}
#endregion
private Button buttonPath;
private Button buttonBuild;
private ComboBox comboBoxEmployee;
private DateTimePicker dateTimePickerEndDate;
private DateTimePicker dateTimePickerStartDate;
private TextBox textBoxPath;
private Label labelEmployee;
private Label labelStartDate;
private Label labelEndDate;
private Label labelPath;
}
}

View File

@ -0,0 +1,85 @@
using Accounting_Time_It_Company.Entities.Enums;
using Accounting_Time_It_Company.Reports;
using Accounting_Time_It_Company.Repositories;
using Accounting_Time_It_Company.Repositories.Implementations;
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 Unity;
namespace Accounting_Time_It_Company.Forms
{
public partial class FormEmployeeReport : Form
{
private readonly IUnityContainer _container;
public FormEmployeeReport(IUnityContainer container, IEmployeeRepositories employeeRepositories, IPostRepositories postRepositories)
{
InitializeComponent();
_container = container;
List<int> DirectorId = postRepositories.ReadPosts().Where(y => y.NamePost == TypePost.Director).Select(y => y.Id).ToList();
comboBoxEmployee.DataSource = employeeRepositories.ReadEmployees().Where(x => DirectorId.Any(z => z != x.PostId)).ToList();
comboBoxEmployee.DisplayMember = "Name";
comboBoxEmployee.ValueMember = "Id";
}
private void ButtonBuild_Click(object sender, EventArgs e)
{
try
{
if (string.IsNullOrWhiteSpace(textBoxPath.Text))
{
throw new Exception("Отсутствует имя файла для отчета");
}
if (comboBoxEmployee.SelectedIndex < 0)
{
throw new Exception("Не выбран работник");
}
if (dateTimePickerEndDate.Value <= dateTimePickerStartDate.Value)
{
throw new Exception("Дата начала должна быть раньше даты окончания");
}
if
(_container.Resolve<TableReport>().CreateTable(textBoxPath.Text,
(int)comboBoxEmployee.SelectedValue!,
dateTimePickerStartDate.Value, dateTimePickerEndDate.Value))
{
MessageBox.Show("Документ сформирован", "Формирование документа",
MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MessageBox.Show("Возникли ошибки при формировании документа.Подробности в логах", "Формирование документа",
MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при создании очета",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonPath_Click(object sender, EventArgs e)
{
var sfd = new SaveFileDialog()
{
Filter = "Excel Files | *.xlsx"
};
if (sfd.ShowDialog() != DialogResult.OK)
{
return;
}
textBoxPath.Text = sfd.FileName;
}
}
}

View 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>

View File

@ -0,0 +1,127 @@
namespace Accounting_Time_It_Company.Forms
{
partial class FormEmployees
{
/// <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()
{
dataGridViewData = new DataGridView();
panel1 = new Panel();
buttonDelete = new Button();
buttonUpdate = new Button();
buttonAdd = new Button();
((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit();
panel1.SuspendLayout();
SuspendLayout();
//
// dataGridViewData
//
dataGridViewData.AllowUserToAddRows = false;
dataGridViewData.AllowUserToDeleteRows = false;
dataGridViewData.AllowUserToResizeColumns = false;
dataGridViewData.AllowUserToResizeRows = false;
dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridViewData.Dock = DockStyle.Fill;
dataGridViewData.Location = new Point(0, 0);
dataGridViewData.MultiSelect = false;
dataGridViewData.Name = "dataGridViewData";
dataGridViewData.ReadOnly = true;
dataGridViewData.RowHeadersVisible = false;
dataGridViewData.RowHeadersWidth = 51;
dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridViewData.Size = new Size(686, 450);
dataGridViewData.TabIndex = 3;
//
// panel1
//
panel1.Controls.Add(buttonDelete);
panel1.Controls.Add(buttonUpdate);
panel1.Controls.Add(buttonAdd);
panel1.Dock = DockStyle.Right;
panel1.Location = new Point(686, 0);
panel1.Name = "panel1";
panel1.Size = new Size(114, 450);
panel1.TabIndex = 2;
//
// buttonDelete
//
buttonDelete.BackgroundImage = Properties.Resources.Delete;
buttonDelete.BackgroundImageLayout = ImageLayout.Stretch;
buttonDelete.Location = new Point(8, 280);
buttonDelete.Name = "buttonDelete";
buttonDelete.Size = new Size(94, 94);
buttonDelete.TabIndex = 2;
buttonDelete.UseVisualStyleBackColor = true;
buttonDelete.Click += ButtonDelete_Click;
//
// buttonUpdate
//
buttonUpdate.BackgroundImage = Properties.Resources.Update;
buttonUpdate.BackgroundImageLayout = ImageLayout.Stretch;
buttonUpdate.Location = new Point(8, 167);
buttonUpdate.Name = "buttonUpdate";
buttonUpdate.Size = new Size(94, 94);
buttonUpdate.TabIndex = 1;
buttonUpdate.UseVisualStyleBackColor = true;
buttonUpdate.Click += ButtonUpdate_Click;
//
// buttonAdd
//
buttonAdd.BackgroundImage = Properties.Resources.Add;
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
buttonAdd.Location = new Point(8, 59);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(94, 94);
buttonAdd.TabIndex = 0;
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += ButtonAdd_Click;
//
// FormEmployees
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450);
Controls.Add(dataGridViewData);
Controls.Add(panel1);
Name = "FormEmployees";
StartPosition = FormStartPosition.CenterParent;
Text = "Работники";
Load += FormEmployees_Load;
((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
panel1.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private DataGridView dataGridViewData;
private Panel panel1;
private Button buttonDelete;
private Button buttonUpdate;
private Button buttonAdd;
}
}

View File

@ -0,0 +1,98 @@
using Accounting_Time_It_Company.Repositories;
using Unity;
namespace Accounting_Time_It_Company.Forms
{
public partial class FormEmployees : Form
{
private readonly IUnityContainer _container;
private readonly IEmployeeRepositories _employeeRepositories;
public FormEmployees(IUnityContainer container, IEmployeeRepositories employeeRepositories)
{
InitializeComponent();
_container = container ?? throw new ArgumentNullException(nameof(container));
_employeeRepositories = employeeRepositories ?? throw new ArgumentNullException(nameof(employeeRepositories));
}
private void FormEmployees_Load(object sender, EventArgs e)
{
try
{
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonAdd_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormEmployee>().ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonUpdate_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectedRow(out var findId))
{
return;
}
try
{
var form = _container.Resolve<FormEmployee>();
form.Id = findId;
form.ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonDelete_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectedRow(out var findId))
{
return;
}
if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes)
{
return;
}
try
{
_employeeRepositories.DeleteEmployee(findId);
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void LoadList() => dataGridViewData.DataSource = _employeeRepositories.ReadEmployees();
private bool TryGetIdentifierFromSelectedRow(out int id)
{
id = 0;
if (dataGridViewData.SelectedRows.Count < 1)
{
MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
id = Convert.ToInt32(dataGridViewData.SelectedRows[0].Cells["Id"].Value);
return true;
}
}
}

View 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>

View File

@ -0,0 +1,148 @@
namespace Accounting_Time_It_Company.Forms
{
partial class FormPost
{
/// <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()
{
numericUpDownWage = new NumericUpDown();
labelAllowance = new Label();
labelName = new Label();
buttonCansle = new Button();
buttonSave = new Button();
comboBoxName = new ComboBox();
labelLevelPost = new Label();
textBoxLevelPost = new TextBox();
((System.ComponentModel.ISupportInitialize)numericUpDownWage).BeginInit();
SuspendLayout();
//
// numericUpDownWage
//
numericUpDownWage.DecimalPlaces = 2;
numericUpDownWage.Location = new Point(132, 87);
numericUpDownWage.Maximum = new decimal(new int[] { 500, 0, 0, 0 });
numericUpDownWage.Minimum = new decimal(new int[] { 100, 0, 0, 0 });
numericUpDownWage.Name = "numericUpDownWage";
numericUpDownWage.Size = new Size(205, 27);
numericUpDownWage.TabIndex = 20;
numericUpDownWage.Value = new decimal(new int[] { 100, 0, 0, 0 });
//
// labelAllowance
//
labelAllowance.AutoSize = true;
labelAllowance.Location = new Point(13, 89);
labelAllowance.Name = "labelAllowance";
labelAllowance.Size = new Size(80, 20);
labelAllowance.TabIndex = 19;
labelAllowance.Text = "Зарплата: ";
//
// labelName
//
labelName.AutoSize = true;
labelName.Location = new Point(13, 18);
labelName.Name = "labelName";
labelName.Size = new Size(119, 20);
labelName.TabIndex = 17;
labelName.Text = "Наименование:";
//
// buttonCansle
//
buttonCansle.Location = new Point(243, 120);
buttonCansle.Name = "buttonCansle";
buttonCansle.Size = new Size(94, 29);
buttonCansle.TabIndex = 22;
buttonCansle.Text = "Отмена";
buttonCansle.UseVisualStyleBackColor = true;
buttonCansle.Click += ButtonCansle_Click;
//
// buttonSave
//
buttonSave.Location = new Point(132, 120);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(94, 29);
buttonSave.TabIndex = 21;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += ButtonSave_Click;
//
// comboBoxName
//
comboBoxName.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxName.FormattingEnabled = true;
comboBoxName.Location = new Point(132, 15);
comboBoxName.Name = "comboBoxName";
comboBoxName.Size = new Size(205, 28);
comboBoxName.TabIndex = 23;
//
// labelLevelPost
//
labelLevelPost.AutoSize = true;
labelLevelPost.Location = new Point(13, 55);
labelLevelPost.Name = "labelLevelPost";
labelLevelPost.Size = new Size(69, 20);
labelLevelPost.TabIndex = 24;
labelLevelPost.Text = "Уровень";
//
// textBoxLevelPost
//
textBoxLevelPost.Location = new Point(132, 52);
textBoxLevelPost.Name = "textBoxLevelPost";
textBoxLevelPost.Size = new Size(205, 27);
textBoxLevelPost.TabIndex = 25;
//
// FormPost
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(348, 162);
Controls.Add(textBoxLevelPost);
Controls.Add(labelLevelPost);
Controls.Add(comboBoxName);
Controls.Add(buttonCansle);
Controls.Add(buttonSave);
Controls.Add(numericUpDownWage);
Controls.Add(labelAllowance);
Controls.Add(labelName);
Name = "FormPost";
StartPosition = FormStartPosition.CenterParent;
Text = "Должность";
((System.ComponentModel.ISupportInitialize)numericUpDownWage).EndInit();
ResumeLayout(false);
PerformLayout();
}
#endregion
private NumericUpDown numericUpDownWage;
private Label labelAllowance;
private Label labelName;
private Button buttonCansle;
private Button buttonSave;
private ComboBox comboBoxName;
private Label labelLevelPost;
private TextBox textBoxLevelPost;
}
}

View File

@ -0,0 +1,76 @@
using Accounting_Time_It_Company.Entities;
using Accounting_Time_It_Company.Entities.Enums;
using Accounting_Time_It_Company.Repositories;
namespace Accounting_Time_It_Company.Forms
{
public partial class FormPost : Form
{
private readonly IPostRepositories _postRepositories;
private int? _postId;
public int Id
{
set
{
try
{
var post = _postRepositories.ReadPostById(value);
if (post == null)
{
throw new InvalidDataException(nameof(post));
}
comboBoxName.SelectedItem = post.NamePost;
textBoxLevelPost.Text = post.LevelPost;
numericUpDownWage.Value = post.Wage;
_postId = value;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при получении двнных", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
}
public FormPost(IPostRepositories postRepositories)
{
InitializeComponent();
_postRepositories = postRepositories ?? throw new ArgumentNullException(nameof(postRepositories));
comboBoxName.DataSource = Enum.GetValues(typeof(TypePost));
}
private void ButtonSave_Click(object sender, EventArgs e)
{
try
{
if (comboBoxName.SelectedIndex < 0 ||
string.IsNullOrWhiteSpace(textBoxLevelPost.Text))
{
throw new Exception("Имеются незаполненные поля");
}
if (_postId.HasValue)
{
_postRepositories.UpdatePost(CreatePost(_postId.Value));
}
else
{
_postRepositories.CreatePost(CreatePost(0));
}
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonCansle_Click(object sender, EventArgs e) => Close();
private Post CreatePost(int id) => Post.CreateEntity(id, (TypePost)comboBoxName.SelectedItem!,
textBoxLevelPost.Text, (int)numericUpDownWage.Value);
}
}

View 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>

View File

@ -0,0 +1,127 @@
namespace Accounting_Time_It_Company.Forms
{
partial class FormPosts
{
/// <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()
{
dataGridViewData = new DataGridView();
buttonDelete = new Button();
buttonUpdate = new Button();
buttonAdd = new Button();
panel1 = new Panel();
((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit();
panel1.SuspendLayout();
SuspendLayout();
//
// dataGridViewData
//
dataGridViewData.AllowUserToAddRows = false;
dataGridViewData.AllowUserToDeleteRows = false;
dataGridViewData.AllowUserToResizeColumns = false;
dataGridViewData.AllowUserToResizeRows = false;
dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridViewData.Dock = DockStyle.Fill;
dataGridViewData.Location = new Point(0, 0);
dataGridViewData.MultiSelect = false;
dataGridViewData.Name = "dataGridViewData";
dataGridViewData.ReadOnly = true;
dataGridViewData.RowHeadersVisible = false;
dataGridViewData.RowHeadersWidth = 51;
dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridViewData.Size = new Size(686, 450);
dataGridViewData.TabIndex = 5;
//
// buttonDelete
//
buttonDelete.BackgroundImage = Properties.Resources.Delete;
buttonDelete.BackgroundImageLayout = ImageLayout.Stretch;
buttonDelete.Location = new Point(8, 280);
buttonDelete.Name = "buttonDelete";
buttonDelete.Size = new Size(94, 94);
buttonDelete.TabIndex = 2;
buttonDelete.UseVisualStyleBackColor = true;
buttonDelete.Click += ButtonDelete_Click;
//
// buttonUpdate
//
buttonUpdate.BackgroundImage = Properties.Resources.Update;
buttonUpdate.BackgroundImageLayout = ImageLayout.Stretch;
buttonUpdate.Location = new Point(8, 167);
buttonUpdate.Name = "buttonUpdate";
buttonUpdate.Size = new Size(94, 94);
buttonUpdate.TabIndex = 1;
buttonUpdate.UseVisualStyleBackColor = true;
buttonUpdate.Click += ButtonUpdate_Click;
//
// buttonAdd
//
buttonAdd.BackgroundImage = Properties.Resources.Add;
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
buttonAdd.Location = new Point(8, 59);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(94, 94);
buttonAdd.TabIndex = 0;
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += ButtonAdd_Click;
//
// panel1
//
panel1.Controls.Add(buttonDelete);
panel1.Controls.Add(buttonUpdate);
panel1.Controls.Add(buttonAdd);
panel1.Dock = DockStyle.Right;
panel1.Location = new Point(686, 0);
panel1.Name = "panel1";
panel1.Size = new Size(114, 450);
panel1.TabIndex = 4;
//
// FormPosts
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450);
Controls.Add(dataGridViewData);
Controls.Add(panel1);
Name = "FormPosts";
StartPosition = FormStartPosition.CenterParent;
Text = "Должности";
Load += FormPosts_Load;
((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
panel1.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private DataGridView dataGridViewData;
private Button buttonDelete;
private Button buttonUpdate;
private Button buttonAdd;
private Panel panel1;
}
}

View File

@ -0,0 +1,98 @@
using Accounting_Time_It_Company.Repositories;
using Unity;
namespace Accounting_Time_It_Company.Forms
{
public partial class FormPosts : Form
{
private readonly IUnityContainer _container;
private readonly IPostRepositories _postRepositories;
public FormPosts(IUnityContainer container, IPostRepositories postRepositories)
{
InitializeComponent();
_container = container ?? throw new ArgumentNullException(nameof(container));
_postRepositories = postRepositories ?? throw new ArgumentNullException(nameof(postRepositories));
}
private void FormPosts_Load(object sender, EventArgs e)
{
try
{
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonAdd_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormPost>().ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonUpdate_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectedRow(out var findId))
{
return;
}
try
{
var form = _container.Resolve<FormPost>();
form.Id = findId;
form.ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonDelete_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectedRow(out var findId))
{
return;
}
if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes)
{
return;
}
try
{
_postRepositories.DeletePost(findId);
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void LoadList() => dataGridViewData.DataSource = _postRepositories.ReadPosts();
private bool TryGetIdentifierFromSelectedRow(out int id)
{
id = 0;
if (dataGridViewData.SelectedRows.Count < 1)
{
MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
id = Convert.ToInt32(dataGridViewData.SelectedRows[0].Cells["Id"].Value);
return true;
}
}
}

View 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>

View File

@ -0,0 +1,143 @@
namespace Accounting_Time_It_Company.Forms
{
partial class FormProduct
{
/// <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()
{
textBoxName = new TextBox();
labelName = new Label();
labelClientName = new Label();
comboBoxClientName = new ComboBox();
buttonCansle = new Button();
buttonSave = new Button();
checkedListBoxTypeProduct = new CheckedListBox();
labelTypeProduct = new Label();
SuspendLayout();
//
// textBoxName
//
textBoxName.Location = new Point(85, 207);
textBoxName.Name = "textBoxName";
textBoxName.Size = new Size(205, 27);
textBoxName.TabIndex = 20;
//
// labelName
//
labelName.AutoSize = true;
labelName.Location = new Point(10, 210);
labelName.Name = "labelName";
labelName.Size = new Size(42, 20);
labelName.TabIndex = 19;
labelName.Text = "Имя:";
//
// labelClientName
//
labelClientName.AutoSize = true;
labelClientName.Location = new Point(10, 252);
labelClientName.Name = "labelClientName";
labelClientName.Size = new Size(74, 20);
labelClientName.TabIndex = 21;
labelClientName.Text = "Заказчик:";
//
// comboBoxClientName
//
comboBoxClientName.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxClientName.FormattingEnabled = true;
comboBoxClientName.Location = new Point(85, 249);
comboBoxClientName.Name = "comboBoxClientName";
comboBoxClientName.Size = new Size(205, 28);
comboBoxClientName.TabIndex = 23;
//
// buttonCansle
//
buttonCansle.Location = new Point(196, 290);
buttonCansle.Name = "buttonCansle";
buttonCansle.Size = new Size(94, 29);
buttonCansle.TabIndex = 25;
buttonCansle.Text = "Отмена";
buttonCansle.UseVisualStyleBackColor = true;
buttonCansle.Click += ButtonCansle_Click;
//
// buttonSave
//
buttonSave.Location = new Point(87, 290);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(94, 29);
buttonSave.TabIndex = 24;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += ButtonSave_Click;
//
// checkedListBoxTypeProduct
//
checkedListBoxTypeProduct.FormattingEnabled = true;
checkedListBoxTypeProduct.Location = new Point(87, 12);
checkedListBoxTypeProduct.Name = "checkedListBoxTypeProduct";
checkedListBoxTypeProduct.Size = new Size(203, 180);
checkedListBoxTypeProduct.TabIndex = 26;
//
// labelTypeProduct
//
labelTypeProduct.AutoSize = true;
labelTypeProduct.Location = new Point(10, 12);
labelTypeProduct.Name = "labelTypeProduct";
labelTypeProduct.Size = new Size(38, 20);
labelTypeProduct.TabIndex = 27;
labelTypeProduct.Text = "Тип:";
//
// FormProduct
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(315, 336);
Controls.Add(labelTypeProduct);
Controls.Add(checkedListBoxTypeProduct);
Controls.Add(buttonCansle);
Controls.Add(buttonSave);
Controls.Add(comboBoxClientName);
Controls.Add(labelClientName);
Controls.Add(textBoxName);
Controls.Add(labelName);
Name = "FormProduct";
StartPosition = FormStartPosition.CenterParent;
Text = "Проект";
ResumeLayout(false);
PerformLayout();
}
#endregion
private TextBox textBoxName;
private Label labelName;
private Label labelClientName;
private ComboBox comboBoxClientName;
private Button buttonCansle;
private Button buttonSave;
private CheckedListBox checkedListBoxTypeProduct;
private Label labelTypeProduct;
}
}

View File

@ -0,0 +1,98 @@
using Accounting_Time_It_Company.Entities;
using Accounting_Time_It_Company.Entities.Enums;
using Accounting_Time_It_Company.Repositories;
namespace Accounting_Time_It_Company.Forms
{
public partial class FormProduct : Form
{
private readonly IProductRepositories _productRepositories;
private int? _productId;
public int Id
{
set
{
try
{
var product = _productRepositories.ReadProductById(value);
if (product == null)
{
throw new InvalidDataException(nameof(product));
}
foreach (TypeProduct elem in Enum.GetValues(typeof(TypeProduct)))
{
if ((elem & product.Type) != 0)
{
checkedListBoxTypeProduct.SetItemChecked(checkedListBoxTypeProduct.Items.IndexOf(elem), true);
}
}
textBoxName.Text = product.Name;
comboBoxClientName.SelectedValue = product.ClientId;
_productId = value;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при получении двнных", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
}
public FormProduct(IProductRepositories productRepositories, IClientRepositories clientRepositories)
{
InitializeComponent();
_productRepositories = productRepositories ?? throw new ArgumentNullException(nameof(productRepositories));
comboBoxClientName.DataSource = clientRepositories.ReadClients();
comboBoxClientName.DisplayMember = "NameClient";
comboBoxClientName.ValueMember = "Id";
foreach (TypeProduct elem in Enum.GetValues(typeof(TypeProduct)))
{
checkedListBoxTypeProduct.Items.Add(elem);
}
}
private void ButtonSave_Click(object sender, EventArgs e)
{
try
{
if (string.IsNullOrWhiteSpace(textBoxName.Text) ||
comboBoxClientName.SelectedIndex < 0 ||
checkedListBoxTypeProduct.CheckedItems.Count == 0)
{
throw new Exception("Имеются незаполненные поля");
}
if (_productId.HasValue)
{
_productRepositories.UpdateProduct(CreateProduct(_productId.Value));
}
else
{
_productRepositories.CreateProduct(CreateProduct(0));
}
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonCansle_Click(object sender, EventArgs e) => Close();
private Product CreateProduct(int id)
{
TypeProduct type = TypeProduct.None;
foreach (var elem in checkedListBoxTypeProduct.CheckedItems)
{
type |= (TypeProduct)elem;
}
return Product.CreateEntity(id, (int)comboBoxClientName.SelectedValue!, textBoxName.Text, type);
}
}
}

View 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>

View File

@ -0,0 +1,127 @@
namespace Accounting_Time_It_Company.Forms
{
partial class FormProducts
{
/// <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()
{
dataGridViewData = new DataGridView();
panel1 = new Panel();
buttonDelete = new Button();
buttonUpdate = new Button();
buttonAdd = new Button();
((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit();
panel1.SuspendLayout();
SuspendLayout();
//
// dataGridViewData
//
dataGridViewData.AllowUserToAddRows = false;
dataGridViewData.AllowUserToDeleteRows = false;
dataGridViewData.AllowUserToResizeColumns = false;
dataGridViewData.AllowUserToResizeRows = false;
dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridViewData.Dock = DockStyle.Fill;
dataGridViewData.Location = new Point(0, 0);
dataGridViewData.MultiSelect = false;
dataGridViewData.Name = "dataGridViewData";
dataGridViewData.ReadOnly = true;
dataGridViewData.RowHeadersVisible = false;
dataGridViewData.RowHeadersWidth = 51;
dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridViewData.Size = new Size(686, 450);
dataGridViewData.TabIndex = 7;
//
// panel1
//
panel1.Controls.Add(buttonDelete);
panel1.Controls.Add(buttonUpdate);
panel1.Controls.Add(buttonAdd);
panel1.Dock = DockStyle.Right;
panel1.Location = new Point(686, 0);
panel1.Name = "panel1";
panel1.Size = new Size(114, 450);
panel1.TabIndex = 6;
//
// buttonDelete
//
buttonDelete.BackgroundImage = Properties.Resources.Delete;
buttonDelete.BackgroundImageLayout = ImageLayout.Stretch;
buttonDelete.Location = new Point(8, 280);
buttonDelete.Name = "buttonDelete";
buttonDelete.Size = new Size(94, 94);
buttonDelete.TabIndex = 2;
buttonDelete.UseVisualStyleBackColor = true;
buttonDelete.Click += ButtonDelete_Click;
//
// buttonUpdate
//
buttonUpdate.BackgroundImage = Properties.Resources.Update;
buttonUpdate.BackgroundImageLayout = ImageLayout.Stretch;
buttonUpdate.Location = new Point(8, 167);
buttonUpdate.Name = "buttonUpdate";
buttonUpdate.Size = new Size(94, 94);
buttonUpdate.TabIndex = 1;
buttonUpdate.UseVisualStyleBackColor = true;
buttonUpdate.Click += ButtonUpdate_Click;
//
// buttonAdd
//
buttonAdd.BackgroundImage = Properties.Resources.Add;
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
buttonAdd.Location = new Point(8, 59);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(94, 94);
buttonAdd.TabIndex = 0;
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += ButtonAdd_Click;
//
// FormProducts
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450);
Controls.Add(dataGridViewData);
Controls.Add(panel1);
Name = "FormProducts";
StartPosition = FormStartPosition.CenterParent;
Text = "Проекты";
Load += FormProducts_Load;
((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
panel1.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private DataGridView dataGridViewData;
private Panel panel1;
private Button buttonDelete;
private Button buttonUpdate;
private Button buttonAdd;
}
}

View File

@ -0,0 +1,98 @@
using Accounting_Time_It_Company.Repositories;
using Unity;
namespace Accounting_Time_It_Company.Forms
{
public partial class FormProducts : Form
{
private readonly IUnityContainer _container;
private readonly IProductRepositories _productRepositories;
public FormProducts(IUnityContainer container, IProductRepositories productRepositories)
{
InitializeComponent();
_container = container ?? throw new ArgumentNullException(nameof(container));
_productRepositories = productRepositories ?? throw new ArgumentNullException(nameof(productRepositories));
}
private void FormProducts_Load(object sender, EventArgs e)
{
try
{
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonAdd_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormProduct>().ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonUpdate_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectedRow(out var findId))
{
return;
}
try
{
var form = _container.Resolve<FormProduct>();
form.Id = findId;
form.ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonDelete_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectedRow(out var findId))
{
return;
}
if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes)
{
return;
}
try
{
_productRepositories.DeleteProduct(findId);
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void LoadList() => dataGridViewData.DataSource = _productRepositories.ReadProducts();
private bool TryGetIdentifierFromSelectedRow(out int id)
{
id = 0;
if (dataGridViewData.SelectedRows.Count < 1)
{
MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
id = Convert.ToInt32(dataGridViewData.SelectedRows[0].Cells["Id"].Value);
return true;
}
}
}

View 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>

View File

@ -0,0 +1,297 @@
namespace Accounting_Time_It_Company.Forms
{
partial class FormTypeJob
{
/// <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()
{
labelProduct = new Label();
textBoxDescriptoin = new TextBox();
comboBoxProduct = new ComboBox();
numericUpDownAllowanceForJob = new NumericUpDown();
labelDescriptoin = new Label();
labelAllowanceForJob = new Label();
buttonCansle = new Button();
buttonSave = new Button();
groupBoxDevelops = new GroupBox();
dataGridViewDevelops = new DataGridView();
ColumnDevelop = new DataGridViewComboBoxColumn();
ColumnHoursDev = new DataGridViewTextBoxColumn();
groupBoxManagers = new GroupBox();
dataGridViewManagers = new DataGridView();
ColumnManager = new DataGridViewComboBoxColumn();
ColumnHoursMan = new DataGridViewTextBoxColumn();
labelDate = new Label();
dateTimePickerDate = new DateTimePicker();
comboBoxDirector = new ComboBox();
labelDirector = new Label();
((System.ComponentModel.ISupportInitialize)numericUpDownAllowanceForJob).BeginInit();
groupBoxDevelops.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridViewDevelops).BeginInit();
groupBoxManagers.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridViewManagers).BeginInit();
SuspendLayout();
//
// labelProduct
//
labelProduct.AutoSize = true;
labelProduct.Location = new Point(22, 24);
labelProduct.Name = "labelProduct";
labelProduct.Size = new Size(62, 20);
labelProduct.TabIndex = 0;
labelProduct.Text = "Проект:";
//
// textBoxDescriptoin
//
textBoxDescriptoin.Location = new Point(178, 89);
textBoxDescriptoin.Name = "textBoxDescriptoin";
textBoxDescriptoin.Size = new Size(203, 27);
textBoxDescriptoin.TabIndex = 1;
//
// comboBoxProduct
//
comboBoxProduct.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxProduct.FormattingEnabled = true;
comboBoxProduct.Location = new Point(178, 21);
comboBoxProduct.Name = "comboBoxProduct";
comboBoxProduct.Size = new Size(203, 28);
comboBoxProduct.TabIndex = 2;
//
// numericUpDownAllowanceForJob
//
numericUpDownAllowanceForJob.Location = new Point(179, 122);
numericUpDownAllowanceForJob.Maximum = new decimal(new int[] { 1000, 0, 0, 0 });
numericUpDownAllowanceForJob.Name = "numericUpDownAllowanceForJob";
numericUpDownAllowanceForJob.Size = new Size(202, 27);
numericUpDownAllowanceForJob.TabIndex = 5;
//
// labelDescriptoin
//
labelDescriptoin.AutoSize = true;
labelDescriptoin.Location = new Point(22, 92);
labelDescriptoin.Name = "labelDescriptoin";
labelDescriptoin.Size = new Size(138, 20);
labelDescriptoin.TabIndex = 6;
labelDescriptoin.Text = "Описание работы:";
//
// labelAllowanceForJob
//
labelAllowanceForJob.AutoSize = true;
labelAllowanceForJob.Location = new Point(22, 124);
labelAllowanceForJob.Name = "labelAllowanceForJob";
labelAllowanceForJob.Size = new Size(150, 20);
labelAllowanceForJob.TabIndex = 7;
labelAllowanceForJob.Text = "Надбавка за работу:";
//
// buttonCansle
//
buttonCansle.Location = new Point(287, 577);
buttonCansle.Name = "buttonCansle";
buttonCansle.Size = new Size(94, 29);
buttonCansle.TabIndex = 11;
buttonCansle.Text = "Отмена";
buttonCansle.UseVisualStyleBackColor = true;
buttonCansle.Click += ButtonCansle_Click;
//
// buttonSave
//
buttonSave.Location = new Point(177, 577);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(94, 29);
buttonSave.TabIndex = 10;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += ButtonSave_Click;
//
// groupBoxDevelops
//
groupBoxDevelops.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
groupBoxDevelops.Controls.Add(dataGridViewDevelops);
groupBoxDevelops.Location = new Point(26, 188);
groupBoxDevelops.Name = "groupBoxDevelops";
groupBoxDevelops.Size = new Size(358, 183);
groupBoxDevelops.TabIndex = 12;
groupBoxDevelops.TabStop = false;
groupBoxDevelops.Text = "Разработчики";
//
// dataGridViewDevelops
//
dataGridViewDevelops.AllowUserToResizeColumns = false;
dataGridViewDevelops.AllowUserToResizeRows = false;
dataGridViewDevelops.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridViewDevelops.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridViewDevelops.Columns.AddRange(new DataGridViewColumn[] { ColumnDevelop, ColumnHoursDev });
dataGridViewDevelops.Location = new Point(3, 23);
dataGridViewDevelops.MultiSelect = false;
dataGridViewDevelops.Name = "dataGridViewDevelops";
dataGridViewDevelops.RowHeadersVisible = false;
dataGridViewDevelops.RowHeadersWidth = 51;
dataGridViewDevelops.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridViewDevelops.Size = new Size(352, 141);
dataGridViewDevelops.TabIndex = 8;
//
// ColumnDevelop
//
ColumnDevelop.HeaderText = "Разработчик";
ColumnDevelop.MinimumWidth = 6;
ColumnDevelop.Name = "ColumnDevelop";
//
// ColumnHoursDev
//
ColumnHoursDev.HeaderText = "Часы";
ColumnHoursDev.MinimumWidth = 6;
ColumnHoursDev.Name = "ColumnHoursDev";
//
// groupBoxManagers
//
groupBoxManagers.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
groupBoxManagers.Controls.Add(dataGridViewManagers);
groupBoxManagers.Location = new Point(26, 377);
groupBoxManagers.Name = "groupBoxManagers";
groupBoxManagers.Size = new Size(358, 182);
groupBoxManagers.TabIndex = 13;
groupBoxManagers.TabStop = false;
groupBoxManagers.Text = "Менеджеры";
//
// dataGridViewManagers
//
dataGridViewManagers.AllowUserToResizeColumns = false;
dataGridViewManagers.AllowUserToResizeRows = false;
dataGridViewManagers.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridViewManagers.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridViewManagers.Columns.AddRange(new DataGridViewColumn[] { ColumnManager, ColumnHoursMan });
dataGridViewManagers.Dock = DockStyle.Fill;
dataGridViewManagers.Location = new Point(3, 23);
dataGridViewManagers.MultiSelect = false;
dataGridViewManagers.Name = "dataGridViewManagers";
dataGridViewManagers.RowHeadersVisible = false;
dataGridViewManagers.RowHeadersWidth = 51;
dataGridViewManagers.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridViewManagers.Size = new Size(352, 156);
dataGridViewManagers.TabIndex = 9;
//
// ColumnManager
//
ColumnManager.HeaderText = "Менеджер";
ColumnManager.MinimumWidth = 6;
ColumnManager.Name = "ColumnManager";
//
// ColumnHoursMan
//
ColumnHoursMan.HeaderText = "Часы";
ColumnHoursMan.MinimumWidth = 6;
ColumnHoursMan.Name = "ColumnHoursMan";
//
// labelDate
//
labelDate.AutoSize = true;
labelDate.Location = new Point(22, 160);
labelDate.Name = "labelDate";
labelDate.Size = new Size(44, 20);
labelDate.TabIndex = 14;
labelDate.Text = "Дата:";
//
// dateTimePickerDate
//
dateTimePickerDate.Enabled = false;
dateTimePickerDate.Location = new Point(178, 155);
dateTimePickerDate.Name = "dateTimePickerDate";
dateTimePickerDate.Size = new Size(206, 27);
dateTimePickerDate.TabIndex = 15;
//
// comboBoxDirector
//
comboBoxDirector.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxDirector.FormattingEnabled = true;
comboBoxDirector.Location = new Point(178, 55);
comboBoxDirector.Name = "comboBoxDirector";
comboBoxDirector.Size = new Size(203, 28);
comboBoxDirector.TabIndex = 17;
//
// labelDirector
//
labelDirector.AutoSize = true;
labelDirector.Location = new Point(22, 58);
labelDirector.Name = "labelDirector";
labelDirector.Size = new Size(76, 20);
labelDirector.TabIndex = 16;
labelDirector.Text = "Директор";
//
// FormTypeJob
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(391, 717);
Controls.Add(comboBoxDirector);
Controls.Add(labelDirector);
Controls.Add(dateTimePickerDate);
Controls.Add(labelDate);
Controls.Add(groupBoxManagers);
Controls.Add(groupBoxDevelops);
Controls.Add(buttonCansle);
Controls.Add(buttonSave);
Controls.Add(labelAllowanceForJob);
Controls.Add(labelDescriptoin);
Controls.Add(numericUpDownAllowanceForJob);
Controls.Add(comboBoxProduct);
Controls.Add(textBoxDescriptoin);
Controls.Add(labelProduct);
Name = "FormTypeJob";
StartPosition = FormStartPosition.CenterParent;
Text = "Тип работы";
((System.ComponentModel.ISupportInitialize)numericUpDownAllowanceForJob).EndInit();
groupBoxDevelops.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridViewDevelops).EndInit();
groupBoxManagers.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridViewManagers).EndInit();
ResumeLayout(false);
PerformLayout();
}
#endregion
private Label labelProduct;
private TextBox textBoxDescriptoin;
private ComboBox comboBoxProduct;
private NumericUpDown numericUpDownAllowanceForJob;
private Label labelDescriptoin;
private Label labelAllowanceForJob;
private Button buttonCansle;
private Button buttonSave;
private GroupBox groupBoxDevelops;
private GroupBox groupBoxManagers;
private DataGridView dataGridViewDevelops;
private DataGridView dataGridViewManagers;
private Label labelDate;
private DateTimePicker dateTimePickerDate;
private DataGridViewComboBoxColumn ColumnDevelop;
private DataGridViewTextBoxColumn ColumnHoursDev;
private DataGridViewComboBoxColumn ColumnManager;
private DataGridViewTextBoxColumn ColumnHoursMan;
private ComboBox comboBoxDirector;
private Label labelDirector;
}
}

View File

@ -0,0 +1,78 @@
using Accounting_Time_It_Company.Entities;
using Accounting_Time_It_Company.Entities.Enums;
using Accounting_Time_It_Company.Repositories;
using Accounting_Time_It_Company.Repositories.Implementations;
using System.Data;
namespace Accounting_Time_It_Company.Forms
{
public partial class FormTypeJob : Form
{
private readonly ITypeJobRepositories _typeJobRepositories;
public FormTypeJob(ITypeJobRepositories typeJobRepositories, IProductRepositories productRepositories,
IEmployeeRepositories employeeRepositories, IPostRepositories postRepositories)
{
InitializeComponent();
_typeJobRepositories = typeJobRepositories ?? throw new ArgumentNullException(nameof(typeJobRepositories));
comboBoxProduct.DataSource = productRepositories.ReadProducts();
comboBoxProduct.DisplayMember = "Name";
comboBoxProduct.ValueMember = "Id";
List<int> DirectorId = postRepositories.ReadPosts().Where(y => y.NamePost == TypePost.Director).Select(y => y.Id).ToList();
List<int> ManagerId = postRepositories.ReadPosts().Where(y => y.NamePost == TypePost.Manager).Select(y => y.Id).ToList();
List<int> DeveloperId = postRepositories.ReadPosts().Where(y => y.NamePost == TypePost.Developer).Select(y => y.Id).ToList();
comboBoxDirector.DataSource = employeeRepositories.ReadEmployees().Where(x => DirectorId.Any(z => z == x.PostId)).ToList();
comboBoxDirector.DisplayMember = "Name";
comboBoxDirector.ValueMember = "Id";
ColumnDevelop.DataSource = employeeRepositories.ReadEmployees().Where(x => DeveloperId.Any(z => z == x.PostId)).ToList();
ColumnDevelop.DisplayMember = "Name";
ColumnDevelop.ValueMember = "Id";
ColumnManager.DataSource = employeeRepositories.ReadEmployees().Where(x => ManagerId.Any(z => z == x.PostId)).ToList();
ColumnManager.DisplayMember = "Name";
ColumnManager.ValueMember = "Id";
}
private void ButtonSave_Click(object sender, EventArgs e)
{
try
{
if (string.IsNullOrWhiteSpace(textBoxDescriptoin.Text) ||
comboBoxProduct.SelectedIndex < 0)
{
throw new Exception("Имеются незаполненные поля");
}
_typeJobRepositories.CreateTypeJob(TypeJob.CreateOperation(0, (int)comboBoxProduct.SelectedValue!, (int)comboBoxDirector.SelectedValue!, textBoxDescriptoin.Text,
(int)numericUpDownAllowanceForJob.Value, CreateListWorkTimeFromDataGrid(dataGridViewDevelops),
CreateListWorkTimeFromDataGrid(dataGridViewManagers)));
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonCansle_Click(object sender, EventArgs e) => Close();
private List<WorkTime> CreateListWorkTimeFromDataGrid(DataGridView dataGrid)
{
var list = new List<WorkTime>();
foreach (DataGridViewRow row in dataGrid.Rows)
{
if (row.Cells[0].Value == null || row.Cells[1] == null)
{
continue;
}
list.Add(WorkTime.CreateElement(0, Convert.ToInt32(row.Cells[0].Value), Convert.ToInt32(row.Cells[1].Value)));
}
return list.GroupBy(x => x.EmployeeId, x => x.Hours, (id, hours) => WorkTime.CreateElement(0, id, hours.Sum())).ToList();
}
}
}

View File

@ -0,0 +1,144 @@
<?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="ColumnDevelop.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ColumnHoursDev.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ColumnDevelop.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ColumnHoursDev.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ColumnManager.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ColumnHoursMan.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ColumnManager.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ColumnHoursMan.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root>

View File

@ -0,0 +1,113 @@
namespace Accounting_Time_It_Company.Forms
{
partial class FormTypeJobs
{
/// <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()
{
panel1 = new Panel();
buttonDelete = new Button();
buttonAdd = new Button();
dataGridViewData = new DataGridView();
panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit();
SuspendLayout();
//
// panel1
//
panel1.Controls.Add(buttonDelete);
panel1.Controls.Add(buttonAdd);
panel1.Dock = DockStyle.Right;
panel1.Location = new Point(686, 0);
panel1.Name = "panel1";
panel1.Size = new Size(114, 450);
panel1.TabIndex = 6;
//
// buttonDelete
//
buttonDelete.BackgroundImage = Properties.Resources.Delete;
buttonDelete.BackgroundImageLayout = ImageLayout.Stretch;
buttonDelete.Location = new Point(8, 159);
buttonDelete.Name = "buttonDelete";
buttonDelete.Size = new Size(94, 94);
buttonDelete.TabIndex = 2;
buttonDelete.UseVisualStyleBackColor = true;
buttonDelete.Click += ButtonDelete_Click;
//
// buttonAdd
//
buttonAdd.BackgroundImage = Properties.Resources.Add;
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
buttonAdd.Location = new Point(8, 59);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(94, 94);
buttonAdd.TabIndex = 0;
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += ButtonAdd_Click;
//
// dataGridViewData
//
dataGridViewData.AllowUserToAddRows = false;
dataGridViewData.AllowUserToDeleteRows = false;
dataGridViewData.AllowUserToResizeColumns = false;
dataGridViewData.AllowUserToResizeRows = false;
dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridViewData.Dock = DockStyle.Fill;
dataGridViewData.Location = new Point(0, 0);
dataGridViewData.MultiSelect = false;
dataGridViewData.Name = "dataGridViewData";
dataGridViewData.ReadOnly = true;
dataGridViewData.RowHeadersVisible = false;
dataGridViewData.RowHeadersWidth = 51;
dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridViewData.Size = new Size(800, 450);
dataGridViewData.TabIndex = 7;
//
// FormTypeJobs
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450);
Controls.Add(panel1);
Controls.Add(dataGridViewData);
Name = "FormTypeJobs";
StartPosition = FormStartPosition.CenterParent;
Text = "Тип работ";
Load += FormTypeJobs_Load;
panel1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
ResumeLayout(false);
}
#endregion
private Panel panel1;
private Button buttonDelete;
private Button buttonAdd;
private DataGridView dataGridViewData;
}
}

View File

@ -0,0 +1,79 @@
using Accounting_Time_It_Company.Repositories;
using Unity;
namespace Accounting_Time_It_Company.Forms
{
public partial class FormTypeJobs : Form
{
private readonly IUnityContainer _container;
private readonly ITypeJobRepositories _typeJobRepositories;
public FormTypeJobs(IUnityContainer container, ITypeJobRepositories typeJobRepositories)
{
InitializeComponent();
_container = container ?? throw new ArgumentNullException(nameof(container));
_typeJobRepositories = typeJobRepositories ?? throw new ArgumentNullException(nameof(typeJobRepositories));
}
private void FormTypeJobs_Load(object sender, EventArgs e)
{
try
{
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonAdd_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormTypeJob>().ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonDelete_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectedRow(out var findId))
{
return;
}
if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes)
{
return;
}
try
{
_typeJobRepositories.DeleteTypeJob(findId);
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void LoadList() => dataGridViewData.DataSource = _typeJobRepositories.ReadTypeJobs();
private bool TryGetIdentifierFromSelectedRow(out int id)
{
id = 0;
if (dataGridViewData.SelectedRows.Count < 1)
{
MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
id = Convert.ToInt32(dataGridViewData.SelectedRows[0].Cells["Id"].Value);
return true;
}
}
}

View 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>

View File

@ -0,0 +1,166 @@
namespace Accounting_Time_It_Company.Forms
{
partial class FormVacation
{
/// <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()
{
labelEmployee = new Label();
comboBoxEmployee = new ComboBox();
dateTimePickerStartDate = new DateTimePicker();
labelStartDate = new Label();
labelEndDate = new Label();
dateTimePickerEndDate = new DateTimePicker();
buttonCansle = new Button();
buttonSave = new Button();
comboBoxDirector = new ComboBox();
labelDirector = new Label();
SuspendLayout();
//
// labelEmployee
//
labelEmployee.AutoSize = true;
labelEmployee.Location = new Point(12, 43);
labelEmployee.Name = "labelEmployee";
labelEmployee.Size = new Size(77, 20);
labelEmployee.TabIndex = 0;
labelEmployee.Text = "Работник:";
//
// comboBoxEmployee
//
comboBoxEmployee.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxEmployee.FormattingEnabled = true;
comboBoxEmployee.Location = new Point(179, 40);
comboBoxEmployee.Name = "comboBoxEmployee";
comboBoxEmployee.Size = new Size(203, 28);
comboBoxEmployee.TabIndex = 1;
//
// dateTimePickerStartDate
//
dateTimePickerStartDate.Location = new Point(179, 74);
dateTimePickerStartDate.Name = "dateTimePickerStartDate";
dateTimePickerStartDate.Size = new Size(203, 27);
dateTimePickerStartDate.TabIndex = 2;
//
// labelStartDate
//
labelStartDate.AutoSize = true;
labelStartDate.Location = new Point(12, 79);
labelStartDate.Name = "labelStartDate";
labelStartDate.Size = new Size(64, 20);
labelStartDate.TabIndex = 3;
labelStartDate.Text = "Начало:";
//
// labelEndDate
//
labelEndDate.AutoSize = true;
labelEndDate.Location = new Point(12, 113);
labelEndDate.Name = "labelEndDate";
labelEndDate.Size = new Size(56, 20);
labelEndDate.TabIndex = 4;
labelEndDate.Text = "Конец:";
//
// dateTimePickerEndDate
//
dateTimePickerEndDate.Location = new Point(179, 108);
dateTimePickerEndDate.Name = "dateTimePickerEndDate";
dateTimePickerEndDate.Size = new Size(203, 27);
dateTimePickerEndDate.TabIndex = 5;
//
// buttonCansle
//
buttonCansle.Location = new Point(288, 157);
buttonCansle.Name = "buttonCansle";
buttonCansle.Size = new Size(94, 29);
buttonCansle.TabIndex = 24;
buttonCansle.Text = "Отмена";
buttonCansle.UseVisualStyleBackColor = true;
buttonCansle.Click += ButtonCansle_Click;
//
// buttonSave
//
buttonSave.Location = new Point(179, 157);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(94, 29);
buttonSave.TabIndex = 23;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += ButtonSave_Click;
//
// comboBoxDirector
//
comboBoxDirector.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxDirector.FormattingEnabled = true;
comboBoxDirector.Location = new Point(179, 6);
comboBoxDirector.Name = "comboBoxDirector";
comboBoxDirector.Size = new Size(203, 28);
comboBoxDirector.TabIndex = 26;
//
// labelDirector
//
labelDirector.AutoSize = true;
labelDirector.Location = new Point(12, 9);
labelDirector.Name = "labelDirector";
labelDirector.Size = new Size(118, 20);
labelDirector.TabIndex = 25;
labelDirector.Text = "Ответственный:";
//
// FormVacation
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(383, 192);
Controls.Add(comboBoxDirector);
Controls.Add(labelDirector);
Controls.Add(buttonCansle);
Controls.Add(buttonSave);
Controls.Add(dateTimePickerEndDate);
Controls.Add(labelEndDate);
Controls.Add(labelStartDate);
Controls.Add(dateTimePickerStartDate);
Controls.Add(comboBoxEmployee);
Controls.Add(labelEmployee);
Name = "FormVacation";
StartPosition = FormStartPosition.CenterParent;
Text = "Отпуск";
ResumeLayout(false);
PerformLayout();
}
#endregion
private Label labelEmployee;
private ComboBox comboBoxEmployee;
private DateTimePicker dateTimePickerStartDate;
private Label labelStartDate;
private Label labelEndDate;
private DateTimePicker dateTimePickerEndDate;
private Button buttonCansle;
private Button buttonSave;
private ComboBox comboBoxDirector;
private Label labelDirector;
}
}

View File

@ -0,0 +1,51 @@
using Accounting_Time_It_Company.Entities;
using Accounting_Time_It_Company.Entities.Enums;
using Accounting_Time_It_Company.Repositories;
using Accounting_Time_It_Company.Repositories.Implementations;
namespace Accounting_Time_It_Company.Forms
{
public partial class FormVacation : Form
{
private readonly IVacationRepositories _vacationRepositories;
public FormVacation(IVacationRepositories vacationRepositories, IEmployeeRepositories employeeRepositories, IPostRepositories postRepositories)
{
InitializeComponent();
_vacationRepositories = vacationRepositories ?? throw new ArgumentNullException(nameof(vacationRepositories));
List<int> DirectorId = postRepositories.ReadPosts().Where(y => y.NamePost == TypePost.Director).Select(y => y.Id).ToList();
comboBoxEmployee.DataSource = employeeRepositories.ReadEmployees().Where(x => DirectorId.Any(z => z != x.PostId)).ToList();
comboBoxEmployee.DisplayMember = "Name";
comboBoxEmployee.ValueMember = "Id";
comboBoxDirector.DataSource = employeeRepositories.ReadEmployees().Where(x => DirectorId.Any(z => z == x.PostId)).ToList();
comboBoxDirector.DisplayMember = "Name";
comboBoxDirector.ValueMember = "Id";
}
private void ButtonSave_Click(object sender, EventArgs e)
{
try
{
if (comboBoxEmployee.SelectedIndex < 0 || comboBoxDirector.SelectedIndex < 0 ||
dateTimePickerStartDate.Value >= dateTimePickerEndDate.Value)
{
throw new Exception("Имеются незаполненные поля");
}
_vacationRepositories.CreateVacation(Vacation.CreateOpeartion(0, (int)comboBoxDirector.SelectedValue!, (int)comboBoxEmployee.SelectedValue!,
dateTimePickerStartDate.Value, dateTimePickerEndDate.Value));
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonCansle_Click(object sender, EventArgs e) => Close();
}
}

View 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>

View File

@ -0,0 +1,107 @@
namespace Accounting_Time_It_Company.Forms
{
partial class FormVacationEmployeeDistributionReport
{
/// <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()
{
buttonPath = new Button();
labelPath = new Label();
dateTimePicker = new DateTimePicker();
labelDate = new Label();
buttonBuild = new Button();
SuspendLayout();
//
// buttonPath
//
buttonPath.Location = new Point(5, 5);
buttonPath.Name = "buttonPath";
buttonPath.Size = new Size(94, 29);
buttonPath.TabIndex = 0;
buttonPath.Text = "Выбрать";
buttonPath.UseVisualStyleBackColor = true;
buttonPath.Click += ButtonPath_Click;
//
// labelPath
//
labelPath.AutoSize = true;
labelPath.Location = new Point(105, 9);
labelPath.Name = "labelPath";
labelPath.Size = new Size(45, 20);
labelPath.TabIndex = 1;
labelPath.Text = "Файл";
//
// dateTimePicker
//
dateTimePicker.Location = new Point(68, 49);
dateTimePicker.Name = "dateTimePicker";
dateTimePicker.Size = new Size(163, 27);
dateTimePicker.TabIndex = 2;
//
// labelDate
//
labelDate.AutoSize = true;
labelDate.Location = new Point(12, 54);
labelDate.Name = "labelDate";
labelDate.Size = new Size(41, 20);
labelDate.TabIndex = 3;
labelDate.Text = "Дата";
//
// buttonBuild
//
buttonBuild.Location = new Point(53, 82);
buttonBuild.Name = "buttonBuild";
buttonBuild.Size = new Size(125, 29);
buttonBuild.TabIndex = 4;
buttonBuild.Text = "Сформировать";
buttonBuild.UseVisualStyleBackColor = true;
buttonBuild.Click += ButtonBuild_Click;
//
// FormVacationEmployeeDistributionReport
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(374, 122);
Controls.Add(buttonBuild);
Controls.Add(labelDate);
Controls.Add(dateTimePicker);
Controls.Add(labelPath);
Controls.Add(buttonPath);
Name = "FormVacationEmployeeDistributionReport";
Text = "FormVacationEmployeeDistributionReport";
ResumeLayout(false);
PerformLayout();
}
#endregion
private Button buttonPath;
private Label labelPath;
private DateTimePicker dateTimePicker;
private Label labelDate;
private Button buttonBuild;
}
}

View File

@ -0,0 +1,58 @@
using Accounting_Time_It_Company.Reports;
using Unity;
namespace Accounting_Time_It_Company.Forms
{
public partial class FormVacationEmployeeDistributionReport : Form
{
private string _fileName = string.Empty;
private readonly IUnityContainer _container;
public FormVacationEmployeeDistributionReport(IUnityContainer container)
{
InitializeComponent();
_container = container ??
throw new ArgumentNullException(nameof(container));
}
private void ButtonBuild_Click(object sender, EventArgs e)
{
try
{
if (string.IsNullOrWhiteSpace(_fileName))
{
throw new Exception("Отсутствует имя файла для отчета");
}
if
(_container.Resolve<ChartReport>().CreateChart(_fileName, dateTimePicker.Value))
{
MessageBox.Show("Документ сформирован", "Формирование документа",
MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MessageBox.Show("Возникли ошибки при формировании документа.Подробности в логах", "Формирование документа",
MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при создании очета",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonPath_Click(object sender, EventArgs e)
{
var sfd = new SaveFileDialog()
{
Filter = "Pdf Files | *.pdf"
};
if (sfd.ShowDialog() == DialogResult.OK)
{
_fileName = sfd.FileName;
labelPath.Text = Path.GetFileName(_fileName);
}
}
}
}

View 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>

View File

@ -0,0 +1,99 @@
namespace Accounting_Time_It_Company.Forms
{
partial class FormVacations
{
/// <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()
{
buttonAdd = new Button();
panel1 = new Panel();
dataGridViewData = new DataGridView();
panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit();
SuspendLayout();
//
// buttonAdd
//
buttonAdd.BackgroundImage = Properties.Resources.Add;
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
buttonAdd.Location = new Point(8, 59);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(94, 94);
buttonAdd.TabIndex = 0;
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += ButtonAdd_Click;
//
// panel1
//
panel1.Controls.Add(buttonAdd);
panel1.Dock = DockStyle.Right;
panel1.Location = new Point(686, 0);
panel1.Name = "panel1";
panel1.Size = new Size(114, 450);
panel1.TabIndex = 8;
//
// dataGridViewData
//
dataGridViewData.AllowUserToAddRows = false;
dataGridViewData.AllowUserToDeleteRows = false;
dataGridViewData.AllowUserToResizeColumns = false;
dataGridViewData.AllowUserToResizeRows = false;
dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridViewData.Dock = DockStyle.Fill;
dataGridViewData.Location = new Point(0, 0);
dataGridViewData.MultiSelect = false;
dataGridViewData.Name = "dataGridViewData";
dataGridViewData.ReadOnly = true;
dataGridViewData.RowHeadersVisible = false;
dataGridViewData.RowHeadersWidth = 51;
dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridViewData.Size = new Size(800, 450);
dataGridViewData.TabIndex = 9;
//
// FormVacations
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450);
Controls.Add(panel1);
Controls.Add(dataGridViewData);
Name = "FormVacations";
StartPosition = FormStartPosition.CenterParent;
Text = "Отпуска";
Load += FormVacations_Load;
panel1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
ResumeLayout(false);
}
#endregion
private Button buttonAdd;
private Panel panel1;
private DataGridView dataGridViewData;
}
}

View File

@ -0,0 +1,46 @@
using Accounting_Time_It_Company.Repositories;
using Unity;
namespace Accounting_Time_It_Company.Forms
{
public partial class FormVacations : Form
{
private readonly IUnityContainer _container;
private readonly IVacationRepositories _vacationRepositories;
public FormVacations(IUnityContainer container, IVacationRepositories vacationRepositories)
{
InitializeComponent();
_container = container ?? throw new ArgumentNullException(nameof(container));
_vacationRepositories = vacationRepositories ?? throw new ArgumentNullException(nameof(vacationRepositories));
}
private void FormVacations_Load(object sender, EventArgs e)
{
try
{
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonAdd_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormVacation>().ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void LoadList() => dataGridViewData.DataSource = _vacationRepositories.ReadVacations();
}
}

View 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>

View File

@ -1,3 +1,11 @@
using Accounting_Time_It_Company.Repositories;
using Accounting_Time_It_Company.Repositories.Implementations;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Serilog;
using Unity;
using Unity.Microsoft.Logging;
namespace Accounting_Time_It_Company
{
internal static class Program
@ -11,7 +19,36 @@ namespace Accounting_Time_It_Company
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
Application.Run(new Form1());
Application.Run(CreateContainer().Resolve<FormCompany>());
}
private static IUnityContainer CreateContainer()
{
var container = new UnityContainer();
container.AddExtension(new LoggingExtension(CreateLoggerFactory()));
container.RegisterType<IClientRepositories, ClientRepositories>();
container.RegisterType<IEmployeeRepositories, EmployeeRepositories>();
container.RegisterType<IPostRepositories, PostRepositories>();
container.RegisterType<IProductRepositories, ProductRepositories>();
container.RegisterType<ITypeJobRepositories, TypeJobRepositories>();
container.RegisterType<IVacationRepositories, VacationRepositories>();
container.RegisterType<IConnectionString, ConnectionString>();
return container;
}
private static LoggerFactory CreateLoggerFactory()
{
var loggerFactory = new LoggerFactory();
loggerFactory.AddSerilog(new LoggerConfiguration()
.ReadFrom.Configuration(new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json")
.Build())
.CreateLogger());
return loggerFactory;
}
}
}

View File

@ -0,0 +1,103 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Этот код создан программой.
// Исполняемая версия:4.0.30319.42000
//
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
// повторной генерации кода.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Accounting_Time_It_Company.Properties {
using System;
/// <summary>
/// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д.
/// </summary>
// Этот класс создан автоматически классом StronglyTypedResourceBuilder
// с помощью такого средства, как ResGen или Visual Studio.
// Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen
// с параметром /str или перестройте свой проект VS.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Accounting_Time_It_Company.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Перезаписывает свойство CurrentUICulture текущего потока для всех
/// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap Add {
get {
object obj = ResourceManager.GetObject("Add", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap BG {
get {
object obj = ResourceManager.GetObject("BG", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap Delete {
get {
object obj = ResourceManager.GetObject("Delete", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap Update {
get {
object obj = ResourceManager.GetObject("Update", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
}
}

View File

@ -0,0 +1,133 @@
<?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>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="BG" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\BG.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="Add" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Add.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="Delete" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Delete.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="Update" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Update.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

View File

@ -0,0 +1,44 @@
using Accounting_Time_It_Company.Repositories;
using Microsoft.Extensions.Logging;
namespace Accounting_Time_It_Company.Reports;
internal class ChartReport
{
private readonly IVacationRepositories _vacationRepositories;
private readonly ILogger<ChartReport> _logger;
public ChartReport(IVacationRepositories feedingAnimalRepository,
ILogger<ChartReport> logger)
{
_vacationRepositories = feedingAnimalRepository ?? throw new ArgumentNullException(nameof(feedingAnimalRepository));
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
}
public bool CreateChart(string filePath, DateTime dateTime)
{
try
{
new PdfBuilder(filePath)
.AddHeader("Отпуска сотрудников")
.AddPieChart("Выданные часы", GetData(dateTime))
.Build();
return true;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при формировании документа");
return false;
}
}
private List<(string Caption, double Value)> GetData(DateTime dateTime)
{
return _vacationRepositories
.ReadVacations()
.Where(x => x.StartDate.Date <= dateTime.Date && x.EndDate.Date >= dateTime.Date)
.GroupBy(x => x.EmployeeId, (key, group) => new {
Id = key,
Count = group.Sum(x => (x.EndDate - x.StartDate).TotalHours)
})
.Select(x => (x.Id.ToString(), (double)x.Count))
.ToList();
}
}

View File

@ -0,0 +1,99 @@
using Accounting_Time_It_Company.Repositories;
using Microsoft.Extensions.Logging;
namespace Accounting_Time_It_Company.Reports;
internal class DocReport
{
private readonly IClientRepositories _clientRepository;
private readonly IEmployeeRepositories _employeeRepository;
private readonly IPostRepositories _postRepository;
private readonly IProductRepositories _productRepository;
private readonly ILogger<DocReport> _logger;
public DocReport(IClientRepositories clientRepository, IEmployeeRepositories employeeRepository,
IPostRepositories postRepository, IProductRepositories productRepository, ILogger<DocReport> logger)
{
_clientRepository = clientRepository ??
throw new ArgumentNullException(nameof(clientRepository));
_employeeRepository = employeeRepository ??
throw new ArgumentNullException(nameof(employeeRepository));
_postRepository = postRepository ??
throw new ArgumentNullException(nameof(postRepository));
_productRepository = productRepository ?? throw new ArgumentNullException(nameof(productRepository));
_logger = logger ??
throw new ArgumentNullException(nameof(logger));
}
public bool CreateDoc(string filePath, bool includeClients, bool
includeEmployees, bool includePosts, bool includeProducts)
{
try
{
var builder = new WordBuilder(filePath)
.AddHeader("Документ со справочниками");
if (includeClients)
{
builder.AddParagraph("Клиенты")
.AddTable([2400, 2400],
GetClients());
}
if (includeEmployees)
{
builder.AddParagraph("Работники")
.AddTable([2400, 1200, 2400, 1200], GetEmployess());
}
if (includePosts)
{
builder.AddParagraph("Должности")
.AddTable([2400, 1200, 1200], GetPosts());
}
if (includeProducts)
{
builder.AddParagraph("Проекты")
.AddTable([1200, 2400, 2400], GetProducts());
}
builder.Build();
return true;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при формировании документа");
return false;
}
}
private List<string[]> GetClients()
{
return [
["Имя клиента", "Телефон"],
.. _clientRepository
.ReadClients()
.Select(x => new string[] { x.NameClient, x.Phone}),
];
}
private List<string[]> GetEmployess()
{
return [
["Имя", "Id должности", "Телефон", "Надбавка"],
.. _employeeRepository
.ReadEmployees()
.Select(x => new string[] { x.Name, x.PostId.ToString(), x.Phone, x.Allowance.ToString() }),
];
}
private List<string[]> GetPosts()
{
return [
["Название", "Уровень", "Зарплата"],
.. _postRepository
.ReadPosts()
.Select(x => new string[] { x.NamePost.ToString(), x.LevelPost, x.Wage.ToString() }),
];
}
private List<string[]> GetProducts()
{
return [
["Id заказчика", "Название", "Тип"],
.. _productRepository
.ReadProducts()
.Select(x => new string[] { x.ClientId.ToString(), x.Name, x.Type.ToString() }),
];
}
}

View File

@ -0,0 +1,314 @@
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Spreadsheet;
using DocumentFormat.OpenXml;
namespace Accounting_Time_It_Company.Reports;
internal class ExcelBuilder
{
private readonly string _filePath;
private readonly SheetData _sheetData;
private readonly MergeCells _mergeCells;
private readonly Columns _columns;
private uint _rowIndex = 0;
public ExcelBuilder(string filePath)
{
if (string.IsNullOrWhiteSpace(filePath))
{
throw new ArgumentNullException(nameof(filePath));
}
if (File.Exists(filePath))
{
File.Delete(filePath);
}
_filePath = filePath;
_sheetData = new SheetData();
_mergeCells = new MergeCells();
_columns = new Columns();
_rowIndex = 1;
}
public ExcelBuilder AddHeader(string header, int startIndex, int count)
{
CreateCell(startIndex, _rowIndex, header,
StyleIndex.BoldTextWithoutBorder);
for (int i = startIndex + 1; i < startIndex + count; ++i)
{
CreateCell(i, _rowIndex, "",
StyleIndex.BoldTextWithoutBorder);
}
_mergeCells.Append(new MergeCell()
{
Reference = new StringValue($"{GetExcelColumnName(startIndex)}{_rowIndex}:{GetExcelColumnName(startIndex + count - 1)}{_rowIndex}")
});
_rowIndex++;
return this;
}
public ExcelBuilder AddParagraph(string text, int columnIndex)
{
CreateCell(columnIndex, _rowIndex++, text,
StyleIndex.SimpleTextWithoutBorder);
return this;
}
public ExcelBuilder AddTable(int[] columnsWidths, List<string[]> data)
{
if (columnsWidths == null || columnsWidths.Length == 0)
{
throw new ArgumentNullException(nameof(columnsWidths));
}
if (data == null || data.Count == 0)
{
throw new ArgumentNullException(nameof(data));
}
if (data.Any(x => x.Length != columnsWidths.Length))
{
throw new InvalidOperationException("widths.Length != data.Length");
}
uint counter = 1;
int coef = 2;
_columns.Append(columnsWidths.Select(x => new Column
{
Min = counter,
Max = counter++,
Width = x * coef,
CustomWidth = true
}));
for (var j = 0; j < data.First().Length; ++j)
{
CreateCell(j, _rowIndex, data.First()[j],
StyleIndex.BoldTextWithBorders);
}
_rowIndex++;
for (var i = 1; i < data.Count - 1; ++i)
{
for (var j = 0; j < data[i].Length; ++j)
{
CreateCell(j, _rowIndex, data[i][j],
StyleIndex.SimpleTextWithBorders);
}
_rowIndex++;
}
for (var j = 0; j < data.Last().Length; ++j)
{
CreateCell(j, _rowIndex, data.Last()[j],
StyleIndex.SimpleTextWithBorders);
}
_rowIndex++;
return this;
}
public void Build()
{
using var spreadsheetDocument = SpreadsheetDocument.Create(_filePath,
SpreadsheetDocumentType.Workbook);
var workbookpart = spreadsheetDocument.AddWorkbookPart();
GenerateStyle(workbookpart);
workbookpart.Workbook = new Workbook();
var worksheetPart = workbookpart.AddNewPart<WorksheetPart>();
worksheetPart.Worksheet = new Worksheet();
if (_columns.HasChildren)
{
worksheetPart.Worksheet.Append(_columns);
}
worksheetPart.Worksheet.Append(_sheetData);
var sheets =
spreadsheetDocument.WorkbookPart!.Workbook.AppendChild(new Sheets());
var sheet = new Sheet()
{
Id =
spreadsheetDocument.WorkbookPart.GetIdOfPart(worksheetPart),
SheetId = 1,
Name = "Лист 1"
};
sheets.Append(sheet);
if (_mergeCells.HasChildren)
{
worksheetPart.Worksheet.InsertAfter(_mergeCells,
worksheetPart.Worksheet.Elements<SheetData>().First());
}
}
private static void GenerateStyle(WorkbookPart workbookPart)
{
var workbookStylesPart =
workbookPart.AddNewPart<WorkbookStylesPart>();
workbookStylesPart.Stylesheet = new Stylesheet();
var fonts = new Fonts()
{
Count = 2,
KnownFonts = BooleanValue.FromBoolean(true)
};
fonts.Append(new DocumentFormat.OpenXml.Spreadsheet.Font
{
FontSize = new FontSize() { Val = 11 },
FontName = new FontName() { Val = "Calibri" },
FontFamilyNumbering = new FontFamilyNumbering() { Val = 2 },
FontScheme = new FontScheme()
{
Val = new EnumValue<FontSchemeValues>(FontSchemeValues.Minor)
}
});
// TODO добавить шрифт с жирным
fonts.Append(new DocumentFormat.OpenXml.Spreadsheet.Font
{
Bold = new Bold(),
FontSize = new FontSize() { Val = 11 },
FontName = new FontName() { Val = "Calibri" },
FontFamilyNumbering = new FontFamilyNumbering() { Val = 2 },
FontScheme = new FontScheme()
{
Val = new EnumValue<FontSchemeValues>(FontSchemeValues.Minor)
}
});
workbookStylesPart.Stylesheet.Append(fonts);
// Default Fill
var fills = new Fills() { Count = 1 };
fills.Append(new Fill
{
PatternFill = new PatternFill()
{
PatternType = new
EnumValue<PatternValues>(PatternValues.None)
}
});
workbookStylesPart.Stylesheet.Append(fills);
// Default Border
var borders = new Borders() { Count = 2 };
borders.Append(new Border
{
LeftBorder = new LeftBorder(),
RightBorder = new RightBorder(),
TopBorder = new TopBorder(),
BottomBorder = new BottomBorder(),
DiagonalBorder = new DiagonalBorder()
});
// TODO добавить настройку с границами
borders.Append(new Border
{
LeftBorder = new LeftBorder { Style = BorderStyleValues.Thin },
RightBorder = new RightBorder { Style = BorderStyleValues.Thin },
TopBorder = new TopBorder { Style = BorderStyleValues.Thin },
BottomBorder = new BottomBorder { Style = BorderStyleValues.Thin },
DiagonalBorder = new DiagonalBorder()
});
workbookStylesPart.Stylesheet.Append(borders);
var cellFormats = new CellFormats() { Count = 4 };
cellFormats.Append(new CellFormat
{
NumberFormatId = 0,
FormatId = 0,
FontId = 0,
BorderId = 0,
FillId = 0,
Alignment = new Alignment()
{
Horizontal = HorizontalAlignmentValues.Left,
Vertical = VerticalAlignmentValues.Center,
WrapText = true
}
});
// TODO дополнить форматы
cellFormats.Append(new CellFormat
{
NumberFormatId = 1,
FormatId = 0,
FontId = 1,
BorderId = 1,
FillId = 0,
Alignment = new Alignment()
{
Horizontal = HorizontalAlignmentValues.Left,
Vertical = VerticalAlignmentValues.Center,
WrapText = true
}
});
cellFormats.Append(new CellFormat
{
NumberFormatId = 2,
FormatId = 0,
FontId = 0,
BorderId = 1,
FillId = 0,
Alignment = new Alignment()
{
Horizontal = HorizontalAlignmentValues.Left,
Vertical = VerticalAlignmentValues.Center,
WrapText = true
}
});
cellFormats.Append(new CellFormat
{
NumberFormatId = 3,
FormatId = 0,
FontId = 1,
BorderId = 0,
FillId = 0,
Alignment = new Alignment()
{
Horizontal = HorizontalAlignmentValues.Left,
Vertical = VerticalAlignmentValues.Center,
WrapText = true
}
});
workbookStylesPart.Stylesheet.Append(cellFormats);
}
private enum StyleIndex
{
SimpleTextWithoutBorder = 0,
BoldTextWithBorders = 1,
SimpleTextWithBorders = 2,
BoldTextWithoutBorder = 3
}
private void CreateCell(int columnIndex, uint rowIndex, string text, StyleIndex styleIndex)
{
var columnName = GetExcelColumnName(columnIndex);
var cellReference = columnName + rowIndex;
var row = _sheetData.Elements<Row>().FirstOrDefault(r => r.RowIndex!
== rowIndex);
if (row == null)
{
row = new Row() { RowIndex = rowIndex };
_sheetData.Append(row);
}
var newCell = row.Elements<Cell>()
.FirstOrDefault(c => c.CellReference != null &&
c.CellReference.Value == columnName + rowIndex);
if (newCell == null)
{
Cell? refCell = null;
foreach (Cell cell in row.Elements<Cell>())
{
if (cell.CellReference?.Value != null &&
cell.CellReference.Value.Length == cellReference.Length)
{
if (string.Compare(cell.CellReference.Value,
cellReference, true) > 0)
{
refCell = cell;
break;
}
}
}
newCell = new Cell() { CellReference = cellReference };
row.InsertBefore(newCell, refCell);
}
newCell.CellValue = new CellValue(text);
newCell.DataType = CellValues.String;
newCell.StyleIndex = (uint)styleIndex;
}
private static string GetExcelColumnName(int columnNumber)
{
columnNumber += 1;
int dividend = columnNumber;
string columnName = string.Empty;
int modulo;
while (dividend > 0)
{
modulo = (dividend - 1) % 26;
columnName = Convert.ToChar(65 + modulo).ToString() +
columnName;
dividend = (dividend - modulo) / 26;
}
return columnName;
}
}

View File

@ -0,0 +1,75 @@
using MigraDoc.DocumentObjectModel;
using MigraDoc.DocumentObjectModel.Shapes.Charts;
using MigraDoc.Rendering;
using System.Text;
namespace Accounting_Time_It_Company.Reports;
internal class PdfBuilder
{
private readonly string _filePath;
private readonly Document _document;
public PdfBuilder(string filePath)
{
if (string.IsNullOrWhiteSpace(filePath))
{
throw new ArgumentNullException(nameof(filePath));
}
if (File.Exists(filePath))
{
File.Delete(filePath);
}
_filePath = filePath;
_document = new Document();
DefineStyles();
}
public PdfBuilder AddHeader(string header)
{
_document.AddSection().AddParagraph(header, "NormalBold");
return this;
}
public PdfBuilder AddPieChart(string title, List<(string Caption, double
Value)> data)
{
if (data == null || data.Count == 0)
{
return this;
}
var chart = new Chart(ChartType.Pie2D);
var series = chart.SeriesCollection.AddSeries();
series.Add(data.Select(x => x.Value).ToArray());
var xseries = chart.XValues.AddXSeries();
xseries.Add(data.Select(x => x.Caption).ToArray());
chart.DataLabel.Type = DataLabelType.Percent;
chart.DataLabel.Position = DataLabelPosition.OutsideEnd;
chart.Width = Unit.FromCentimeter(16);
chart.Height = Unit.FromCentimeter(12);
chart.TopArea.AddParagraph(title);
chart.XAxis.MajorTickMark = TickMarkType.Outside;
chart.YAxis.MajorTickMark = TickMarkType.Outside;
chart.YAxis.HasMajorGridlines = true;
chart.PlotArea.LineFormat.Width = 1;
chart.PlotArea.LineFormat.Visible = true;
chart.TopArea.AddLegend();
_document.LastSection.Add(chart);
return this;
}
public void Build()
{
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
var renderer = new PdfDocumentRenderer(true)
{
Document = _document
};
renderer.RenderDocument();
renderer.PdfDocument.Save(_filePath);
}
private void DefineStyles()
{
// TODO задать стиль для заголовка (жирный)
var headerStyle = _document.Styles.AddStyle("HeaderStyle", "Normal");
headerStyle.Font.Bold = true;
headerStyle.Font.Size = 14;
headerStyle.ParagraphFormat.Alignment = ParagraphAlignment.Center;
}
}

View File

@ -0,0 +1,82 @@

using Accounting_Time_It_Company.Entities;
using Accounting_Time_It_Company.Repositories;
using Microsoft.Extensions.Logging;
using System.Diagnostics.Metrics;
using System.Linq;
namespace Accounting_Time_It_Company.Reports;
internal class TableReport
{
private readonly ITypeJobRepositories _typeJobRepositories;
private readonly IVacationRepositories _vacationRepositories;
private readonly ILogger<TableReport> _logger;
internal static readonly string[] item = ["Ответственный", "Дата", "Отработано часов", "Дней отпуска"];
public TableReport(ITypeJobRepositories typeJobRepositories,
IVacationRepositories vacationRepositories, ILogger<TableReport> logger)
{
_typeJobRepositories = typeJobRepositories ??
throw new ArgumentNullException(nameof(typeJobRepositories));
_vacationRepositories = vacationRepositories ??
throw new ArgumentNullException(nameof(vacationRepositories));
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
}
public bool CreateTable(string filePath, int employeeId, DateTime startDate, DateTime endDate)
{
try
{
new ExcelBuilder(filePath)
.AddHeader("Сводка по работе сотрудников", 0, 6)
.AddParagraph("за период", 0)
.AddTable([10, 10, 15, 15], GetData(employeeId, startDate, endDate)).Build();
return true;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при формировании документа");
return false;
}
}
private List<string[]> GetData(int employeeId, DateTime startDate, DateTime endDate)
{
// бяда
var data = _typeJobRepositories
.ReadTypeJobs()
.Where(x => x.Date >= startDate && x.Date <= endDate
&& (x.WorkTimesDevelop.Any(y => y.EmployeeId == employeeId)
|| x.WorkTimesManager.Any(y => y.EmployeeId == employeeId)))
.Select(x => new {
x.DirectorId,
x.Date,
CountIn = x.WorkTimesManager.Concat(x.WorkTimesDevelop).FirstOrDefault(y => y.EmployeeId == employeeId)?.Hours,
CountOut = (int?)null,
})
.Union(_vacationRepositories
.ReadVacations()
.Where(x => x.StartDate >= startDate
&& x.StartDate <= endDate
&& x.EmployeeId == employeeId)
.Select(x => new {
x.DirectorId,
Date = x.StartDate,
CountIn = (int?)null,
CountOut = (int?)(x.EndDate - x.StartDate).TotalDays,
}))
.OrderBy(x => x.Date);
return new List<string[]>() { item }
.Union(data.Select(x => new string[] {
x.DirectorId.ToString(), x.Date.ToString(),
x.CountIn?.ToString() ?? string.Empty, x.CountOut?.ToString() ?? string.Empty}))
.Union(
[["Всего", "", data.Sum(x => x.CountIn ?? 0).ToString(), data.Sum(x => x.CountOut ?? 0).ToString()]])
.ToList();
}
}

View File

@ -0,0 +1,129 @@
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Wordprocessing;
using DocumentFormat.OpenXml;
namespace Accounting_Time_It_Company.Reports;
internal class WordBuilder
{
private readonly string _filePath;
private readonly Document _document;
private readonly Body _body;
public WordBuilder(string filePath)
{
if (string.IsNullOrWhiteSpace(filePath))
{
throw new ArgumentNullException(nameof(filePath));
}
if (File.Exists(filePath))
{
File.Delete(filePath);
}
_filePath = filePath;
_document = new Document();
_body = _document.AppendChild(new Body());
}
public WordBuilder AddHeader(string header)
{
var paragraph = _body.AppendChild(new Paragraph());
var run = paragraph.AppendChild(new Run());
// TODO прописать настройки под жирный текст
var runProperties = new RunProperties();
runProperties.AppendChild(new Bold());
run.AppendChild(runProperties);
run.AppendChild(new Text(header));
return this;
}
public WordBuilder AddParagraph(string text)
{
var paragraph = _body.AppendChild(new Paragraph());
var run = paragraph.AppendChild(new Run());
run.AppendChild(new Text(text));
return this;
}
public WordBuilder AddTable(int[] widths, List<string[]> data)
{
if (widths == null || widths.Length == 0)
{
throw new ArgumentNullException(nameof(widths));
}
if (data == null || data.Count == 0)
{
throw new ArgumentNullException(nameof(data));
}
if (data.Any(x => x.Length != widths.Length))
{
throw new InvalidOperationException("widths.Length != data.Length");
}
var table = new Table();
table.AppendChild(new TableProperties(
new TableBorders(
new TopBorder()
{
Val = new
EnumValue<BorderValues>(BorderValues.Single),
Size = 12
},
new BottomBorder()
{
Val = new
EnumValue<BorderValues>(BorderValues.Single),
Size = 12
},
new LeftBorder()
{
Val = new
EnumValue<BorderValues>(BorderValues.Single),
Size = 12
},
new RightBorder()
{
Val = new
EnumValue<BorderValues>(BorderValues.Single),
Size = 12
},
new InsideHorizontalBorder()
{
Val = new
EnumValue<BorderValues>(BorderValues.Single),
Size = 12
},
new InsideVerticalBorder()
{
Val = new
EnumValue<BorderValues>(BorderValues.Single),
Size = 12
}
)
));
// Заголовок
var tr = new TableRow();
for (var j = 0; j < widths.Length; ++j)
{
tr.Append(new TableCell(
new TableCellProperties(new TableCellWidth()
{
Width =
widths[j].ToString()
}),
new Paragraph(new Run(new RunProperties(new Bold()), new
Text(data.First()[j])))));
}
table.Append(tr);
// Данные
table.Append(data.Skip(1).Select(x =>
new TableRow(x.Select(y => new TableCell(new Paragraph(new
Run(new Text(y))))))));
_body.Append(table);
return this;
}
public void Build()
{
using var wordDocument = WordprocessingDocument.Create(_filePath,
WordprocessingDocumentType.Document);
var mainPart = wordDocument.AddMainDocumentPart();
mainPart.Document = _document;
}
}

View File

@ -0,0 +1,16 @@
using Accounting_Time_It_Company.Entities;
namespace Accounting_Time_It_Company.Repositories;
public interface IClientRepositories
{
IEnumerable<Client> ReadClients();
Client ReadClientById(int id);
void CreateClient(Client client);
void UpdateClient(Client client);
void DeleteClient(int id);
}

View File

@ -0,0 +1,7 @@

namespace Accounting_Time_It_Company.Repositories;
public interface IConnectionString
{
string ConnectionString { get; }
}

View File

@ -0,0 +1,16 @@
using Accounting_Time_It_Company.Entities;
namespace Accounting_Time_It_Company.Repositories;
public interface IEmployeeRepositories
{
IEnumerable<Employee> ReadEmployees();
Employee ReadEmployeeById(int id);
void CreateEmployee(Employee employee);
void UpdateEmployee(Employee employee);
void DeleteEmployee(int id);
}

View File

@ -0,0 +1,16 @@
using Accounting_Time_It_Company.Entities;
namespace Accounting_Time_It_Company.Repositories;
public interface IPostRepositories
{
IEnumerable<Post> ReadPosts();
Post ReadPostById(int id);
void CreatePost(Post post);
void UpdatePost(Post post);
void DeletePost(int id);
}

View File

@ -0,0 +1,16 @@
using Accounting_Time_It_Company.Entities;
namespace Accounting_Time_It_Company.Repositories;
public interface IProductRepositories
{
IEnumerable<Product> ReadProducts();
Product ReadProductById(int id);
void CreateProduct(Product product);
void UpdateProduct(Product product);
void DeleteProduct(int id);
}

View File

@ -0,0 +1,12 @@
using Accounting_Time_It_Company.Entities;
namespace Accounting_Time_It_Company.Repositories;
public interface ITypeJobRepositories
{
IEnumerable<TypeJob> ReadTypeJobs(DateTime? dateFrom = null, DateTime? dateTo = null, int? productId = null, int? directorId = null);
void CreateTypeJob(TypeJob typeJob);
void DeleteTypeJob(int id);
}

View File

@ -0,0 +1,12 @@
using Accounting_Time_It_Company.Entities;
namespace Accounting_Time_It_Company.Repositories;
public interface IVacationRepositories
{
IEnumerable<Vacation> ReadVacations(DateTime? startDateFrom = null, DateTime? startDateTo = null,
DateTime? endDateFrom = null, DateTime? endtDateTo = null,
int? employeeId = null, int? directorId = null);
void CreateVacation(Vacation vacation);
}

View File

@ -0,0 +1,128 @@
using Accounting_Time_It_Company.Entities;
using Dapper;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Npgsql;
using System.Data.SqlClient;
#pragma warning disable CS0618
namespace Accounting_Time_It_Company.Repositories.Implementations;
internal class ClientRepositories : IClientRepositories
{
private readonly IConnectionString _connectionString;
private readonly ILogger<ClientRepositories> _logger;
public ClientRepositories(IConnectionString connectionString, ILogger<ClientRepositories> logger)
{
_connectionString = connectionString;
_logger = logger;
}
public void CreateClient(Client client)
{
_logger.LogInformation("Добавление объекта");
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(client));
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
connection.Open();
var queryInsert = @"
INSERT INTO Client
VALUES (DEFAULT, @NameClient, @Phone)";
connection.Execute(queryInsert, client);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при добавдении объекта");
throw;
}
}
public void UpdateClient(Client client)
{
_logger.LogInformation("Редактирование объекта");
_logger.LogDebug("Объект: {json}",
JsonConvert.SerializeObject(client));
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
connection.Open();
var queryUpdate = @"
UPDATE Client
SET
NameClient=@NameClient,
Phone=@Phone
WHERE Id=@id";
connection.Execute(queryUpdate, client);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при редактировании объекта");
throw;
}
}
public void DeleteClient(int id)
{
_logger.LogInformation("Удаление объекта");
_logger.LogDebug("Объект: {id}", id);
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
connection.Open();
var queryDelete = @"
DELETE FROM Client
WHERE Id=@id";
connection.Execute(queryDelete, new { id });
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при удалении объекта");
throw;
}
}
public Client ReadClientById(int id)
{
_logger.LogInformation("Получение объекта по идентификатору");
_logger.LogDebug("Объект: {id}", id);
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
connection.Open();
var querySelect = @"
SELECT * FROM Client
WHERE Id=@id";
var client = connection.QueryFirst<Client>(querySelect, new { id });
_logger.LogDebug("Найденный объект: {json}", JsonConvert.SerializeObject(client));
return client;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при поиске объекта");
throw;
}
}
public IEnumerable<Client> ReadClients()
{
_logger.LogInformation("Получение всех объектов");
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
connection.Open();
var querySelect = "SELECT * FROM Client";
var clients = connection.Query<Client>(querySelect);
_logger.LogDebug("Полученные объекты: {json}",
JsonConvert.SerializeObject(clients));
return clients;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при чтении объектов");
throw;
}
}
}

View File

@ -0,0 +1,7 @@

namespace Accounting_Time_It_Company.Repositories.Implementations;
public class ConnectionString : IConnectionString
{
string IConnectionString.ConnectionString => "Server=localhost:5432;Database=workTime;User Id=postgres;Password=postgres;";
}

View File

@ -0,0 +1,128 @@
using Accounting_Time_It_Company.Entities;
using Dapper;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Npgsql;
namespace Accounting_Time_It_Company.Repositories.Implementations;
public class EmployeeRepositories : IEmployeeRepositories
{
private readonly IConnectionString _connectionString;
private readonly ILogger<EmployeeRepositories> _logger;
public EmployeeRepositories(IConnectionString connectionString, ILogger<EmployeeRepositories> logger)
{
_connectionString = connectionString;
_logger = logger;
}
public void CreateEmployee(Employee employee)
{
_logger.LogInformation("Добавление объекта");
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(employee));
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
connection.Open();
var queryInsert = @"
INSERT INTO Employee
VALUES (DEFAULT, @PostId, @Name, @Phone, @Allowance)";
connection.Execute(queryInsert, employee);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при добавдении объекта");
throw;
}
}
public void UpdateEmployee(Employee employee)
{
_logger.LogInformation("Редактирование объекта");
_logger.LogDebug("Объект: {json}",
JsonConvert.SerializeObject(employee));
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
connection.Open();
var queryUpdate = @"
UPDATE Employee
SET
PostId=@PostId,
Name=@Name,
Phone=@Phone,
Allowance=@Allowance
WHERE Id=@id";
connection.Execute(queryUpdate, employee);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при редактировании объекта");
throw;
}
}
public void DeleteEmployee(int id)
{
_logger.LogInformation("Удаление объекта");
_logger.LogDebug("Объект: {id}", id);
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
connection.Open();
var queryDelete = @"
DELETE FROM Employee
WHERE Id=@id";
connection.Execute(queryDelete, new { id });
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при удалении объекта");
throw;
}
}
public Employee ReadEmployeeById(int id)
{
_logger.LogInformation("Получение объекта по идентификатору");
_logger.LogDebug("Объект: {id}", id);
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
connection.Open();
var querySelect = @"
SELECT * FROM Employee
WHERE Id=@id";
var employee = connection.QueryFirst<Employee>(querySelect, new { id });
_logger.LogDebug("Найденный объект: {json}", JsonConvert.SerializeObject(employee));
return employee;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при поиске объекта");
throw;
}
}
public IEnumerable<Employee> ReadEmployees()
{
_logger.LogInformation("Получение всех объектов");
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
connection.Open();
var querySelect = "SELECT * FROM Employee";
var employees = connection.Query<Employee>(querySelect);
_logger.LogDebug("Полученные объекты: {json}",
JsonConvert.SerializeObject(employees));
return employees;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при чтении объектов");
throw;
}
}
}

View File

@ -0,0 +1,127 @@
using Accounting_Time_It_Company.Entities;
using Dapper;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Npgsql;
namespace Accounting_Time_It_Company.Repositories.Implementations;
public class PostRepositories : IPostRepositories
{
private readonly IConnectionString _connectionString;
private readonly ILogger<PostRepositories> _logger;
public PostRepositories(IConnectionString connectionString, ILogger<PostRepositories> logger)
{
_connectionString = connectionString;
_logger = logger;
}
public void CreatePost(Post post)
{
_logger.LogInformation("Добавление объекта");
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(post));
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
connection.Open();
var queryInsert = @"
INSERT INTO Post
VALUES (DEFAULT, @NamePost, @LevelPost, @Wage)";
connection.Execute(queryInsert, new { NamePost = post.NamePost.ToString(), post.LevelPost, post.Wage });
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при добавдении объекта");
throw;
}
}
public void UpdatePost(Post post)
{
_logger.LogInformation("Редактирование объекта");
_logger.LogDebug("Объект: {json}",
JsonConvert.SerializeObject(post));
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
connection.Open();
var queryUpdate = @"
UPDATE Post
SET
NamePost=@NamePost,
LevelPost=@LevelPost,
Wage=@Wage
WHERE Id=@id";
connection.Execute(queryUpdate, new { id = post.Id, NamePost = post.NamePost.ToString(), post.LevelPost, post.Wage });
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при редактировании объекта");
throw;
}
}
public void DeletePost(int id)
{
_logger.LogInformation("Удаление объекта");
_logger.LogDebug("Объект: {id}", id);
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
connection.Open();
var queryDelete = @"
DELETE FROM Post
WHERE Id=@id";
connection.Execute(queryDelete, new { id });
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при удалении объекта");
throw;
}
}
public Post ReadPostById(int id)
{
_logger.LogInformation("Получение объекта по идентификатору");
_logger.LogDebug("Объект: {id}", id);
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
connection.Open();
var querySelect = @"
SELECT * FROM Post
WHERE Id=@id";
var post = connection.QueryFirst<Post>(querySelect, new { id });
_logger.LogDebug("Найденный объект: {json}", JsonConvert.SerializeObject(post));
return post;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при поиске объекта");
throw;
}
}
public IEnumerable<Post> ReadPosts()
{
_logger.LogInformation("Получение всех объектов");
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
connection.Open();
var querySelect = "SELECT * FROM Post";
var posts = connection.Query<Post>(querySelect);
_logger.LogDebug("Полученные объекты: {json}",
JsonConvert.SerializeObject(posts));
return posts;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при чтении объектов");
throw;
}
}
}

View File

@ -0,0 +1,127 @@
using Accounting_Time_It_Company.Entities;
using Dapper;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Npgsql;
namespace Accounting_Time_It_Company.Repositories.Implementations;
public class ProductRepositories : IProductRepositories
{
private readonly IConnectionString _connectionString;
private readonly ILogger<ProductRepositories> _logger;
public ProductRepositories(IConnectionString connectionString, ILogger<ProductRepositories> logger)
{
_connectionString = connectionString;
_logger = logger;
}
public void CreateProduct(Product product)
{
_logger.LogInformation("Добавление объекта");
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(product));
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
connection.Open();
var queryInsert = @"
INSERT INTO Product
VALUES (DEFAULT, @ClientId, @Name, @Type)";
connection.Execute(queryInsert, product);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при добавдении объекта");
throw;
}
}
public void UpdateProduct(Product product)
{
_logger.LogInformation("Редактирование объекта");
_logger.LogDebug("Объект: {json}",
JsonConvert.SerializeObject(product));
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
connection.Open();
var queryUpdate = @"
UPDATE Product
SET
ClientId=@ClientId,
Name=@Name,
Type=@Type
WHERE Id=@id";
connection.Execute(queryUpdate, product);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при редактировании объекта");
throw;
}
}
public void DeleteProduct(int id)
{
_logger.LogInformation("Удаление объекта");
_logger.LogDebug("Объект: {id}", id);
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
connection.Open();
var queryDelete = @"
DELETE FROM Product
WHERE Id=@id";
connection.Execute(queryDelete, new { id });
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при удалении объекта");
throw;
}
}
public Product ReadProductById(int id)
{
_logger.LogInformation("Получение объекта по идентификатору");
_logger.LogDebug("Объект: {id}", id);
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
connection.Open();
var querySelect = @"
SELECT * FROM Product
WHERE Id=@id";
var product = connection.QueryFirst<Product>(querySelect, new { id });
_logger.LogDebug("Найденный объект: {json}", JsonConvert.SerializeObject(product));
return product;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при поиске объекта");
throw;
}
}
public IEnumerable<Product> ReadProducts()
{
_logger.LogInformation("Получение всех объектов");
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
connection.Open();
var querySelect = "SELECT * FROM Product";
var products = connection.Query<Product>(querySelect);
_logger.LogDebug("Полученные объекты: {json}",
JsonConvert.SerializeObject(products));
return products;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при чтении объектов");
throw;
}
}
}

View File

@ -0,0 +1,114 @@
using Accounting_Time_It_Company.Entities;
using Accounting_Time_It_Company.Entities.Enums;
using Dapper;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Npgsql;
namespace Accounting_Time_It_Company.Repositories.Implementations;
public class TypeJobRepositories : ITypeJobRepositories
{
private readonly IConnectionString _connectionString;
private readonly ILogger<TypeJobRepositories> _logger;
public TypeJobRepositories(IConnectionString connectionString, ILogger<TypeJobRepositories> logger)
{
_connectionString = connectionString;
_logger = logger;
}
public void CreateTypeJob(TypeJob typeJob)
{
_logger.LogInformation("Добавление объекта");
_logger.LogDebug("Объект: {json}",
JsonConvert.SerializeObject(typeJob));
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
connection.Open();
using var transaction = connection.BeginTransaction();
var queryInsert = @"
INSERT INTO TypeJob
VALUES (DEFAULT, @ProductId, @DirectorId, @Description, @AllowanceForJob, @Date);
SELECT MAX(Id) FROM TypeJob";
var typeJobId = connection.QueryFirst<int>(queryInsert, typeJob, transaction);
var querySubInsert = @"
INSERT INTO WorkTime
VALUES (DEFAULT, @TypeJobId, @EmployeeId, @Hours)";
foreach (var elem in typeJob.WorkTimesDevelop)
{
connection.Execute(querySubInsert, new
{
typeJobId,
elem.EmployeeId,
elem.Hours
}, transaction);
}
foreach (var elem in typeJob.WorkTimesManager)
{
connection.Execute(querySubInsert, new
{
typeJobId,
elem.EmployeeId,
elem.Hours
}, transaction);
}
transaction.Commit();
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при добавлении объекта");
throw;
}
}
public void DeleteTypeJob(int id)
{
_logger.LogInformation("Удаление объекта");
_logger.LogDebug("Объект: {id}", id);
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
connection.Open();
var queryDelete = @"
DELETE FROM TypeJob
WHERE Id=@id";
connection.Execute(queryDelete, new { id });
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при удалении объекта");
throw;
}
}
public IEnumerable<TypeJob> ReadTypeJobs(DateTime? dateFrom = null, DateTime? dateTo = null, int? productId = null, int? directorId = null)
{
_logger.LogInformation("Получение всех объектов");
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
connection.Open();
var querySelect = @"SELECT tj.*, wt.EmployeeId, wt.Hours, p.namepost
FROM TypeJob tj
INNER JOIN WorkTime wt ON wt.typejobid = tj.id
INNER JOIN Employee e ON e.id = wt.employeeid
INNER JOIN Post p ON p.id = e.PostId;";
var typeJobs = connection.Query<TempWorkTime>(querySelect);
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(typeJobs));
return typeJobs.GroupBy(x => x.Id, y => y,
(key, value) => TypeJob.CreateOperation(value.First(),
value.Where(z => z.NamePost == TypePost.Developer).Select(h => WorkTime.CreateElement(0, h.EmployeeId, h.Hours)).ToList(),
value.Where(z => z.NamePost == TypePost.Manager).Select(h => WorkTime.CreateElement(0, h.EmployeeId, h.Hours)).ToList())).ToList();
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при чтении объектов");
throw;
}
}
}

View File

@ -0,0 +1,63 @@
using Accounting_Time_It_Company.Entities;
using Dapper;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Npgsql;
namespace Accounting_Time_It_Company.Repositories.Implementations;
public class VacationRepositories : IVacationRepositories
{
private readonly IConnectionString _connectionString;
private readonly ILogger<VacationRepositories> _logger;
public VacationRepositories(IConnectionString connectionString, ILogger<VacationRepositories> logger)
{
_connectionString = connectionString;
_logger = logger;
}
public void CreateVacation(Vacation vacation)
{
_logger.LogInformation("Добавление объекта");
_logger.LogDebug("Объект: {json}",
JsonConvert.SerializeObject(vacation));
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
connection.Open();
var queryInsert = @"
INSERT INTO Vacation
VALUES (DEFAULT, @DirectorId, @EmployeeId, @StartDate, @EndDate)";
connection.Execute(queryInsert, vacation);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при добавлении объекта");
throw;
}
}
public IEnumerable<Vacation> ReadVacations(DateTime? startDateFrom = null, DateTime? startDateTo = null,
DateTime? endDateFrom = null, DateTime? endtDateTo = null,
int? employeeId = null, int? directorId = null)
{
_logger.LogInformation("Получение всех объектов");
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
connection.Open();
var querySelect = "SELECT * FROM Vacation";
var vacations = connection.Query<Vacation>(querySelect);
_logger.LogDebug("Полученные объекты: {json}",
JsonConvert.SerializeObject(vacations));
return vacations;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при чтении объектов");
throw;
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 73 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

View File

@ -0,0 +1,15 @@
{
"Serilog": {
"Using": [ "Serilog.Sinks.File" ],
"MinimumLevel": "Debug",
"WriteTo": [
{
"Name": "File",
"Args": {
"path": "Logs/company_log.txt",
"rollingInterval": "Day"
}
}
]
}
}