LabWork 4.1.0 (Итог)
This commit is contained in:
parent
a5d0da4b75
commit
c178331965
@ -1,4 +1,5 @@
|
|||||||
using ProjectAutoenterprise.Entities.Enums;
|
using ProjectAutoenterprise.Entities.Enums;
|
||||||
|
using System.ComponentModel;
|
||||||
namespace ProjectAutoenterprise.Entities;
|
namespace ProjectAutoenterprise.Entities;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -7,8 +8,14 @@ namespace ProjectAutoenterprise.Entities;
|
|||||||
public class Bus
|
public class Bus
|
||||||
{
|
{
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Марка")]
|
||||||
public string Brand { get; private set; } = string.Empty;
|
public string Brand { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Вместимость")]
|
||||||
public int Capacity { get; private set; }
|
public int Capacity { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Цвета")]
|
||||||
public BusColors BusColors { get; private set; }
|
public BusColors BusColors { get; private set; }
|
||||||
|
|
||||||
public static Bus CreateEntity(int id, string brand, int capacity, BusColors busColors)
|
public static Bus CreateEntity(int id, string brand, int capacity, BusColors busColors)
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
namespace ProjectAutoenterprise.Entities;
|
using System.ComponentModel;
|
||||||
|
|
||||||
|
namespace ProjectAutoenterprise.Entities;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Сущность-операция "Ремонт автобуса"
|
/// Сущность-операция "Ремонт автобуса"
|
||||||
@ -6,8 +8,17 @@
|
|||||||
public class BusRepair
|
public class BusRepair
|
||||||
{
|
{
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
[Browsable(false)]
|
||||||
public int BusId { get; private set; }
|
public int BusId { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Марка автобуса")]
|
||||||
|
public string BusBrand { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Дата ремонта")]
|
||||||
public DateTime RepairDate { get; private set; }
|
public DateTime RepairDate { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Описание")]
|
||||||
public string Description { get; private set; } = string.Empty;
|
public string Description { get; private set; } = string.Empty;
|
||||||
|
|
||||||
public static BusRepair CreateOperation(int id, int busId, string description)
|
public static BusRepair CreateOperation(int id, int busId, string description)
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using ProjectAutoenterprise.Entities.Enums;
|
using ProjectAutoenterprise.Entities.Enums;
|
||||||
|
using System.ComponentModel;
|
||||||
namespace ProjectAutoenterprise.Entities;
|
namespace ProjectAutoenterprise.Entities;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -7,9 +8,19 @@ namespace ProjectAutoenterprise.Entities;
|
|||||||
public class Employee
|
public class Employee
|
||||||
{
|
{
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Имя")]
|
||||||
public string FirstName { get; private set; } = string.Empty;
|
public string FirstName { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Фамилия")]
|
||||||
public string LastName { get; private set; } = string.Empty;
|
public string LastName { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
public string FullName => $"{LastName} {FirstName}";
|
||||||
|
|
||||||
|
[DisplayName("Дата рождения")]
|
||||||
public DateTime BirthDate { get; private set; }
|
public DateTime BirthDate { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Должность")]
|
||||||
public EmployeePost EmployeePost { get; private set; }
|
public EmployeePost EmployeePost { get; private set; }
|
||||||
|
|
||||||
public static Employee CreateEntity(int id, string firstName, string lastName, DateTime birthDate, EmployeePost employeePost)
|
public static Employee CreateEntity(int id, string firstName, string lastName, DateTime birthDate, EmployeePost employeePost)
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
namespace ProjectAutoenterprise.Entities;
|
using System.ComponentModel;
|
||||||
|
|
||||||
|
namespace ProjectAutoenterprise.Entities;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Сущность-операция "Маршрутный лист"
|
/// Сущность-операция "Маршрутный лист"
|
||||||
@ -6,11 +8,36 @@
|
|||||||
public class Itinerary
|
public class Itinerary
|
||||||
{
|
{
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
[Browsable(false)]
|
||||||
public int BusId { get; private set; }
|
public int BusId { get; private set; }
|
||||||
|
|
||||||
|
[Browsable(false)]
|
||||||
public IEnumerable<ItineraryRoute> ItineraryRoutes { get; private set; } = [];
|
public IEnumerable<ItineraryRoute> ItineraryRoutes { get; private set; } = [];
|
||||||
|
|
||||||
|
[Browsable(false)]
|
||||||
public int DriverId { get; private set; }
|
public int DriverId { get; private set; }
|
||||||
|
|
||||||
|
[Browsable(false)]
|
||||||
public int ConductorId { get; private set; }
|
public int ConductorId { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Марка автобуса")]
|
||||||
|
public string BusBrand { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Полное имя водителя")]
|
||||||
|
public string DriverFullName { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Полное имя кондуктора")]
|
||||||
|
public string ConductorFullName { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Маршруты")]
|
||||||
|
public string Routes => ItineraryRoutes != null ?
|
||||||
|
string.Join(", ", ItineraryRoutes.Select(x => $"{x.RouteId}")) : string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Дата")]
|
||||||
public DateTime ItineraryDate { get; private set; }
|
public DateTime ItineraryDate { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Описание")]
|
||||||
public string Description { get; private set; } = string.Empty;
|
public string Description { get; private set; } = string.Empty;
|
||||||
|
|
||||||
public static Itinerary CreateOperation(int id, int busId, int driverId, int conductorId, DateTime itineraryDate, string description,
|
public static Itinerary CreateOperation(int id, int busId, int driverId, int conductorId, DateTime itineraryDate, string description,
|
||||||
@ -27,7 +54,16 @@ public class Itinerary
|
|||||||
Description = description ?? string.Empty
|
Description = description ?? string.Empty
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
public static Itinerary CreateOpeartion(TempItineraryRoute tempItineraryRoute, IEnumerable<ItineraryRoute> itineraryRoutes)
|
|
||||||
|
public void SetItineraryRoutes(IEnumerable<ItineraryRoute> itineraryRoutes)
|
||||||
|
{
|
||||||
|
if (itineraryRoutes != null && itineraryRoutes.Any())
|
||||||
|
{
|
||||||
|
ItineraryRoutes = itineraryRoutes;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*public static Itinerary CreateOpeartion(TempItineraryRoute tempItineraryRoute, IEnumerable<ItineraryRoute> itineraryRoutes)
|
||||||
{
|
{
|
||||||
return new Itinerary
|
return new Itinerary
|
||||||
{
|
{
|
||||||
@ -39,5 +75,5 @@ public class Itinerary
|
|||||||
Description = tempItineraryRoute.Description,
|
Description = tempItineraryRoute.Description,
|
||||||
ItineraryRoutes = itineraryRoutes
|
ItineraryRoutes = itineraryRoutes
|
||||||
};
|
};
|
||||||
}
|
}*/
|
||||||
}
|
}
|
@ -8,6 +8,8 @@ public class ItineraryRoute
|
|||||||
public int ItineraryId { get; private set; }
|
public int ItineraryId { get; private set; }
|
||||||
public int RouteId { get; private set; }
|
public int RouteId { get; private set; }
|
||||||
|
|
||||||
|
public string RoutePoints { get; private set; } = string.Empty;
|
||||||
|
|
||||||
public static ItineraryRoute CreateElement(int itineraryId, int routeId)
|
public static ItineraryRoute CreateElement(int itineraryId, int routeId)
|
||||||
{
|
{
|
||||||
return new ItineraryRoute
|
return new ItineraryRoute
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
namespace ProjectAutoenterprise.Entities;
|
using DocumentFormat.OpenXml.Wordprocessing;
|
||||||
|
using System.ComponentModel;
|
||||||
|
|
||||||
|
namespace ProjectAutoenterprise.Entities;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Сущность-справочник "Маршрут"
|
/// Сущность-справочник "Маршрут"
|
||||||
@ -6,9 +9,15 @@
|
|||||||
public class Route
|
public class Route
|
||||||
{
|
{
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Начальная точка маршрута")]
|
||||||
public string BeginRoutePoint { get; private set; } = string.Empty;
|
public string BeginRoutePoint { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Конечная точка маршрута")]
|
||||||
public string EndRoutePoint { get; private set; } = string.Empty;
|
public string EndRoutePoint { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
public string RoutePoints => $"{BeginRoutePoint} - {EndRoutePoint}";
|
||||||
|
|
||||||
public static Route CreateEntity(int id, string beginRoutePoint, string endRoutePoint)
|
public static Route CreateEntity(int id, string beginRoutePoint, string endRoutePoint)
|
||||||
{
|
{
|
||||||
return new Route
|
return new Route
|
||||||
|
@ -11,7 +11,7 @@ public partial class FormBusRepair : Form
|
|||||||
_busRepairRepository = busRepairRepository ??
|
_busRepairRepository = busRepairRepository ??
|
||||||
throw new ArgumentNullException(nameof(busRepairRepository));
|
throw new ArgumentNullException(nameof(busRepairRepository));
|
||||||
comboBoxBus.DataSource = busRepository.ReadBuses();
|
comboBoxBus.DataSource = busRepository.ReadBuses();
|
||||||
comboBoxBus.DisplayMember = "Id";
|
comboBoxBus.DisplayMember = "BusBrand";
|
||||||
comboBoxBus.ValueMember = "Id";
|
comboBoxBus.ValueMember = "Id";
|
||||||
}
|
}
|
||||||
private void ButtonSave_Click(object sender, EventArgs e)
|
private void ButtonSave_Click(object sender, EventArgs e)
|
||||||
|
@ -37,5 +37,9 @@ public partial class FormBusRepairs : Form
|
|||||||
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void LoadList() => dataGridViewData.DataSource = _busRepairRepository.ReadBusRepairs();
|
private void LoadList()
|
||||||
|
{
|
||||||
|
dataGridViewData.DataSource = _busRepairRepository.ReadBusRepairs();
|
||||||
|
dataGridViewData.Columns["Id"].Visible = false;
|
||||||
|
}
|
||||||
}
|
}
|
@ -75,7 +75,12 @@ public partial class FormBuses : Form
|
|||||||
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void LoadList() => dataGridViewData.DataSource = _busRepository.ReadBuses();
|
private void LoadList()
|
||||||
|
{
|
||||||
|
dataGridViewData.DataSource = _busRepository.ReadBuses();
|
||||||
|
dataGridViewData.Columns["Id"].Visible = false;
|
||||||
|
}
|
||||||
|
|
||||||
private bool TryGetIdentifierFromSelectedRow(out int id)
|
private bool TryGetIdentifierFromSelectedRow(out int id)
|
||||||
{
|
{
|
||||||
id = 0;
|
id = 0;
|
||||||
|
@ -76,7 +76,13 @@ public partial class FormEmployees : Form
|
|||||||
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void LoadList() => dataGridViewData.DataSource = _employeeRepository.ReadEmployees();
|
private void LoadList()
|
||||||
|
{
|
||||||
|
dataGridViewData.DataSource = _employeeRepository.ReadEmployees();
|
||||||
|
dataGridViewData.Columns["Id"].Visible = false;
|
||||||
|
dataGridViewData.Columns["FullName"].Visible = false;
|
||||||
|
}
|
||||||
|
|
||||||
private bool TryGetIdentifierFromSelectedRow(out int id)
|
private bool TryGetIdentifierFromSelectedRow(out int id)
|
||||||
{
|
{
|
||||||
id = 0;
|
id = 0;
|
||||||
|
@ -61,7 +61,12 @@ public partial class FormItineraries : Form
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadList() => dataGridViewData.DataSource = _itineraryRepository.ReadItinerary();
|
private void LoadList()
|
||||||
|
{
|
||||||
|
dataGridViewData.DataSource = _itineraryRepository.ReadItinerary();
|
||||||
|
dataGridViewData.Columns["Id"].Visible = false;
|
||||||
|
dataGridViewData.Columns["RoutePoints"].Visible = false;
|
||||||
|
}
|
||||||
|
|
||||||
private bool TryGetIdentifierFromSelectedRow(out int id)
|
private bool TryGetIdentifierFromSelectedRow(out int id)
|
||||||
{
|
{
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
{
|
{
|
||||||
groupBoxRoutes = new GroupBox();
|
groupBoxRoutes = new GroupBox();
|
||||||
dataGridViewRoutes = new DataGridView();
|
dataGridViewRoutes = new DataGridView();
|
||||||
|
ColumnRoute = new DataGridViewComboBoxColumn();
|
||||||
comboBoxBus = new ComboBox();
|
comboBoxBus = new ComboBox();
|
||||||
label1 = new Label();
|
label1 = new Label();
|
||||||
comboBoxDriver = new ComboBox();
|
comboBoxDriver = new ComboBox();
|
||||||
@ -42,7 +43,6 @@
|
|||||||
label5 = new Label();
|
label5 = new Label();
|
||||||
buttonCancel = new Button();
|
buttonCancel = new Button();
|
||||||
buttonSave = new Button();
|
buttonSave = new Button();
|
||||||
ColumnRoute = new DataGridViewComboBoxColumn();
|
|
||||||
groupBoxRoutes.SuspendLayout();
|
groupBoxRoutes.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridViewRoutes).BeginInit();
|
((System.ComponentModel.ISupportInitialize)dataGridViewRoutes).BeginInit();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
@ -51,9 +51,9 @@
|
|||||||
//
|
//
|
||||||
groupBoxRoutes.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
groupBoxRoutes.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
groupBoxRoutes.Controls.Add(dataGridViewRoutes);
|
groupBoxRoutes.Controls.Add(dataGridViewRoutes);
|
||||||
groupBoxRoutes.Location = new Point(333, 12);
|
groupBoxRoutes.Location = new Point(17, 251);
|
||||||
groupBoxRoutes.Name = "groupBoxRoutes";
|
groupBoxRoutes.Name = "groupBoxRoutes";
|
||||||
groupBoxRoutes.Size = new Size(259, 202);
|
groupBoxRoutes.Size = new Size(575, 235);
|
||||||
groupBoxRoutes.TabIndex = 0;
|
groupBoxRoutes.TabIndex = 0;
|
||||||
groupBoxRoutes.TabStop = false;
|
groupBoxRoutes.TabStop = false;
|
||||||
groupBoxRoutes.Text = "Маршруты";
|
groupBoxRoutes.Text = "Маршруты";
|
||||||
@ -66,9 +66,15 @@
|
|||||||
dataGridViewRoutes.Dock = DockStyle.Fill;
|
dataGridViewRoutes.Dock = DockStyle.Fill;
|
||||||
dataGridViewRoutes.Location = new Point(3, 19);
|
dataGridViewRoutes.Location = new Point(3, 19);
|
||||||
dataGridViewRoutes.Name = "dataGridViewRoutes";
|
dataGridViewRoutes.Name = "dataGridViewRoutes";
|
||||||
dataGridViewRoutes.Size = new Size(253, 180);
|
dataGridViewRoutes.Size = new Size(569, 213);
|
||||||
dataGridViewRoutes.TabIndex = 0;
|
dataGridViewRoutes.TabIndex = 0;
|
||||||
//
|
//
|
||||||
|
// ColumnRoute
|
||||||
|
//
|
||||||
|
ColumnRoute.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
ColumnRoute.HeaderText = "Маршрут";
|
||||||
|
ColumnRoute.Name = "ColumnRoute";
|
||||||
|
//
|
||||||
// comboBoxBus
|
// comboBoxBus
|
||||||
//
|
//
|
||||||
comboBoxBus.DropDownStyle = ComboBoxStyle.DropDownList;
|
comboBoxBus.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||||
@ -147,17 +153,17 @@
|
|||||||
// textBoxDescription
|
// textBoxDescription
|
||||||
//
|
//
|
||||||
textBoxDescription.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
textBoxDescription.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
textBoxDescription.Location = new Point(122, 251);
|
textBoxDescription.Location = new Point(338, 43);
|
||||||
textBoxDescription.Multiline = true;
|
textBoxDescription.Multiline = true;
|
||||||
textBoxDescription.Name = "textBoxDescription";
|
textBoxDescription.Name = "textBoxDescription";
|
||||||
textBoxDescription.Size = new Size(467, 108);
|
textBoxDescription.Size = new Size(254, 177);
|
||||||
textBoxDescription.TabIndex = 20;
|
textBoxDescription.TabIndex = 20;
|
||||||
//
|
//
|
||||||
// label5
|
// label5
|
||||||
//
|
//
|
||||||
label5.AutoSize = true;
|
label5.AutoSize = true;
|
||||||
label5.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point, 204);
|
label5.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point, 204);
|
||||||
label5.Location = new Point(32, 249);
|
label5.Location = new Point(423, 9);
|
||||||
label5.Name = "label5";
|
label5.Name = "label5";
|
||||||
label5.Size = new Size(84, 21);
|
label5.Size = new Size(84, 21);
|
||||||
label5.TabIndex = 19;
|
label5.TabIndex = 19;
|
||||||
@ -166,7 +172,7 @@
|
|||||||
// buttonCancel
|
// buttonCancel
|
||||||
//
|
//
|
||||||
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
buttonCancel.Location = new Point(477, 399);
|
buttonCancel.Location = new Point(477, 492);
|
||||||
buttonCancel.Name = "buttonCancel";
|
buttonCancel.Name = "buttonCancel";
|
||||||
buttonCancel.Size = new Size(112, 30);
|
buttonCancel.Size = new Size(112, 30);
|
||||||
buttonCancel.TabIndex = 22;
|
buttonCancel.TabIndex = 22;
|
||||||
@ -177,7 +183,7 @@
|
|||||||
// buttonSave
|
// buttonSave
|
||||||
//
|
//
|
||||||
buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||||
buttonSave.Location = new Point(17, 399);
|
buttonSave.Location = new Point(17, 492);
|
||||||
buttonSave.Name = "buttonSave";
|
buttonSave.Name = "buttonSave";
|
||||||
buttonSave.Size = new Size(111, 30);
|
buttonSave.Size = new Size(111, 30);
|
||||||
buttonSave.TabIndex = 21;
|
buttonSave.TabIndex = 21;
|
||||||
@ -185,17 +191,11 @@
|
|||||||
buttonSave.UseVisualStyleBackColor = true;
|
buttonSave.UseVisualStyleBackColor = true;
|
||||||
buttonSave.Click += ButtonSave_Click;
|
buttonSave.Click += ButtonSave_Click;
|
||||||
//
|
//
|
||||||
// ColumnRoute
|
|
||||||
//
|
|
||||||
ColumnRoute.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
|
||||||
ColumnRoute.HeaderText = "Маршрут";
|
|
||||||
ColumnRoute.Name = "ColumnRoute";
|
|
||||||
//
|
|
||||||
// FormItinerary
|
// FormItinerary
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(604, 441);
|
ClientSize = new Size(604, 534);
|
||||||
Controls.Add(buttonCancel);
|
Controls.Add(buttonCancel);
|
||||||
Controls.Add(buttonSave);
|
Controls.Add(buttonSave);
|
||||||
Controls.Add(textBoxDescription);
|
Controls.Add(textBoxDescription);
|
||||||
@ -209,7 +209,7 @@
|
|||||||
Controls.Add(comboBoxBus);
|
Controls.Add(comboBoxBus);
|
||||||
Controls.Add(label1);
|
Controls.Add(label1);
|
||||||
Controls.Add(groupBoxRoutes);
|
Controls.Add(groupBoxRoutes);
|
||||||
MaximumSize = new Size(800, 500);
|
MaximumSize = new Size(800, 900);
|
||||||
MinimumSize = new Size(620, 480);
|
MinimumSize = new Size(620, 480);
|
||||||
Name = "FormItinerary";
|
Name = "FormItinerary";
|
||||||
StartPosition = FormStartPosition.CenterParent;
|
StartPosition = FormStartPosition.CenterParent;
|
||||||
|
@ -18,15 +18,15 @@ public partial class FormItinerary : Form
|
|||||||
comboBoxBus.ValueMember = "Id";
|
comboBoxBus.ValueMember = "Id";
|
||||||
|
|
||||||
comboBoxDriver.DataSource = employeeRepository.ReadEmployees(EmployeePost.Driver);
|
comboBoxDriver.DataSource = employeeRepository.ReadEmployees(EmployeePost.Driver);
|
||||||
comboBoxDriver.DisplayMember = "FirstName";
|
comboBoxDriver.DisplayMember = "FullName";
|
||||||
comboBoxDriver.ValueMember = "Id";
|
comboBoxDriver.ValueMember = "Id";
|
||||||
|
|
||||||
comboBoxConductor.DataSource = employeeRepository.ReadEmployees(EmployeePost.Conductor);
|
comboBoxConductor.DataSource = employeeRepository.ReadEmployees(EmployeePost.Conductor);
|
||||||
comboBoxConductor.DisplayMember = "FirstName";
|
comboBoxConductor.DisplayMember = "FullName";
|
||||||
comboBoxConductor.ValueMember = "Id";
|
comboBoxConductor.ValueMember = "Id";
|
||||||
|
|
||||||
ColumnRoute.DataSource = routeRepository.ReadRoutes();
|
ColumnRoute.DataSource = routeRepository.ReadRoutes();
|
||||||
ColumnRoute.DisplayMember = "Id";
|
ColumnRoute.DisplayMember = "RoutePoints";
|
||||||
ColumnRoute.ValueMember = "Id";
|
ColumnRoute.ValueMember = "Id";
|
||||||
}
|
}
|
||||||
private void ButtonSave_Click(object sender, EventArgs e)
|
private void ButtonSave_Click(object sender, EventArgs e)
|
||||||
|
@ -81,7 +81,11 @@ public partial class FormRoutes : Form
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadList() => dataGridViewData.DataSource = _routeRepository.ReadRoutes();
|
private void LoadList()
|
||||||
|
{
|
||||||
|
dataGridViewData.DataSource = _routeRepository.ReadRoutes();
|
||||||
|
dataGridViewData.Columns["Id"].Visible = false;
|
||||||
|
}
|
||||||
|
|
||||||
private bool TryGetIdentifierFromSelectedRow(out int id)
|
private bool TryGetIdentifierFromSelectedRow(out int id)
|
||||||
{
|
{
|
||||||
|
@ -20,7 +20,7 @@ internal class ChartReport
|
|||||||
{
|
{
|
||||||
new PdfBuilder(filePath)
|
new PdfBuilder(filePath)
|
||||||
.AddHeader("Ремонт автобусов")
|
.AddHeader("Ремонт автобусов")
|
||||||
.AddPieChart("Отремонтированные автобусы", GetData(startDate, endDate))
|
.AddPieChart($"за период c {startDate:dd.MM.yyyy} по {endDate: dd.MM.yyyy}", GetData(startDate, endDate))
|
||||||
.Build();
|
.Build();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -33,10 +33,9 @@ internal class ChartReport
|
|||||||
private List<(string Caption, double Value)> GetData(DateTime startDate, DateTime endDate)
|
private List<(string Caption, double Value)> GetData(DateTime startDate, DateTime endDate)
|
||||||
{
|
{
|
||||||
return _busRepairRepository
|
return _busRepairRepository
|
||||||
.ReadBusRepairs()
|
.ReadBusRepairs(startDate, endDate)
|
||||||
.Where(x => x.RepairDate >= startDate && x.RepairDate <= endDate)
|
.GroupBy(x => x.BusBrand, (key, group) => new { BusBrand = key, Count = group.Count() })
|
||||||
.GroupBy(x => x.BusId, (key, group) => new { Id = key, Count = group.Count() })
|
.Select(x => (x.BusBrand.ToString(), (double)x.Count))
|
||||||
.Select(x => (x.Id.ToString(), (double)x.Count))
|
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -67,7 +67,7 @@ internal class DocReport
|
|||||||
return [
|
return [
|
||||||
["Имя", "Фамилия", "Дата рождения", "Должность"],
|
["Имя", "Фамилия", "Дата рождения", "Должность"],
|
||||||
.. _employeeRepository.ReadEmployees().Select(x => new string[]
|
.. _employeeRepository.ReadEmployees().Select(x => new string[]
|
||||||
{ x.FirstName, x.LastName, x.BirthDate.ToString("dd-MM-yyyy"), x.EmployeePost.ToString()}),
|
{ x.FirstName, x.LastName, x.BirthDate.ToString("dd.MM.yyyy"), x.EmployeePost.ToString()}),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
private List<string[]> GetBuses()
|
private List<string[]> GetBuses()
|
||||||
|
@ -8,7 +8,6 @@ namespace ProjectAutoenterprise.Reports;
|
|||||||
internal class TableReport
|
internal class TableReport
|
||||||
{
|
{
|
||||||
private readonly IItineraryRepository _itineraryRepository;
|
private readonly IItineraryRepository _itineraryRepository;
|
||||||
private readonly IBusRepository _busRepository;
|
|
||||||
private readonly ILogger<TableReport> _logger;
|
private readonly ILogger<TableReport> _logger;
|
||||||
internal static readonly string[] item = ["Дата", "Id Автобуса", "Id Водителя", "Id Кондуктора", "Кол-во маршрутов"];
|
internal static readonly string[] item = ["Дата", "Id Автобуса", "Id Водителя", "Id Кондуктора", "Кол-во маршрутов"];
|
||||||
public TableReport(IItineraryRepository itineraryRepository,
|
public TableReport(IItineraryRepository itineraryRepository,
|
||||||
@ -16,8 +15,6 @@ internal class TableReport
|
|||||||
{
|
{
|
||||||
_itineraryRepository = itineraryRepository ??
|
_itineraryRepository = itineraryRepository ??
|
||||||
throw new ArgumentNullException(nameof(itineraryRepository));
|
throw new ArgumentNullException(nameof(itineraryRepository));
|
||||||
_busRepository = busRepository ??
|
|
||||||
throw new ArgumentNullException(nameof(busRepository));
|
|
||||||
_logger = logger ??
|
_logger = logger ??
|
||||||
throw new ArgumentNullException(nameof(logger));
|
throw new ArgumentNullException(nameof(logger));
|
||||||
}
|
}
|
||||||
@ -28,7 +25,7 @@ internal class TableReport
|
|||||||
{
|
{
|
||||||
new ExcelBuilder(filePath)
|
new ExcelBuilder(filePath)
|
||||||
.AddHeader("Сводка по поездкам автобуса", 0, 5)
|
.AddHeader("Сводка по поездкам автобуса", 0, 5)
|
||||||
.AddParagraph("за период", 0)
|
.AddParagraph($"за период c {startDate:dd.MM.yyyy} по { endDate: dd.MM.yyyy}", 0)
|
||||||
.AddTable([10, 10, 10, 10, 10], GetData(busId, startDate, endDate))
|
.AddTable([10, 10, 10, 10, 10], GetData(busId, startDate, endDate))
|
||||||
.Build();
|
.Build();
|
||||||
return true;
|
return true;
|
||||||
@ -43,8 +40,7 @@ internal class TableReport
|
|||||||
{
|
{
|
||||||
|
|
||||||
var data = _itineraryRepository
|
var data = _itineraryRepository
|
||||||
.ReadItinerary()
|
.ReadItinerary(startDate, endDate, busId)
|
||||||
.Where(x => x.ItineraryDate >= startDate && x.ItineraryDate <= endDate && x.BusId == busId)
|
|
||||||
.Select(x => new
|
.Select(x => new
|
||||||
{
|
{
|
||||||
Date = x.ItineraryDate,
|
Date = x.ItineraryDate,
|
||||||
@ -58,7 +54,7 @@ internal class TableReport
|
|||||||
new List<string[]>() { item }
|
new List<string[]>() { item }
|
||||||
.Union(
|
.Union(
|
||||||
data
|
data
|
||||||
.Select(x => new string[] { x.Date.ToString("dd-MM-yyyy"), x.BusId.ToString(), x.DriverId.ToString(), x.ConductorId.ToString(), x.CountRoutes.ToString()}))
|
.Select(x => new string[] { x.Date.ToString("dd.MM.yyyy"), x.BusId.ToString(), x.DriverId.ToString(), x.ConductorId.ToString(), x.CountRoutes.ToString()}))
|
||||||
.Union(
|
.Union(
|
||||||
[["Всего", "", "", "", data.Sum(x => x.CountRoutes ?? 0).ToString()]])
|
[["Всего", "", "", "", data.Sum(x => x.CountRoutes ?? 0).ToString()]])
|
||||||
.ToList();
|
.ToList();
|
||||||
|
@ -5,5 +5,5 @@ public interface IBusRepairRepository
|
|||||||
{
|
{
|
||||||
void CreateBusRepair(BusRepair busRepair);
|
void CreateBusRepair(BusRepair busRepair);
|
||||||
IEnumerable<BusRepair> ReadBusRepairs(DateTime? dateForm = null, DateTime? dateTo = null,
|
IEnumerable<BusRepair> ReadBusRepairs(DateTime? dateForm = null, DateTime? dateTo = null,
|
||||||
int? busId = null, string? description = null);
|
int? busId = null);
|
||||||
}
|
}
|
@ -4,7 +4,7 @@ namespace ProjectAutoenterprise.Repositories;
|
|||||||
public interface IItineraryRepository
|
public interface IItineraryRepository
|
||||||
{
|
{
|
||||||
IEnumerable<Itinerary> ReadItinerary(DateTime? dateForm = null, DateTime? dateTo = null,
|
IEnumerable<Itinerary> ReadItinerary(DateTime? dateForm = null, DateTime? dateTo = null,
|
||||||
int? driverId = null, int? conductorId = null);
|
int? busId = null, int? driverId = null, int? conductorId = null, int? routeId = null);
|
||||||
void CreateItinerary(Itinerary itinerary);
|
void CreateItinerary(Itinerary itinerary);
|
||||||
void DeleteItinerary(int id);
|
void DeleteItinerary(int id);
|
||||||
}
|
}
|
@ -3,7 +3,6 @@ using Microsoft.Extensions.Logging;
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Npgsql;
|
using Npgsql;
|
||||||
using ProjectAutoenterprise.Entities;
|
using ProjectAutoenterprise.Entities;
|
||||||
using System.Data.SqlClient;
|
|
||||||
namespace ProjectAutoenterprise.Repositories.Implementations;
|
namespace ProjectAutoenterprise.Repositories.Implementations;
|
||||||
|
|
||||||
internal class BusRepairRepository : IBusRepairRepository
|
internal class BusRepairRepository : IBusRepairRepository
|
||||||
@ -35,14 +34,31 @@ VALUES (@BusId, @RepairDate, @Description)";
|
|||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public IEnumerable<BusRepair> ReadBusRepairs(DateTime? dateForm = null, DateTime? dateTo = null, int? busId = null, string? description = null)
|
public IEnumerable<BusRepair> ReadBusRepairs(DateTime? dateForm = null, DateTime? dateTo = null, int? busId = null)
|
||||||
{
|
{
|
||||||
_logger.LogInformation("Получение всех объектов");
|
_logger.LogInformation("Получение всех объектов");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
var builder = new QueryBuilder();
|
||||||
|
if (dateForm.HasValue)
|
||||||
|
{
|
||||||
|
builder.AddCondition("br.RepairDate >= @dateForm");
|
||||||
|
}
|
||||||
|
if (dateTo.HasValue)
|
||||||
|
{
|
||||||
|
builder.AddCondition("br.RepairDate <= @dateTo");
|
||||||
|
}
|
||||||
|
if (busId.HasValue)
|
||||||
|
{
|
||||||
|
builder.AddCondition("br.BusId = @busId");
|
||||||
|
}
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
var querySelect = "SELECT * FROM BusRepairs";
|
var querySelect = $@"
|
||||||
var busRepairss = connection.Query<BusRepair>(querySelect);
|
SELECT br.*, b.Brand as BusBrand
|
||||||
|
FROM BusRepairs br
|
||||||
|
LEFT JOIN Buses b on b.Id = br.BusId
|
||||||
|
{builder.Build()}";
|
||||||
|
var busRepairss = connection.Query<BusRepair>(querySelect, new { dateForm, dateTo, busId });
|
||||||
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(busRepairss));
|
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(busRepairss));
|
||||||
return busRepairss;
|
return busRepairss;
|
||||||
}
|
}
|
||||||
|
@ -67,15 +67,81 @@ WHERE Id=@id";
|
|||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Itinerary> ReadItinerary(
|
public IEnumerable<Itinerary> ReadItinerary(
|
||||||
DateTime? dateForm = null, DateTime? dateTo = null, int? driverId = null, int? conductorId = null)
|
DateTime? dateForm = null, DateTime? dateTo = null, int? busId = null, int? driverId = null, int? conductorId = null, int? routeId = null)
|
||||||
{
|
{
|
||||||
_logger.LogInformation("Получение всех объектов");
|
_logger.LogInformation("Получение всех объектов");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
var builder = new QueryBuilder();
|
||||||
|
if (dateForm.HasValue)
|
||||||
|
{
|
||||||
|
builder.AddCondition("i.ItineraryDate >= @dateForm");
|
||||||
|
}
|
||||||
|
if (dateTo.HasValue)
|
||||||
|
{
|
||||||
|
builder.AddCondition("i.ItineraryDate <= @dateTo");
|
||||||
|
}
|
||||||
|
if (driverId.HasValue)
|
||||||
|
{
|
||||||
|
builder.AddCondition("i.DriverId = @driverId");
|
||||||
|
}
|
||||||
|
if (conductorId.HasValue)
|
||||||
|
{
|
||||||
|
builder.AddCondition("i.ConductorId = @conductorId");
|
||||||
|
}
|
||||||
|
if (busId.HasValue)
|
||||||
|
{
|
||||||
|
builder.AddCondition("i.BusId = @busId");
|
||||||
|
}
|
||||||
|
if (routeId.HasValue)
|
||||||
|
{
|
||||||
|
builder.AddCondition("ir.RouteId = @routeId");
|
||||||
|
}
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
var querySelect = @"
|
var querySelect = $@"
|
||||||
SELECT it.*, itr.RouteId FROM Itineraries it
|
SELECT
|
||||||
INNER JOIN ItineraryRoutes itr ON itr.ItineraryId = it.Id";
|
i.*,
|
||||||
|
b.Brand as BusBrand,
|
||||||
|
CONCAT(d.LastName, ' ', d.FirstName) as DriverFullName,
|
||||||
|
CONCAT(c.LastName, ' ', c.FirstName) as ConductorFullName,
|
||||||
|
ir.RouteId,
|
||||||
|
CONCAT(r.BeginRoutePoint, ' - ', r.EndRoutePoint) as RoutePoints
|
||||||
|
FROM Itineraries i
|
||||||
|
LEFT JOIN Buses b ON b.Id = i.BusId
|
||||||
|
LEFT JOIN Employees d ON d.Id = i.DriverId AND d.EmployeePost = 'Driver'
|
||||||
|
LEFT JOIN Employees c ON c.Id = i.ConductorId AND c.EmployeePost = 'Conductor'
|
||||||
|
INNER JOIN ItineraryRoutes ir ON ir.ItineraryId = i.Id
|
||||||
|
LEFT JOIN Routes r ON r.Id = ir.RouteId
|
||||||
|
{builder.Build()}";
|
||||||
|
var itineraryDict = new Dictionary<int, List<ItineraryRoute>>();
|
||||||
|
var itineraries = connection.Query<Itinerary, ItineraryRoute, Itinerary>(querySelect,
|
||||||
|
(itinerary, itineraries) =>
|
||||||
|
{
|
||||||
|
if (!itineraryDict.TryGetValue(itinerary.Id, out var ir))
|
||||||
|
{
|
||||||
|
ir = [];
|
||||||
|
itineraryDict.Add(itinerary.Id, ir);
|
||||||
|
}
|
||||||
|
ir.Add(itineraries);
|
||||||
|
return itinerary;
|
||||||
|
},
|
||||||
|
splitOn: "RouteId",
|
||||||
|
param: new { dateForm, dateTo, driverId, conductorId, routeId });
|
||||||
|
|
||||||
|
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(itineraries));
|
||||||
|
return itineraryDict.Select(x =>
|
||||||
|
{
|
||||||
|
var i = itineraries.First(y => y.Id == x.Key);
|
||||||
|
i.SetItineraryRoutes(x.Value);
|
||||||
|
return i;
|
||||||
|
}).ToArray();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при чтении объектов");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
/*
|
||||||
var itineraries = connection.Query<TempItineraryRoute>(querySelect);
|
var itineraries = connection.Query<TempItineraryRoute>(querySelect);
|
||||||
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(itineraries));
|
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(itineraries));
|
||||||
|
|
||||||
@ -86,6 +152,6 @@ INNER JOIN ItineraryRoutes itr ON itr.ItineraryId = it.Id";
|
|||||||
{
|
{
|
||||||
_logger.LogError(ex, "Ошибка при чтении объектов");
|
_logger.LogError(ex, "Ошибка при чтении объектов");
|
||||||
throw;
|
throw;
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,29 @@
|
|||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace ProjectAutoenterprise.Repositories.Implementations;
|
||||||
|
|
||||||
|
internal class QueryBuilder
|
||||||
|
{
|
||||||
|
private readonly StringBuilder _builder;
|
||||||
|
public QueryBuilder()
|
||||||
|
{
|
||||||
|
_builder = new();
|
||||||
|
}
|
||||||
|
public QueryBuilder AddCondition(string condition)
|
||||||
|
{
|
||||||
|
if (_builder.Length > 0)
|
||||||
|
{
|
||||||
|
_builder.Append(" AND ");
|
||||||
|
}
|
||||||
|
_builder.Append(condition);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public string Build()
|
||||||
|
{
|
||||||
|
if (_builder.Length == 0)
|
||||||
|
{
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
return $"WHERE {_builder}";
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user