Compare commits

...

6 Commits

Author SHA1 Message Date
RomaEredavkin
f8ebb5c74b 4 лабараторная 2024-12-26 18:35:28 +04:00
RomaEredavkin
495cc259ca Лабараторная номер 3 2024-12-18 15:21:46 +04:00
RomaEredavkin
ba0ecef360 Лабараторная 2 конечная 2024-12-14 16:40:02 +04:00
RomaEredavkin
261d9f15c6 Лабараторная 2 2024-12-14 15:24:14 +04:00
RomaEredavkin
d30d0181c9 Лабараторная 1 V2.1 2024-12-10 12:31:06 +04:00
RomaEredavkin
9d4c05a076 Мега большой коммит всей фазы 2024-12-01 14:36:42 +04:00
85 changed files with 7181 additions and 75 deletions

View File

@ -0,0 +1,36 @@
using PIbd_24_EredavkinRA_BusBusiness.Entities.Enums;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PIbd_24_EredavkinRA_BusBusiness.Entities;
public class Bus
{
public int Id { get; private set; }
[DisplayName("Модель автобуса")]
public ModelType ModelType { get; private set; }
[DisplayName("Номерной знак")]
public string N_Z { get; private set; } = string.Empty;
[DisplayName("Вместимость автобуса")]
public int Capacity { get; private set; }
[DisplayName("Пробег")]
public double Bus_mileage { get; private set; }
public static Bus CreateEntity(int id, ModelType modeltype, string n_z, double bus_mileage, int capacity)
{
return new Bus
{
Id = id,
ModelType = modeltype,
N_Z = n_z ?? string.Empty,
Capacity = capacity,
Bus_mileage = bus_mileage
};
}
}

View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PIbd_24_EredavkinRA_BusBusiness.Entities.Enums;
[Flags]
public enum EmployeePost
{
None = 0,
Conductor = 1,
Driver = 2,
Mechanic = 4,
Boss = 8,
}

View File

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PIbd_24_EredavkinRA_BusBusiness.Entities.Enums;
public enum ModelType
{
None = 0,
Maz = 1,
Gaz = 2,
Mercedes = 3,
Ford = 4
}

View File

@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PIbd_24_EredavkinRA_BusBusiness.Entities;
public class Rout
{
public int Id { get; private set; }
[DisplayName("Начальная остановка")]
public string StartStop { get; private set; } = string.Empty;
[DisplayName("Конечная остановка")]
public string EndStop { get; private set; } = string.Empty;
[DisplayName("Номер Маршрута")]
public int NumberRout { get; private set; }
public string FullRout => $"{NumberRout} {StartStop} {EndStop}";
public static Rout CreateEntity(int id, string startstop, string endstop, int numberrout)
{
return new Rout
{
Id = id,
StartStop = startstop ?? string.Empty,
EndStop = endstop ?? string.Empty,
NumberRout = numberrout
};
}
}

View File

@ -0,0 +1,54 @@
using DocumentFormat.OpenXml.Bibliography;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PIbd_24_EredavkinRA_BusBusiness.Entities;
public class RoutSheet
{
public int Id { get; private set; }
[Browsable(false)]
public int DriverId { get; private set; }
[Browsable(false)]
public int ConductorId { get; private set; }
[Browsable(false)]
public int RoutId { get; private set; }
[DisplayName("Водитель")]
public string EmployeeNameDriver { get; private set; } = string.Empty;
[DisplayName("Кондуктор")]
public string EmployeeNameConductor { get; private set; } = string.Empty;
[DisplayName("Маршрут")]
public string RoutName { get; private set; } = string.Empty;
[DisplayName("Автобусы")]
public string Bus => RoutSheetBus != null ? string.Join(", ", RoutSheetBus.Select(x => $"{x.BusName}")) : string.Empty;
[Browsable(false)]
public IEnumerable<RoutSheetBus> RoutSheetBus { get; private set; } = [];
[DisplayName("Дата Выезда")]
public DateTime BusDate { get; private set; }
public static RoutSheet CreatOpeartion(int id, int driverid, int conductorid, int routid, DateTime busDate, IEnumerable<RoutSheetBus> RoutSheetBus)
{
return new RoutSheet
{
Id = id,
DriverId = driverid,
ConductorId = conductorid,
RoutId = routid,
RoutSheetBus = RoutSheetBus,
BusDate = busDate
};
}
public void SetRoutSheetBus(IEnumerable<RoutSheetBus> routSheetBus)
{
if (routSheetBus != null && routSheetBus.Any())
{
RoutSheetBus = routSheetBus;
}
}
}

View File

@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PIbd_24_EredavkinRA_BusBusiness.Entities;
public class RoutSheetBus
{
public int Id { get; private set; }
public int BusID { get; private set; }
public string BusName { get; set; } = string.Empty;
public static RoutSheetBus CreateElement(int id, int busid)
{
return new RoutSheetBus
{
Id = id,
BusID = busid,
};
}
}

View File

@ -0,0 +1,31 @@
using PIbd_24_EredavkinRA_BusBusiness.Entities.Enums;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PIbd_24_EredavkinRA_BusBusiness.Entities;
public class Staff
{
public int Id { get; private set; }
[DisplayName("Имя")]
public string FirstName { get; private set; } = string.Empty;
[DisplayName("Фамилия")]
public string LastName { get; private set; } = string.Empty;
public string FullName => $"{LastName} {FirstName}";
[DisplayName("Должность")]
public EmployeePost EmployeePost { get; private set; }
public static Staff CreatEntity(int id, string first, string last, EmployeePost employeePost)
{
return new Staff
{
Id = id,
FirstName = first ?? string.Empty,
LastName = last ?? string.Empty,
EmployeePost = employeePost
};
}
}

View File

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PIbd_24_EredavkinRA_BusBusiness.Entities;
public class TempRoutSheetBus
{
public int Id { get; private set; }
public int DriverId { get; private set; }
public int ConductorId { get; private set; }
public int RoutId { get; private set; }
public DateTime BusDate { get; private set; }
public int BusId { get; private set; }
public decimal Cost { get; private set; }
}

View File

@ -0,0 +1,43 @@
using Microsoft.VisualBasic;
using PIbd_24_EredavkinRA_BusBusiness.Entities.Enums;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PIbd_24_EredavkinRA_BusBusiness.Entities;
public class To
{
public int Id { get; private set; }
[Browsable(false)]
public int BusID { get; private set; }
[Browsable(false)]
public int StaffID { get; private set; }
[DisplayName("Автобус")]
public string BusName { get; set; } = string.Empty;
[DisplayName("Механик")]
public string StaffName { get; set; } = string.Empty;
[DisplayName("Описание")]
public string Discription { get; private set; } = string.Empty;
[DisplayName("Стоимость Ремонта")]
public double Cost { get; private set; }
[DisplayName("Дата дня")]
public DateTime DateTo { get; private set; }
public static To CreatOperation(int id, string discription, double cost, DateTime dateTo, int busid, int staffid)
{
return new To()
{
Id = id,
Discription = discription ?? string.Empty,
Cost = cost,
DateTo = dateTo,
BusID = busid,
StaffID = staffid
};
}
}

View File

@ -1,39 +0,0 @@
namespace PIbd_24_EredavkinRA_BusBusiness
{
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 PIbd_24_EredavkinRA_BusBusiness
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}

View File

@ -0,0 +1,168 @@
namespace PIbd_24_EredavkinRA_BusBusiness
{
partial class FormBus
{
/// <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();
RefrencesToolStripMenuItem = new ToolStripMenuItem();
StaffToolStripMenuItem = new ToolStripMenuItem();
BusToolStripMenuItem = new ToolStripMenuItem();
RoutToolStripMenuItem = new ToolStripMenuItem();
ToToolStripMenuItem = new ToolStripMenuItem();
RoutSheetToolStripMenuItem = new ToolStripMenuItem();
ToesToolStripMenuItem = new ToolStripMenuItem();
отчетыToolStripMenuItem = new ToolStripMenuItem();
DirectoryReportToolStripMenuItem = new ToolStripMenuItem();
ToolStripMenuItem = new ToolStripMenuItem();
ToolStripMenuItemTo = new ToolStripMenuItem();
menuStrip1.SuspendLayout();
SuspendLayout();
//
// menuStrip1
//
menuStrip1.Items.AddRange(new ToolStripItem[] { RefrencesToolStripMenuItem, ToToolStripMenuItem, отчетыToolStripMenuItem });
menuStrip1.Location = new Point(0, 0);
menuStrip1.Name = "menuStrip1";
menuStrip1.Size = new Size(784, 24);
menuStrip1.TabIndex = 0;
menuStrip1.Text = "menuStrip1";
//
// RefrencesToolStripMenuItem
//
RefrencesToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { StaffToolStripMenuItem, BusToolStripMenuItem, RoutToolStripMenuItem });
RefrencesToolStripMenuItem.Name = "RefrencesToolStripMenuItem";
RefrencesToolStripMenuItem.Size = new Size(94, 20);
RefrencesToolStripMenuItem.Text = "Справочники";
//
// StaffToolStripMenuItem
//
StaffToolStripMenuItem.Name = "StaffToolStripMenuItem";
StaffToolStripMenuItem.Size = new Size(136, 22);
StaffToolStripMenuItem.Text = "Работники";
StaffToolStripMenuItem.Click += StaffToolStripMenuItem_Click;
//
// BusToolStripMenuItem
//
BusToolStripMenuItem.Name = "BusToolStripMenuItem";
BusToolStripMenuItem.Size = new Size(136, 22);
BusToolStripMenuItem.Text = "Автобусы";
BusToolStripMenuItem.Click += BusToolStripMenuItem_Click;
//
// RoutToolStripMenuItem
//
RoutToolStripMenuItem.Name = "RoutToolStripMenuItem";
RoutToolStripMenuItem.Size = new Size(136, 22);
RoutToolStripMenuItem.Text = "Маршруты";
RoutToolStripMenuItem.Click += RoutToolStripMenuItem_Click;
//
// ToToolStripMenuItem
//
ToToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { RoutSheetToolStripMenuItem, ToesToolStripMenuItem });
ToToolStripMenuItem.Name = "ToToolStripMenuItem";
ToToolStripMenuItem.Size = new Size(75, 20);
ToToolStripMenuItem.Text = "Операции";
//
// RoutSheetToolStripMenuItem
//
RoutSheetToolStripMenuItem.Name = "RoutSheetToolStripMenuItem";
RoutSheetToolStripMenuItem.Size = new Size(309, 22);
RoutSheetToolStripMenuItem.Text = "Получение Маршрутного листа";
RoutSheetToolStripMenuItem.Click += RoutSheetToolStripMenuItem_Click;
//
// ToesToolStripMenuItem
//
ToesToolStripMenuItem.Name = "ToesToolStripMenuItem";
ToesToolStripMenuItem.Size = new Size(309, 22);
ToesToolStripMenuItem.Text = "Проведение Технического Обслуживания ";
ToesToolStripMenuItem.Click += ToesToolStripMenuItem_Click_1;
//
// отчетыToolStripMenuItem
//
отчетыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { DirectoryReportToolStripMenuItem, ToolStripMenuItem, ToolStripMenuItemTo });
отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
отчетыToolStripMenuItem.Size = new Size(60, 20);
отчетыToolStripMenuItem.Text = "Отчеты";
//
// DirectoryReportToolStripMenuItem
//
DirectoryReportToolStripMenuItem.Name = "DirectoryReportToolStripMenuItem";
DirectoryReportToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.W;
DirectoryReportToolStripMenuItem.Size = new Size(362, 22);
DirectoryReportToolStripMenuItem.Text = "Документ со справочниками";
DirectoryReportToolStripMenuItem.Click += DirectoryReportToolStripMenuItem_Click;
//
// ToolStripMenuItem
//
ToolStripMenuItem.Name = "ToolStripMenuItem";
ToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.E;
ToolStripMenuItem.Size = new Size(362, 22);
ToolStripMenuItem.Text = "Сводка по Автобусам";
ToolStripMenuItem.Click += ToolStripMenuItem_Click;
//
// ToolStripMenuItemTo
//
ToolStripMenuItemTo.Name = "ToolStripMenuItemTo";
ToolStripMenuItemTo.ShortcutKeys = Keys.Control | Keys.P;
ToolStripMenuItemTo.Size = new Size(362, 22);
ToolStripMenuItemTo.Text = "Распределение Технического обслуживания";
ToolStripMenuItemTo.Click += ToolStripMenuItemTo_Click;
//
// FormBus
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
BackgroundImage = Properties.Resources.МАТП;
BackgroundImageLayout = ImageLayout.Stretch;
ClientSize = new Size(784, 411);
Controls.Add(menuStrip1);
MainMenuStrip = menuStrip1;
Name = "FormBus";
StartPosition = FormStartPosition.CenterScreen;
Text = "МАТП ";
menuStrip1.ResumeLayout(false);
menuStrip1.PerformLayout();
ResumeLayout(false);
PerformLayout();
}
#endregion
private MenuStrip menuStrip1;
private ToolStripMenuItem RefrencesToolStripMenuItem;
private ToolStripMenuItem StaffToolStripMenuItem;
private ToolStripMenuItem BusToolStripMenuItem;
private ToolStripMenuItem RoutToolStripMenuItem;
private ToolStripMenuItem RoutSheetToolStripMenuItem;
private ToolStripMenuItem отчетыToolStripMenuItem;
private ToolStripMenuItem ToesToolStripMenuItem;
private ToolStripMenuItem ToToolStripMenuItem;
private ToolStripMenuItem DirectoryReportToolStripMenuItem;
private ToolStripMenuItem ToolStripMenuItem;
private ToolStripMenuItem ToolStripMenuItemTo;
}
}

View File

@ -0,0 +1,117 @@
using PIbd_24_EredavkinRA_BusBusiness.Forms;
using System.ComponentModel;
using Unity;
namespace PIbd_24_EredavkinRA_BusBusiness;
public partial class FormBus : Form
{
private readonly IUnityContainer _container;
public FormBus(IUnityContainer container)
{
InitializeComponent();
_container = container ?? throw new ArgumentException(nameof(container));
}
private void StaffToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormStaffes>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void BusToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormBuses>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void RoutToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormRoutes>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void RoutSheetToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormRoutSheetes>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ToesToolStripMenuItem_Click_1(object sender, EventArgs e)
{
try
{
_container.Resolve<FormTOes>().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 ToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormBusReport>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ToolStripMenuItemTo_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormToDistributionReport>().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,171 @@
namespace PIbd_24_EredavkinRA_BusBusiness.Forms
{
partial class FormBus
{
/// <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()
{
labelModel = new Label();
labelNZ = new Label();
labelMileage = new Label();
labelCpacity = new Label();
textBoxNZ = new TextBox();
numericUpDownCapacity = new NumericUpDown();
Mileage = new NumericUpDown();
buttonSave = new Button();
buttonleave = new Button();
comboBoxBus = new ComboBox();
((System.ComponentModel.ISupportInitialize)numericUpDownCapacity).BeginInit();
((System.ComponentModel.ISupportInitialize)Mileage).BeginInit();
SuspendLayout();
//
// labelModel
//
labelModel.AutoSize = true;
labelModel.Location = new Point(33, 24);
labelModel.Name = "labelModel";
labelModel.Size = new Size(104, 15);
labelModel.TabIndex = 0;
labelModel.Text = "Модель Автобуса";
//
// labelNZ
//
labelNZ.AutoSize = true;
labelNZ.Location = new Point(33, 67);
labelNZ.Name = "labelNZ";
labelNZ.Size = new Size(143, 15);
labelNZ.TabIndex = 1;
labelNZ.Text = "Государственный номер";
//
// labelMileage
//
labelMileage.AutoSize = true;
labelMileage.Location = new Point(33, 107);
labelMileage.Name = "labelMileage";
labelMileage.Size = new Size(48, 15);
labelMileage.TabIndex = 2;
labelMileage.Text = "Пробег";
//
// labelCpacity
//
labelCpacity.AutoSize = true;
labelCpacity.Location = new Point(24, 147);
labelCpacity.Name = "labelCpacity";
labelCpacity.Size = new Size(223, 15);
labelCpacity.TabIndex = 3;
labelCpacity.Text = "Максимально Количество пассажиров";
//
// textBoxNZ
//
textBoxNZ.Location = new Point(182, 59);
textBoxNZ.Name = "textBoxNZ";
textBoxNZ.Size = new Size(386, 23);
textBoxNZ.TabIndex = 5;
//
// numericUpDownCapacity
//
numericUpDownCapacity.Location = new Point(253, 147);
numericUpDownCapacity.Maximum = new decimal(new int[] { 2000000, 0, 0, 0 });
numericUpDownCapacity.Name = "numericUpDownCapacity";
numericUpDownCapacity.Size = new Size(199, 23);
numericUpDownCapacity.TabIndex = 6;
//
// Mileage
//
Mileage.DecimalPlaces = 2;
Mileage.Location = new Point(182, 105);
Mileage.Maximum = new decimal(new int[] { 1000000, 0, 0, 0 });
Mileage.Name = "Mileage";
Mileage.Size = new Size(131, 23);
Mileage.TabIndex = 7;
//
// buttonSave
//
buttonSave.Location = new Point(24, 277);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(213, 23);
buttonSave.TabIndex = 8;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += buttonSave_Click;
//
// buttonleave
//
buttonleave.Location = new Point(348, 277);
buttonleave.Name = "buttonleave";
buttonleave.Size = new Size(220, 23);
buttonleave.TabIndex = 9;
buttonleave.Text = "Выйти ";
buttonleave.UseVisualStyleBackColor = true;
buttonleave.Click += buttonleave_Click;
//
// comboBoxBus
//
comboBoxBus.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxBus.FormattingEnabled = true;
comboBoxBus.Location = new Point(182, 16);
comboBoxBus.Name = "comboBoxBus";
comboBoxBus.Size = new Size(386, 23);
comboBoxBus.TabIndex = 16;
//
// FormBus
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(601, 307);
Controls.Add(comboBoxBus);
Controls.Add(buttonleave);
Controls.Add(buttonSave);
Controls.Add(Mileage);
Controls.Add(numericUpDownCapacity);
Controls.Add(textBoxNZ);
Controls.Add(labelCpacity);
Controls.Add(labelMileage);
Controls.Add(labelNZ);
Controls.Add(labelModel);
Name = "FormBus";
StartPosition = FormStartPosition.CenterParent;
Text = "Автобусы";
((System.ComponentModel.ISupportInitialize)numericUpDownCapacity).EndInit();
((System.ComponentModel.ISupportInitialize)Mileage).EndInit();
ResumeLayout(false);
PerformLayout();
}
#endregion
private Label labelModel;
private Label labelNZ;
private Label labelMileage;
private Label labelCpacity;
private TextBox textBoxNZ;
private NumericUpDown numericUpDownCapacity;
private NumericUpDown Mileage;
private Button buttonSave;
private Button buttonleave;
private ComboBox comboBoxBus;
}
}

View File

@ -0,0 +1,90 @@
using PIbd_24_EredavkinRA_BusBusiness.Entities;
using PIbd_24_EredavkinRA_BusBusiness.Entities.Enums;
using PIbd_24_EredavkinRA_BusBusiness.Repositories;
using PIbd_24_EredavkinRA_BusBusiness.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;
namespace PIbd_24_EredavkinRA_BusBusiness.Forms;
public partial class FormBus : Form
{
private readonly IBusRepository _busRepository;
private int? _busId;
public int Id
{
set
{
try
{
var bus = _busRepository.ReadBusByID(value);
if (bus == null)
{
throw new InvalidDataException(nameof(bus));
}
comboBoxBus.SelectedItem = bus.ModelType;
textBoxNZ.Text = bus.N_Z;
Mileage.Value = (decimal)bus.Bus_mileage;
numericUpDownCapacity.Value = bus.Capacity;
_busId = bus.Id;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
}
public FormBus(IBusRepository busRepository)
{
InitializeComponent();
_busRepository = busRepository ??
throw new ArgumentNullException(nameof(busRepository));
comboBoxBus.DataSource = Enum.GetValues(typeof(ModelType));
}
private void buttonSave_Click(object sender, EventArgs e)
{
try
{
if (comboBoxBus.SelectedIndex < 1 || string.IsNullOrWhiteSpace(textBoxNZ.Text))
{
throw new Exception("Имеются незаполненные поля");
}
if (_busId.HasValue)
{
_busRepository.UpdateBus(CreateBus(_busId.Value));
}
else
{
_busRepository.CreateBus(CreateBus(0));
}
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при сохранении",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonleave_Click(object sender, EventArgs e) => Close();
private Bus CreateBus(int id) => Bus.CreateEntity(id,
(ModelType)comboBoxBus.SelectedItem!,
textBoxNZ.Text,
Convert.ToDouble(Mileage.Value),
Convert.ToInt32(numericUpDownCapacity.Value));
}

View File

@ -0,0 +1,163 @@
namespace PIbd_24_EredavkinRA_BusBusiness.Forms
{
partial class FormBusReport
{
/// <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()
{
dateTimePickerDateBegin = new DateTimePicker();
dateTimePickerDateEnd = new DateTimePicker();
comboBoxBus = new ComboBox();
textBoxFilePath = new TextBox();
buttonSelectFilePath = new Button();
label1 = new Label();
label2 = new Label();
label3 = new Label();
label4 = new Label();
buttonMakeReport = new Button();
SuspendLayout();
//
// dateTimePickerDateBegin
//
dateTimePickerDateBegin.Location = new Point(123, 115);
dateTimePickerDateBegin.Name = "dateTimePickerDateBegin";
dateTimePickerDateBegin.Size = new Size(278, 23);
dateTimePickerDateBegin.TabIndex = 0;
//
// dateTimePickerDateEnd
//
dateTimePickerDateEnd.Location = new Point(123, 156);
dateTimePickerDateEnd.Name = "dateTimePickerDateEnd";
dateTimePickerDateEnd.Size = new Size(278, 23);
dateTimePickerDateEnd.TabIndex = 1;
//
// comboBoxBus
//
comboBoxBus.FormattingEnabled = true;
comboBoxBus.Location = new Point(123, 56);
comboBoxBus.Name = "comboBoxBus";
comboBoxBus.Size = new Size(278, 23);
comboBoxBus.TabIndex = 2;
//
// textBoxFilePath
//
textBoxFilePath.Location = new Point(123, 9);
textBoxFilePath.Name = "textBoxFilePath";
textBoxFilePath.ReadOnly = true;
textBoxFilePath.Size = new Size(208, 23);
textBoxFilePath.TabIndex = 3;
//
// buttonSelectFilePath
//
buttonSelectFilePath.Location = new Point(337, 12);
buttonSelectFilePath.Name = "buttonSelectFilePath";
buttonSelectFilePath.Size = new Size(64, 24);
buttonSelectFilePath.TabIndex = 4;
buttonSelectFilePath.Text = "...";
buttonSelectFilePath.UseVisualStyleBackColor = true;
buttonSelectFilePath.Click += ButtonSelectFilePath_Click;
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(12, 9);
label1.Name = "label1";
label1.Size = new Size(87, 15);
label1.TabIndex = 5;
label1.Text = "Путь до файла";
//
// label2
//
label2.AutoSize = true;
label2.Location = new Point(37, 64);
label2.Name = "label2";
label2.Size = new Size(52, 15);
label2.TabIndex = 6;
label2.Text = "Автобус";
//
// label3
//
label3.AutoSize = true;
label3.Location = new Point(31, 115);
label3.Name = "label3";
label3.Size = new Size(74, 15);
label3.TabIndex = 7;
label3.Text = "Дата начала";
//
// label4
//
label4.AutoSize = true;
label4.Location = new Point(37, 162);
label4.Name = "label4";
label4.Size = new Size(68, 15);
label4.TabIndex = 8;
label4.Text = "Дата конца";
//
// buttonMakeReport
//
buttonMakeReport.Location = new Point(123, 204);
buttonMakeReport.Name = "buttonMakeReport";
buttonMakeReport.Size = new Size(204, 23);
buttonMakeReport.TabIndex = 9;
buttonMakeReport.Text = "Сформировать";
buttonMakeReport.UseVisualStyleBackColor = true;
buttonMakeReport.Click += ButtonMakeReport_Click;
//
// FormBusReport
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(425, 243);
Controls.Add(buttonMakeReport);
Controls.Add(label4);
Controls.Add(label3);
Controls.Add(label2);
Controls.Add(label1);
Controls.Add(buttonSelectFilePath);
Controls.Add(textBoxFilePath);
Controls.Add(comboBoxBus);
Controls.Add(dateTimePickerDateEnd);
Controls.Add(dateTimePickerDateBegin);
Name = "FormBusReport";
Text = "FormBusReport";
ResumeLayout(false);
PerformLayout();
}
#endregion
private DateTimePicker dateTimePickerDateBegin;
private DateTimePicker dateTimePickerDateEnd;
private ComboBox comboBoxBus;
private TextBox textBoxFilePath;
private Button buttonSelectFilePath;
private Label label1;
private Label label2;
private Label label3;
private Label label4;
private Button buttonMakeReport;
}
}

View File

@ -0,0 +1,82 @@
using PIbd_24_EredavkinRA_BusBusiness.Reports;
using PIbd_24_EredavkinRA_BusBusiness.Repositories;
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 PIbd_24_EredavkinRA_BusBusiness.Forms;
public partial class FormBusReport : Form
{
private readonly IUnityContainer _container;
public FormBusReport(IUnityContainer container, IBusRepository busRepository)
{
InitializeComponent();
_container = container ??
throw new ArgumentNullException(nameof(container));
comboBoxBus.DataSource = busRepository.ReadBus();
comboBoxBus.DisplayMember = "N_Z";
comboBoxBus.ValueMember = "Id";
}
private void ButtonSelectFilePath_Click(object sender, EventArgs e)
{
var sfd = new SaveFileDialog()
{
Filter = "Excel Files | *.xlsx"
};
if (sfd.ShowDialog() != DialogResult.OK)
{
return;
}
textBoxFilePath.Text = sfd.FileName;
}
private void ButtonMakeReport_Click(object sender, EventArgs e)
{
try
{
if (string.IsNullOrWhiteSpace(textBoxFilePath.Text))
{
throw new Exception("Отсутствует имя файла для отчета");
}
if (comboBoxBus.SelectedIndex < 0)
{
throw new Exception("Не выбран автобус");
}
if (dateTimePickerDateEnd.Value <= dateTimePickerDateBegin.Value)
{
throw new Exception("Дата начала должна быть раньше даты окончания");
}
if (_container.Resolve<TableReport>().CreateTable(textBoxFilePath.Text,
(int)comboBoxBus.SelectedValue!, dateTimePickerDateBegin.Value, dateTimePickerDateEnd.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);
}
}
}

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,126 @@
namespace PIbd_24_EredavkinRA_BusBusiness.Forms
{
partial class FormBuses
{
/// <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();
buttonDel = new Button();
buttonUpd = new Button();
buttonAdd = new Button();
dataGridViewData = new DataGridView();
panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit();
SuspendLayout();
//
// panel1
//
panel1.Controls.Add(buttonDel);
panel1.Controls.Add(buttonUpd);
panel1.Controls.Add(buttonAdd);
panel1.Dock = DockStyle.Right;
panel1.Location = new Point(596, 0);
panel1.Name = "panel1";
panel1.Size = new Size(150, 428);
panel1.TabIndex = 0;
//
// buttonDel
//
buttonDel.BackgroundImage = Properties.Resources.del;
buttonDel.BackgroundImageLayout = ImageLayout.Stretch;
buttonDel.Location = new Point(27, 211);
buttonDel.Name = "buttonDel";
buttonDel.Size = new Size(99, 85);
buttonDel.TabIndex = 2;
buttonDel.UseVisualStyleBackColor = true;
buttonDel.Click += buttonDel_Click;
//
// buttonUpd
//
buttonUpd.BackgroundImage = Properties.Resources.rev;
buttonUpd.BackgroundImageLayout = ImageLayout.Stretch;
buttonUpd.Location = new Point(27, 109);
buttonUpd.Name = "buttonUpd";
buttonUpd.Size = new Size(96, 76);
buttonUpd.TabIndex = 1;
buttonUpd.UseVisualStyleBackColor = true;
buttonUpd.Click += buttonUpd_Click;
//
// buttonAdd
//
buttonAdd.BackgroundImage = Properties.Resources.add;
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
buttonAdd.Location = new Point(27, 12);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(98, 78);
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.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridViewData.Size = new Size(596, 428);
dataGridViewData.TabIndex = 1;
//
// FormBuses
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(746, 428);
Controls.Add(dataGridViewData);
Controls.Add(panel1);
Name = "FormBuses";
StartPosition = FormStartPosition.CenterParent;
Text = "Автобусы";
Load += FormBuses_Load;
panel1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
ResumeLayout(false);
}
#endregion
private Panel panel1;
private Button buttonDel;
private Button buttonUpd;
private Button buttonAdd;
private DataGridView dataGridViewData;
}
}

View File

@ -0,0 +1,119 @@
using PIbd_24_EredavkinRA_BusBusiness.Repositories;
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 PIbd_24_EredavkinRA_BusBusiness.Forms;
public partial class FormBuses : Form
{
private readonly IUnityContainer _container;
private readonly IBusRepository _busRepository;
public FormBuses(IUnityContainer container, IBusRepository busRepository)
{
InitializeComponent();
_container = container ??
throw new ArgumentNullException(nameof(container));
_busRepository = busRepository ??
throw new ArgumentNullException(nameof(busRepository));
}
private void FormBuses_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<FormBus>().ShowDialog();
LoadList();
}
catch(Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при добовлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonUpd_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectedRow(out var findId))
{
return;
}
try
{
var form = _container.Resolve<FormBus>();
form.Id = findId;
form.ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при изменении",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonDel_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectedRow(out var findId))
{
return;
}
if (MessageBox.Show("Удалить запись?", "Удаление",
MessageBoxButtons.YesNo) != DialogResult.Yes)
{
return;
}
try
{
_busRepository.DeleteBus(findId);
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при удалении",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void LoadList()
{
dataGridViewData.DataSource = _busRepository.ReadBus();
dataGridViewData.Columns["Id"].Visible = false;
}
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,99 @@
namespace PIbd_24_EredavkinRA_BusBusiness.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()
{
checkBoxStaff = new CheckBox();
checkBoxRout = new CheckBox();
checkBoxBus = new CheckBox();
buttonBuild = new Button();
SuspendLayout();
//
// checkBoxStaff
//
checkBoxStaff.AutoSize = true;
checkBoxStaff.Location = new Point(12, 12);
checkBoxStaff.Name = "checkBoxStaff";
checkBoxStaff.Size = new Size(92, 19);
checkBoxStaff.TabIndex = 0;
checkBoxStaff.Text = "Сотрудники";
checkBoxStaff.UseVisualStyleBackColor = true;
//
// checkBoxRout
//
checkBoxRout.AutoSize = true;
checkBoxRout.Location = new Point(12, 53);
checkBoxRout.Name = "checkBoxRout";
checkBoxRout.Size = new Size(88, 19);
checkBoxRout.TabIndex = 1;
checkBoxRout.Text = "Маршруты";
checkBoxRout.UseVisualStyleBackColor = true;
//
// checkBoxBus
//
checkBoxBus.AutoSize = true;
checkBoxBus.Location = new Point(12, 98);
checkBoxBus.Name = "checkBoxBus";
checkBoxBus.Size = new Size(83, 19);
checkBoxBus.TabIndex = 2;
checkBoxBus.Text = "Автобусы ";
checkBoxBus.UseVisualStyleBackColor = true;
//
// buttonBuild
//
buttonBuild.Location = new Point(193, 53);
buttonBuild.Name = "buttonBuild";
buttonBuild.Size = new Size(134, 23);
buttonBuild.TabIndex = 3;
buttonBuild.Text = "Сформировать";
buttonBuild.UseVisualStyleBackColor = true;
buttonBuild.Click += buttonBuild_Click;
//
// FormDirectoryReport
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(372, 142);
Controls.Add(buttonBuild);
Controls.Add(checkBoxBus);
Controls.Add(checkBoxRout);
Controls.Add(checkBoxStaff);
Name = "FormDirectoryReport";
Text = "FormDirectoryReport";
ResumeLayout(false);
PerformLayout();
}
#endregion
private CheckBox checkBoxStaff;
private CheckBox checkBoxRout;
private CheckBox checkBoxBus;
private Button buttonBuild;
}
}

View File

@ -0,0 +1,63 @@
using PIbd_24_EredavkinRA_BusBusiness.Reports;
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 PIbd_24_EredavkinRA_BusBusiness.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 (!checkBoxBus.Checked && !checkBoxStaff.Checked && !checkBoxRout.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, checkBoxBus.Checked,
checkBoxRout.Checked, checkBoxStaff.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,141 @@
namespace PIbd_24_EredavkinRA_BusBusiness.Forms
{
partial class FormRout
{
/// <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()
{
numericUpDownNumber = new NumericUpDown();
textBoxStarPoint = new TextBox();
textBoxEndPoint = new TextBox();
label1 = new Label();
label2 = new Label();
label3 = new Label();
buttonSave = new Button();
buttonLoad = new Button();
((System.ComponentModel.ISupportInitialize)numericUpDownNumber).BeginInit();
SuspendLayout();
//
// numericUpDownNumber
//
numericUpDownNumber.Location = new Point(177, 33);
numericUpDownNumber.Name = "numericUpDownNumber";
numericUpDownNumber.Size = new Size(178, 23);
numericUpDownNumber.TabIndex = 0;
//
// textBoxStarPoint
//
textBoxStarPoint.Location = new Point(177, 79);
textBoxStarPoint.Name = "textBoxStarPoint";
textBoxStarPoint.Size = new Size(178, 23);
textBoxStarPoint.TabIndex = 1;
//
// textBoxEndPoint
//
textBoxEndPoint.Location = new Point(177, 126);
textBoxEndPoint.Name = "textBoxEndPoint";
textBoxEndPoint.Size = new Size(178, 23);
textBoxEndPoint.TabIndex = 2;
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(41, 35);
label1.Name = "label1";
label1.Size = new Size(105, 15);
label1.TabIndex = 3;
label1.Text = "Номер маршрута";
//
// label2
//
label2.AutoSize = true;
label2.Location = new Point(41, 87);
label2.Name = "label2";
label2.Size = new Size(126, 15);
label2.TabIndex = 4;
label2.Text = "Начальная остановка";
//
// label3
//
label3.AutoSize = true;
label3.Location = new Point(41, 134);
label3.Name = "label3";
label3.Size = new Size(119, 15);
label3.TabIndex = 5;
label3.Text = "Конечная остановка";
//
// buttonSave
//
buttonSave.Location = new Point(22, 243);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(106, 57);
buttonSave.TabIndex = 6;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += buttonSave_Click;
//
// buttonLoad
//
buttonLoad.Location = new Point(218, 243);
buttonLoad.Name = "buttonLoad";
buttonLoad.Size = new Size(120, 57);
buttonLoad.TabIndex = 7;
buttonLoad.Text = "Выйти";
buttonLoad.UseVisualStyleBackColor = true;
buttonLoad.Click += buttonLoad_Click;
//
// FormRout
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(372, 314);
Controls.Add(buttonLoad);
Controls.Add(buttonSave);
Controls.Add(label3);
Controls.Add(label2);
Controls.Add(label1);
Controls.Add(textBoxEndPoint);
Controls.Add(textBoxStarPoint);
Controls.Add(numericUpDownNumber);
Name = "FormRout";
Text = "Маршрут";
((System.ComponentModel.ISupportInitialize)numericUpDownNumber).EndInit();
ResumeLayout(false);
PerformLayout();
}
#endregion
private NumericUpDown numericUpDownNumber;
private TextBox textBoxStarPoint;
private TextBox textBoxEndPoint;
private Label label1;
private Label label2;
private Label label3;
private Button buttonSave;
private Button buttonLoad;
}
}

View File

@ -0,0 +1,94 @@
using PIbd_24_EredavkinRA_BusBusiness.Entities;
using PIbd_24_EredavkinRA_BusBusiness.Entities.Enums;
using PIbd_24_EredavkinRA_BusBusiness.Repositories;
using PIbd_24_EredavkinRA_BusBusiness.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 static System.Windows.Forms.VisualStyles.VisualStyleElement;
namespace PIbd_24_EredavkinRA_BusBusiness.Forms;
public partial class FormRout : Form
{
private readonly IRoutRepositories _routRepository;
private int? _routId;
public int Id
{
set
{
try
{
var rout = _routRepository.ReadRoutByID(value);
if (rout == null)
{
throw new
InvalidDataException(nameof(rout));
}
textBoxStarPoint.Text = rout.StartStop;
textBoxEndPoint.Text = rout.EndStop;
numericUpDownNumber.Value = rout.NumberRout;
_routId = value;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
}
public FormRout(IRoutRepositories routRepositories)
{
InitializeComponent();
_routRepository = routRepositories ??
throw new ArgumentNullException(nameof(routRepositories));
}
private void buttonSave_Click(object sender, EventArgs e)
{
try
{
if (string.IsNullOrWhiteSpace(textBoxStarPoint.Text) || string.IsNullOrWhiteSpace(textBoxEndPoint.Text))
{
throw new Exception("Имеются незаполненные поля");
}
if (_routId.HasValue)
{
_routRepository.UpdateRout(CreateRout(_routId.Value));
}
else
{
_routRepository.CreateRout(CreateRout(0));
}
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при сохранении",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonLoad_Click(object sender, EventArgs e) => Close();
private Rout CreateRout(int id) => Rout.CreateEntity(id,
textBoxStarPoint.Text,
textBoxEndPoint.Text,
Convert.ToInt32(numericUpDownNumber.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,204 @@
namespace PIbd_24_EredavkinRA_BusBusiness.Forms
{
partial class FormRoutSheet
{
/// <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()
{
buttonSave = new Button();
buttonLeave = new Button();
groupBox1 = new GroupBox();
dataGridViewRoutSheet = new DataGridView();
ColumnBus = new DataGridViewComboBoxColumn();
label1 = new Label();
label2 = new Label();
label3 = new Label();
comboBoxDriver = new ComboBox();
comboBoxConductor = new ComboBox();
comboBoxRout = new ComboBox();
dateTimePicker1 = new DateTimePicker();
npgsqlDataAdapter1 = new Npgsql.NpgsqlDataAdapter();
groupBox1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridViewRoutSheet).BeginInit();
SuspendLayout();
//
// buttonSave
//
buttonSave.Location = new Point(12, 604);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(81, 35);
buttonSave.TabIndex = 8;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += buttonSave_Click;
//
// buttonLeave
//
buttonLeave.Location = new Point(179, 604);
buttonLeave.Name = "buttonLeave";
buttonLeave.Size = new Size(92, 35);
buttonLeave.TabIndex = 9;
buttonLeave.Text = "Отмена";
buttonLeave.UseVisualStyleBackColor = true;
buttonLeave.Click += buttonLeave_Click;
//
// groupBox1
//
groupBox1.Controls.Add(dataGridViewRoutSheet);
groupBox1.Location = new Point(21, 211);
groupBox1.Name = "groupBox1";
groupBox1.Size = new Size(250, 387);
groupBox1.TabIndex = 10;
groupBox1.TabStop = false;
groupBox1.Text = "Путевой Лист";
//
// dataGridViewRoutSheet
//
dataGridViewRoutSheet.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridViewRoutSheet.Columns.AddRange(new DataGridViewColumn[] { ColumnBus });
dataGridViewRoutSheet.Dock = DockStyle.Fill;
dataGridViewRoutSheet.Location = new Point(3, 19);
dataGridViewRoutSheet.MultiSelect = false;
dataGridViewRoutSheet.Name = "dataGridViewRoutSheet";
dataGridViewRoutSheet.RowHeadersVisible = false;
dataGridViewRoutSheet.Size = new Size(244, 365);
dataGridViewRoutSheet.TabIndex = 0;
//
// ColumnBus
//
ColumnBus.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
ColumnBus.DisplayStyleForCurrentCellOnly = true;
ColumnBus.HeaderText = "Автобус";
ColumnBus.Name = "ColumnBus";
ColumnBus.Resizable = DataGridViewTriState.True;
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(12, 9);
label1.Name = "label1";
label1.Size = new Size(58, 15);
label1.TabIndex = 11;
label1.Text = "Водитель";
//
// label2
//
label2.AutoSize = true;
label2.Location = new Point(12, 46);
label2.Name = "label2";
label2.Size = new Size(65, 15);
label2.TabIndex = 12;
label2.Text = "Кондуктор";
//
// label3
//
label3.AutoSize = true;
label3.Location = new Point(12, 88);
label3.Name = "label3";
label3.Size = new Size(60, 15);
label3.TabIndex = 13;
label3.Text = "Маршрут";
//
// comboBoxDriver
//
comboBoxDriver.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxDriver.FormattingEnabled = true;
comboBoxDriver.Location = new Point(83, 6);
comboBoxDriver.Name = "comboBoxDriver";
comboBoxDriver.Size = new Size(188, 23);
comboBoxDriver.TabIndex = 15;
//
// comboBoxConductor
//
comboBoxConductor.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxConductor.FormattingEnabled = true;
comboBoxConductor.Location = new Point(83, 43);
comboBoxConductor.Name = "comboBoxConductor";
comboBoxConductor.Size = new Size(188, 23);
comboBoxConductor.TabIndex = 16;
//
// comboBoxRout
//
comboBoxRout.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxRout.FormattingEnabled = true;
comboBoxRout.Location = new Point(83, 88);
comboBoxRout.Name = "comboBoxRout";
comboBoxRout.Size = new Size(188, 23);
comboBoxRout.TabIndex = 17;
//
// dateTimePicker1
//
dateTimePicker1.Location = new Point(12, 141);
dateTimePicker1.Name = "dateTimePicker1";
dateTimePicker1.Size = new Size(256, 23);
dateTimePicker1.TabIndex = 18;
//
// npgsqlDataAdapter1
//
npgsqlDataAdapter1.DeleteCommand = null;
npgsqlDataAdapter1.InsertCommand = null;
npgsqlDataAdapter1.SelectCommand = null;
npgsqlDataAdapter1.UpdateCommand = null;
//
// FormRoutSheet
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(292, 651);
Controls.Add(dateTimePicker1);
Controls.Add(comboBoxRout);
Controls.Add(comboBoxConductor);
Controls.Add(comboBoxDriver);
Controls.Add(label3);
Controls.Add(label2);
Controls.Add(label1);
Controls.Add(groupBox1);
Controls.Add(buttonLeave);
Controls.Add(buttonSave);
Name = "FormRoutSheet";
Text = "Путевой Лист";
groupBox1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridViewRoutSheet).EndInit();
ResumeLayout(false);
PerformLayout();
}
#endregion
private Button buttonSave;
private Button buttonLeave;
private GroupBox groupBox1;
private DataGridView dataGridViewRoutSheet;
private Label label1;
private Label label2;
private Label label3;
private ComboBox comboBoxDriver;
private ComboBox comboBoxConductor;
private ComboBox comboBoxRout;
private DataGridViewComboBoxColumn ColumnBus;
private DateTimePicker dateTimePicker1;
private Npgsql.NpgsqlDataAdapter npgsqlDataAdapter1;
}
}

View File

@ -0,0 +1,73 @@
using PIbd_24_EredavkinRA_BusBusiness.Entities;
using PIbd_24_EredavkinRA_BusBusiness.Repositories;
namespace PIbd_24_EredavkinRA_BusBusiness.Forms;
public partial class FormRoutSheet : Form
{
private readonly IRoutSheetRepository _routSheetRepository;
public FormRoutSheet(IBusRepository busRepository, IStaffRepositories staffRepositories, IRoutRepositories routRepositories, IRoutSheetRepository routSheetRepository)
{
InitializeComponent();
_routSheetRepository = routSheetRepository ?? throw new ArgumentNullException(nameof(routSheetRepository));
comboBoxDriver.DataSource = staffRepositories.ReadStaff();
comboBoxDriver.DisplayMember = "FullName";
comboBoxDriver.ValueMember = "Id";
comboBoxConductor.DataSource = staffRepositories.ReadStaff();
comboBoxConductor.DisplayMember = "FullName";
comboBoxConductor.ValueMember = "Id";
comboBoxRout.DataSource = routRepositories.ReadRout();
comboBoxRout.DisplayMember = "FullRout";
comboBoxRout.ValueMember = "Id";
ColumnBus.DataSource = busRepository.ReadBus();
ColumnBus.DisplayMember = "N_Z";
ColumnBus.ValueMember = "Id";
}
private void buttonSave_Click(object sender, EventArgs e)
{
try
{
if (dataGridViewRoutSheet.RowCount < 1 || comboBoxDriver.SelectedIndex < 0 || comboBoxRout.SelectedIndex < 0)
{
throw new Exception("Имеются не заполненые поля");
}
_routSheetRepository.CreateRoutSheet(RoutSheet.CreatOpeartion(0, (int)comboBoxDriver.SelectedValue!, (int)comboBoxConductor.SelectedValue!,
(int)comboBoxRout.SelectedValue!, dateTimePicker1.Value, CreateListRoudSheetBusFromDataGrid()));
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonLeave_Click(object sender, EventArgs e) => Close();
private List<RoutSheetBus> CreateListRoudSheetBusFromDataGrid()
{
var list = new List<RoutSheetBus>();
foreach (DataGridViewRow row in dataGridViewRoutSheet.Rows)
{
if (row.Cells["ColumnBus"].Value == null)
{
continue;
}
list.Add(RoutSheetBus.CreateElement(0, Convert.ToInt32( row.Cells["ColumnBus"].Value)));
}
return list;
}
}

View File

@ -0,0 +1,126 @@
<?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="ColumnBus.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="npgsqlDataAdapter1.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,97 @@
namespace PIbd_24_EredavkinRA_BusBusiness.Forms
{
partial class FormRoutSheetes
{
/// <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();
buttonadd = new Button();
dataGridViewData = new DataGridView();
panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit();
SuspendLayout();
//
// panel1
//
panel1.Controls.Add(buttonadd);
panel1.Dock = DockStyle.Right;
panel1.Location = new Point(656, 0);
panel1.Name = "panel1";
panel1.Size = new Size(160, 450);
panel1.TabIndex = 0;
//
// buttonadd
//
buttonadd.BackgroundImage = Properties.Resources.add;
buttonadd.BackgroundImageLayout = ImageLayout.Stretch;
buttonadd.Location = new Point(40, 12);
buttonadd.Name = "buttonadd";
buttonadd.Size = new Size(108, 76);
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.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridViewData.Size = new Size(656, 450);
dataGridViewData.TabIndex = 2;
//
// FormRoutSheetes
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(816, 450);
Controls.Add(dataGridViewData);
Controls.Add(panel1);
Name = "FormRoutSheetes";
Text = "Путевой лист";
Load += FormRoutSheetes_Load;
panel1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
ResumeLayout(false);
}
#endregion
private Panel panel1;
private Button buttonadd;
private DataGridView dataGridViewData;
}
}

View File

@ -0,0 +1,56 @@
using PIbd_24_EredavkinRA_BusBusiness.Repositories;
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 PIbd_24_EredavkinRA_BusBusiness.Forms;
public partial class FormRoutSheetes : Form
{
private readonly IUnityContainer _container;
private readonly IRoutSheetRepository _routSheetRepository;
public FormRoutSheetes(IUnityContainer container, IRoutSheetRepository routSheetRepository)
{
InitializeComponent();
_container = container ?? throw new ArgumentException(nameof(container));
_routSheetRepository = routSheetRepository ?? throw new ArgumentException(nameof(routSheetRepository));
}
private void FormRoutSheetes_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<FormRoutSheet>().ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void LoadList()
{
dataGridViewData.DataSource = _routSheetRepository.ReadRoutSheet();
dataGridViewData.Columns["Id"].Visible = false;
dataGridViewData.Columns["BusDate"].DefaultCellStyle.Format = "dd MMMM yyyy";
}
}

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,125 @@
namespace PIbd_24_EredavkinRA_BusBusiness.Forms
{
partial class FormRoutes
{
/// <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();
buttonDel = new Button();
buttonUpd = 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.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridViewData.Size = new Size(840, 450);
dataGridViewData.TabIndex = 2;
//
// panel1
//
panel1.Controls.Add(buttonDel);
panel1.Controls.Add(buttonUpd);
panel1.Controls.Add(buttonAdd);
panel1.Dock = DockStyle.Right;
panel1.Location = new Point(690, 0);
panel1.Name = "panel1";
panel1.Size = new Size(150, 450);
panel1.TabIndex = 3;
//
// buttonDel
//
buttonDel.BackgroundImage = Properties.Resources.del;
buttonDel.BackgroundImageLayout = ImageLayout.Stretch;
buttonDel.Location = new Point(27, 211);
buttonDel.Name = "buttonDel";
buttonDel.Size = new Size(99, 85);
buttonDel.TabIndex = 2;
buttonDel.UseVisualStyleBackColor = true;
buttonDel.Click += buttonDel_Click;
//
// buttonUpd
//
buttonUpd.BackgroundImage = Properties.Resources.rev;
buttonUpd.BackgroundImageLayout = ImageLayout.Stretch;
buttonUpd.Location = new Point(27, 109);
buttonUpd.Name = "buttonUpd";
buttonUpd.Size = new Size(96, 76);
buttonUpd.TabIndex = 1;
buttonUpd.UseVisualStyleBackColor = true;
buttonUpd.Click += buttonUpd_Click;
//
// buttonAdd
//
buttonAdd.BackgroundImage = Properties.Resources.add;
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
buttonAdd.Location = new Point(27, 12);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(98, 78);
buttonAdd.TabIndex = 0;
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += buttonAdd_Click;
//
// FormRoutes
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(840, 450);
Controls.Add(panel1);
Controls.Add(dataGridViewData);
Name = "FormRoutes";
Text = "FormRoutes";
Load += FormRoutes_Load;
((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
panel1.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private DataGridView dataGridViewData;
private Panel panel1;
private Button buttonDel;
private Button buttonUpd;
private Button buttonAdd;
}
}

View File

@ -0,0 +1,122 @@
using PIbd_24_EredavkinRA_BusBusiness.Repositories;
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 PIbd_24_EredavkinRA_BusBusiness.Forms;
public partial class FormRoutes : Form
{
private readonly IUnityContainer _container;
private readonly IRoutRepositories _routRepository;
public FormRoutes(IUnityContainer container, IRoutRepositories routRepository)
{
InitializeComponent();
_container = container ??
throw new ArgumentNullException(nameof(container));
_routRepository = routRepository ??
throw new ArgumentNullException(nameof(routRepository));
}
private void FormRoutes_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<FormRout>().ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при добовлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonUpd_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectedRow(out var findId))
{
return;
}
try
{
var form = _container.Resolve<FormRout>();
form.Id = findId;
form.ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при изменении",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonDel_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectedRow(out var findId))
{
return;
}
if (MessageBox.Show("Удалить запись?", "Удаление",
MessageBoxButtons.YesNo) != DialogResult.Yes)
{
return;
}
try
{
_routRepository.DeleteRout(findId);
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при удалении",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void LoadList()
{
dataGridViewData.DataSource = _routRepository.ReadRout();
dataGridViewData.Columns["Id"].Visible = false;
dataGridViewData.Columns["FullRout"].Visible = false;
}
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,139 @@
namespace PIbd_24_EredavkinRA_BusBusiness.Forms
{
partial class FormStaff
{
/// <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()
{
textBoxLastName = new TextBox();
textBoxFirstName = new TextBox();
label1 = new Label();
label2 = new Label();
label3 = new Label();
buttoтSave = new Button();
buttonCancel = new Button();
checkedListBoxStaff = new CheckedListBox();
SuspendLayout();
//
// textBoxLastName
//
textBoxLastName.Location = new Point(132, 65);
textBoxLastName.Name = "textBoxLastName";
textBoxLastName.Size = new Size(228, 23);
textBoxLastName.TabIndex = 1;
//
// textBoxFirstName
//
textBoxFirstName.Location = new Point(132, 15);
textBoxFirstName.Name = "textBoxFirstName";
textBoxFirstName.Size = new Size(228, 23);
textBoxFirstName.TabIndex = 2;
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(21, 15);
label1.Name = "label1";
label1.Size = new Size(34, 15);
label1.TabIndex = 3;
label1.Text = "Имя:";
//
// label2
//
label2.AutoSize = true;
label2.Location = new Point(21, 65);
label2.Name = "label2";
label2.Size = new Size(61, 15);
label2.TabIndex = 4;
label2.Text = "Фамилия:";
//
// label3
//
label3.AutoSize = true;
label3.Location = new Point(21, 124);
label3.Name = "label3";
label3.Size = new Size(72, 15);
label3.TabIndex = 5;
label3.Text = "Должность:";
//
// buttoтSave
//
buttoтSave.Location = new Point(21, 277);
buttoтSave.Name = "buttoтSave";
buttoтSave.Size = new Size(75, 23);
buttoтSave.TabIndex = 6;
buttoтSave.Text = "Сохранить";
buttoтSave.UseVisualStyleBackColor = true;
buttoтSave.Click += buttoтSave_Click;
//
// buttonCancel
//
buttonCancel.Location = new Point(341, 277);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(75, 23);
buttonCancel.TabIndex = 7;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += buttonCancel_Click;
//
// checkedListBoxStaff
//
checkedListBoxStaff.FormattingEnabled = true;
checkedListBoxStaff.Location = new Point(132, 124);
checkedListBoxStaff.Name = "checkedListBoxStaff";
checkedListBoxStaff.Size = new Size(228, 148);
checkedListBoxStaff.TabIndex = 8;
//
// FormStaff
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(439, 312);
Controls.Add(checkedListBoxStaff);
Controls.Add(buttonCancel);
Controls.Add(buttoтSave);
Controls.Add(label3);
Controls.Add(label2);
Controls.Add(label1);
Controls.Add(textBoxFirstName);
Controls.Add(textBoxLastName);
Name = "FormStaff";
Text = "FormStaff";
ResumeLayout(false);
PerformLayout();
}
#endregion
private TextBox textBoxLastName;
private TextBox textBoxFirstName;
private Label label1;
private Label label2;
private Label label3;
private Button buttoтSave;
private Button buttonCancel;
private CheckedListBox checkedListBoxStaff;
}
}

View File

@ -0,0 +1,95 @@
using PIbd_24_EredavkinRA_BusBusiness.Entities;
using PIbd_24_EredavkinRA_BusBusiness.Entities.Enums;
using PIbd_24_EredavkinRA_BusBusiness.Repositories;
namespace PIbd_24_EredavkinRA_BusBusiness.Forms;
public partial class FormStaff : Form
{
private readonly IStaffRepositories _staffRepository;
private int? _staffId;
public int Id
{
set
{
try
{
var staff = _staffRepository.ReadStaffByID(value);
if (staff == null)
{
throw new
InvalidDataException(nameof(staff));
}
foreach (EmployeePost elem in Enum.GetValues(typeof(EmployeePost)))
{
if ((elem & staff.EmployeePost) != 0)
{
checkedListBoxStaff.SetItemChecked(checkedListBoxStaff.Items.IndexOf(elem), true);
}
}
textBoxFirstName.Text = staff.FirstName;
textBoxLastName.Text = staff.LastName;
_staffId = value;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
}
public FormStaff(IStaffRepositories staffRepositories)
{
InitializeComponent();
_staffRepository = staffRepositories ??
throw new ArgumentNullException(nameof(staffRepositories));
foreach (var elem in Enum.GetValues(typeof(EmployeePost)))
{
checkedListBoxStaff.Items.Add(elem);
}
}
private void buttoтSave_Click(object sender, EventArgs e)
{
try
{
if (string.IsNullOrWhiteSpace(textBoxFirstName.Text) ||string.IsNullOrWhiteSpace(textBoxLastName.Text) || checkedListBoxStaff.CheckedItems.Count == 0)
{
throw new Exception("Имеются незаполненныеполя");
}
if (_staffId.HasValue)
{
_staffRepository.UpdateStaff(CreateStaff(_staffId.Value));
}
else
{
_staffRepository.CreateStaff(CreateStaff(0));
}
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при сохранении",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonCancel_Click(object sender, EventArgs e) => Close();
private Staff CreateStaff(int id)
{
EmployeePost employeePost = EmployeePost.None;
foreach (var elem in checkedListBoxStaff.CheckedItems)
{
employeePost |= (EmployeePost)elem;
}
return Staff.CreatEntity(id, textBoxFirstName.Text, textBoxLastName.Text, employeePost);
}
}

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,125 @@
namespace PIbd_24_EredavkinRA_BusBusiness.Forms
{
partial class FormStaffes
{
/// <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();
buttonDel = new Button();
buttonUpd = new Button();
buttonAdd = new Button();
dataGridViewData = new DataGridView();
panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit();
SuspendLayout();
//
// panel1
//
panel1.Controls.Add(buttonDel);
panel1.Controls.Add(buttonUpd);
panel1.Controls.Add(buttonAdd);
panel1.Dock = DockStyle.Right;
panel1.Location = new Point(698, 0);
panel1.Name = "panel1";
panel1.Size = new Size(200, 586);
panel1.TabIndex = 0;
//
// buttonDel
//
buttonDel.BackgroundImage = Properties.Resources.del;
buttonDel.BackgroundImageLayout = ImageLayout.Stretch;
buttonDel.Location = new Point(54, 231);
buttonDel.Name = "buttonDel";
buttonDel.Size = new Size(99, 85);
buttonDel.TabIndex = 3;
buttonDel.UseVisualStyleBackColor = true;
buttonDel.Click += buttonDel_Click;
//
// buttonUpd
//
buttonUpd.BackgroundImage = Properties.Resources.rev;
buttonUpd.BackgroundImageLayout = ImageLayout.Stretch;
buttonUpd.Location = new Point(54, 119);
buttonUpd.Name = "buttonUpd";
buttonUpd.Size = new Size(96, 76);
buttonUpd.TabIndex = 2;
buttonUpd.UseVisualStyleBackColor = true;
buttonUpd.Click += buttonUpd_Click;
//
// buttonAdd
//
buttonAdd.BackgroundImage = Properties.Resources.add;
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
buttonAdd.Location = new Point(54, 23);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(98, 78);
buttonAdd.TabIndex = 1;
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.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridViewData.Size = new Size(698, 586);
dataGridViewData.TabIndex = 2;
//
// FormStaffes
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(898, 586);
Controls.Add(dataGridViewData);
Controls.Add(panel1);
Name = "FormStaffes";
Text = "Сотрудники";
Load += FormStaffes_Load;
panel1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
ResumeLayout(false);
}
#endregion
private Panel panel1;
private DataGridView dataGridViewData;
private Button buttonAdd;
private Button buttonUpd;
private Button buttonDel;
}
}

View File

@ -0,0 +1,124 @@
using PIbd_24_EredavkinRA_BusBusiness.Repositories;
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 PIbd_24_EredavkinRA_BusBusiness.Forms
{
public partial class FormStaffes : Form
{
private readonly IUnityContainer _container;
private readonly IStaffRepositories _staffRepository;
public FormStaffes(IUnityContainer container, IStaffRepositories staffRepository)
{
InitializeComponent();
_container = container ??
throw new ArgumentNullException(nameof(container));
_staffRepository = staffRepository ??
throw new ArgumentNullException(nameof(staffRepository));
}
private void buttonAdd_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormStaff>().ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при добовлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonUpd_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectedRow(out var findId))
{
return;
}
try
{
var form = _container.Resolve<FormStaff>();
form.Id = findId;
form.ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при изменении",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonDel_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectedRow(out var findId))
{
return;
}
if (MessageBox.Show("Удалить запись?", "Удаление",
MessageBoxButtons.YesNo) != DialogResult.Yes)
{
return;
}
try
{
_staffRepository.DeleteStaff(findId);
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при удалении",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void LoadList()
{
dataGridViewData.DataSource = _staffRepository.ReadStaff();
dataGridViewData.Columns["Id"].Visible = false;
dataGridViewData.Columns["FullName"].Visible = false;
}
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;
}
private void FormStaffes_Load(object sender, EventArgs e)
{
try
{
LoadList();
}
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,191 @@
namespace PIbd_24_EredavkinRA_BusBusiness.Forms
{
partial class FormTO
{
/// <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()
{
buttonSave = new Button();
buttonLeave = new Button();
comboBoxStaff = new ComboBox();
label3 = new Label();
label1 = new Label();
dateTimePicker1 = new DateTimePicker();
label2 = new Label();
textBoxDescription = new TextBox();
numericUpDownCost = new NumericUpDown();
label4 = new Label();
label5 = new Label();
comboBoxBus = new ComboBox();
((System.ComponentModel.ISupportInitialize)numericUpDownCost).BeginInit();
SuspendLayout();
//
// buttonSave
//
buttonSave.Location = new Point(15, 391);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(94, 44);
buttonSave.TabIndex = 4;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += buttonSave_Click;
//
// buttonLeave
//
buttonLeave.Location = new Point(248, 391);
buttonLeave.Name = "buttonLeave";
buttonLeave.Size = new Size(106, 44);
buttonLeave.TabIndex = 5;
buttonLeave.Text = "Отмена";
buttonLeave.UseVisualStyleBackColor = true;
buttonLeave.Click += buttonLeave_Click;
//
// comboBoxStaff
//
comboBoxStaff.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxStaff.FormattingEnabled = true;
comboBoxStaff.Location = new Point(98, 20);
comboBoxStaff.Name = "comboBoxStaff";
comboBoxStaff.Size = new Size(245, 23);
comboBoxStaff.TabIndex = 7;
//
// label3
//
label3.AutoSize = true;
label3.Location = new Point(10, 23);
label3.Name = "label3";
label3.Size = new Size(59, 15);
label3.TabIndex = 9;
label3.Text = "Работник";
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(10, 119);
label1.Name = "label1";
label1.Size = new Size(50, 15);
label1.TabIndex = 12;
label1.Text = "Дата ТО";
//
// dateTimePicker1
//
dateTimePicker1.Location = new Point(98, 111);
dateTimePicker1.Name = "dateTimePicker1";
dateTimePicker1.Size = new Size(245, 23);
dateTimePicker1.TabIndex = 13;
//
// label2
//
label2.AutoSize = true;
label2.Location = new Point(3, 159);
label2.Name = "label2";
label2.Size = new Size(62, 15);
label2.TabIndex = 14;
label2.Text = "Описание";
//
// textBoxDescription
//
textBoxDescription.Location = new Point(98, 159);
textBoxDescription.Multiline = true;
textBoxDescription.Name = "textBoxDescription";
textBoxDescription.Size = new Size(238, 145);
textBoxDescription.TabIndex = 15;
//
// numericUpDownCost
//
numericUpDownCost.DecimalPlaces = 2;
numericUpDownCost.Location = new Point(105, 334);
numericUpDownCost.Maximum = new decimal(new int[] { 1000000, 0, 0, 0 });
numericUpDownCost.Name = "numericUpDownCost";
numericUpDownCost.Size = new Size(238, 23);
numericUpDownCost.TabIndex = 16;
//
// label4
//
label4.AutoSize = true;
label4.Location = new Point(15, 334);
label4.Name = "label4";
label4.Size = new Size(67, 15);
label4.TabIndex = 17;
label4.Text = "Стоимость";
//
// label5
//
label5.AutoSize = true;
label5.Location = new Point(15, 77);
label5.Name = "label5";
label5.Size = new Size(52, 15);
label5.TabIndex = 18;
label5.Text = "Автобус";
//
// comboBoxBus
//
comboBoxBus.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxBus.FormattingEnabled = true;
comboBoxBus.Location = new Point(98, 69);
comboBoxBus.Name = "comboBoxBus";
comboBoxBus.Size = new Size(245, 23);
comboBoxBus.TabIndex = 19;
//
// FormTO
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(380, 441);
Controls.Add(comboBoxBus);
Controls.Add(label5);
Controls.Add(label4);
Controls.Add(numericUpDownCost);
Controls.Add(textBoxDescription);
Controls.Add(label2);
Controls.Add(dateTimePicker1);
Controls.Add(label1);
Controls.Add(label3);
Controls.Add(comboBoxStaff);
Controls.Add(buttonLeave);
Controls.Add(buttonSave);
Name = "FormTO";
Text = "Техническое обслуживание";
((System.ComponentModel.ISupportInitialize)numericUpDownCost).EndInit();
ResumeLayout(false);
PerformLayout();
}
#endregion
private Button buttonSave;
private Button buttonLeave;
private ComboBox comboBoxStaff;
private Label label3;
private Label label1;
private DateTimePicker dateTimePicker1;
private Label label2;
private TextBox textBoxDescription;
private NumericUpDown numericUpDownCost;
private Label label4;
private Label label5;
private ComboBox comboBoxBus;
}
}

View File

@ -0,0 +1,53 @@
using PIbd_24_EredavkinRA_BusBusiness.Entities;
using PIbd_24_EredavkinRA_BusBusiness.Repositories;
namespace PIbd_24_EredavkinRA_BusBusiness.Forms;
public partial class FormTO : Form
{
private readonly IToRepository _toRepository;
public FormTO(IToRepository toRepository, IStaffRepositories staffRepositories, IBusRepository busRepository)
{
InitializeComponent();
_toRepository = toRepository ?? throw new ArgumentNullException(nameof(toRepository));
comboBoxStaff.DataSource = staffRepositories.ReadStaff();
comboBoxStaff.DisplayMember = "FullName";
comboBoxStaff.ValueMember = "Id";
comboBoxBus.DataSource = busRepository.ReadBus();
comboBoxBus.DisplayMember = "N_Z";
comboBoxBus.ValueMember = "Id";
}
private void buttonSave_Click(object sender, EventArgs e)
{
try
{
if (comboBoxStaff.SelectedIndex < 0 || comboBoxBus.SelectedIndex < 0 || string.IsNullOrWhiteSpace(textBoxDescription.Text))
{
throw new Exception("Имеются не заполненые поля");
}
_toRepository.CreateTo(To.CreatOperation(0, textBoxDescription.Text, Convert.ToDouble(numericUpDownCost.Value), dateTimePicker1.Value, (int)comboBoxBus.SelectedValue!,
(int)comboBoxStaff.SelectedValue!));
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonLeave_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,111 @@
namespace PIbd_24_EredavkinRA_BusBusiness.Forms
{
partial class FormTOes
{
/// <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();
buttonDel = 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.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridViewData.Size = new Size(1241, 450);
dataGridViewData.TabIndex = 2;
//
// panel1
//
panel1.Controls.Add(buttonDel);
panel1.Controls.Add(buttonAdd);
panel1.Dock = DockStyle.Right;
panel1.Location = new Point(1091, 0);
panel1.Name = "panel1";
panel1.Size = new Size(150, 450);
panel1.TabIndex = 3;
//
// buttonDel
//
buttonDel.BackgroundImage = Properties.Resources.del;
buttonDel.BackgroundImageLayout = ImageLayout.Stretch;
buttonDel.Location = new Point(27, 211);
buttonDel.Name = "buttonDel";
buttonDel.Size = new Size(99, 85);
buttonDel.TabIndex = 2;
buttonDel.UseVisualStyleBackColor = true;
buttonDel.Click += buttonDel_Click;
//
// buttonAdd
//
buttonAdd.BackgroundImage = Properties.Resources.add;
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
buttonAdd.Location = new Point(27, 12);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(98, 78);
buttonAdd.TabIndex = 0;
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += buttonAdd_Click;
//
// FormTOes
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(1241, 450);
Controls.Add(panel1);
Controls.Add(dataGridViewData);
Name = "FormTOes";
Text = "FormTOes";
Load += FormTOes_Load;
((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
panel1.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private DataGridView dataGridViewData;
private Panel panel1;
private Button buttonDel;
private Button buttonAdd;
}
}

View File

@ -0,0 +1,104 @@
using PIbd_24_EredavkinRA_BusBusiness.Repositories;
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 PIbd_24_EredavkinRA_BusBusiness.Forms;
public partial class FormTOes : Form
{
private readonly IUnityContainer _container;
private readonly IToRepository _toRepository;
public FormTOes(IUnityContainer container, IToRepository toRepository)
{
InitializeComponent();
_container = container ??
throw new ArgumentNullException(nameof(container));
_toRepository = toRepository ??
throw new ArgumentNullException(nameof(toRepository));
}
private void FormTOes_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<FormTO>().ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при добовлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonDel_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectedRow(out var findId))
{
return;
}
if (MessageBox.Show("Удалить запись?", "Удаление",
MessageBoxButtons.YesNo) != DialogResult.Yes)
{
return;
}
try
{
_toRepository.DeleteTo(findId);
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при удалении",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void LoadList()
{
dataGridViewData.DataSource = _toRepository.ReadTo();
dataGridViewData.Columns["Id"].Visible = false;
dataGridViewData.Columns["DateTo"].DefaultCellStyle.Format = "dd.MM.yyyy";
}
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,107 @@
namespace PIbd_24_EredavkinRA_BusBusiness.Forms
{
partial class FormToDistributionReport
{
/// <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()
{
dateTimePicker = new DateTimePicker();
ButtonChoice = new Button();
labelFileName = new Label();
label2 = new Label();
buttontoform = new Button();
SuspendLayout();
//
// dateTimePicker
//
dateTimePicker.Location = new Point(100, 72);
dateTimePicker.Name = "dateTimePicker";
dateTimePicker.Size = new Size(168, 23);
dateTimePicker.TabIndex = 0;
//
// ButtonChoice
//
ButtonChoice.Location = new Point(23, 25);
ButtonChoice.Name = "ButtonChoice";
ButtonChoice.Size = new Size(75, 23);
ButtonChoice.TabIndex = 1;
ButtonChoice.Text = "Выбрать";
ButtonChoice.UseVisualStyleBackColor = true;
ButtonChoice.Click += ButtonChoice_Click;
//
// labelFileName
//
labelFileName.AutoSize = true;
labelFileName.Location = new Point(120, 29);
labelFileName.Name = "labelFileName";
labelFileName.Size = new Size(36, 15);
labelFileName.TabIndex = 2;
labelFileName.Text = "Файл";
//
// label2
//
label2.AutoSize = true;
label2.Location = new Point(23, 78);
label2.Name = "label2";
label2.Size = new Size(32, 15);
label2.TabIndex = 3;
label2.Text = "Дата";
//
// buttontoform
//
buttontoform.Location = new Point(70, 139);
buttontoform.Name = "buttontoform";
buttontoform.Size = new Size(117, 23);
buttontoform.TabIndex = 4;
buttontoform.Text = "Сформировать";
buttontoform.UseVisualStyleBackColor = true;
buttontoform.Click += buttontoform_Click;
//
// FormToDistributionReport
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(280, 209);
Controls.Add(buttontoform);
Controls.Add(label2);
Controls.Add(labelFileName);
Controls.Add(ButtonChoice);
Controls.Add(dateTimePicker);
Name = "FormToDistributionReport";
Text = "FormToDistributionReport";
ResumeLayout(false);
PerformLayout();
}
#endregion
private DateTimePicker dateTimePicker;
private Button ButtonChoice;
private Label labelFileName;
private Label label2;
private Button buttontoform;
}
}

View File

@ -0,0 +1,66 @@
using PIbd_24_EredavkinRA_BusBusiness.Reports;
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 PIbd_24_EredavkinRA_BusBusiness.Forms;
public partial class FormToDistributionReport : Form
{
private string _fileName = string.Empty;
private readonly IUnityContainer _container;
public FormToDistributionReport(IUnityContainer container)
{
InitializeComponent();
_container = container ??
throw new ArgumentNullException(nameof(container));
}
private void ButtonChoice_Click(object sender, EventArgs e)
{
var sfd = new SaveFileDialog()
{
Filter = "Pdf Files | *.pdf"
};
if (sfd.ShowDialog() == DialogResult.OK)
{
_fileName = sfd.FileName;
labelFileName.Text = Path.GetFileName(_fileName);
}
}
private void buttontoform_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);
}
}
}

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

@ -9,4 +9,36 @@
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Dapper" Version="2.1.35" />
<PackageReference Include="DocumentFormat.OpenXml" Version="3.2.0" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="9.0.0" />
<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.1.0" />
<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="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>
</Project>

View File

@ -1,3 +1,12 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using PIbd_24_EredavkinRA_BusBusiness.Repositories;
using PIbd_24_EredavkinRA_BusBusiness.Repositories.Implementations;
using Serilog;
using Unity;
using Unity.Lifetime;
using Unity.Microsoft.Logging;
namespace PIbd_24_EredavkinRA_BusBusiness
{
internal static class Program
@ -11,7 +20,32 @@ namespace PIbd_24_EredavkinRA_BusBusiness
// 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<FormBus>());
}
private static IUnityContainer CreateContainer()
{
var container = new UnityContainer();
container.AddExtension(new LoggingExtension(CreateLoggerFactory()));
container.RegisterType<IBusRepository, BusRepository>(new TransientLifetimeManager());
container.RegisterType<IRoutRepositories, RoutRepositories>(new TransientLifetimeManager());
container.RegisterType<IRoutSheetRepository, RoutSheetRepository>(new TransientLifetimeManager());
container.RegisterType<IStaffRepositories, StaffRepository>(new TransientLifetimeManager());
container.RegisterType<IToRepository, ToRepository>(new TransientLifetimeManager());
container.RegisterType<IConnectionString, ConnectionString>(new SingletonLifetimeManager());
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 PIbd_24_EredavkinRA_BusBusiness.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("PIbd_24_EredavkinRA_BusBusiness.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 del {
get {
object obj = ResourceManager.GetObject("del", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap rev {
get {
object obj = ResourceManager.GetObject("rev", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap МАТП {
get {
object obj = ResourceManager.GetObject("МАТП", 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="МАТП" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\МАТП.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="rev" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\rev.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="del" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\del.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

View File

@ -0,0 +1,51 @@
using Microsoft.Extensions.Logging;
using PIbd_24_EredavkinRA_BusBusiness.Repositories;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PIbd_24_EredavkinRA_BusBusiness.Reports;
internal class ChartReport
{
private readonly IToRepository _toRepository;
private readonly ILogger<ChartReport> _logger;
public ChartReport(IToRepository toRepository, ILogger<ChartReport> logger)
{
_toRepository = toRepository ??
throw new ArgumentNullException(nameof(toRepository));
_logger = logger ??
throw new ArgumentNullException(nameof(logger));
}
public bool CreateChart(string filePath, DateTime dateTime)
{
try
{
new PdfBuilder(filePath)
.AddHeader($"Количество Обслуживаний Автобусов на {dateTime:dd MMMM yyyy}")
.AddPieChart("Автобусы", GetData(dateTime))
.Build();
return true;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при формировании документа");
return false;
}
}
private List<(string Caption, double Value)> GetData(DateTime dateTime)
{
return _toRepository
.ReadTo(dateForm: dateTime.Date, dateTo: dateTime.Date.AddDays(1))
.GroupBy(x => x.BusName, (key, cost) => new { BusName = key, Count = cost.Count() })
.Select(x => (x.BusName, (double)x.Count))
.ToList();
}
}

View File

@ -0,0 +1,103 @@
using Microsoft.Extensions.Logging;
using PIbd_24_EredavkinRA_BusBusiness.Repositories;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PIbd_24_EredavkinRA_BusBusiness.Reports;
internal class DocReport
{
private readonly IBusRepository _busRepository;
private readonly IRoutRepositories _routRepository;
private readonly IStaffRepositories _staffRepository;
private readonly ILogger<DocReport> _logger;
public DocReport(IBusRepository busRepository,
IRoutRepositories routRepository, IStaffRepositories staffRepository, ILogger<DocReport> logger)
{
_busRepository = busRepository ??
throw new ArgumentNullException(nameof(busRepository));
_routRepository = routRepository ??
throw new ArgumentNullException(nameof(routRepository));
_staffRepository = staffRepository ??
throw new ArgumentNullException(nameof(staffRepository));
_logger = logger ??
throw new ArgumentNullException(nameof(logger));
}
public bool CreateDoc(string filePath, bool includeBus, bool includeRout,
bool includeStaff)
{
try
{
var builder = new WordBuilder(filePath)
.AddHeader("Документ со справочниками");
if (includeBus)
{
builder.AddParagraph("Автобусы")
.AddTable([1200, 2400, 1200], GetBuses());
}
if (includeRout)
{
builder.AddParagraph("Маршруты")
.AddTable([2400, 2400, 2400], GetRout());
}
if (includeStaff)
{
builder.AddParagraph("Сотрудники")
.AddTable([2400, 2400, 2400], GetStaff());
}
builder.Build();
return true;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при формировании документа");
return false;
}
}
private List<string[]> GetBuses()
{
return [
["Модель", "Номерной знак", "Количество мест"],
.. _busRepository
.ReadBus()
.Select(x => new string[] { x.ModelType.ToString(), x.N_Z, x.Capacity.ToString() }),
];
}
private List<string[]> GetStaff()
{
return [
["Фамилия", "Имя", "Должность"],
.. _staffRepository
.ReadStaff()
.Select(x => new string[] { x.LastName, x.FirstName, x.EmployeePost.ToString() }),
];
}
private List<string[]> GetRout()
{
return [
["Номер Маршрута", "Начальная остановка", "Конечная остановка"],
.. _routRepository
.ReadRout()
.Select(x => new string[] { x.NumberRout.ToString(), x.StartStop, x.EndStop }),
];
}
}

View File

@ -0,0 +1,328 @@
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Spreadsheet;
using DocumentFormat.OpenXml;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PIbd_24_EredavkinRA_BusBusiness.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.SimpleTextWithoutBorder);
}
_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("columnsWidths.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.BoldTextWithBorder);
}
_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.SimpleTextWithBorder);
}
_rowIndex++;
}
for (var j = 0; j < data.Last().Length; ++j)
{
CreateCell(j, _rowIndex, data.Last()[j], StyleIndex.BoldTextWithBorder);
}
_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) }
});
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) },
Bold = new Bold() { Val = true }
});
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()
});
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);
// Default cell format and a date cell format
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
}
});
cellFormats.Append(new CellFormat
{
NumberFormatId = 0,
FormatId = 0,
FontId = 0,
BorderId = 1,
FillId = 0,
Alignment = new Alignment()
{
Horizontal = HorizontalAlignmentValues.Right,
Vertical = VerticalAlignmentValues.Center,
WrapText = true
}
});
cellFormats.Append(new CellFormat
{
NumberFormatId = 0,
FormatId = 0,
FontId = 1,
BorderId = 0,
FillId = 0,
Alignment = new Alignment()
{
Horizontal = HorizontalAlignmentValues.Center,
Vertical = VerticalAlignmentValues.Center,
WrapText = true
}
});
cellFormats.Append(new CellFormat
{
NumberFormatId = 0,
FormatId = 0,
FontId = 1,
BorderId = 1,
FillId = 0,
Alignment = new Alignment()
{
Horizontal = HorizontalAlignmentValues.Center,
Vertical = VerticalAlignmentValues.Center,
WrapText = true
}
});
workbookStylesPart.Stylesheet.Append(cellFormats);
}
private enum StyleIndex
{
SimpleTextWithoutBorder = 0,
SimpleTextWithBorder = 1,
BoldTextWithoutBorder = 2,
BoldTextWithBorder = 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,93 @@
using MigraDoc.DocumentObjectModel;
using MigraDoc.Rendering;
using MigraDoc.DocumentObjectModel.Shapes.Charts;
using System.Text;
using System.Threading.Tasks;
namespace PIbd_24_EredavkinRA_BusBusiness.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()
{
var headerStyle = _document.Styles.AddStyle("NormalBold", "Normal");
headerStyle.Font.Bold = true;
headerStyle.Font.Size = 14;
}
}

View File

@ -0,0 +1,96 @@
using Microsoft.Extensions.Logging;
using PIbd_24_EredavkinRA_BusBusiness.Entities;
using PIbd_24_EredavkinRA_BusBusiness.Repositories;
using PIbd_24_EredavkinRA_BusBusiness.Repositories.Implementations;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PIbd_24_EredavkinRA_BusBusiness.Reports;
internal class TableReport
{
private readonly IRoutSheetRepository _routsheetRepository;
private readonly IToRepository _toRepository;
private readonly IBusRepository _busRepository;
private readonly ILogger<TableReport> _logger;
internal static readonly string[] item = ["Дата", "Номер Маршрута", "Стоимость ремонта"];
public TableReport(IRoutSheetRepository routsheetRepository, IToRepository toRepository, IBusRepository busRepository, ILogger<TableReport> logger)
{
_routsheetRepository = routsheetRepository ??
throw new ArgumentNullException(nameof(routsheetRepository));
_toRepository = toRepository ??
throw new ArgumentNullException(nameof(toRepository));
_busRepository = busRepository ??
throw new ArgumentNullException(nameof(busRepository));
_logger = logger ??
throw new ArgumentNullException(nameof(logger));
}
public bool CreateTable(string filePath, int busId, DateTime startDate, DateTime endDate)
{
try
{
new ExcelBuilder(filePath)
.AddHeader("Общая сводка за Автобусами", 0, 3)
.AddParagraph($"за период c {startDate:dd.MM.yyyy} по {endDate:dd.MM.yyyy}", 0)
.AddTable([15, 10, 10], GetData(busId, startDate, endDate))
.Build();
return true;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при формировании документа");
return false;
}
}
public List<string[]> GetData(int busId, DateTime startDate, DateTime endDate)
{
var data = _routsheetRepository
.ReadRoutSheet(dateForm: startDate, dateTo: endDate, busid: busId)
.Select(x => new {
Date = x.BusDate,
Rout = x.RoutName ?? string.Empty,
Cost = (decimal?)null
})
.Union(
_toRepository
.ReadTo(dateForm: startDate, dateTo: endDate, busid: busId)
.Select(x => new {
Date = x.DateTo,
Rout = string.Empty,
Cost = (decimal?)x.Cost
}))
.OrderBy(x => x.Date);
return new List<string[]> { item }
.Union(
data.Select(x => new string[]
{
x.Date.ToString("dd.MM.yyyy"),
x.Rout?.ToString() ?? string.Empty,
x.Cost?.ToString("N0") ?? string.Empty
}))
.Union(new[] { new string[] { "Всего", "", data.Sum(x => x.Cost ?? 0).ToString("N0") } })
.ToList();
}
}

View File

@ -0,0 +1,107 @@
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Wordprocessing;
using DocumentFormat.OpenXml;
namespace PIbd_24_EredavkinRA_BusBusiness.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());
run.AppendChild(new RunProperties(new Bold()));
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,20 @@
using PIbd_24_EredavkinRA_BusBusiness.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PIbd_24_EredavkinRA_BusBusiness.Repositories;
public interface IBusRepository
{
IEnumerable<Bus> ReadBus();
Bus ReadBusByID(int id);
void CreateBus(Bus bus);
void UpdateBus(Bus bus);
void DeleteBus(int id);
}

View File

@ -0,0 +1,7 @@

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

View File

@ -0,0 +1,20 @@
using PIbd_24_EredavkinRA_BusBusiness.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PIbd_24_EredavkinRA_BusBusiness.Repositories;
public interface IRoutRepositories
{
IEnumerable<Rout> ReadRout();
Rout ReadRoutByID(int id);
void CreateRout(Rout rout);
void UpdateRout(Rout rout);
void DeleteRout(int id);
}

View File

@ -0,0 +1,15 @@
using PIbd_24_EredavkinRA_BusBusiness.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PIbd_24_EredavkinRA_BusBusiness.Repositories;
public interface IRoutSheetRepository
{
IEnumerable<RoutSheet> ReadRoutSheet(DateTime? dateForm = null, DateTime? dateTo = null, int? routId = null, int? busid = null, int? driverid = null, int? conductorid = null);
void CreateRoutSheet(RoutSheet routsheet);
}

View File

@ -0,0 +1,20 @@
using PIbd_24_EredavkinRA_BusBusiness.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PIbd_24_EredavkinRA_BusBusiness.Repositories;
public interface IStaffRepositories
{
IEnumerable<Staff> ReadStaff();
Staff ReadStaffByID(int id);
void CreateStaff(Staff staff);
void UpdateStaff(Staff staff);
void DeleteStaff(int id);
}

View File

@ -0,0 +1,17 @@
using PIbd_24_EredavkinRA_BusBusiness.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PIbd_24_EredavkinRA_BusBusiness.Repositories;
public interface IToRepository
{
IEnumerable<To> ReadTo(DateTime? dateForm = null, DateTime? dateTo = null, int? mechanicid = null, int? busid = null);
void CreateTo(To to);
void DeleteTo(int id);
}

View File

@ -0,0 +1,127 @@
using Dapper;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Npgsql;
using PIbd_24_EredavkinRA_BusBusiness.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PIbd_24_EredavkinRA_BusBusiness.Repositories.Implementations;
public class BusRepository : IBusRepository
{
private readonly IConnectionString _connectionString;
private readonly ILogger<BusRepository> _logger;
public BusRepository(IConnectionString connectionString, ILogger<BusRepository> logger)
{
_connectionString = connectionString;
_logger = logger;
}
public void CreateBus(Bus bus)
{
_logger.LogInformation("Добавление объекта");
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(bus));
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var queryInsert = @"
INSERT INTO Bus (ModelType, N_Z, Capacity, Bus_mileage)
VALUES (@ModelType, @N_Z, @Capacity, @Bus_mileage)";
connection.Execute(queryInsert, bus);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при добавлении объекта");
throw;
}
}
public void UpdateBus(Bus bus)
{
_logger.LogInformation("Редактирование объекта");
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(bus));
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var queryUpdate = @"
UPDATE Bus
SET
ModelType=@ModelType,
N_Z=@N_Z,
Capacity=@Capacity,
Bus_mileage=@Bus_mileage
WHERE Id=@Id";
connection.Execute(queryUpdate, bus);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при редактировании объекта");
throw;
}
}
public void DeleteBus(int id)
{
_logger.LogInformation("Удаление объекта");
_logger.LogDebug("Объект: {id}", id);
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var queryDelete = @"
DELETE FROM Bus
WHERE Id=@id";
connection.Execute(queryDelete, new { id });
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при удалении объекта");
throw;
}
}
public Bus ReadBusByID(int id)
{
_logger.LogInformation("Получение объекта по идентификатору");
_logger.LogDebug("Объект: {id}", id);
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var querySelect = @"
SELECT * FROM Bus
WHERE Id=@id";
var bus = connection.QueryFirst<Bus>(querySelect, new { id });
_logger.LogDebug("Найденный объект: {json}", JsonConvert.SerializeObject(bus));
return bus;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при поиске объекта");
throw;
}
}
public IEnumerable<Bus> ReadBus()
{
_logger.LogInformation("Получение всех объектов");
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var querySelect = "SELECT * FROM Bus";
var bus = connection.Query<Bus>(querySelect);
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(bus));
return bus;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при чтении объектов");
throw;
}
}
}

View File

@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PIbd_24_EredavkinRA_BusBusiness.Repositories.Implementations;
internal class ConnectionString : IConnectionString
{
string IConnectionString.ConnectionString => "Host=127.0.0.1:5432;Database=basdetebus;Username=postgres;Password=postgres; Include Error Detail=true;";
}

View File

@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PIbd_24_EredavkinRA_BusBusiness.Repositories.Implementations;
internal class QueryBuilder
{
private readonly StringBuilder _builder;
public QueryBuilder()
{
_builder = new();
}
public QueryBuilder AddCondition(string condition)
{
if (_builder.Length > 0)
{
_builder.Append(" AND ");
}
_builder.Append(condition);
return this;
}
public string Build()
{
if (_builder.Length == 0)
{
return string.Empty;
}
return $" WHERE {_builder}";
}
}

View File

@ -0,0 +1,125 @@
using Dapper;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Npgsql;
using PIbd_24_EredavkinRA_BusBusiness.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PIbd_24_EredavkinRA_BusBusiness.Repositories.Implementations;
public class RoutRepositories : IRoutRepositories
{
private readonly IConnectionString _connectionString;
private readonly ILogger<RoutRepositories> _logger;
public RoutRepositories(IConnectionString connectionString, ILogger<RoutRepositories> logger)
{
_connectionString = connectionString;
_logger = logger;
}
public void CreateRout(Rout rout)
{
_logger.LogInformation("Добавление объекта");
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(rout));
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var queryInsert = @"
INSERT INTO Rout (StartStop, EndStop, NumberRout)
VALUES (@StartStop, @EndStop, @NumberRout)";
connection.Execute(queryInsert, rout);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при добавлении объекта");
throw;
}
}
public void UpdateRout(Rout rout)
{
_logger.LogInformation("Редактирование объекта");
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(rout));
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var queryUpdate = @"
UPDATE Rout
SET
StartStop=@StartStop,
EndStop=@EndStop,
NumberRout=@NumberRout
WHERE Id=@Id";
connection.Execute(queryUpdate, rout);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при редактировании объекта");
throw;
}
}
public void DeleteRout(int id)
{
_logger.LogInformation("Удаление объекта");
_logger.LogDebug("Объект: {id}", id);
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var queryDelete = @"
DELETE FROM Rout
WHERE Id=@id";
connection.Execute(queryDelete, new { id });
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при удалении объекта");
throw;
}
}
public Rout ReadRoutByID(int id)
{
_logger.LogInformation("Получение объекта по идентификатору");
_logger.LogDebug("Объект: {id}", id);
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var querySelect = @"
SELECT * FROM Rout
WHERE Id=@id";
var rout = connection.QueryFirst<Rout>(querySelect, new { id });
_logger.LogDebug("Найденный объект: {json}", JsonConvert.SerializeObject(rout));
return rout;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при поиске объекта");
throw;
}
}
public IEnumerable<Rout> ReadRout()
{
_logger.LogInformation("Получение всех объектов");
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var querySelect = "SELECT * FROM Rout";
var rout = connection.Query<Rout>(querySelect);
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(rout));
return rout;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при чтении объектов");
throw;
}
}
}

View File

@ -0,0 +1,132 @@
using Dapper;
using DocumentFormat.OpenXml.Bibliography;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Npgsql;
using PIbd_24_EredavkinRA_BusBusiness.Entities;
namespace PIbd_24_EredavkinRA_BusBusiness.Repositories.Implementations;
public class RoutSheetRepository : IRoutSheetRepository
{
private readonly IConnectionString _connectionString;
private readonly ILogger<RoutSheetRepository> _logger;
public RoutSheetRepository(IConnectionString connectionString, ILogger<RoutSheetRepository> logger)
{
_connectionString = connectionString;
_logger = logger;
}
public void CreateRoutSheet(RoutSheet routsheet)
{
_logger.LogInformation("Добавление объекта");
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(routsheet));
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
connection.Open();
using var transaction = connection.BeginTransaction();
var queryInsert = @"
INSERT INTO RoutSheet (RoutId, DriverId, ConductorId, BusDate)
VALUES (@RoutId, @DriverId, @ConductorID, @BusDate);
SELECT MAX(Id) FROM RoutSheet";
var routsheetId = connection.QueryFirst<int>(queryInsert, routsheet, transaction);
var querySubInsert = @"
INSERT INTO RoutSheetBus (RoutSheetId, BusId)
VALUES (@RoutSheetId, @BusId)";
foreach (var elem in routsheet.RoutSheetBus)
{
connection.Execute(querySubInsert, new { routsheetId, elem.BusID }, transaction);
}
transaction.Commit();
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при добавлении объекта");
throw;
}
}
public IEnumerable<RoutSheet> ReadRoutSheet(DateTime? dateForm = null, DateTime? dateBus = null, int? routId = null, int? busid = null, int? driverid = null, int? conductorid = null)
{
_logger.LogInformation("Получение всех объектов");
try
{
var builder = new QueryBuilder();
if (dateForm.HasValue)
{
builder.AddCondition("cs.BusDate >= @dateForm");
}
if (dateBus.HasValue)
{
builder.AddCondition("cs.BusDate <= @dateBus");
}
if (driverid.HasValue)
{
builder.AddCondition("cs.DriverId = @driverid");
}
if (conductorid.HasValue)
{
builder.AddCondition("cs.ConductorId = @conductorid");
}
if (busid.HasValue)
{
builder.AddCondition("rsh.BusId = @busid");
}
if (routId.HasValue)
{
builder.AddCondition("cs.RoutId = @routid");
}
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var querySelect = $@"
SELECT
cs.*,
CONCAT(s.FirstName, ' ', s.LastName) AS EmployeeNameDriver,
CONCAT(c.FirstName, ' ', c.LastName) AS EmployeeNameConductor,
CONCAT(ro.NumberRout, ' ', ro.StartStop, ' ', ro.EndStop) AS RoutName,
rsh.BusId,
b.N_Z AS BusName
FROM RoutSheet cs
LEFT JOIN Staff s ON s.Id = cs.DriverId
LEFT JOIN Staff c ON c.Id = cs.ConductorId
LEFT JOIN Rout ro ON ro.Id = cs.RoutId
INNER JOIN RoutSheetBus rsh ON rsh.RoutSheetId = cs.Id
LEFT JOIN Bus b ON b.Id = rsh.BusId
{builder.Build()}";
var supplementDict = new Dictionary<int, List<RoutSheetBus>>();
var curriculumSupplements = connection.Query<RoutSheet, RoutSheetBus, RoutSheet>(querySelect,
(supplement, curriculumSupplements) =>
{
if (!supplementDict.TryGetValue(supplement.Id, out var rsh))
{
rsh = [];
supplementDict.Add(supplement.Id, rsh);
}
rsh.Add(curriculumSupplements);
return supplement;
}, splitOn: "BusId", param: new { dateForm, dateBus, routId, busid, driverid, conductorid });
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(curriculumSupplements));
return supplementDict.Select(x =>
{
var cs = curriculumSupplements.First(y => y.Id == x.Key);
cs.SetRoutSheetBus(x.Value);
return cs;
}).ToArray();
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при чтении объектов");
throw;
}
}
}

View File

@ -0,0 +1,125 @@
using Dapper;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Npgsql;
using PIbd_24_EredavkinRA_BusBusiness.Entities;
using PIbd_24_EredavkinRA_BusBusiness.Entities.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PIbd_24_EredavkinRA_BusBusiness.Repositories.Implementations;
internal class StaffRepository : IStaffRepositories
{
private readonly IConnectionString _connectionString;
private readonly ILogger<StaffRepository> _logger;
public StaffRepository(IConnectionString connectionString, ILogger<StaffRepository> logger)
{
_connectionString = connectionString;
_logger = logger;
}
public void CreateStaff(Staff staff)
{
_logger.LogInformation("Добавление объекта");
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(staff));
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var queryInsert = @"
INSERT INTO Staff (FirstName, LastName, EmployeePost)
VALUES (@FirstName, @LastName, @EmployeePost)";
connection.Execute(queryInsert, staff);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при добавлении объекта");
throw;
}
}
public void UpdateStaff(Staff staff)
{
_logger.LogInformation("Редактирование объекта");
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(staff));
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var queryUpdate = @"
UPDATE Staff
SET
FirstName=@FirstName,
LastName=@LastName,
EmployeePost=@EmployeePost
WHERE Id=@Id";
connection.Execute(queryUpdate, staff);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при редактировании объекта");
throw;
}
}
public void DeleteStaff(int id)
{
_logger.LogInformation("Удаление объекта");
_logger.LogDebug("Объект: {id}", id);
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var queryDelete = @"
DELETE FROM Staff
WHERE Id=@id";
connection.Execute(queryDelete, new { id });
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при удалении объекта");
throw;
}
}
public Staff ReadStaffByID(int id)
{
_logger.LogInformation("Получение объекта по идентификатору");
_logger.LogDebug("Объект: {id}", id);
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var querySelect = @"
SELECT * FROM Staff
WHERE Id=@id";
var staff = connection.QueryFirst<Staff>(querySelect, new { id });
_logger.LogDebug("Найденный объект: {json}", JsonConvert.SerializeObject(staff));
return staff;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при поиске объекта");
throw;
}
}
public IEnumerable<Staff> ReadStaff()
{
_logger.LogInformation("Получение всех объектов");
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var querySelect = "SELECT * FROM Staff";
var staff = connection.Query<Staff>(querySelect);
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(staff));
return staff;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при чтении объектов");
throw;
}
}
}

View File

@ -0,0 +1,105 @@
using Dapper;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Npgsql;
using PIbd_24_EredavkinRA_BusBusiness.Entities;
namespace PIbd_24_EredavkinRA_BusBusiness.Repositories.Implementations;
public class ToRepository : IToRepository
{
private readonly IConnectionString _connectionString;
private readonly ILogger<ToRepository> _logger;
public ToRepository(IConnectionString connectionString, ILogger<ToRepository> logger)
{
_connectionString = connectionString;
_logger = logger;
}
public void CreateTo(To to)
{
_logger.LogInformation("Добавление объекта");
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(to));
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var queryInsert = @"
INSERT INTO TOs (BusId, StaffId, Discription, Cost, DateTo)
VALUES (@BusId, @StaffId, @Discription, @Cost, @DateTo)";
connection.Execute(queryInsert, to);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при добавлении объекта");
throw;
}
}
public void DeleteTo(int id)
{
_logger.LogInformation("Удаление объекта");
_logger.LogDebug("Объект: {id}", id);
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var queryDelete = @"
DELETE FROM TOs
WHERE Id=@id";
connection.Execute(queryDelete, new { id });
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при удалении объекта");
throw;
}
}
public IEnumerable<To> ReadTo(DateTime? dateForm = null, DateTime? dateTo = null, int? staffid = null, int? busid = null)
{
_logger.LogInformation("Получение всех объектов");
try
{
var builder = new QueryBuilder();
if (dateForm.HasValue)
{
builder.AddCondition("cs.DateTo >= @dateForm");
}
if (dateTo.HasValue)
{
builder.AddCondition("cs.DateTo <= @dateTo");
}
if (staffid.HasValue)
{
builder.AddCondition("cs.StaffId = @staffid");
}
if (busid.HasValue)
{
builder.AddCondition("cs.BusId = @busid");
}
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var querySelect = $@"
SELECT
cs.*,
CONCAT(s.FirstName, ' ', s.LastName) AS StaffName,
b.N_Z AS BusName
FROM TOs cs
LEFT JOIN Bus b ON b.Id = cs.BusId
LEFT JOIN Staff s ON s.Id = cs.StaffId
{builder.Build()}";
var compilingSchedules = connection.Query<To>(querySelect, new { dateForm, dateTo, busid, staffid});
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(compilingSchedules));
return compilingSchedules;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при чтении объектов");
throw;
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 408 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 87 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 252 KiB

View File

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

31
test/test.sln Normal file
View File

@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.9.34728.123
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test", "test\test.vcxproj", "{F77B0358-2B48-4BD7-8CCD-1AD9C73D1BCB}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{F77B0358-2B48-4BD7-8CCD-1AD9C73D1BCB}.Debug|x64.ActiveCfg = Debug|x64
{F77B0358-2B48-4BD7-8CCD-1AD9C73D1BCB}.Debug|x64.Build.0 = Debug|x64
{F77B0358-2B48-4BD7-8CCD-1AD9C73D1BCB}.Debug|x86.ActiveCfg = Debug|Win32
{F77B0358-2B48-4BD7-8CCD-1AD9C73D1BCB}.Debug|x86.Build.0 = Debug|Win32
{F77B0358-2B48-4BD7-8CCD-1AD9C73D1BCB}.Release|x64.ActiveCfg = Release|x64
{F77B0358-2B48-4BD7-8CCD-1AD9C73D1BCB}.Release|x64.Build.0 = Release|x64
{F77B0358-2B48-4BD7-8CCD-1AD9C73D1BCB}.Release|x86.ActiveCfg = Release|Win32
{F77B0358-2B48-4BD7-8CCD-1AD9C73D1BCB}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {0CC34090-EEB4-4546-B06A-461C6A4A843F}
EndGlobalSection
EndGlobal

34
test/test/test.cpp Normal file
View File

@ -0,0 +1,34 @@
#include <iostream>
#include <cmath>
using namespace std;
int main() {
int n;
cin >> n;
int power_of_2 = 0;
int power_of_5 = 0;
while (n % 2 == 0) {
n /= 2;
power_of_2++;
}
while (n % 5 == 0) {
n /= 5;
power_of_5++;
}
if (n > 1) {
cout << "No" << endl;
}
else {
cout << max(power_of_2, power_of_5) << endl;
}
return 0;
}

135
test/test/test.vcxproj Normal file
View File

@ -0,0 +1,135 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>17.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{f77b0358-2b48-4bd7-8ccd-1ad9c73d1bcb}</ProjectGuid>
<RootNamespace>test</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="test.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Исходные файлы">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Файлы заголовков">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="Файлы ресурсов">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="test.cpp">
<Filter>Исходные файлы</Filter>
</ClCompile>
</ItemGroup>
</Project>