готовая 1 лаба

This commit is contained in:
cyxaruk 2024-11-13 22:40:40 +04:00
parent e2d291b861
commit 1db123d40d
13 changed files with 1002 additions and 41 deletions

View File

@ -34,9 +34,9 @@
автобусыToolStripMenuItem = new ToolStripMenuItem(); автобусыToolStripMenuItem = new ToolStripMenuItem();
маршрутныеЛистыToolStripMenuItem = new ToolStripMenuItem(); маршрутныеЛистыToolStripMenuItem = new ToolStripMenuItem();
операцииToolStripMenuItem = new ToolStripMenuItem(); операцииToolStripMenuItem = new ToolStripMenuItem();
отчетыToolStripMenuItem = new ToolStripMenuItem();
раздачаМаршрутовToolStripMenuItem = new ToolStripMenuItem(); раздачаМаршрутовToolStripMenuItem = new ToolStripMenuItem();
началоСменыToolStripMenuItem = new ToolStripMenuItem(); началоСменыToolStripMenuItem = new ToolStripMenuItem();
отчетыToolStripMenuItem = new ToolStripMenuItem();
menuStrip.SuspendLayout(); menuStrip.SuspendLayout();
SuspendLayout(); SuspendLayout();
// //
@ -61,18 +61,21 @@
работникToolStripMenuItem.Name = "работникToolStripMenuItem"; работникToolStripMenuItem.Name = "работникToolStripMenuItem";
работникToolStripMenuItem.Size = new Size(186, 22); работникToolStripMenuItem.Size = new Size(186, 22);
работникToolStripMenuItem.Text = "Работники"; работникToolStripMenuItem.Text = "Работники";
работникToolStripMenuItem.Click += EmployeeToolStripMenuItem_Click;
// //
// автобусыToolStripMenuItem // автобусыToolStripMenuItem
// //
автобусыToolStripMenuItem.Name = "автобусыToolStripMenuItem"; автобусыToolStripMenuItem.Name = "автобусыToolStripMenuItem";
автобусыToolStripMenuItem.Size = new Size(186, 22); автобусыToolStripMenuItem.Size = new Size(186, 22);
автобусыToolStripMenuItem.Text = "Автобусы"; автобусыToolStripMenuItem.Text = "Автобусы";
автобусыToolStripMenuItem.Click += BusesToolStripMenuItem_Click;
// //
// маршрутныеЛистыToolStripMenuItem // маршрутныеЛистыToolStripMenuItem
// //
маршрутныеЛистыToolStripMenuItem.Name = аршрутныеЛистыToolStripMenuItem"; маршрутныеЛистыToolStripMenuItem.Name = аршрутныеЛистыToolStripMenuItem";
маршрутныеЛистыToolStripMenuItem.Size = new Size(186, 22); маршрутныеЛистыToolStripMenuItem.Size = new Size(186, 22);
маршрутныеЛистыToolStripMenuItem.Text = "Маршрутные листы"; маршрутныеЛистыToolStripMenuItem.Text = "Маршрутные листы";
маршрутныеЛистыToolStripMenuItem.Click += RouteListsToolStripMenuItem_Click;
// //
// операцииToolStripMenuItem // операцииToolStripMenuItem
// //
@ -81,23 +84,25 @@
операцииToolStripMenuItem.Size = new Size(75, 20); операцииToolStripMenuItem.Size = new Size(75, 20);
операцииToolStripMenuItem.Text = "Операции"; операцииToolStripMenuItem.Text = "Операции";
// //
// отчетыToolStripMenuItem
//
отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
отчетыToolStripMenuItem.Size = new Size(60, 20);
отчетыToolStripMenuItem.Text = "Отчеты";
//
// раздачаМаршрутовToolStripMenuItem // раздачаМаршрутовToolStripMenuItem
// //
раздачаМаршрутовToolStripMenuItem.Name = "раздачаМаршрутовToolStripMenuItem"; раздачаМаршрутовToolStripMenuItem.Name = "раздачаМаршрутовToolStripMenuItem";
раздачаМаршрутовToolStripMenuItem.Size = new Size(184, 22); раздачаМаршрутовToolStripMenuItem.Size = new Size(184, 22);
раздачаМаршрутовToolStripMenuItem.Text = "Раздача маршрутов"; раздачаМаршрутовToolStripMenuItem.Text = "Раздача маршрутов";
раздачаМаршрутовToolStripMenuItem.Click += RouteGiveawayToolStripMenuItem_Click;
// //
// началоСменыToolStripMenuItem // началоСменыToolStripMenuItem
// //
началоСменыToolStripMenuItem.Name = ачалоСменыToolStripMenuItem"; началоСменыToolStripMenuItem.Name = ачалоСменыToolStripMenuItem";
началоСменыToolStripMenuItem.Size = new Size(184, 22); началоСменыToolStripMenuItem.Size = new Size(184, 22);
началоСменыToolStripMenuItem.Text = "Начало смены"; началоСменыToolStripMenuItem.Text = "Начало смены";
началоСменыToolStripMenuItem.Click += StartingShiftToolStripMenuItem_Click;
//
// отчетыToolStripMenuItem
//
отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
отчетыToolStripMenuItem.Size = new Size(60, 20);
отчетыToolStripMenuItem.Text = "Отчеты";
// //
// FormPeopleTransportation // FormPeopleTransportation
// //

View File

@ -1,10 +1,76 @@
using ProjectPeopleTransportation.Forms;
using Unity;
namespace ProjectPeopleTransportation namespace ProjectPeopleTransportation
{ {
public partial class FormPeopleTransportation : Form public partial class FormPeopleTransportation : Form
{ {
public FormPeopleTransportation() private readonly IUnityContainer _container;
public FormPeopleTransportation(IUnityContainer container)
{ {
InitializeComponent(); InitializeComponent();
_container = container ??
throw new ArgumentNullException(nameof(container));
}
private void EmployeeToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormEmployees>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void BusesToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormBuses>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void RouteListsToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormRouteLists>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void RouteGiveawayToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormRouteGiveaways>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void StartingShiftToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormStartingShifts>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
} }
} }
} }

View File

@ -28,12 +28,120 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.components = new System.ComponentModel.Container(); comboBoxEmployee = new ComboBox();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; labelEmployee = new Label();
this.ClientSize = new System.Drawing.Size(800, 450); groupBoxRoutes = new GroupBox();
this.Text = "FormRouteGiveaway"; dataGridViewRoutes = new DataGridView();
ColumnRouteName = new DataGridViewComboBoxColumn();
ColumnRouteNum = new DataGridViewTextBoxColumn();
buttonSave = new Button();
buttonCancel = new Button();
groupBoxRoutes.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridViewRoutes).BeginInit();
SuspendLayout();
//
// comboBoxEmployee
//
comboBoxEmployee.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxEmployee.FormattingEnabled = true;
comboBoxEmployee.Location = new Point(199, 45);
comboBoxEmployee.Name = "comboBoxEmployee";
comboBoxEmployee.Size = new Size(121, 23);
comboBoxEmployee.TabIndex = 7;
//
// labelEmployee
//
labelEmployee.AutoSize = true;
labelEmployee.Location = new Point(42, 53);
labelEmployee.Name = "labelEmployee";
labelEmployee.Size = new Size(59, 15);
labelEmployee.TabIndex = 6;
labelEmployee.Text = "Работник";
//
// groupBoxRoutes
//
groupBoxRoutes.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
groupBoxRoutes.Controls.Add(dataGridViewRoutes);
groupBoxRoutes.Location = new Point(42, 110);
groupBoxRoutes.Name = "groupBoxRoutes";
groupBoxRoutes.Size = new Size(243, 254);
groupBoxRoutes.TabIndex = 8;
groupBoxRoutes.TabStop = false;
groupBoxRoutes.Text = "Маршруты";
//
// dataGridViewRoutes
//
dataGridViewRoutes.AllowUserToResizeColumns = false;
dataGridViewRoutes.AllowUserToResizeRows = false;
dataGridViewRoutes.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridViewRoutes.Columns.AddRange(new DataGridViewColumn[] { ColumnRouteName, ColumnRouteNum });
dataGridViewRoutes.Dock = DockStyle.Fill;
dataGridViewRoutes.Location = new Point(3, 19);
dataGridViewRoutes.MultiSelect = false;
dataGridViewRoutes.Name = "dataGridViewRoutes";
dataGridViewRoutes.RowHeadersVisible = false;
dataGridViewRoutes.Size = new Size(237, 232);
dataGridViewRoutes.TabIndex = 9;
//
// ColumnRouteName
//
ColumnRouteName.HeaderText = "Название";
ColumnRouteName.Name = "ColumnRouteName";
//
// ColumnRouteNum
//
ColumnRouteNum.HeaderText = "Количество";
ColumnRouteNum.Name = "ColumnRouteNum";
//
// buttonSave
//
buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
buttonSave.Location = new Point(45, 374);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(75, 23);
buttonSave.TabIndex = 9;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += ButtonSave_Click;
//
// buttonCancel
//
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonCancel.Location = new Point(207, 374);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(75, 23);
buttonCancel.TabIndex = 10;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += ButtonCancel_Click;
//
// FormRouteGiveaway
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(343, 409);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Controls.Add(groupBoxRoutes);
Controls.Add(comboBoxEmployee);
Controls.Add(labelEmployee);
Name = "FormRouteGiveaway";
Text = "Раздача маршрутов";
groupBoxRoutes.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridViewRoutes).EndInit();
ResumeLayout(false);
PerformLayout();
} }
#endregion #endregion
private ComboBox comboBoxEmployee;
private Label labelEmployee;
private GroupBox groupBoxRoutes;
private DataGridView dataGridViewRoutes;
private Button buttonSave;
private Button buttonCancel;
private DataGridViewComboBoxColumn ColumnRouteName;
private DataGridViewTextBoxColumn ColumnRouteNum;
} }
} }

View File

@ -1,4 +1,7 @@
using System; using ProjectPeopleTransportation.Entities;
using ProjectPeopleTransportation.Repositories;
using ProjectPeopleTransportation.Repositories.Implementations;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Data; using System.Data;
@ -12,9 +15,61 @@ namespace ProjectPeopleTransportation.Forms
{ {
public partial class FormRouteGiveaway : Form public partial class FormRouteGiveaway : Form
{ {
public FormRouteGiveaway() private readonly IRouteGiveawayRepository _routeGiveawayRepository;
public FormRouteGiveaway(IRouteGiveawayRepository routeGiveawayRepository,
IEmployeeRepository employeeRepository,
IRouteListRepository routeListRepository)
{ {
InitializeComponent(); InitializeComponent();
_routeGiveawayRepository = routeGiveawayRepository ??
throw new ArgumentNullException(nameof(routeGiveawayRepository));
comboBoxEmployee.DataSource = employeeRepository.ReadEmployees();
comboBoxEmployee.DisplayMember = "FirstName";
comboBoxEmployee.ValueMember = "Id";
ColumnRouteName.DataSource = routeListRepository.ReadRouteLists();
ColumnRouteName.DisplayMember = "RoutName";
ColumnRouteName.ValueMember = "Id";
}
private void ButtonSave_Click(object sender, EventArgs e)
{
try
{
if (dataGridViewRoutes.RowCount < 1 ||
comboBoxEmployee.SelectedIndex < 0)
{
throw new Exception("Имеются незаполненные поля");
}
_routeGiveawayRepository.CreateRouteGiveaway(RouteGiveaway.CreateOperation(0,
(int)comboBoxEmployee.SelectedValue!, CreateListRouteRouteGiveawayFromDataGrid()));
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
private List<RouteRouteGiveaway> CreateListRouteRouteGiveawayFromDataGrid()
{
var list = new List<RouteRouteGiveaway>();
foreach (DataGridViewRow row in dataGridViewRoutes.Rows)
{
if (row.Cells["ColumnRoute"].Value == null || row.Cells["ColumnCount"].Value == null)
{
continue;
}
list.Add(RouteRouteGiveaway.CreateElement(0, Convert.ToInt32(row.Cells["ColumnRoute"].Value),
Convert.ToInt32(row.Cells["ColumnCount"].Value)));
}
return list;
} }
} }
} }

View File

@ -117,4 +117,16 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<metadata name="ColumnRouteName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ColumnRouteNum.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ColumnRouteName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ColumnRouteNum.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root> </root>

View File

@ -0,0 +1,104 @@
namespace ProjectPeopleTransportation.Forms
{
partial class FormRouteGiveaways
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
panel1 = new Panel();
buttonDelete = new Button();
buttonAdd = new Button();
dataGridViewGiveaway = new DataGridView();
panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridViewGiveaway).BeginInit();
SuspendLayout();
//
// panel1
//
panel1.Controls.Add(buttonDelete);
panel1.Controls.Add(buttonAdd);
panel1.Dock = DockStyle.Right;
panel1.Location = new Point(651, 0);
panel1.Name = "panel1";
panel1.Size = new Size(133, 439);
panel1.TabIndex = 0;
//
// buttonDelete
//
buttonDelete.BackgroundImage = Properties.Resources.remove_151678_1280;
buttonDelete.BackgroundImageLayout = ImageLayout.Stretch;
buttonDelete.Location = new Point(28, 193);
buttonDelete.Name = "buttonDelete";
buttonDelete.Size = new Size(75, 67);
buttonDelete.TabIndex = 4;
buttonDelete.UseVisualStyleBackColor = true;
buttonDelete.Click += ButtonDelete_Click;
//
// buttonAdd
//
buttonAdd.BackgroundImage = Properties.Resources.Fairytale_button_add_svg;
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
buttonAdd.Location = new Point(28, 43);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(75, 67);
buttonAdd.TabIndex = 2;
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += ButtonAdd_Click;
//
// dataGridViewGiveaway
//
dataGridViewGiveaway.AllowUserToAddRows = false;
dataGridViewGiveaway.AllowUserToDeleteRows = false;
dataGridViewGiveaway.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridViewGiveaway.Dock = DockStyle.Fill;
dataGridViewGiveaway.Location = new Point(0, 0);
dataGridViewGiveaway.Name = "dataGridViewGiveaway";
dataGridViewGiveaway.ReadOnly = true;
dataGridViewGiveaway.Size = new Size(651, 439);
dataGridViewGiveaway.TabIndex = 1;
//
// FormRouteGiveaways
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(784, 439);
Controls.Add(dataGridViewGiveaway);
Controls.Add(panel1);
Name = "FormRouteGiveaways";
Text = "Раздачи маршрутов";
panel1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridViewGiveaway).EndInit();
ResumeLayout(false);
}
#endregion
private Panel panel1;
private DataGridView dataGridViewGiveaway;
private Button buttonAdd;
private Button buttonDelete;
}
}

View File

@ -0,0 +1,76 @@
using ProjectPeopleTransportation.Repositories;
using ProjectPeopleTransportation.Repositories.Implementations;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Unity;
namespace ProjectPeopleTransportation.Forms
{
public partial class FormRouteGiveaways : Form
{
private readonly IUnityContainer _container;
private readonly IRouteGiveawayRepository _routeGiveawayRepository;
public FormRouteGiveaways(IUnityContainer container, IRouteGiveawayRepository routeGiveawayRepository)
{
InitializeComponent();
_container = container ?? throw new ArgumentNullException(nameof(container));
_routeGiveawayRepository = routeGiveawayRepository ?? throw new ArgumentNullException(nameof(routeGiveawayRepository));
}
private void ButtonAdd_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormRouteGiveaway>().ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonDelete_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectedRow(out var findId))
{
return;
}
if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes)
{
return;
}
try
{
_routeGiveawayRepository.DeleteRouteGiveaway(findId);
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void LoadList() => dataGridViewGiveaway.DataSource = _routeGiveawayRepository.ReadRouteGiveaway();
private bool TryGetIdentifierFromSelectedRow(out int id)
{
id = 0;
if (dataGridViewGiveaway.SelectedRows.Count < 1)
{
MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
id = Convert.ToInt32(dataGridViewGiveaway.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,115 @@
namespace ProjectPeopleTransportation.Forms
{
partial class FormRouteLists
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
panel1 = new Panel();
buttonDelete = new Button();
buttonUpdate = new Button();
buttonAdd = new Button();
dataGridViewRoute = new DataGridView();
panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridViewRoute).BeginInit();
SuspendLayout();
//
// panel1
//
panel1.Controls.Add(buttonDelete);
panel1.Controls.Add(buttonUpdate);
panel1.Controls.Add(buttonAdd);
panel1.Dock = DockStyle.Right;
panel1.Location = new Point(702, 0);
panel1.Name = "panel1";
panel1.Size = new Size(151, 347);
panel1.TabIndex = 0;
//
// buttonDelete
//
buttonDelete.BackgroundImage = Properties.Resources.remove_151678_1280;
buttonDelete.BackgroundImageLayout = ImageLayout.Stretch;
buttonDelete.Location = new Point(38, 196);
buttonDelete.Name = "buttonDelete";
buttonDelete.Size = new Size(75, 67);
buttonDelete.TabIndex = 5;
buttonDelete.UseVisualStyleBackColor = true;
buttonDelete.Click += ButtonDelete_Click;
//
// buttonUpdate
//
buttonUpdate.BackgroundImage = Properties.Resources.d5b7655bb6ab6f1a24b6ac537fcb639a;
buttonUpdate.BackgroundImageLayout = ImageLayout.Stretch;
buttonUpdate.Location = new Point(38, 113);
buttonUpdate.Name = "buttonUpdate";
buttonUpdate.Size = new Size(75, 67);
buttonUpdate.TabIndex = 4;
buttonUpdate.UseVisualStyleBackColor = true;
buttonUpdate.Click += ButtonUpdate_Click;
//
// buttonAdd
//
buttonAdd.BackgroundImage = Properties.Resources.Fairytale_button_add_svg;
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
buttonAdd.Location = new Point(38, 32);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(75, 67);
buttonAdd.TabIndex = 2;
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += ButtonAdd_Click;
//
// dataGridViewRoute
//
dataGridViewRoute.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridViewRoute.Dock = DockStyle.Fill;
dataGridViewRoute.Location = new Point(0, 0);
dataGridViewRoute.Name = "dataGridViewRoute";
dataGridViewRoute.Size = new Size(702, 347);
dataGridViewRoute.TabIndex = 1;
//
// FormRouteLists
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(853, 347);
Controls.Add(dataGridViewRoute);
Controls.Add(panel1);
Name = "FormRouteLists";
Text = "Маршрутные листы";
panel1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridViewRoute).EndInit();
ResumeLayout(false);
}
#endregion
private Panel panel1;
private DataGridView dataGridViewRoute;
private Button buttonAdd;
private Button buttonDelete;
private Button buttonUpdate;
}
}

View File

@ -0,0 +1,100 @@
using ProjectPeopleTransportation.Repositories;
using ProjectPeopleTransportation.Repositories.Implementations;
using Unity;
namespace ProjectPeopleTransportation.Forms
{
public partial class FormRouteLists : Form
{
private readonly IUnityContainer _container;
private readonly IRouteListRepository _routeListRepository;
public FormRouteLists(IUnityContainer container, IRouteListRepository routeListRepository)
{
InitializeComponent();
_container = container ?? throw new ArgumentNullException(nameof(container));
_routeListRepository = routeListRepository ?? throw new ArgumentNullException(nameof(routeListRepository));
}
private void FormRouteLists_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<FormRouteList>().ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonUpdate_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectedRow(out var findId))
{
return;
}
try
{
var form = _container.Resolve<FormRouteList>();
form.Id = findId;
form.ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonDelete_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectedRow(out var findId))
{
return;
}
if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes)
{
return;
}
try
{
_routeListRepository.DeleteRouteList(findId);
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void LoadList() => dataGridViewRoute.DataSource = _routeListRepository.ReadRouteLists();
private bool TryGetIdentifierFromSelectedRow(out int id)
{
id = 0;
if (dataGridViewRoute.SelectedRows.Count < 1)
{
MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
id = Convert.ToInt32(dataGridViewRoute.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

@ -28,18 +28,63 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
panel1 = new Panel();
buttonAdd = new Button();
dataGridViewData = new DataGridView();
panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit();
SuspendLayout(); SuspendLayout();
// //
// panel1
//
panel1.Controls.Add(buttonAdd);
panel1.Dock = DockStyle.Right;
panel1.Location = new Point(658, 0);
panel1.Name = "panel1";
panel1.Size = new Size(142, 450);
panel1.TabIndex = 0;
//
// buttonAdd
//
buttonAdd.BackgroundImage = Properties.Resources.Fairytale_button_add_svg;
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
buttonAdd.Location = new Point(32, 46);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(75, 67);
buttonAdd.TabIndex = 2;
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += ButtonAdd_Click;
//
// dataGridViewData
//
dataGridViewData.AllowUserToAddRows = false;
dataGridViewData.AllowUserToDeleteRows = false;
dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridViewData.Dock = DockStyle.Fill;
dataGridViewData.Location = new Point(0, 0);
dataGridViewData.Name = "dataGridViewData";
dataGridViewData.ReadOnly = true;
dataGridViewData.Size = new Size(658, 450);
dataGridViewData.TabIndex = 1;
//
// FormStartingShifts // FormStartingShifts
// //
AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450); ClientSize = new Size(800, 450);
Controls.Add(dataGridViewData);
Controls.Add(panel1);
Name = "FormStartingShifts"; Name = "FormStartingShifts";
Text = "Начало смен"; Text = "Начало смен";
panel1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
ResumeLayout(false); ResumeLayout(false);
} }
#endregion #endregion
private Panel panel1;
private DataGridView dataGridViewData;
private Button buttonAdd;
} }
} }

View File

@ -1,4 +1,6 @@
using System; using ProjectPeopleTransportation.Repositories;
using ProjectPeopleTransportation.Repositories.Implementations;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Data; using System.Data;
@ -7,14 +9,47 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using Unity;
namespace ProjectPeopleTransportation.Forms namespace ProjectPeopleTransportation.Forms
{ {
public partial class FormStartingShifts : Form public partial class FormStartingShifts : Form
{ {
public FormStartingShifts() private readonly IUnityContainer _container;
private readonly IStartingShiftRepository _startingShiftRepository;
public FormStartingShifts(IUnityContainer container, IStartingShiftRepository startingShiftRepository)
{ {
InitializeComponent(); InitializeComponent();
_container = container ?? throw new ArgumentNullException(nameof(container));
_startingShiftRepository = startingShiftRepository ?? throw new ArgumentNullException(nameof(startingShiftRepository));
}
private void FormStartingShifts_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<FormStartingShift>().ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void LoadList() => dataGridViewData.DataSource = _startingShiftRepository.ReadStartingShifts();
}
} }