все исправлено
This commit is contained in:
parent
71aa88ad1d
commit
14f19dba3b
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using ProjectPeopleTransportation.Entities.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@ -11,15 +12,18 @@ public class Bus
|
||||
public int ID { get; private set; }
|
||||
|
||||
public string BusName { get; private set; } = string.Empty;
|
||||
|
||||
|
||||
public BusElementType BusElementType { get; private set; }
|
||||
|
||||
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
|
||||
{
|
||||
ID = id,
|
||||
BusName = busName,
|
||||
BusElementType = busElementType,
|
||||
LicensePlate = licensePlate
|
||||
};
|
||||
}
|
||||
|
@ -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
|
||||
};
|
||||
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
namespace ProjectPeopleTransportation.Entities;
|
||||
|
||||
public class RouteGiveaway
|
||||
public class BusCheck
|
||||
{
|
||||
public int ID { get; private set; }
|
||||
|
||||
@ -8,16 +8,16 @@ public class RouteGiveaway
|
||||
|
||||
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,
|
||||
EmployeeID = employeeID,
|
||||
DateReceipt = DateTime.Now,
|
||||
RouteRouteGiveaway = routeRouteGiveaway
|
||||
BusBusCheck = busBusCheck
|
||||
};
|
||||
|
||||
}
|
@ -7,15 +7,15 @@ using System.Threading.Tasks;
|
||||
namespace ProjectPeopleTransportation.Entities.Enums;
|
||||
|
||||
[Flags]
|
||||
public enum RouteListType
|
||||
public enum BusElementType
|
||||
{
|
||||
None = 0,
|
||||
|
||||
RouteNum1 = 1,
|
||||
Wheels = 1,
|
||||
|
||||
RouteNum2 = 2,
|
||||
Headlights = 2,
|
||||
|
||||
RouteNum3 = 4,
|
||||
Cabin = 4,
|
||||
|
||||
RouteNum4 = 8
|
||||
Windows = 8
|
||||
}
|
@ -13,18 +13,15 @@ public class RouteList
|
||||
{
|
||||
public int ID { get; private set; }
|
||||
|
||||
public RouteListType RouteListType { get; private set; }
|
||||
|
||||
public string Name { 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
|
||||
{
|
||||
ID = id,
|
||||
RouteListType = routeListType,
|
||||
Name = name ?? string.Empty,
|
||||
Description = description ?? string.Empty
|
||||
};
|
||||
|
@ -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
|
||||
};
|
||||
|
||||
}
|
||||
}
|
@ -87,14 +87,14 @@
|
||||
// раздачаМаршрутовToolStripMenuItem
|
||||
//
|
||||
раздачаМаршрутовToolStripMenuItem.Name = "раздачаМаршрутовToolStripMenuItem";
|
||||
раздачаМаршрутовToolStripMenuItem.Size = new Size(184, 22);
|
||||
раздачаМаршрутовToolStripMenuItem.Text = "Раздача маршрутов";
|
||||
раздачаМаршрутовToolStripMenuItem.Click += RouteGiveawayToolStripMenuItem_Click;
|
||||
раздачаМаршрутовToolStripMenuItem.Size = new Size(226, 22);
|
||||
раздачаМаршрутовToolStripMenuItem.Text = "Проверка деталей автобуса";
|
||||
раздачаМаршрутовToolStripMenuItem.Click += BusCheckToolStripMenuItem_Click;
|
||||
//
|
||||
// началоСменыToolStripMenuItem
|
||||
//
|
||||
началоСменыToolStripMenuItem.Name = "началоСменыToolStripMenuItem";
|
||||
началоСменыToolStripMenuItem.Size = new Size(184, 22);
|
||||
началоСменыToolStripMenuItem.Size = new Size(226, 22);
|
||||
началоСменыToolStripMenuItem.Text = "Начало смены";
|
||||
началоСменыToolStripMenuItem.Click += StartingShiftToolStripMenuItem_Click;
|
||||
//
|
||||
|
@ -49,11 +49,11 @@ namespace ProjectPeopleTransportation
|
||||
}
|
||||
}
|
||||
|
||||
private void RouteGiveawayToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
private void BusCheckToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_container.Resolve<FormRouteGiveaways>().ShowDialog();
|
||||
_container.Resolve<FormBusChecks>().ShowDialog();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -34,12 +34,14 @@
|
||||
buttonSave = new Button();
|
||||
buttonCancel = new Button();
|
||||
textBoxBusName = new TextBox();
|
||||
checkedListBoxBusElementType = new CheckedListBox();
|
||||
labelBusElement = new Label();
|
||||
SuspendLayout();
|
||||
//
|
||||
// labelLicensePlate
|
||||
//
|
||||
labelLicensePlate.AutoSize = true;
|
||||
labelLicensePlate.Location = new Point(37, 42);
|
||||
labelLicensePlate.Location = new Point(21, 165);
|
||||
labelLicensePlate.Name = "labelLicensePlate";
|
||||
labelLicensePlate.Size = new Size(62, 15);
|
||||
labelLicensePlate.TabIndex = 0;
|
||||
@ -47,7 +49,7 @@
|
||||
//
|
||||
// textBoxLicensePlate
|
||||
//
|
||||
textBoxLicensePlate.Location = new Point(129, 39);
|
||||
textBoxLicensePlate.Location = new Point(129, 162);
|
||||
textBoxLicensePlate.Name = "textBoxLicensePlate";
|
||||
textBoxLicensePlate.Size = new Size(100, 23);
|
||||
textBoxLicensePlate.TabIndex = 1;
|
||||
@ -55,7 +57,7 @@
|
||||
// labelBusName
|
||||
//
|
||||
labelBusName.AutoSize = true;
|
||||
labelBusName.Location = new Point(12, 116);
|
||||
labelBusName.Location = new Point(8, 211);
|
||||
labelBusName.Name = "labelBusName";
|
||||
labelBusName.Size = new Size(104, 15);
|
||||
labelBusName.TabIndex = 2;
|
||||
@ -63,7 +65,7 @@
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.Location = new Point(37, 206);
|
||||
buttonSave.Location = new Point(37, 299);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(75, 23);
|
||||
buttonSave.TabIndex = 6;
|
||||
@ -73,7 +75,7 @@
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(222, 206);
|
||||
buttonCancel.Location = new Point(189, 299);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(75, 23);
|
||||
buttonCancel.TabIndex = 7;
|
||||
@ -83,16 +85,35 @@
|
||||
//
|
||||
// textBoxBusName
|
||||
//
|
||||
textBoxBusName.Location = new Point(129, 113);
|
||||
textBoxBusName.Location = new Point(129, 208);
|
||||
textBoxBusName.Name = "textBoxBusName";
|
||||
textBoxBusName.Size = new Size(100, 23);
|
||||
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
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(326, 279);
|
||||
ClientSize = new Size(326, 363);
|
||||
Controls.Add(labelBusElement);
|
||||
Controls.Add(checkedListBoxBusElementType);
|
||||
Controls.Add(textBoxBusName);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonSave);
|
||||
@ -114,5 +135,7 @@
|
||||
private Button buttonSave;
|
||||
private Button buttonCancel;
|
||||
private TextBox textBoxBusName;
|
||||
private CheckedListBox checkedListBoxBusElementType;
|
||||
private Label labelBusElement;
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@
|
||||
using ProjectPeopleTransportation.Entities;
|
||||
using ProjectPeopleTransportation.Entities.Enums;
|
||||
using System.Runtime.InteropServices.JavaScript;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace ProjectPeopleTransportation.Forms;
|
||||
|
||||
@ -23,6 +24,14 @@ public partial class FormBus : Form
|
||||
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;
|
||||
textBoxBusName.Text = bus.BusName;
|
||||
_busId = value;
|
||||
@ -38,13 +47,19 @@ public partial class FormBus : Form
|
||||
{
|
||||
InitializeComponent();
|
||||
_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)
|
||||
{
|
||||
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("Имеются незаполненные поля");
|
||||
}
|
||||
@ -67,6 +82,17 @@ public partial class FormBus : Form
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
namespace ProjectPeopleTransportation.Forms
|
||||
{
|
||||
partial class FormRouteGiveaway
|
||||
partial class FormBusCheck
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
@ -30,14 +30,14 @@
|
||||
{
|
||||
comboBoxEmployee = new ComboBox();
|
||||
labelEmployee = new Label();
|
||||
groupBoxRoutes = new GroupBox();
|
||||
dataGridViewRoutes = new DataGridView();
|
||||
ColumnRouteName = new DataGridViewComboBoxColumn();
|
||||
ColumnRouteNum = new DataGridViewTextBoxColumn();
|
||||
groupBoxDetail = new GroupBox();
|
||||
dataGridViewDetails = new DataGridView();
|
||||
buttonSave = new Button();
|
||||
buttonCancel = new Button();
|
||||
groupBoxRoutes.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridViewRoutes).BeginInit();
|
||||
ColumnDetail = new DataGridViewComboBoxColumn();
|
||||
ColumnDetailCount = new DataGridViewTextBoxColumn();
|
||||
groupBoxDetail.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridViewDetails).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// comboBoxEmployee
|
||||
@ -58,40 +58,30 @@
|
||||
labelEmployee.TabIndex = 6;
|
||||
labelEmployee.Text = "Работник";
|
||||
//
|
||||
// groupBoxRoutes
|
||||
// groupBoxDetail
|
||||
//
|
||||
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 = "Маршруты";
|
||||
groupBoxDetail.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||
groupBoxDetail.Controls.Add(dataGridViewDetails);
|
||||
groupBoxDetail.Location = new Point(42, 110);
|
||||
groupBoxDetail.Name = "groupBoxDetail";
|
||||
groupBoxDetail.Size = new Size(243, 254);
|
||||
groupBoxDetail.TabIndex = 8;
|
||||
groupBoxDetail.TabStop = false;
|
||||
groupBoxDetail.Text = "Детали";
|
||||
//
|
||||
// dataGridViewRoutes
|
||||
// dataGridViewDetails
|
||||
//
|
||||
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";
|
||||
dataGridViewDetails.AllowUserToResizeColumns = false;
|
||||
dataGridViewDetails.AllowUserToResizeRows = false;
|
||||
dataGridViewDetails.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridViewDetails.Columns.AddRange(new DataGridViewColumn[] { ColumnDetail, ColumnDetailCount });
|
||||
dataGridViewDetails.Dock = DockStyle.Fill;
|
||||
dataGridViewDetails.Location = new Point(3, 19);
|
||||
dataGridViewDetails.MultiSelect = false;
|
||||
dataGridViewDetails.Name = "dataGridViewDetails";
|
||||
dataGridViewDetails.RowHeadersVisible = false;
|
||||
dataGridViewDetails.Size = new Size(237, 232);
|
||||
dataGridViewDetails.TabIndex = 9;
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
@ -115,20 +105,30 @@
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
buttonCancel.Click += ButtonCancel_Click;
|
||||
//
|
||||
// FormRouteGiveaway
|
||||
// ColumnDetail
|
||||
//
|
||||
ColumnDetail.HeaderText = "Название";
|
||||
ColumnDetail.Name = "ColumnDetail";
|
||||
//
|
||||
// ColumnDetailCount
|
||||
//
|
||||
ColumnDetailCount.HeaderText = "Количество";
|
||||
ColumnDetailCount.Name = "ColumnDetailCount";
|
||||
//
|
||||
// FormBusCheck
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(343, 409);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonSave);
|
||||
Controls.Add(groupBoxRoutes);
|
||||
Controls.Add(groupBoxDetail);
|
||||
Controls.Add(comboBoxEmployee);
|
||||
Controls.Add(labelEmployee);
|
||||
Name = "FormRouteGiveaway";
|
||||
Text = "Раздача маршрутов";
|
||||
groupBoxRoutes.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)dataGridViewRoutes).EndInit();
|
||||
Name = "FormBusCheck";
|
||||
Text = "Проверка деталей автобуса";
|
||||
groupBoxDetail.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)dataGridViewDetails).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
@ -137,11 +137,11 @@
|
||||
|
||||
private ComboBox comboBoxEmployee;
|
||||
private Label labelEmployee;
|
||||
private GroupBox groupBoxRoutes;
|
||||
private DataGridView dataGridViewRoutes;
|
||||
private GroupBox groupBoxDetail;
|
||||
private DataGridView dataGridViewDetails;
|
||||
private Button buttonSave;
|
||||
private Button buttonCancel;
|
||||
private DataGridViewComboBoxColumn ColumnRouteName;
|
||||
private DataGridViewTextBoxColumn ColumnRouteNum;
|
||||
private DataGridViewComboBoxColumn ColumnDetail;
|
||||
private DataGridViewTextBoxColumn ColumnDetailCount;
|
||||
}
|
||||
}
|
@ -13,39 +13,39 @@ using System.Windows.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,
|
||||
IRouteListRepository routeListRepository)
|
||||
IBusRepository busRepository)
|
||||
{
|
||||
InitializeComponent();
|
||||
_routeGiveawayRepository = routeGiveawayRepository ??
|
||||
throw new ArgumentNullException(nameof(routeGiveawayRepository));
|
||||
_busCheckRepository = busCheckRepository ??
|
||||
throw new ArgumentNullException(nameof(busCheckRepository));
|
||||
|
||||
comboBoxEmployee.DataSource = employeeRepository.ReadEmployees();
|
||||
comboBoxEmployee.DisplayMember = "FirstName";
|
||||
comboBoxEmployee.ValueMember = "Id";
|
||||
|
||||
ColumnRouteName.DataSource = routeListRepository.ReadRouteLists();
|
||||
ColumnRouteName.DisplayMember = "RoutName";
|
||||
ColumnRouteName.ValueMember = "Id";
|
||||
ColumnDetail.DataSource = busRepository.ReadBuses();
|
||||
ColumnDetail.DisplayMember = "BusName";
|
||||
ColumnDetail.ValueMember = "Id";
|
||||
}
|
||||
|
||||
private void ButtonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (dataGridViewRoutes.RowCount < 1 ||
|
||||
if (dataGridViewDetails.RowCount < 1 ||
|
||||
comboBoxEmployee.SelectedIndex < 0)
|
||||
{
|
||||
throw new Exception("Имеются незаполненные поля");
|
||||
}
|
||||
|
||||
_routeGiveawayRepository.CreateRouteGiveaway(RouteGiveaway.CreateOperation(0,
|
||||
(int)comboBoxEmployee.SelectedValue!, CreateListRouteRouteGiveawayFromDataGrid()));
|
||||
_busCheckRepository.CreateBusCheck(BusCheck.CreateOperation(0,
|
||||
(int)comboBoxEmployee.SelectedValue!, CreateListBusBusCheckFromDataGrid()));
|
||||
|
||||
Close();
|
||||
}
|
||||
@ -57,16 +57,16 @@ namespace ProjectPeopleTransportation.Forms
|
||||
|
||||
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
|
||||
|
||||
private List<RouteRouteGiveaway> CreateListRouteRouteGiveawayFromDataGrid()
|
||||
private List<BusBusCheck> CreateListBusBusCheckFromDataGrid()
|
||||
{
|
||||
var list = new List<RouteRouteGiveaway>();
|
||||
foreach (DataGridViewRow row in dataGridViewRoutes.Rows)
|
||||
var list = new List<BusBusCheck>();
|
||||
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;
|
||||
}
|
||||
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)));
|
||||
}
|
||||
return list;
|
@ -117,16 +117,10 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</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>
|
||||
</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">
|
||||
<metadata name="ColumnDetailCount.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
</root>
|
@ -1,6 +1,6 @@
|
||||
namespace ProjectPeopleTransportation.Forms
|
||||
{
|
||||
partial class FormRouteGiveaways
|
||||
partial class FormBusChecks
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
@ -31,9 +31,9 @@
|
||||
panel1 = new Panel();
|
||||
buttonDelete = new Button();
|
||||
buttonAdd = new Button();
|
||||
dataGridViewGiveaway = new DataGridView();
|
||||
dataGridViewCheck = new DataGridView();
|
||||
panel1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridViewGiveaway).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridViewCheck).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// panel1
|
||||
@ -68,36 +68,36 @@
|
||||
buttonAdd.UseVisualStyleBackColor = true;
|
||||
buttonAdd.Click += ButtonAdd_Click;
|
||||
//
|
||||
// dataGridViewGiveaway
|
||||
// dataGridViewCheck
|
||||
//
|
||||
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;
|
||||
dataGridViewCheck.AllowUserToAddRows = false;
|
||||
dataGridViewCheck.AllowUserToDeleteRows = false;
|
||||
dataGridViewCheck.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridViewCheck.Dock = DockStyle.Fill;
|
||||
dataGridViewCheck.Location = new Point(0, 0);
|
||||
dataGridViewCheck.Name = "dataGridViewCheck";
|
||||
dataGridViewCheck.ReadOnly = true;
|
||||
dataGridViewCheck.Size = new Size(651, 439);
|
||||
dataGridViewCheck.TabIndex = 1;
|
||||
//
|
||||
// FormRouteGiveaways
|
||||
// FormBusChecks
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(784, 439);
|
||||
Controls.Add(dataGridViewGiveaway);
|
||||
Controls.Add(dataGridViewCheck);
|
||||
Controls.Add(panel1);
|
||||
Name = "FormRouteGiveaways";
|
||||
Name = "FormBusChecks";
|
||||
Text = "Раздачи маршрутов";
|
||||
panel1.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)dataGridViewGiveaway).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridViewCheck).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Panel panel1;
|
||||
private DataGridView dataGridViewGiveaway;
|
||||
private DataGridView dataGridViewCheck;
|
||||
private Button buttonAdd;
|
||||
private Button buttonDelete;
|
||||
}
|
@ -13,22 +13,22 @@ using Unity;
|
||||
|
||||
namespace ProjectPeopleTransportation.Forms
|
||||
{
|
||||
public partial class FormRouteGiveaways : Form
|
||||
public partial class FormBusChecks : Form
|
||||
{
|
||||
private readonly IUnityContainer _container;
|
||||
|
||||
private readonly IRouteGiveawayRepository _routeGiveawayRepository;
|
||||
public FormRouteGiveaways(IUnityContainer container, IRouteGiveawayRepository routeGiveawayRepository)
|
||||
private readonly IBusCheckRepository _busCheckRepository;
|
||||
public FormBusChecks(IUnityContainer container, IBusCheckRepository busCheckRepository)
|
||||
{
|
||||
InitializeComponent();
|
||||
_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)
|
||||
{
|
||||
try
|
||||
{
|
||||
_container.Resolve<FormRouteGiveaway>().ShowDialog();
|
||||
_container.Resolve<FormBusCheck>().ShowDialog();
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -49,7 +49,7 @@ namespace ProjectPeopleTransportation.Forms
|
||||
|
||||
try
|
||||
{
|
||||
_routeGiveawayRepository.DeleteRouteGiveaway(findId);
|
||||
_busCheckRepository.DeleteBusCheck(findId);
|
||||
LoadList();
|
||||
}
|
||||
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)
|
||||
{
|
||||
id = 0;
|
||||
if (dataGridViewGiveaway.SelectedRows.Count < 1)
|
||||
if (dataGridViewCheck.SelectedRows.Count < 1)
|
||||
{
|
||||
MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
id = Convert.ToInt32(dataGridViewGiveaway.SelectedRows[0].Cells["Id"].Value);
|
||||
id = Convert.ToInt32(dataGridViewCheck.SelectedRows[0].Cells["Id"].Value);
|
||||
return true;
|
||||
}
|
||||
}
|
@ -28,9 +28,7 @@
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
checkedListBoxRouteListType = new CheckedListBox();
|
||||
textBoxName = new TextBox();
|
||||
labelRouteListType = new Label();
|
||||
labelRouteListName = new Label();
|
||||
labelRouteDescription = new Label();
|
||||
textBoxDescription = new TextBox();
|
||||
@ -38,35 +36,18 @@
|
||||
buttonCancel = new Button();
|
||||
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.Location = new Point(153, 130);
|
||||
textBoxName.Location = new Point(153, 31);
|
||||
textBoxName.Multiline = true;
|
||||
textBoxName.Name = "textBoxName";
|
||||
textBoxName.Size = new Size(186, 31);
|
||||
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.AutoSize = true;
|
||||
labelRouteListName.Location = new Point(21, 146);
|
||||
labelRouteListName.Location = new Point(37, 34);
|
||||
labelRouteListName.Name = "labelRouteListName";
|
||||
labelRouteListName.Size = new Size(59, 15);
|
||||
labelRouteListName.TabIndex = 3;
|
||||
@ -75,7 +56,7 @@
|
||||
// labelRouteDescription
|
||||
//
|
||||
labelRouteDescription.AutoSize = true;
|
||||
labelRouteDescription.Location = new Point(21, 207);
|
||||
labelRouteDescription.Location = new Point(31, 110);
|
||||
labelRouteDescription.Name = "labelRouteDescription";
|
||||
labelRouteDescription.Size = new Size(65, 15);
|
||||
labelRouteDescription.TabIndex = 4;
|
||||
@ -83,7 +64,7 @@
|
||||
//
|
||||
// textBoxDescription
|
||||
//
|
||||
textBoxDescription.Location = new Point(153, 189);
|
||||
textBoxDescription.Location = new Point(153, 97);
|
||||
textBoxDescription.Multiline = true;
|
||||
textBoxDescription.Name = "textBoxDescription";
|
||||
textBoxDescription.Size = new Size(186, 91);
|
||||
@ -91,7 +72,7 @@
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.Location = new Point(37, 303);
|
||||
buttonSave.Location = new Point(37, 232);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(75, 23);
|
||||
buttonSave.TabIndex = 6;
|
||||
@ -101,7 +82,7 @@
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(190, 303);
|
||||
buttonCancel.Location = new Point(186, 232);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(75, 23);
|
||||
buttonCancel.TabIndex = 7;
|
||||
@ -113,15 +94,13 @@
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(366, 348);
|
||||
ClientSize = new Size(366, 283);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonSave);
|
||||
Controls.Add(textBoxDescription);
|
||||
Controls.Add(labelRouteDescription);
|
||||
Controls.Add(labelRouteListName);
|
||||
Controls.Add(labelRouteListType);
|
||||
Controls.Add(textBoxName);
|
||||
Controls.Add(checkedListBoxRouteListType);
|
||||
Name = "FormRouteList";
|
||||
Text = "FormRouteList";
|
||||
ResumeLayout(false);
|
||||
@ -129,10 +108,7 @@
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private CheckedListBox checkedListBoxRouteListType;
|
||||
private TextBox textBoxName;
|
||||
private Label labelRouteListType;
|
||||
private Label labelRouteListName;
|
||||
private Label labelRouteDescription;
|
||||
private TextBox textBoxDescription;
|
||||
|
@ -22,14 +22,6 @@ namespace ProjectPeopleTransportation.Forms
|
||||
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;
|
||||
textBoxDescription.Text = routeList.Description;
|
||||
@ -47,10 +39,6 @@ namespace ProjectPeopleTransportation.Forms
|
||||
{
|
||||
InitializeComponent();
|
||||
_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)
|
||||
@ -58,8 +46,7 @@ namespace ProjectPeopleTransportation.Forms
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(textBoxName.Text) ||
|
||||
string.IsNullOrWhiteSpace(textBoxDescription.Text) ||
|
||||
checkedListBoxRouteListType.CheckedItems.Count == 0)
|
||||
string.IsNullOrWhiteSpace(textBoxDescription.Text))
|
||||
{
|
||||
throw new Exception("Имеются незаполненные поля");
|
||||
}
|
||||
@ -83,16 +70,6 @@ namespace ProjectPeopleTransportation.Forms
|
||||
|
||||
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
|
||||
|
||||
private RouteList CreateRouteList(int id)
|
||||
{
|
||||
RouteListType routeListType = RouteListType.None;
|
||||
|
||||
foreach (var elem in checkedListBoxRouteListType.CheckedItems)
|
||||
{
|
||||
routeListType |= (RouteListType)elem;
|
||||
}
|
||||
|
||||
return RouteList.CreateEntity(id, textBoxName.Text, textBoxDescription.Text, routeListType);
|
||||
}
|
||||
private RouteList CreateRouteList(int id) => RouteList.CreateEntity(id, textBoxName.Text, textBoxDescription.Text);
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ namespace ProjectPeopleTransportation
|
||||
|
||||
container.RegisterType<IBusRepository, BusRepository>();
|
||||
container.RegisterType<IEmployeeRepository, EmployeeRepository>();
|
||||
container.RegisterType<IRouteGiveawayRepository, RouteGiveawayRepository>();
|
||||
container.RegisterType<IBusCheckRepository, BusCheckRepository>();
|
||||
container.RegisterType<IRouteListRepository, RouteListRepository>();
|
||||
container.RegisterType<IStartingShiftRepository, StartingShiftRepository>();
|
||||
|
||||
|
@ -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);
|
||||
}
|
@ -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);
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
using ProjectPeopleTransportation.Entities;
|
||||
using ProjectPeopleTransportation.Entities.Enums;
|
||||
|
||||
namespace ProjectPeopleTransportation.Repositories.Implementations;
|
||||
|
||||
@ -14,7 +15,7 @@ public class BusRepository : IBusRepository
|
||||
|
||||
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()
|
||||
|
@ -2,17 +2,17 @@
|
||||
|
||||
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 [];
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ public class RouteListRepository : IRouteListRepository
|
||||
|
||||
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()
|
||||
|
Loading…
Reference in New Issue
Block a user