все исправлено

This commit is contained in:
cyxaruk 2024-11-15 12:59:52 +04:00
parent 71aa88ad1d
commit 14f19dba3b
24 changed files with 227 additions and 229 deletions

View File

@ -1,4 +1,5 @@
using System; using ProjectPeopleTransportation.Entities.Enums;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@ -11,15 +12,18 @@ public class Bus
public int ID { get; private set; } public int ID { get; private set; }
public string BusName { get; private set; } = string.Empty; public string BusName { get; private set; } = string.Empty;
public BusElementType BusElementType { get; private set; }
public string LicensePlate { get; private set; } = string.Empty; public string LicensePlate { get; private set; } = string.Empty;
public static Bus CreateEntity(int id, string busName, string licensePlate) public static Bus CreateEntity(int id, string busName, string licensePlate, BusElementType busElementType)
{ {
return new Bus return new Bus
{ {
ID = id, ID = id,
BusName = busName, BusName = busName,
BusElementType = busElementType,
LicensePlate = licensePlate LicensePlate = licensePlate
}; };
} }

View File

@ -0,0 +1,21 @@
namespace ProjectPeopleTransportation.Entities;
public class BusBusCheck
{
public int ID { get; private set; }
public int BusID { get; private set; }
public int Count { get; private set; }
public static BusBusCheck CreateElement(int id, int busID, int count)
{
return new BusBusCheck
{
ID = id,
BusID = busID,
Count = count
};
}
}

View File

@ -1,6 +1,6 @@
namespace ProjectPeopleTransportation.Entities; namespace ProjectPeopleTransportation.Entities;
public class RouteGiveaway public class BusCheck
{ {
public int ID { get; private set; } public int ID { get; private set; }
@ -8,16 +8,16 @@ public class RouteGiveaway
public DateTime DateReceipt { get; private set; } public DateTime DateReceipt { get; private set; }
public IEnumerable<RouteRouteGiveaway> RouteRouteGiveaway { get; private set; } = []; public IEnumerable<BusBusCheck> BusBusCheck { get; private set; } = [];
public static RouteGiveaway CreateOperation(int id, int employeeID, IEnumerable<RouteRouteGiveaway> routeRouteGiveaway) public static BusCheck CreateOperation(int id, int employeeID, IEnumerable<BusBusCheck> busBusCheck)
{ {
return new RouteGiveaway return new BusCheck
{ {
ID = id, ID = id,
EmployeeID = employeeID, EmployeeID = employeeID,
DateReceipt = DateTime.Now, DateReceipt = DateTime.Now,
RouteRouteGiveaway = routeRouteGiveaway BusBusCheck = busBusCheck
}; };
} }

View File

@ -7,15 +7,15 @@ using System.Threading.Tasks;
namespace ProjectPeopleTransportation.Entities.Enums; namespace ProjectPeopleTransportation.Entities.Enums;
[Flags] [Flags]
public enum RouteListType public enum BusElementType
{ {
None = 0, None = 0,
RouteNum1 = 1, Wheels = 1,
RouteNum2 = 2, Headlights = 2,
RouteNum3 = 4, Cabin = 4,
RouteNum4 = 8 Windows = 8
} }

View File

@ -13,18 +13,15 @@ public class RouteList
{ {
public int ID { get; private set; } public int ID { get; private set; }
public RouteListType RouteListType { get; private set; }
public string Name { get; private set; } = string.Empty; public string Name { get; private set; } = string.Empty;
public string Description { get; private set; } = string.Empty; public string Description { get; private set; } = string.Empty;
public static RouteList CreateEntity(int id, string name, string description, RouteListType routeListType) public static RouteList CreateEntity(int id, string name, string description)
{ {
return new RouteList return new RouteList
{ {
ID = id, ID = id,
RouteListType = routeListType,
Name = name ?? string.Empty, Name = name ?? string.Empty,
Description = description ?? string.Empty Description = description ?? string.Empty
}; };

View File

@ -1,21 +0,0 @@
namespace ProjectPeopleTransportation.Entities;
public class RouteRouteGiveaway
{
public int ID { get; private set; }
public int RouteID { get; private set; }
public int Count { get; private set; }
public static RouteRouteGiveaway CreateElement(int id, int routeID, int count)
{
return new RouteRouteGiveaway
{
ID = id,
RouteID = routeID,
Count = count
};
}
}

View File

@ -87,14 +87,14 @@
// раздачаМаршрутовToolStripMenuItem // раздачаМаршрутовToolStripMenuItem
// //
раздачаМаршрутовToolStripMenuItem.Name = "раздачаМаршрутовToolStripMenuItem"; раздачаМаршрутовToolStripMenuItem.Name = "раздачаМаршрутовToolStripMenuItem";
раздачаМаршрутовToolStripMenuItem.Size = new Size(184, 22); раздачаМаршрутовToolStripMenuItem.Size = new Size(226, 22);
раздачаМаршрутовToolStripMenuItem.Text = "Раздача маршрутов"; раздачаМаршрутовToolStripMenuItem.Text = "Проверка деталей автобуса";
раздачаМаршрутовToolStripMenuItem.Click += RouteGiveawayToolStripMenuItem_Click; раздачаМаршрутовToolStripMenuItem.Click += BusCheckToolStripMenuItem_Click;
// //
// началоСменыToolStripMenuItem // началоСменыToolStripMenuItem
// //
началоСменыToolStripMenuItem.Name = ачалоСменыToolStripMenuItem"; началоСменыToolStripMenuItem.Name = ачалоСменыToolStripMenuItem";
началоСменыToolStripMenuItem.Size = new Size(184, 22); началоСменыToolStripMenuItem.Size = new Size(226, 22);
началоСменыToolStripMenuItem.Text = "Начало смены"; началоСменыToolStripMenuItem.Text = "Начало смены";
началоСменыToolStripMenuItem.Click += StartingShiftToolStripMenuItem_Click; началоСменыToolStripMenuItem.Click += StartingShiftToolStripMenuItem_Click;
// //

View File

@ -49,11 +49,11 @@ namespace ProjectPeopleTransportation
} }
} }
private void RouteGiveawayToolStripMenuItem_Click(object sender, EventArgs e) private void BusCheckToolStripMenuItem_Click(object sender, EventArgs e)
{ {
try try
{ {
_container.Resolve<FormRouteGiveaways>().ShowDialog(); _container.Resolve<FormBusChecks>().ShowDialog();
} }
catch (Exception ex) catch (Exception ex)
{ {

View File

@ -34,12 +34,14 @@
buttonSave = new Button(); buttonSave = new Button();
buttonCancel = new Button(); buttonCancel = new Button();
textBoxBusName = new TextBox(); textBoxBusName = new TextBox();
checkedListBoxBusElementType = new CheckedListBox();
labelBusElement = new Label();
SuspendLayout(); SuspendLayout();
// //
// labelLicensePlate // labelLicensePlate
// //
labelLicensePlate.AutoSize = true; labelLicensePlate.AutoSize = true;
labelLicensePlate.Location = new Point(37, 42); labelLicensePlate.Location = new Point(21, 165);
labelLicensePlate.Name = "labelLicensePlate"; labelLicensePlate.Name = "labelLicensePlate";
labelLicensePlate.Size = new Size(62, 15); labelLicensePlate.Size = new Size(62, 15);
labelLicensePlate.TabIndex = 0; labelLicensePlate.TabIndex = 0;
@ -47,7 +49,7 @@
// //
// textBoxLicensePlate // textBoxLicensePlate
// //
textBoxLicensePlate.Location = new Point(129, 39); textBoxLicensePlate.Location = new Point(129, 162);
textBoxLicensePlate.Name = "textBoxLicensePlate"; textBoxLicensePlate.Name = "textBoxLicensePlate";
textBoxLicensePlate.Size = new Size(100, 23); textBoxLicensePlate.Size = new Size(100, 23);
textBoxLicensePlate.TabIndex = 1; textBoxLicensePlate.TabIndex = 1;
@ -55,7 +57,7 @@
// labelBusName // labelBusName
// //
labelBusName.AutoSize = true; labelBusName.AutoSize = true;
labelBusName.Location = new Point(12, 116); labelBusName.Location = new Point(8, 211);
labelBusName.Name = "labelBusName"; labelBusName.Name = "labelBusName";
labelBusName.Size = new Size(104, 15); labelBusName.Size = new Size(104, 15);
labelBusName.TabIndex = 2; labelBusName.TabIndex = 2;
@ -63,7 +65,7 @@
// //
// buttonSave // buttonSave
// //
buttonSave.Location = new Point(37, 206); buttonSave.Location = new Point(37, 299);
buttonSave.Name = "buttonSave"; buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(75, 23); buttonSave.Size = new Size(75, 23);
buttonSave.TabIndex = 6; buttonSave.TabIndex = 6;
@ -73,7 +75,7 @@
// //
// buttonCancel // buttonCancel
// //
buttonCancel.Location = new Point(222, 206); buttonCancel.Location = new Point(189, 299);
buttonCancel.Name = "buttonCancel"; buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(75, 23); buttonCancel.Size = new Size(75, 23);
buttonCancel.TabIndex = 7; buttonCancel.TabIndex = 7;
@ -83,16 +85,35 @@
// //
// textBoxBusName // textBoxBusName
// //
textBoxBusName.Location = new Point(129, 113); textBoxBusName.Location = new Point(129, 208);
textBoxBusName.Name = "textBoxBusName"; textBoxBusName.Name = "textBoxBusName";
textBoxBusName.Size = new Size(100, 23); textBoxBusName.Size = new Size(100, 23);
textBoxBusName.TabIndex = 8; textBoxBusName.TabIndex = 8;
// //
// checkedListBoxBusElementType
//
checkedListBoxBusElementType.FormattingEnabled = true;
checkedListBoxBusElementType.Location = new Point(129, 30);
checkedListBoxBusElementType.Name = "checkedListBoxBusElementType";
checkedListBoxBusElementType.Size = new Size(186, 94);
checkedListBoxBusElementType.TabIndex = 9;
//
// labelBusElement
//
labelBusElement.AutoSize = true;
labelBusElement.Location = new Point(21, 39);
labelBusElement.Name = "labelBusElement";
labelBusElement.Size = new Size(97, 15);
labelBusElement.TabIndex = 10;
labelBusElement.Text = "Деталь автобуса";
//
// FormBus // FormBus
// //
AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(326, 279); ClientSize = new Size(326, 363);
Controls.Add(labelBusElement);
Controls.Add(checkedListBoxBusElementType);
Controls.Add(textBoxBusName); Controls.Add(textBoxBusName);
Controls.Add(buttonCancel); Controls.Add(buttonCancel);
Controls.Add(buttonSave); Controls.Add(buttonSave);
@ -114,5 +135,7 @@
private Button buttonSave; private Button buttonSave;
private Button buttonCancel; private Button buttonCancel;
private TextBox textBoxBusName; private TextBox textBoxBusName;
private CheckedListBox checkedListBoxBusElementType;
private Label labelBusElement;
} }
} }

View File

@ -2,6 +2,7 @@
using ProjectPeopleTransportation.Entities; using ProjectPeopleTransportation.Entities;
using ProjectPeopleTransportation.Entities.Enums; using ProjectPeopleTransportation.Entities.Enums;
using System.Runtime.InteropServices.JavaScript; using System.Runtime.InteropServices.JavaScript;
using System.Windows.Forms;
namespace ProjectPeopleTransportation.Forms; namespace ProjectPeopleTransportation.Forms;
@ -23,6 +24,14 @@ public partial class FormBus : Form
throw new InvalidDataException(nameof(bus)); throw new InvalidDataException(nameof(bus));
} }
foreach (BusElementType elem in Enum.GetValues(typeof(BusElementType)))
{
if ((elem & bus.BusElementType) != 0)
{
checkedListBoxBusElementType.SetItemChecked(checkedListBoxBusElementType.Items.IndexOf(elem), true);
}
}
textBoxLicensePlate.Text = bus.LicensePlate; textBoxLicensePlate.Text = bus.LicensePlate;
textBoxBusName.Text = bus.BusName; textBoxBusName.Text = bus.BusName;
_busId = value; _busId = value;
@ -38,13 +47,19 @@ public partial class FormBus : Form
{ {
InitializeComponent(); InitializeComponent();
_busRepository = busRepository ?? throw new ArgumentNullException(nameof(busRepository)); _busRepository = busRepository ?? throw new ArgumentNullException(nameof(busRepository));
foreach (var elem in Enum.GetValues(typeof(BusElementType)))
{
checkedListBoxBusElementType.Items.Add(elem);
}
} }
private void ButtonSave_Click(object sender, EventArgs e) private void ButtonSave_Click(object sender, EventArgs e)
{ {
try try
{ {
if (string.IsNullOrWhiteSpace(textBoxLicensePlate.Text) || string.IsNullOrWhiteSpace(textBoxBusName.Text)) if (string.IsNullOrWhiteSpace(textBoxLicensePlate.Text) ||
string.IsNullOrWhiteSpace(textBoxBusName.Text) ||
checkedListBoxBusElementType.CheckedItems.Count == 0)
{ {
throw new Exception("Имеются незаполненные поля"); throw new Exception("Имеются незаполненные поля");
} }
@ -67,6 +82,17 @@ public partial class FormBus : Form
} }
private void ButtonCancel_Click(object sender, EventArgs e) => Close(); private void ButtonCancel_Click(object sender, EventArgs e) => Close();
private Bus CreateBus(int id) => Bus.CreateEntity(id, textBoxBusName.Text, textBoxLicensePlate.Text);
private Bus CreateBus(int id)
{
BusElementType busElementType = BusElementType.None;
foreach (var elem in checkedListBoxBusElementType.CheckedItems)
{
busElementType |= (BusElementType)elem;
}
return Bus.CreateEntity(id, textBoxBusName.Text, textBoxLicensePlate.Text, busElementType);
}
} }

View File

@ -1,6 +1,6 @@
namespace ProjectPeopleTransportation.Forms namespace ProjectPeopleTransportation.Forms
{ {
partial class FormRouteGiveaway partial class FormBusCheck
{ {
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.
@ -30,14 +30,14 @@
{ {
comboBoxEmployee = new ComboBox(); comboBoxEmployee = new ComboBox();
labelEmployee = new Label(); labelEmployee = new Label();
groupBoxRoutes = new GroupBox(); groupBoxDetail = new GroupBox();
dataGridViewRoutes = new DataGridView(); dataGridViewDetails = new DataGridView();
ColumnRouteName = new DataGridViewComboBoxColumn();
ColumnRouteNum = new DataGridViewTextBoxColumn();
buttonSave = new Button(); buttonSave = new Button();
buttonCancel = new Button(); buttonCancel = new Button();
groupBoxRoutes.SuspendLayout(); ColumnDetail = new DataGridViewComboBoxColumn();
((System.ComponentModel.ISupportInitialize)dataGridViewRoutes).BeginInit(); ColumnDetailCount = new DataGridViewTextBoxColumn();
groupBoxDetail.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridViewDetails).BeginInit();
SuspendLayout(); SuspendLayout();
// //
// comboBoxEmployee // comboBoxEmployee
@ -58,40 +58,30 @@
labelEmployee.TabIndex = 6; labelEmployee.TabIndex = 6;
labelEmployee.Text = "Работник"; labelEmployee.Text = "Работник";
// //
// groupBoxRoutes // groupBoxDetail
// //
groupBoxRoutes.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; groupBoxDetail.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
groupBoxRoutes.Controls.Add(dataGridViewRoutes); groupBoxDetail.Controls.Add(dataGridViewDetails);
groupBoxRoutes.Location = new Point(42, 110); groupBoxDetail.Location = new Point(42, 110);
groupBoxRoutes.Name = "groupBoxRoutes"; groupBoxDetail.Name = "groupBoxDetail";
groupBoxRoutes.Size = new Size(243, 254); groupBoxDetail.Size = new Size(243, 254);
groupBoxRoutes.TabIndex = 8; groupBoxDetail.TabIndex = 8;
groupBoxRoutes.TabStop = false; groupBoxDetail.TabStop = false;
groupBoxRoutes.Text = "Маршруты"; groupBoxDetail.Text = "Детали";
// //
// dataGridViewRoutes // dataGridViewDetails
// //
dataGridViewRoutes.AllowUserToResizeColumns = false; dataGridViewDetails.AllowUserToResizeColumns = false;
dataGridViewRoutes.AllowUserToResizeRows = false; dataGridViewDetails.AllowUserToResizeRows = false;
dataGridViewRoutes.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; dataGridViewDetails.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridViewRoutes.Columns.AddRange(new DataGridViewColumn[] { ColumnRouteName, ColumnRouteNum }); dataGridViewDetails.Columns.AddRange(new DataGridViewColumn[] { ColumnDetail, ColumnDetailCount });
dataGridViewRoutes.Dock = DockStyle.Fill; dataGridViewDetails.Dock = DockStyle.Fill;
dataGridViewRoutes.Location = new Point(3, 19); dataGridViewDetails.Location = new Point(3, 19);
dataGridViewRoutes.MultiSelect = false; dataGridViewDetails.MultiSelect = false;
dataGridViewRoutes.Name = "dataGridViewRoutes"; dataGridViewDetails.Name = "dataGridViewDetails";
dataGridViewRoutes.RowHeadersVisible = false; dataGridViewDetails.RowHeadersVisible = false;
dataGridViewRoutes.Size = new Size(237, 232); dataGridViewDetails.Size = new Size(237, 232);
dataGridViewRoutes.TabIndex = 9; dataGridViewDetails.TabIndex = 9;
//
// ColumnRouteName
//
ColumnRouteName.HeaderText = "Название";
ColumnRouteName.Name = "ColumnRouteName";
//
// ColumnRouteNum
//
ColumnRouteNum.HeaderText = "Количество";
ColumnRouteNum.Name = "ColumnRouteNum";
// //
// buttonSave // buttonSave
// //
@ -115,20 +105,30 @@
buttonCancel.UseVisualStyleBackColor = true; buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += ButtonCancel_Click; buttonCancel.Click += ButtonCancel_Click;
// //
// FormRouteGiveaway // ColumnDetail
//
ColumnDetail.HeaderText = "Название";
ColumnDetail.Name = "ColumnDetail";
//
// ColumnDetailCount
//
ColumnDetailCount.HeaderText = "Количество";
ColumnDetailCount.Name = "ColumnDetailCount";
//
// FormBusCheck
// //
AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(343, 409); ClientSize = new Size(343, 409);
Controls.Add(buttonCancel); Controls.Add(buttonCancel);
Controls.Add(buttonSave); Controls.Add(buttonSave);
Controls.Add(groupBoxRoutes); Controls.Add(groupBoxDetail);
Controls.Add(comboBoxEmployee); Controls.Add(comboBoxEmployee);
Controls.Add(labelEmployee); Controls.Add(labelEmployee);
Name = "FormRouteGiveaway"; Name = "FormBusCheck";
Text = "Раздача маршрутов"; Text = "Проверка деталей автобуса";
groupBoxRoutes.ResumeLayout(false); groupBoxDetail.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridViewRoutes).EndInit(); ((System.ComponentModel.ISupportInitialize)dataGridViewDetails).EndInit();
ResumeLayout(false); ResumeLayout(false);
PerformLayout(); PerformLayout();
} }
@ -137,11 +137,11 @@
private ComboBox comboBoxEmployee; private ComboBox comboBoxEmployee;
private Label labelEmployee; private Label labelEmployee;
private GroupBox groupBoxRoutes; private GroupBox groupBoxDetail;
private DataGridView dataGridViewRoutes; private DataGridView dataGridViewDetails;
private Button buttonSave; private Button buttonSave;
private Button buttonCancel; private Button buttonCancel;
private DataGridViewComboBoxColumn ColumnRouteName; private DataGridViewComboBoxColumn ColumnDetail;
private DataGridViewTextBoxColumn ColumnRouteNum; private DataGridViewTextBoxColumn ColumnDetailCount;
} }
} }

View File

@ -13,39 +13,39 @@ using System.Windows.Forms;
namespace ProjectPeopleTransportation.Forms namespace ProjectPeopleTransportation.Forms
{ {
public partial class FormRouteGiveaway : Form public partial class FormBusCheck : Form
{ {
private readonly IRouteGiveawayRepository _routeGiveawayRepository; private readonly IBusCheckRepository _busCheckRepository;
public FormRouteGiveaway(IRouteGiveawayRepository routeGiveawayRepository, public FormBusCheck(IBusCheckRepository busCheckRepository,
IEmployeeRepository employeeRepository, IEmployeeRepository employeeRepository,
IRouteListRepository routeListRepository) IBusRepository busRepository)
{ {
InitializeComponent(); InitializeComponent();
_routeGiveawayRepository = routeGiveawayRepository ?? _busCheckRepository = busCheckRepository ??
throw new ArgumentNullException(nameof(routeGiveawayRepository)); throw new ArgumentNullException(nameof(busCheckRepository));
comboBoxEmployee.DataSource = employeeRepository.ReadEmployees(); comboBoxEmployee.DataSource = employeeRepository.ReadEmployees();
comboBoxEmployee.DisplayMember = "FirstName"; comboBoxEmployee.DisplayMember = "FirstName";
comboBoxEmployee.ValueMember = "Id"; comboBoxEmployee.ValueMember = "Id";
ColumnRouteName.DataSource = routeListRepository.ReadRouteLists(); ColumnDetail.DataSource = busRepository.ReadBuses();
ColumnRouteName.DisplayMember = "RoutName"; ColumnDetail.DisplayMember = "BusName";
ColumnRouteName.ValueMember = "Id"; ColumnDetail.ValueMember = "Id";
} }
private void ButtonSave_Click(object sender, EventArgs e) private void ButtonSave_Click(object sender, EventArgs e)
{ {
try try
{ {
if (dataGridViewRoutes.RowCount < 1 || if (dataGridViewDetails.RowCount < 1 ||
comboBoxEmployee.SelectedIndex < 0) comboBoxEmployee.SelectedIndex < 0)
{ {
throw new Exception("Имеются незаполненные поля"); throw new Exception("Имеются незаполненные поля");
} }
_routeGiveawayRepository.CreateRouteGiveaway(RouteGiveaway.CreateOperation(0, _busCheckRepository.CreateBusCheck(BusCheck.CreateOperation(0,
(int)comboBoxEmployee.SelectedValue!, CreateListRouteRouteGiveawayFromDataGrid())); (int)comboBoxEmployee.SelectedValue!, CreateListBusBusCheckFromDataGrid()));
Close(); Close();
} }
@ -57,16 +57,16 @@ namespace ProjectPeopleTransportation.Forms
private void ButtonCancel_Click(object sender, EventArgs e) => Close(); private void ButtonCancel_Click(object sender, EventArgs e) => Close();
private List<RouteRouteGiveaway> CreateListRouteRouteGiveawayFromDataGrid() private List<BusBusCheck> CreateListBusBusCheckFromDataGrid()
{ {
var list = new List<RouteRouteGiveaway>(); var list = new List<BusBusCheck>();
foreach (DataGridViewRow row in dataGridViewRoutes.Rows) foreach (DataGridViewRow row in dataGridViewDetails.Rows)
{ {
if (row.Cells["ColumnRoute"].Value == null || row.Cells["ColumnCount"].Value == null) if (row.Cells["ColumnDetail"].Value == null || row.Cells["ColumnCount"].Value == null)
{ {
continue; continue;
} }
list.Add(RouteRouteGiveaway.CreateElement(0, Convert.ToInt32(row.Cells["ColumnRoute"].Value), list.Add(BusBusCheck.CreateElement(0, Convert.ToInt32(row.Cells["ColumnDetail"].Value),
Convert.ToInt32(row.Cells["ColumnCount"].Value))); Convert.ToInt32(row.Cells["ColumnCount"].Value)));
} }
return list; return list;

View File

@ -117,16 +117,10 @@
<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"> <metadata name="ColumnDetail.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value> <value>True</value>
</metadata> </metadata>
<metadata name="ColumnRouteNum.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="ColumnDetailCount.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> <value>True</value>
</metadata> </metadata>
</root> </root>

View File

@ -1,6 +1,6 @@
namespace ProjectPeopleTransportation.Forms namespace ProjectPeopleTransportation.Forms
{ {
partial class FormRouteGiveaways partial class FormBusChecks
{ {
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.
@ -31,9 +31,9 @@
panel1 = new Panel(); panel1 = new Panel();
buttonDelete = new Button(); buttonDelete = new Button();
buttonAdd = new Button(); buttonAdd = new Button();
dataGridViewGiveaway = new DataGridView(); dataGridViewCheck = new DataGridView();
panel1.SuspendLayout(); panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridViewGiveaway).BeginInit(); ((System.ComponentModel.ISupportInitialize)dataGridViewCheck).BeginInit();
SuspendLayout(); SuspendLayout();
// //
// panel1 // panel1
@ -68,36 +68,36 @@
buttonAdd.UseVisualStyleBackColor = true; buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += ButtonAdd_Click; buttonAdd.Click += ButtonAdd_Click;
// //
// dataGridViewGiveaway // dataGridViewCheck
// //
dataGridViewGiveaway.AllowUserToAddRows = false; dataGridViewCheck.AllowUserToAddRows = false;
dataGridViewGiveaway.AllowUserToDeleteRows = false; dataGridViewCheck.AllowUserToDeleteRows = false;
dataGridViewGiveaway.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; dataGridViewCheck.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridViewGiveaway.Dock = DockStyle.Fill; dataGridViewCheck.Dock = DockStyle.Fill;
dataGridViewGiveaway.Location = new Point(0, 0); dataGridViewCheck.Location = new Point(0, 0);
dataGridViewGiveaway.Name = "dataGridViewGiveaway"; dataGridViewCheck.Name = "dataGridViewCheck";
dataGridViewGiveaway.ReadOnly = true; dataGridViewCheck.ReadOnly = true;
dataGridViewGiveaway.Size = new Size(651, 439); dataGridViewCheck.Size = new Size(651, 439);
dataGridViewGiveaway.TabIndex = 1; dataGridViewCheck.TabIndex = 1;
// //
// FormRouteGiveaways // FormBusChecks
// //
AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(784, 439); ClientSize = new Size(784, 439);
Controls.Add(dataGridViewGiveaway); Controls.Add(dataGridViewCheck);
Controls.Add(panel1); Controls.Add(panel1);
Name = "FormRouteGiveaways"; Name = "FormBusChecks";
Text = "Раздачи маршрутов"; Text = "Раздачи маршрутов";
panel1.ResumeLayout(false); panel1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridViewGiveaway).EndInit(); ((System.ComponentModel.ISupportInitialize)dataGridViewCheck).EndInit();
ResumeLayout(false); ResumeLayout(false);
} }
#endregion #endregion
private Panel panel1; private Panel panel1;
private DataGridView dataGridViewGiveaway; private DataGridView dataGridViewCheck;
private Button buttonAdd; private Button buttonAdd;
private Button buttonDelete; private Button buttonDelete;
} }

View File

@ -13,22 +13,22 @@ using Unity;
namespace ProjectPeopleTransportation.Forms namespace ProjectPeopleTransportation.Forms
{ {
public partial class FormRouteGiveaways : Form public partial class FormBusChecks : Form
{ {
private readonly IUnityContainer _container; private readonly IUnityContainer _container;
private readonly IRouteGiveawayRepository _routeGiveawayRepository; private readonly IBusCheckRepository _busCheckRepository;
public FormRouteGiveaways(IUnityContainer container, IRouteGiveawayRepository routeGiveawayRepository) public FormBusChecks(IUnityContainer container, IBusCheckRepository busCheckRepository)
{ {
InitializeComponent(); InitializeComponent();
_container = container ?? throw new ArgumentNullException(nameof(container)); _container = container ?? throw new ArgumentNullException(nameof(container));
_routeGiveawayRepository = routeGiveawayRepository ?? throw new ArgumentNullException(nameof(routeGiveawayRepository)); _busCheckRepository = busCheckRepository ?? throw new ArgumentNullException(nameof(busCheckRepository));
} }
private void ButtonAdd_Click(object sender, EventArgs e) private void ButtonAdd_Click(object sender, EventArgs e)
{ {
try try
{ {
_container.Resolve<FormRouteGiveaway>().ShowDialog(); _container.Resolve<FormBusCheck>().ShowDialog();
LoadList(); LoadList();
} }
catch (Exception ex) catch (Exception ex)
@ -49,7 +49,7 @@ namespace ProjectPeopleTransportation.Forms
try try
{ {
_routeGiveawayRepository.DeleteRouteGiveaway(findId); _busCheckRepository.DeleteBusCheck(findId);
LoadList(); LoadList();
} }
catch (Exception ex) catch (Exception ex)
@ -58,18 +58,18 @@ namespace ProjectPeopleTransportation.Forms
} }
} }
private void LoadList() => dataGridViewGiveaway.DataSource = _routeGiveawayRepository.ReadRouteGiveaway(); private void LoadList() => dataGridViewCheck.DataSource = _busCheckRepository.ReadBusCheck();
private bool TryGetIdentifierFromSelectedRow(out int id) private bool TryGetIdentifierFromSelectedRow(out int id)
{ {
id = 0; id = 0;
if (dataGridViewGiveaway.SelectedRows.Count < 1) if (dataGridViewCheck.SelectedRows.Count < 1)
{ {
MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false; return false;
} }
id = Convert.ToInt32(dataGridViewGiveaway.SelectedRows[0].Cells["Id"].Value); id = Convert.ToInt32(dataGridViewCheck.SelectedRows[0].Cells["Id"].Value);
return true; return true;
} }
} }

View File

@ -28,9 +28,7 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
checkedListBoxRouteListType = new CheckedListBox();
textBoxName = new TextBox(); textBoxName = new TextBox();
labelRouteListType = new Label();
labelRouteListName = new Label(); labelRouteListName = new Label();
labelRouteDescription = new Label(); labelRouteDescription = new Label();
textBoxDescription = new TextBox(); textBoxDescription = new TextBox();
@ -38,35 +36,18 @@
buttonCancel = new Button(); buttonCancel = new Button();
SuspendLayout(); SuspendLayout();
// //
// checkedListBoxRouteListType
//
checkedListBoxRouteListType.FormattingEnabled = true;
checkedListBoxRouteListType.Location = new Point(153, 12);
checkedListBoxRouteListType.Name = "checkedListBoxRouteListType";
checkedListBoxRouteListType.Size = new Size(186, 94);
checkedListBoxRouteListType.TabIndex = 0;
//
// textBoxName // textBoxName
// //
textBoxName.Location = new Point(153, 130); textBoxName.Location = new Point(153, 31);
textBoxName.Multiline = true; textBoxName.Multiline = true;
textBoxName.Name = "textBoxName"; textBoxName.Name = "textBoxName";
textBoxName.Size = new Size(186, 31); textBoxName.Size = new Size(186, 31);
textBoxName.TabIndex = 1; textBoxName.TabIndex = 1;
// //
// labelRouteListType
//
labelRouteListType.AutoSize = true;
labelRouteListType.Location = new Point(21, 34);
labelRouteListType.Name = "labelRouteListType";
labelRouteListType.Size = new Size(105, 15);
labelRouteListType.TabIndex = 2;
labelRouteListType.Text = "Номер маршрута";
//
// labelRouteListName // labelRouteListName
// //
labelRouteListName.AutoSize = true; labelRouteListName.AutoSize = true;
labelRouteListName.Location = new Point(21, 146); labelRouteListName.Location = new Point(37, 34);
labelRouteListName.Name = "labelRouteListName"; labelRouteListName.Name = "labelRouteListName";
labelRouteListName.Size = new Size(59, 15); labelRouteListName.Size = new Size(59, 15);
labelRouteListName.TabIndex = 3; labelRouteListName.TabIndex = 3;
@ -75,7 +56,7 @@
// labelRouteDescription // labelRouteDescription
// //
labelRouteDescription.AutoSize = true; labelRouteDescription.AutoSize = true;
labelRouteDescription.Location = new Point(21, 207); labelRouteDescription.Location = new Point(31, 110);
labelRouteDescription.Name = "labelRouteDescription"; labelRouteDescription.Name = "labelRouteDescription";
labelRouteDescription.Size = new Size(65, 15); labelRouteDescription.Size = new Size(65, 15);
labelRouteDescription.TabIndex = 4; labelRouteDescription.TabIndex = 4;
@ -83,7 +64,7 @@
// //
// textBoxDescription // textBoxDescription
// //
textBoxDescription.Location = new Point(153, 189); textBoxDescription.Location = new Point(153, 97);
textBoxDescription.Multiline = true; textBoxDescription.Multiline = true;
textBoxDescription.Name = "textBoxDescription"; textBoxDescription.Name = "textBoxDescription";
textBoxDescription.Size = new Size(186, 91); textBoxDescription.Size = new Size(186, 91);
@ -91,7 +72,7 @@
// //
// buttonSave // buttonSave
// //
buttonSave.Location = new Point(37, 303); buttonSave.Location = new Point(37, 232);
buttonSave.Name = "buttonSave"; buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(75, 23); buttonSave.Size = new Size(75, 23);
buttonSave.TabIndex = 6; buttonSave.TabIndex = 6;
@ -101,7 +82,7 @@
// //
// buttonCancel // buttonCancel
// //
buttonCancel.Location = new Point(190, 303); buttonCancel.Location = new Point(186, 232);
buttonCancel.Name = "buttonCancel"; buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(75, 23); buttonCancel.Size = new Size(75, 23);
buttonCancel.TabIndex = 7; buttonCancel.TabIndex = 7;
@ -113,15 +94,13 @@
// //
AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(366, 348); ClientSize = new Size(366, 283);
Controls.Add(buttonCancel); Controls.Add(buttonCancel);
Controls.Add(buttonSave); Controls.Add(buttonSave);
Controls.Add(textBoxDescription); Controls.Add(textBoxDescription);
Controls.Add(labelRouteDescription); Controls.Add(labelRouteDescription);
Controls.Add(labelRouteListName); Controls.Add(labelRouteListName);
Controls.Add(labelRouteListType);
Controls.Add(textBoxName); Controls.Add(textBoxName);
Controls.Add(checkedListBoxRouteListType);
Name = "FormRouteList"; Name = "FormRouteList";
Text = "FormRouteList"; Text = "FormRouteList";
ResumeLayout(false); ResumeLayout(false);
@ -129,10 +108,7 @@
} }
#endregion #endregion
private CheckedListBox checkedListBoxRouteListType;
private TextBox textBoxName; private TextBox textBoxName;
private Label labelRouteListType;
private Label labelRouteListName; private Label labelRouteListName;
private Label labelRouteDescription; private Label labelRouteDescription;
private TextBox textBoxDescription; private TextBox textBoxDescription;

View File

@ -22,14 +22,6 @@ namespace ProjectPeopleTransportation.Forms
throw new InvalidDataException(nameof(routeList)); throw new InvalidDataException(nameof(routeList));
} }
foreach (RouteListType elem in Enum.GetValues(typeof(RouteListType)))
{
if ((elem & routeList.RouteListType) != 0)
{
checkedListBoxRouteListType.SetItemChecked(checkedListBoxRouteListType.Items.IndexOf(elem), true);
}
}
textBoxName.Text = routeList.Name; textBoxName.Text = routeList.Name;
textBoxDescription.Text = routeList.Description; textBoxDescription.Text = routeList.Description;
@ -47,10 +39,6 @@ namespace ProjectPeopleTransportation.Forms
{ {
InitializeComponent(); InitializeComponent();
_routeListRepository = routeListRepository ?? throw new ArgumentNullException(nameof(routeListRepository)); _routeListRepository = routeListRepository ?? throw new ArgumentNullException(nameof(routeListRepository));
foreach (var elem in Enum.GetValues(typeof(RouteListType)))
{
checkedListBoxRouteListType.Items.Add(elem);
}
} }
private void ButtonSave_Click(object sender, EventArgs e) private void ButtonSave_Click(object sender, EventArgs e)
@ -58,8 +46,7 @@ namespace ProjectPeopleTransportation.Forms
try try
{ {
if (string.IsNullOrWhiteSpace(textBoxName.Text) || if (string.IsNullOrWhiteSpace(textBoxName.Text) ||
string.IsNullOrWhiteSpace(textBoxDescription.Text) || string.IsNullOrWhiteSpace(textBoxDescription.Text))
checkedListBoxRouteListType.CheckedItems.Count == 0)
{ {
throw new Exception("Имеются незаполненные поля"); throw new Exception("Имеются незаполненные поля");
} }
@ -83,16 +70,6 @@ namespace ProjectPeopleTransportation.Forms
private void ButtonCancel_Click(object sender, EventArgs e) => Close(); private void ButtonCancel_Click(object sender, EventArgs e) => Close();
private RouteList CreateRouteList(int id) private RouteList CreateRouteList(int id) => RouteList.CreateEntity(id, textBoxName.Text, textBoxDescription.Text);
{
RouteListType routeListType = RouteListType.None;
foreach (var elem in checkedListBoxRouteListType.CheckedItems)
{
routeListType |= (RouteListType)elem;
}
return RouteList.CreateEntity(id, textBoxName.Text, textBoxDescription.Text, routeListType);
}
} }
} }

View File

@ -24,7 +24,7 @@ namespace ProjectPeopleTransportation
container.RegisterType<IBusRepository, BusRepository>(); container.RegisterType<IBusRepository, BusRepository>();
container.RegisterType<IEmployeeRepository, EmployeeRepository>(); container.RegisterType<IEmployeeRepository, EmployeeRepository>();
container.RegisterType<IRouteGiveawayRepository, RouteGiveawayRepository>(); container.RegisterType<IBusCheckRepository, BusCheckRepository>();
container.RegisterType<IRouteListRepository, RouteListRepository>(); container.RegisterType<IRouteListRepository, RouteListRepository>();
container.RegisterType<IStartingShiftRepository, StartingShiftRepository>(); container.RegisterType<IStartingShiftRepository, StartingShiftRepository>();

View File

@ -0,0 +1,13 @@
using ProjectPeopleTransportation.Entities;
namespace ProjectPeopleTransportation.Repositories;
public interface IBusCheckRepository
{
IEnumerable<BusCheck> ReadBusCheck(DateTime? dateForm = null, DateTime? dateTo = null,
int? employeeId = null, int? routelistId = null);
void CreateBusCheck(BusCheck busCheck);
void DeleteBusCheck(int id);
}

View File

@ -1,13 +0,0 @@
using ProjectPeopleTransportation.Entities;
namespace ProjectPeopleTransportation.Repositories;
public interface IRouteGiveawayRepository
{
IEnumerable<RouteGiveaway> ReadRouteGiveaway(DateTime? dateForm = null, DateTime? dateTo = null,
int? employeeId = null, int? busId = null);
void CreateRouteGiveaway(RouteGiveaway routeGiveaway);
void DeleteRouteGiveaway(int id);
}

View File

@ -1,4 +1,5 @@
using ProjectPeopleTransportation.Entities; using ProjectPeopleTransportation.Entities;
using ProjectPeopleTransportation.Entities.Enums;
namespace ProjectPeopleTransportation.Repositories.Implementations; namespace ProjectPeopleTransportation.Repositories.Implementations;
@ -14,7 +15,7 @@ public class BusRepository : IBusRepository
public Bus ReadBusByID(int id) public Bus ReadBusByID(int id)
{ {
return Bus.CreateEntity(0, string.Empty, string.Empty); return Bus.CreateEntity(0, string.Empty, string.Empty, BusElementType.None);
} }
public IEnumerable<Bus> ReadBuses() public IEnumerable<Bus> ReadBuses()

View File

@ -2,17 +2,17 @@
namespace ProjectPeopleTransportation.Repositories.Implementations; namespace ProjectPeopleTransportation.Repositories.Implementations;
public class RouteGiveawayRepository : IRouteGiveawayRepository public class BusCheckRepository : IBusCheckRepository
{ {
public void CreateRouteGiveaway(RouteGiveaway routeGiveaway) public void CreateBusCheck(BusCheck busCheck)
{ {
} }
public void DeleteRouteGiveaway(int id) public void DeleteBusCheck(int id)
{ {
} }
public IEnumerable<RouteGiveaway> ReadRouteGiveaway(DateTime? dateForm = null, DateTime? dateTo = null, int? employeeId = null, int? busId = null) public IEnumerable<BusCheck> ReadBusCheck(DateTime? dateForm = null, DateTime? dateTo = null, int? employeeId = null, int? routelistId = null)
{ {
return []; return [];
} }

View File

@ -15,7 +15,7 @@ public class RouteListRepository : IRouteListRepository
public RouteList ReadRouteListByID(int id) public RouteList ReadRouteListByID(int id)
{ {
return RouteList.CreateEntity(0, string.Empty, string.Empty, RouteListType.None); return RouteList.CreateEntity(0, string.Empty, string.Empty);
} }
public IEnumerable<RouteList> ReadRouteLists() public IEnumerable<RouteList> ReadRouteLists()