diff --git a/ProjectPeopleTransportation/ProjectPeopleTransportation/Entities/Bus.cs b/ProjectPeopleTransportation/ProjectPeopleTransportation/Entities/Bus.cs index 83c3b37..fe465cf 100644 --- a/ProjectPeopleTransportation/ProjectPeopleTransportation/Entities/Bus.cs +++ b/ProjectPeopleTransportation/ProjectPeopleTransportation/Entities/Bus.cs @@ -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 }; } diff --git a/ProjectPeopleTransportation/ProjectPeopleTransportation/Entities/BusBusCheck.cs b/ProjectPeopleTransportation/ProjectPeopleTransportation/Entities/BusBusCheck.cs new file mode 100644 index 0000000..97f0013 --- /dev/null +++ b/ProjectPeopleTransportation/ProjectPeopleTransportation/Entities/BusBusCheck.cs @@ -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 + }; + + } +} diff --git a/ProjectPeopleTransportation/ProjectPeopleTransportation/Entities/RouteGiveaway.cs b/ProjectPeopleTransportation/ProjectPeopleTransportation/Entities/BusCheck.cs similarity index 50% rename from ProjectPeopleTransportation/ProjectPeopleTransportation/Entities/RouteGiveaway.cs rename to ProjectPeopleTransportation/ProjectPeopleTransportation/Entities/BusCheck.cs index 1483f18..b737202 100644 --- a/ProjectPeopleTransportation/ProjectPeopleTransportation/Entities/RouteGiveaway.cs +++ b/ProjectPeopleTransportation/ProjectPeopleTransportation/Entities/BusCheck.cs @@ -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 { get; private set; } = []; + public IEnumerable BusBusCheck { get; private set; } = []; - public static RouteGiveaway CreateOperation(int id, int employeeID, IEnumerable routeRouteGiveaway) + public static BusCheck CreateOperation(int id, int employeeID, IEnumerable busBusCheck) { - return new RouteGiveaway + return new BusCheck { ID = id, EmployeeID = employeeID, DateReceipt = DateTime.Now, - RouteRouteGiveaway = routeRouteGiveaway + BusBusCheck = busBusCheck }; } diff --git a/ProjectPeopleTransportation/ProjectPeopleTransportation/Entities/Enums/RouteListType.cs b/ProjectPeopleTransportation/ProjectPeopleTransportation/Entities/Enums/BusElementType.cs similarity index 66% rename from ProjectPeopleTransportation/ProjectPeopleTransportation/Entities/Enums/RouteListType.cs rename to ProjectPeopleTransportation/ProjectPeopleTransportation/Entities/Enums/BusElementType.cs index 384495b..08d04e2 100644 --- a/ProjectPeopleTransportation/ProjectPeopleTransportation/Entities/Enums/RouteListType.cs +++ b/ProjectPeopleTransportation/ProjectPeopleTransportation/Entities/Enums/BusElementType.cs @@ -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 } diff --git a/ProjectPeopleTransportation/ProjectPeopleTransportation/Entities/RouteList.cs b/ProjectPeopleTransportation/ProjectPeopleTransportation/Entities/RouteList.cs index 99ef7ec..6994700 100644 --- a/ProjectPeopleTransportation/ProjectPeopleTransportation/Entities/RouteList.cs +++ b/ProjectPeopleTransportation/ProjectPeopleTransportation/Entities/RouteList.cs @@ -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 }; diff --git a/ProjectPeopleTransportation/ProjectPeopleTransportation/Entities/RouteRouteGiveaway.cs b/ProjectPeopleTransportation/ProjectPeopleTransportation/Entities/RouteRouteGiveaway.cs deleted file mode 100644 index 500ad18..0000000 --- a/ProjectPeopleTransportation/ProjectPeopleTransportation/Entities/RouteRouteGiveaway.cs +++ /dev/null @@ -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 - }; - - } -} diff --git a/ProjectPeopleTransportation/ProjectPeopleTransportation/FormPeopleTransportation.Designer.cs b/ProjectPeopleTransportation/ProjectPeopleTransportation/FormPeopleTransportation.Designer.cs index c2d4e80..054d4a4 100644 --- a/ProjectPeopleTransportation/ProjectPeopleTransportation/FormPeopleTransportation.Designer.cs +++ b/ProjectPeopleTransportation/ProjectPeopleTransportation/FormPeopleTransportation.Designer.cs @@ -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; // diff --git a/ProjectPeopleTransportation/ProjectPeopleTransportation/FormPeopleTransportation.cs b/ProjectPeopleTransportation/ProjectPeopleTransportation/FormPeopleTransportation.cs index c2c7fc5..aea522c 100644 --- a/ProjectPeopleTransportation/ProjectPeopleTransportation/FormPeopleTransportation.cs +++ b/ProjectPeopleTransportation/ProjectPeopleTransportation/FormPeopleTransportation.cs @@ -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().ShowDialog(); + _container.Resolve().ShowDialog(); } catch (Exception ex) { diff --git a/ProjectPeopleTransportation/ProjectPeopleTransportation/Forms/FormBus.Designer.cs b/ProjectPeopleTransportation/ProjectPeopleTransportation/Forms/FormBus.Designer.cs index 95579c4..b09caee 100644 --- a/ProjectPeopleTransportation/ProjectPeopleTransportation/Forms/FormBus.Designer.cs +++ b/ProjectPeopleTransportation/ProjectPeopleTransportation/Forms/FormBus.Designer.cs @@ -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; } } \ No newline at end of file diff --git a/ProjectPeopleTransportation/ProjectPeopleTransportation/Forms/FormBus.cs b/ProjectPeopleTransportation/ProjectPeopleTransportation/Forms/FormBus.cs index 6b74e60..26eed54 100644 --- a/ProjectPeopleTransportation/ProjectPeopleTransportation/Forms/FormBus.cs +++ b/ProjectPeopleTransportation/ProjectPeopleTransportation/Forms/FormBus.cs @@ -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); + } } diff --git a/ProjectPeopleTransportation/ProjectPeopleTransportation/Forms/FormRouteGiveaway.Designer.cs b/ProjectPeopleTransportation/ProjectPeopleTransportation/Forms/FormBusCheck.Designer.cs similarity index 61% rename from ProjectPeopleTransportation/ProjectPeopleTransportation/Forms/FormRouteGiveaway.Designer.cs rename to ProjectPeopleTransportation/ProjectPeopleTransportation/Forms/FormBusCheck.Designer.cs index 2a239ed..aa9e45f 100644 --- a/ProjectPeopleTransportation/ProjectPeopleTransportation/Forms/FormRouteGiveaway.Designer.cs +++ b/ProjectPeopleTransportation/ProjectPeopleTransportation/Forms/FormBusCheck.Designer.cs @@ -1,6 +1,6 @@ namespace ProjectPeopleTransportation.Forms { - partial class FormRouteGiveaway + partial class FormBusCheck { /// /// 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; } } \ No newline at end of file diff --git a/ProjectPeopleTransportation/ProjectPeopleTransportation/Forms/FormRouteGiveaway.cs b/ProjectPeopleTransportation/ProjectPeopleTransportation/Forms/FormBusCheck.cs similarity index 57% rename from ProjectPeopleTransportation/ProjectPeopleTransportation/Forms/FormRouteGiveaway.cs rename to ProjectPeopleTransportation/ProjectPeopleTransportation/Forms/FormBusCheck.cs index bcdfe37..86ed7d3 100644 --- a/ProjectPeopleTransportation/ProjectPeopleTransportation/Forms/FormRouteGiveaway.cs +++ b/ProjectPeopleTransportation/ProjectPeopleTransportation/Forms/FormBusCheck.cs @@ -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 CreateListRouteRouteGiveawayFromDataGrid() + private List CreateListBusBusCheckFromDataGrid() { - var list = new List(); - foreach (DataGridViewRow row in dataGridViewRoutes.Rows) + var list = new List(); + 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; diff --git a/ProjectPeopleTransportation/ProjectPeopleTransportation/Forms/FormRouteGiveaway.resx b/ProjectPeopleTransportation/ProjectPeopleTransportation/Forms/FormBusCheck.resx similarity index 89% rename from ProjectPeopleTransportation/ProjectPeopleTransportation/Forms/FormRouteGiveaway.resx rename to ProjectPeopleTransportation/ProjectPeopleTransportation/Forms/FormBusCheck.resx index fddcb1e..75dfd26 100644 --- a/ProjectPeopleTransportation/ProjectPeopleTransportation/Forms/FormRouteGiveaway.resx +++ b/ProjectPeopleTransportation/ProjectPeopleTransportation/Forms/FormBusCheck.resx @@ -117,16 +117,10 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + True - - True - - - True - - + True \ No newline at end of file diff --git a/ProjectPeopleTransportation/ProjectPeopleTransportation/Forms/FormRouteGiveaways.Designer.cs b/ProjectPeopleTransportation/ProjectPeopleTransportation/Forms/FormBusChecks.Designer.cs similarity index 76% rename from ProjectPeopleTransportation/ProjectPeopleTransportation/Forms/FormRouteGiveaways.Designer.cs rename to ProjectPeopleTransportation/ProjectPeopleTransportation/Forms/FormBusChecks.Designer.cs index 51c222d..9b3ee8d 100644 --- a/ProjectPeopleTransportation/ProjectPeopleTransportation/Forms/FormRouteGiveaways.Designer.cs +++ b/ProjectPeopleTransportation/ProjectPeopleTransportation/Forms/FormBusChecks.Designer.cs @@ -1,6 +1,6 @@ namespace ProjectPeopleTransportation.Forms { - partial class FormRouteGiveaways + partial class FormBusChecks { /// /// 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; } diff --git a/ProjectPeopleTransportation/ProjectPeopleTransportation/Forms/FormRouteGiveaways.cs b/ProjectPeopleTransportation/ProjectPeopleTransportation/Forms/FormBusChecks.cs similarity index 71% rename from ProjectPeopleTransportation/ProjectPeopleTransportation/Forms/FormRouteGiveaways.cs rename to ProjectPeopleTransportation/ProjectPeopleTransportation/Forms/FormBusChecks.cs index a4fa171..2d77062 100644 --- a/ProjectPeopleTransportation/ProjectPeopleTransportation/Forms/FormRouteGiveaways.cs +++ b/ProjectPeopleTransportation/ProjectPeopleTransportation/Forms/FormBusChecks.cs @@ -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().ShowDialog(); + _container.Resolve().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; } } diff --git a/ProjectPeopleTransportation/ProjectPeopleTransportation/Forms/FormRouteGiveaways.resx b/ProjectPeopleTransportation/ProjectPeopleTransportation/Forms/FormBusChecks.resx similarity index 100% rename from ProjectPeopleTransportation/ProjectPeopleTransportation/Forms/FormRouteGiveaways.resx rename to ProjectPeopleTransportation/ProjectPeopleTransportation/Forms/FormBusChecks.resx diff --git a/ProjectPeopleTransportation/ProjectPeopleTransportation/Forms/FormRouteList.Designer.cs b/ProjectPeopleTransportation/ProjectPeopleTransportation/Forms/FormRouteList.Designer.cs index 477897f..1cd6521 100644 --- a/ProjectPeopleTransportation/ProjectPeopleTransportation/Forms/FormRouteList.Designer.cs +++ b/ProjectPeopleTransportation/ProjectPeopleTransportation/Forms/FormRouteList.Designer.cs @@ -28,9 +28,7 @@ /// 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; diff --git a/ProjectPeopleTransportation/ProjectPeopleTransportation/Forms/FormRouteList.cs b/ProjectPeopleTransportation/ProjectPeopleTransportation/Forms/FormRouteList.cs index 1016521..854cba0 100644 --- a/ProjectPeopleTransportation/ProjectPeopleTransportation/Forms/FormRouteList.cs +++ b/ProjectPeopleTransportation/ProjectPeopleTransportation/Forms/FormRouteList.cs @@ -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); } } diff --git a/ProjectPeopleTransportation/ProjectPeopleTransportation/Program.cs b/ProjectPeopleTransportation/ProjectPeopleTransportation/Program.cs index 022506b..20fbfe2 100644 --- a/ProjectPeopleTransportation/ProjectPeopleTransportation/Program.cs +++ b/ProjectPeopleTransportation/ProjectPeopleTransportation/Program.cs @@ -24,7 +24,7 @@ namespace ProjectPeopleTransportation container.RegisterType(); container.RegisterType(); - container.RegisterType(); + container.RegisterType(); container.RegisterType(); container.RegisterType(); diff --git a/ProjectPeopleTransportation/ProjectPeopleTransportation/Repositories/IBusCheckRepository.cs b/ProjectPeopleTransportation/ProjectPeopleTransportation/Repositories/IBusCheckRepository.cs new file mode 100644 index 0000000..2113877 --- /dev/null +++ b/ProjectPeopleTransportation/ProjectPeopleTransportation/Repositories/IBusCheckRepository.cs @@ -0,0 +1,13 @@ +using ProjectPeopleTransportation.Entities; + +namespace ProjectPeopleTransportation.Repositories; + +public interface IBusCheckRepository +{ + IEnumerable ReadBusCheck(DateTime? dateForm = null, DateTime? dateTo = null, + int? employeeId = null, int? routelistId = null); + + void CreateBusCheck(BusCheck busCheck); + + void DeleteBusCheck(int id); +} diff --git a/ProjectPeopleTransportation/ProjectPeopleTransportation/Repositories/IRouteGiveawayRepository.cs b/ProjectPeopleTransportation/ProjectPeopleTransportation/Repositories/IRouteGiveawayRepository.cs deleted file mode 100644 index 658f482..0000000 --- a/ProjectPeopleTransportation/ProjectPeopleTransportation/Repositories/IRouteGiveawayRepository.cs +++ /dev/null @@ -1,13 +0,0 @@ -using ProjectPeopleTransportation.Entities; - -namespace ProjectPeopleTransportation.Repositories; - -public interface IRouteGiveawayRepository -{ - IEnumerable ReadRouteGiveaway(DateTime? dateForm = null, DateTime? dateTo = null, - int? employeeId = null, int? busId = null); - - void CreateRouteGiveaway(RouteGiveaway routeGiveaway); - - void DeleteRouteGiveaway(int id); -} diff --git a/ProjectPeopleTransportation/ProjectPeopleTransportation/Repositories/Implementations/BusRepository.cs b/ProjectPeopleTransportation/ProjectPeopleTransportation/Repositories/Implementations/BusRepository.cs index 3597080..56c9708 100644 --- a/ProjectPeopleTransportation/ProjectPeopleTransportation/Repositories/Implementations/BusRepository.cs +++ b/ProjectPeopleTransportation/ProjectPeopleTransportation/Repositories/Implementations/BusRepository.cs @@ -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 ReadBuses() diff --git a/ProjectPeopleTransportation/ProjectPeopleTransportation/Repositories/Implementations/RouteGiveawayRepository.cs b/ProjectPeopleTransportation/ProjectPeopleTransportation/Repositories/Implementations/RouteGiveawayRepository.cs index e80afe4..edfb4b5 100644 --- a/ProjectPeopleTransportation/ProjectPeopleTransportation/Repositories/Implementations/RouteGiveawayRepository.cs +++ b/ProjectPeopleTransportation/ProjectPeopleTransportation/Repositories/Implementations/RouteGiveawayRepository.cs @@ -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 ReadRouteGiveaway(DateTime? dateForm = null, DateTime? dateTo = null, int? employeeId = null, int? busId = null) + public IEnumerable ReadBusCheck(DateTime? dateForm = null, DateTime? dateTo = null, int? employeeId = null, int? routelistId = null) { return []; } diff --git a/ProjectPeopleTransportation/ProjectPeopleTransportation/Repositories/Implementations/RouteListRepository.cs b/ProjectPeopleTransportation/ProjectPeopleTransportation/Repositories/Implementations/RouteListRepository.cs index ec05882..5388d99 100644 --- a/ProjectPeopleTransportation/ProjectPeopleTransportation/Repositories/Implementations/RouteListRepository.cs +++ b/ProjectPeopleTransportation/ProjectPeopleTransportation/Repositories/Implementations/RouteListRepository.cs @@ -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 ReadRouteLists()