лабораторная 4 не конец
This commit is contained in:
parent
4662c2e508
commit
5d151fc44f
@ -1,4 +1,5 @@
|
|||||||
using FuelAccounting.Entities.Enums;
|
using FuelAccounting.Entities.Enums;
|
||||||
|
using System.ComponentModel;
|
||||||
|
|
||||||
namespace FuelAccounting.Entities;
|
namespace FuelAccounting.Entities;
|
||||||
|
|
||||||
@ -6,12 +7,18 @@ public class Car
|
|||||||
{
|
{
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Модель")]
|
||||||
public string Model { get; private set; } = string.Empty;
|
public string Model { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Категория")]
|
||||||
public CarCategory Category { get; private set; }
|
public CarCategory Category { get; private set; }
|
||||||
|
|
||||||
|
[Browsable(false)]
|
||||||
public int DriverID { get; private set; }
|
public int DriverID { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Закрепленный водитель")]
|
||||||
|
public string DriverName { get; private set; } = string.Empty;
|
||||||
|
|
||||||
public static Car CreateEntity(int id, string model, CarCategory category, int driverId)
|
public static Car CreateEntity(int id, string model, CarCategory category, int driverId)
|
||||||
{
|
{
|
||||||
return new Car
|
return new Car
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using FuelAccounting.Entities.Enums;
|
using FuelAccounting.Entities.Enums;
|
||||||
|
using System.ComponentModel;
|
||||||
|
|
||||||
namespace FuelAccounting.Entities;
|
namespace FuelAccounting.Entities;
|
||||||
|
|
||||||
@ -6,10 +7,15 @@ public class Driver
|
|||||||
{
|
{
|
||||||
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 DriverName => $"{FirstName} {LastName}";
|
||||||
|
|
||||||
|
[DisplayName("Категория прав")]
|
||||||
public DriverLicenceCategory DriverLicenceCategory { get; private set; }
|
public DriverLicenceCategory DriverLicenceCategory { get; private set; }
|
||||||
|
|
||||||
public static Driver CreateEntity(int id, string firstName, string lastName, DriverLicenceCategory driverLicenceCategory)
|
public static Driver CreateEntity(int id, string firstName, string lastName, DriverLicenceCategory driverLicenceCategory)
|
||||||
|
@ -1,17 +1,38 @@
|
|||||||
namespace FuelAccounting.Entities;
|
using System.ComponentModel;
|
||||||
|
|
||||||
|
namespace FuelAccounting.Entities;
|
||||||
|
|
||||||
public class Equipage
|
public class Equipage
|
||||||
{
|
{
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
[Browsable(false)]
|
||||||
public int CarId { get; private set; }
|
public int CarId { get; private set; }
|
||||||
|
|
||||||
|
[Browsable(false)]
|
||||||
public int DriverId { get; private set; }
|
public int DriverId { get; private set; }
|
||||||
|
|
||||||
|
[Browsable(false)]
|
||||||
public int ShiftId { get; private set; }
|
public int ShiftId { get; private set; }
|
||||||
|
|
||||||
|
[Browsable(false)]
|
||||||
public IEnumerable<RoutesEqipage> RoutesEqipage { get; private set; } = [];
|
public IEnumerable<RoutesEqipage> RoutesEqipage { get; private set; } = [];
|
||||||
|
|
||||||
|
[DisplayName("Автомобиль")]
|
||||||
|
public string CarModel { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Водитель")]
|
||||||
|
public string DriverName { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Смена")]
|
||||||
|
public string ShiftDescription { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Маршруты")]
|
||||||
|
public string Route => RoutesEqipage != null ?
|
||||||
|
string.Join(", ", RoutesEqipage.Select(x => $"{x.RouteDescription} {x.Count}")) :
|
||||||
|
string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Дата выезда")]
|
||||||
public DateTime EquipageDate { get; private set; }
|
public DateTime EquipageDate { get; private set; }
|
||||||
|
|
||||||
public static Equipage CreateOperation(int id, int carId, int driverId, int shiftId, IEnumerable<RoutesEqipage> routesEqipage)
|
public static Equipage CreateOperation(int id, int carId, int driverId, int shiftId, IEnumerable<RoutesEqipage> routesEqipage)
|
||||||
@ -27,17 +48,11 @@ public class Equipage
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Equipage CreateOperation(TempRoutesEquipage tempRoutesEquipage,
|
public void SetRoutesEquipage(IEnumerable<RoutesEqipage> routesEquipage)
|
||||||
IEnumerable<RoutesEqipage> routesEqipage)
|
|
||||||
{
|
{
|
||||||
return new Equipage
|
if (routesEquipage != null && routesEquipage.Any())
|
||||||
{
|
{
|
||||||
Id = tempRoutesEquipage.Id,
|
RoutesEqipage = routesEquipage;
|
||||||
CarId = tempRoutesEquipage.CarId,
|
}
|
||||||
DriverId = tempRoutesEquipage.DriverId,
|
|
||||||
ShiftId = tempRoutesEquipage.ShiftId,
|
|
||||||
RoutesEqipage = routesEqipage,
|
|
||||||
EquipageDate = tempRoutesEquipage.EquipageDate
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,30 @@
|
|||||||
namespace FuelAccounting.Entities;
|
using System.ComponentModel;
|
||||||
|
|
||||||
|
namespace FuelAccounting.Entities;
|
||||||
|
|
||||||
public class Refueling
|
public class Refueling
|
||||||
{
|
{
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
[Browsable(false)]
|
||||||
public int CarId { get; private set; }
|
public int CarId { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Автомобиль")]
|
||||||
|
public string CarModel { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Километров пойдено")]
|
||||||
public double Kilometers { get; private set; }
|
public double Kilometers { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Литров заправлено")]
|
||||||
public double LitersSpent { get; private set; }
|
public double LitersSpent { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Тип топлива")]
|
||||||
public string TypeOfFuel { get; private set; } = string.Empty;
|
public string TypeOfFuel { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Дата заправки")]
|
||||||
public DateTime RefuelingDate { get; private set; }
|
public DateTime RefuelingDate { get; private set; }
|
||||||
|
|
||||||
|
|
||||||
public static Refueling CreateOperation(int id, int carId, double kilometers, double litersSpent, string typeOfFuel)
|
public static Refueling CreateOperation(int id, int carId, double kilometers, double litersSpent, string typeOfFuel)
|
||||||
{
|
{
|
||||||
return new Refueling
|
return new Refueling
|
||||||
|
@ -1,11 +1,15 @@
|
|||||||
namespace FuelAccounting.Entities;
|
using System.ComponentModel;
|
||||||
|
|
||||||
|
namespace FuelAccounting.Entities;
|
||||||
|
|
||||||
public class Route
|
public class Route
|
||||||
{
|
{
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Описание")]
|
||||||
public string Description { get; private set; } = string.Empty;
|
public string Description { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
|
||||||
public static Route CreateEntity(int id, string description)
|
public static Route CreateEntity(int id, string description)
|
||||||
{
|
{
|
||||||
return new Route
|
return new Route
|
||||||
|
@ -6,6 +6,8 @@ public class RoutesEqipage
|
|||||||
|
|
||||||
public int RouteId { get; private set; }
|
public int RouteId { get; private set; }
|
||||||
|
|
||||||
|
public string RouteDescription { get; private set; } = string.Empty;
|
||||||
|
|
||||||
public int Count { get; private set; }
|
public int Count { get; private set; }
|
||||||
|
|
||||||
public static RoutesEqipage CreateElement(int id, int routeId, int count)
|
public static RoutesEqipage CreateElement(int id, int routeId, int count)
|
||||||
|
@ -1,11 +1,15 @@
|
|||||||
namespace FuelAccounting.Entities;
|
using System.ComponentModel;
|
||||||
|
|
||||||
|
namespace FuelAccounting.Entities;
|
||||||
|
|
||||||
public class Shift
|
public class Shift
|
||||||
{
|
{
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Количество часов")]
|
||||||
public int AmountOfHours { get; private set; }
|
public int AmountOfHours { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Описание")]
|
||||||
public string Description { get; private set; } = string.Empty;
|
public string Description { get; private set; } = string.Empty;
|
||||||
|
|
||||||
public static Shift CreateEntity(int id, int amountOfHours, string description)
|
public static Shift CreateEntity(int id, int amountOfHours, string description)
|
||||||
|
@ -1,18 +0,0 @@
|
|||||||
namespace FuelAccounting.Entities;
|
|
||||||
|
|
||||||
public class TempRoutesEquipage
|
|
||||||
{
|
|
||||||
public int Id { get; private set; }
|
|
||||||
|
|
||||||
public int CarId { get; private set; }
|
|
||||||
|
|
||||||
public int DriverId { get; private set; }
|
|
||||||
|
|
||||||
public int ShiftId { get; private set; }
|
|
||||||
|
|
||||||
public int RouteId { get; private set; }
|
|
||||||
|
|
||||||
public int Count { get; private set; }
|
|
||||||
|
|
||||||
public DateTime EquipageDate { get; private set; }
|
|
||||||
}
|
|
@ -52,9 +52,9 @@
|
|||||||
label2.AutoSize = true;
|
label2.AutoSize = true;
|
||||||
label2.Location = new Point(12, 101);
|
label2.Location = new Point(12, 101);
|
||||||
label2.Name = "label2";
|
label2.Name = "label2";
|
||||||
label2.Size = new Size(170, 15);
|
label2.Size = new Size(142, 15);
|
||||||
label2.TabIndex = 1;
|
label2.TabIndex = 1;
|
||||||
label2.Text = "ID закрепленного сотрудника";
|
label2.Text = "Закрепленный водитель";
|
||||||
//
|
//
|
||||||
// label3
|
// label3
|
||||||
//
|
//
|
||||||
@ -104,9 +104,9 @@
|
|||||||
// comboBoxDriverId
|
// comboBoxDriverId
|
||||||
//
|
//
|
||||||
comboBoxDriverId.FormattingEnabled = true;
|
comboBoxDriverId.FormattingEnabled = true;
|
||||||
comboBoxDriverId.Location = new Point(188, 98);
|
comboBoxDriverId.Location = new Point(167, 98);
|
||||||
comboBoxDriverId.Name = "comboBoxDriverId";
|
comboBoxDriverId.Name = "comboBoxDriverId";
|
||||||
comboBoxDriverId.Size = new Size(84, 23);
|
comboBoxDriverId.Size = new Size(105, 23);
|
||||||
comboBoxDriverId.TabIndex = 8;
|
comboBoxDriverId.TabIndex = 8;
|
||||||
//
|
//
|
||||||
// FormCar
|
// FormCar
|
||||||
@ -123,6 +123,7 @@
|
|||||||
Controls.Add(label2);
|
Controls.Add(label2);
|
||||||
Controls.Add(label1);
|
Controls.Add(label1);
|
||||||
Name = "FormCar";
|
Name = "FormCar";
|
||||||
|
StartPosition = FormStartPosition.CenterScreen;
|
||||||
Text = "Автомобиль";
|
Text = "Автомобиль";
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
PerformLayout();
|
PerformLayout();
|
||||||
|
@ -24,7 +24,14 @@ namespace FuelAccounting.Forms
|
|||||||
|
|
||||||
textBoxModel.Text = car.Model;
|
textBoxModel.Text = car.Model;
|
||||||
comboBoxCategory.SelectedItem = car.Category;
|
comboBoxCategory.SelectedItem = car.Category;
|
||||||
comboBoxDriverId.SelectedItem = car.DriverID;
|
if (car.DriverID != 0)
|
||||||
|
{
|
||||||
|
comboBoxDriverId.SelectedValue = car.DriverID;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
comboBoxDriverId.SelectedIndex = 0;
|
||||||
|
}
|
||||||
_carId = value;
|
_carId = value;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -44,7 +51,7 @@ namespace FuelAccounting.Forms
|
|||||||
comboBoxCategory.DataSource = Enum.GetValues(typeof(CarCategory));
|
comboBoxCategory.DataSource = Enum.GetValues(typeof(CarCategory));
|
||||||
|
|
||||||
comboBoxDriverId.DataSource = driversRepository.ReadDrivers();
|
comboBoxDriverId.DataSource = driversRepository.ReadDrivers();
|
||||||
comboBoxDriverId.DisplayMember = "FirstName";
|
comboBoxDriverId.DisplayMember = "DriverName";
|
||||||
comboBoxDriverId.ValueMember = "Id";
|
comboBoxDriverId.ValueMember = "Id";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,6 +106,7 @@
|
|||||||
Controls.Add(dataGridViewData);
|
Controls.Add(dataGridViewData);
|
||||||
Controls.Add(panelButtons);
|
Controls.Add(panelButtons);
|
||||||
Name = "FormCars";
|
Name = "FormCars";
|
||||||
|
StartPosition = FormStartPosition.CenterScreen;
|
||||||
Text = "Автомобили";
|
Text = "Автомобили";
|
||||||
Load += FormCars_Load;
|
Load += FormCars_Load;
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
|
((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
|
||||||
|
@ -84,7 +84,11 @@ namespace FuelAccounting.Forms
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadList() => dataGridViewData.DataSource = _carsRepository.ReadCars();
|
private void LoadList()
|
||||||
|
{
|
||||||
|
dataGridViewData.DataSource = _carsRepository.ReadCars();
|
||||||
|
dataGridViewData.Columns["Id"].Visible = false;
|
||||||
|
}
|
||||||
|
|
||||||
private bool TryGetIdentifierFromSelectedRow(out int id)
|
private bool TryGetIdentifierFromSelectedRow(out int id)
|
||||||
{
|
{
|
||||||
|
@ -121,6 +121,7 @@
|
|||||||
Controls.Add(label1);
|
Controls.Add(label1);
|
||||||
Controls.Add(checkedListBoxDriverLicenceCategory);
|
Controls.Add(checkedListBoxDriverLicenceCategory);
|
||||||
Name = "FormDriver";
|
Name = "FormDriver";
|
||||||
|
StartPosition = FormStartPosition.CenterScreen;
|
||||||
Text = "FormDriver";
|
Text = "FormDriver";
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
PerformLayout();
|
PerformLayout();
|
||||||
|
@ -106,6 +106,7 @@
|
|||||||
Controls.Add(dataGridViewData);
|
Controls.Add(dataGridViewData);
|
||||||
Controls.Add(panelButtons);
|
Controls.Add(panelButtons);
|
||||||
Name = "FormDrivers";
|
Name = "FormDrivers";
|
||||||
|
StartPosition = FormStartPosition.CenterScreen;
|
||||||
Text = "Водители";
|
Text = "Водители";
|
||||||
Load += FormDrivers_Load;
|
Load += FormDrivers_Load;
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
|
((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
|
||||||
|
@ -94,7 +94,12 @@ namespace FuelAccounting.Forms
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadList() => dataGridViewData.DataSource = _driversRepository.ReadDrivers();
|
private void LoadList()
|
||||||
|
{
|
||||||
|
dataGridViewData.DataSource = _driversRepository.ReadDrivers();
|
||||||
|
dataGridViewData.Columns["Id"].Visible = false;
|
||||||
|
dataGridViewData.Columns["DriverName"].Visible = false;
|
||||||
|
}
|
||||||
|
|
||||||
private bool TryGetIdentifierFromSelectedRow(out int id)
|
private bool TryGetIdentifierFromSelectedRow(out int id)
|
||||||
{
|
{
|
||||||
|
@ -169,6 +169,7 @@
|
|||||||
Controls.Add(comboBoxCar);
|
Controls.Add(comboBoxCar);
|
||||||
Controls.Add(label1);
|
Controls.Add(label1);
|
||||||
Name = "FormEquipage";
|
Name = "FormEquipage";
|
||||||
|
StartPosition = FormStartPosition.CenterScreen;
|
||||||
Text = "Выезд";
|
Text = "Выезд";
|
||||||
groupBoxRoutes.ResumeLayout(false);
|
groupBoxRoutes.ResumeLayout(false);
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridViewRoutes).EndInit();
|
((System.ComponentModel.ISupportInitialize)dataGridViewRoutes).EndInit();
|
||||||
|
@ -30,7 +30,7 @@ namespace FuelAccounting.Forms
|
|||||||
comboBoxCar.ValueMember = "Id";
|
comboBoxCar.ValueMember = "Id";
|
||||||
|
|
||||||
comboBoxDriver.DataSource = driversRepository.ReadDrivers();
|
comboBoxDriver.DataSource = driversRepository.ReadDrivers();
|
||||||
comboBoxDriver.DisplayMember = "FirstName";
|
comboBoxDriver.DisplayMember = "DriverName";
|
||||||
comboBoxDriver.ValueMember = "Id";
|
comboBoxDriver.ValueMember = "Id";
|
||||||
|
|
||||||
comboBoxShift.DataSource = shiftRepository.ReadShifts();
|
comboBoxShift.DataSource = shiftRepository.ReadShifts();
|
||||||
|
@ -30,8 +30,8 @@
|
|||||||
{
|
{
|
||||||
dataGridViewData = new DataGridView();
|
dataGridViewData = new DataGridView();
|
||||||
panelButtons = new Panel();
|
panelButtons = new Panel();
|
||||||
buttonAdd = new Button();
|
|
||||||
buttonDelete = new Button();
|
buttonDelete = new Button();
|
||||||
|
buttonAdd = new Button();
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit();
|
((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit();
|
||||||
panelButtons.SuspendLayout();
|
panelButtons.SuspendLayout();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
@ -63,17 +63,6 @@
|
|||||||
panelButtons.Size = new Size(160, 450);
|
panelButtons.Size = new Size(160, 450);
|
||||||
panelButtons.TabIndex = 10;
|
panelButtons.TabIndex = 10;
|
||||||
//
|
//
|
||||||
// buttonAdd
|
|
||||||
//
|
|
||||||
buttonAdd.BackgroundImage = Properties.Resources.pngimg_com___plus_PNG84;
|
|
||||||
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
|
|
||||||
buttonAdd.Location = new Point(18, 12);
|
|
||||||
buttonAdd.Name = "buttonAdd";
|
|
||||||
buttonAdd.Size = new Size(130, 130);
|
|
||||||
buttonAdd.TabIndex = 2;
|
|
||||||
buttonAdd.UseVisualStyleBackColor = true;
|
|
||||||
buttonAdd.Click += ButtonAdd_Click;
|
|
||||||
//
|
|
||||||
// buttonDelete
|
// buttonDelete
|
||||||
//
|
//
|
||||||
buttonDelete.BackgroundImage = Properties.Resources.images;
|
buttonDelete.BackgroundImage = Properties.Resources.images;
|
||||||
@ -85,6 +74,17 @@
|
|||||||
buttonDelete.UseVisualStyleBackColor = true;
|
buttonDelete.UseVisualStyleBackColor = true;
|
||||||
buttonDelete.Click += ButtonDelete_Click;
|
buttonDelete.Click += ButtonDelete_Click;
|
||||||
//
|
//
|
||||||
|
// buttonAdd
|
||||||
|
//
|
||||||
|
buttonAdd.BackgroundImage = Properties.Resources.pngimg_com___plus_PNG84;
|
||||||
|
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
|
buttonAdd.Location = new Point(18, 12);
|
||||||
|
buttonAdd.Name = "buttonAdd";
|
||||||
|
buttonAdd.Size = new Size(130, 130);
|
||||||
|
buttonAdd.TabIndex = 2;
|
||||||
|
buttonAdd.UseVisualStyleBackColor = true;
|
||||||
|
buttonAdd.Click += ButtonAdd_Click;
|
||||||
|
//
|
||||||
// FormEquipages
|
// FormEquipages
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
@ -93,6 +93,7 @@
|
|||||||
Controls.Add(dataGridViewData);
|
Controls.Add(dataGridViewData);
|
||||||
Controls.Add(panelButtons);
|
Controls.Add(panelButtons);
|
||||||
Name = "FormEquipages";
|
Name = "FormEquipages";
|
||||||
|
StartPosition = FormStartPosition.CenterScreen;
|
||||||
Text = "Выезды";
|
Text = "Выезды";
|
||||||
Load += FormEquipages_Load;
|
Load += FormEquipages_Load;
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
|
((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
|
||||||
|
@ -53,7 +53,12 @@ namespace FuelAccounting.Forms
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadList() => dataGridViewData.DataSource = _equipageRepository.ReadEquipages();
|
private void LoadList()
|
||||||
|
{
|
||||||
|
dataGridViewData.DataSource = _equipageRepository.ReadEquipages();
|
||||||
|
dataGridViewData.Columns["Id"].Visible = false;
|
||||||
|
dataGridViewData.Columns["EquipageDate"].DefaultCellStyle.Format = "dd MMMM yyyy hh:mm";
|
||||||
|
}
|
||||||
|
|
||||||
private void ButtonDelete_Click(object sender, EventArgs e)
|
private void ButtonDelete_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
@ -74,7 +74,7 @@
|
|||||||
label4.AutoSize = true;
|
label4.AutoSize = true;
|
||||||
label4.Location = new Point(12, 126);
|
label4.Location = new Point(12, 126);
|
||||||
label4.Name = "label4";
|
label4.Name = "label4";
|
||||||
label4.Size = new Size(75, 15);
|
label4.Size = new Size(76, 15);
|
||||||
label4.TabIndex = 3;
|
label4.TabIndex = 3;
|
||||||
label4.Text = "Тип топлива";
|
label4.Text = "Тип топлива";
|
||||||
//
|
//
|
||||||
@ -149,6 +149,7 @@
|
|||||||
Controls.Add(label2);
|
Controls.Add(label2);
|
||||||
Controls.Add(label1);
|
Controls.Add(label1);
|
||||||
Name = "FormRefueling";
|
Name = "FormRefueling";
|
||||||
|
StartPosition = FormStartPosition.CenterScreen;
|
||||||
Text = "FormRefueling";
|
Text = "FormRefueling";
|
||||||
((System.ComponentModel.ISupportInitialize)numericUpDownKm).EndInit();
|
((System.ComponentModel.ISupportInitialize)numericUpDownKm).EndInit();
|
||||||
((System.ComponentModel.ISupportInitialize)numericUpDownLiters).EndInit();
|
((System.ComponentModel.ISupportInitialize)numericUpDownLiters).EndInit();
|
||||||
|
@ -44,7 +44,7 @@
|
|||||||
buttonAdd.Size = new Size(130, 130);
|
buttonAdd.Size = new Size(130, 130);
|
||||||
buttonAdd.TabIndex = 2;
|
buttonAdd.TabIndex = 2;
|
||||||
buttonAdd.UseVisualStyleBackColor = true;
|
buttonAdd.UseVisualStyleBackColor = true;
|
||||||
buttonAdd.Click += buttonAdd_Click;
|
buttonAdd.Click += ButtonAdd_Click;
|
||||||
//
|
//
|
||||||
// dataGridViewData
|
// dataGridViewData
|
||||||
//
|
//
|
||||||
@ -80,6 +80,7 @@
|
|||||||
Controls.Add(dataGridViewData);
|
Controls.Add(dataGridViewData);
|
||||||
Controls.Add(panelButtons);
|
Controls.Add(panelButtons);
|
||||||
Name = "FormRefuelings";
|
Name = "FormRefuelings";
|
||||||
|
StartPosition = FormStartPosition.CenterScreen;
|
||||||
Text = "Заправки";
|
Text = "Заправки";
|
||||||
Load += FormRefuelings_Load;
|
Load += FormRefuelings_Load;
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
|
((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
|
||||||
|
@ -40,7 +40,7 @@ namespace FuelAccounting.Forms
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buttonAdd_Click(object sender, EventArgs e)
|
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -53,6 +53,11 @@ namespace FuelAccounting.Forms
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadList() => dataGridViewData.DataSource = _refuelingRepository.ReadRefuelings();
|
private void LoadList()
|
||||||
|
{
|
||||||
|
dataGridViewData.DataSource = _refuelingRepository.ReadRefuelings();
|
||||||
|
dataGridViewData.Columns["Id"].Visible = false;
|
||||||
|
dataGridViewData.Columns["RefuelingDate"].DefaultCellStyle.Format = "dd.MM.yyyy hh:mm";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@
|
|||||||
buttonDelete.Size = new Size(130, 130);
|
buttonDelete.Size = new Size(130, 130);
|
||||||
buttonDelete.TabIndex = 4;
|
buttonDelete.TabIndex = 4;
|
||||||
buttonDelete.UseVisualStyleBackColor = true;
|
buttonDelete.UseVisualStyleBackColor = true;
|
||||||
buttonDelete.Click += buttonDelete_Click;
|
buttonDelete.Click += ButtonDelete_Click;
|
||||||
//
|
//
|
||||||
// buttonUpdate
|
// buttonUpdate
|
||||||
//
|
//
|
||||||
@ -68,7 +68,7 @@
|
|||||||
buttonUpdate.Size = new Size(130, 130);
|
buttonUpdate.Size = new Size(130, 130);
|
||||||
buttonUpdate.TabIndex = 3;
|
buttonUpdate.TabIndex = 3;
|
||||||
buttonUpdate.UseVisualStyleBackColor = true;
|
buttonUpdate.UseVisualStyleBackColor = true;
|
||||||
buttonUpdate.Click += buttonUpdate_Click;
|
buttonUpdate.Click += ButtonUpdate_Click;
|
||||||
//
|
//
|
||||||
// buttonAdd
|
// buttonAdd
|
||||||
//
|
//
|
||||||
@ -79,7 +79,7 @@
|
|||||||
buttonAdd.Size = new Size(130, 130);
|
buttonAdd.Size = new Size(130, 130);
|
||||||
buttonAdd.TabIndex = 2;
|
buttonAdd.TabIndex = 2;
|
||||||
buttonAdd.UseVisualStyleBackColor = true;
|
buttonAdd.UseVisualStyleBackColor = true;
|
||||||
buttonAdd.Click += buttonAdd_Click;
|
buttonAdd.Click += ButtonAdd_Click;
|
||||||
//
|
//
|
||||||
// dataGridViewData
|
// dataGridViewData
|
||||||
//
|
//
|
||||||
|
@ -37,7 +37,7 @@ namespace FuelAccounting.Forms
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buttonAdd_Click(object sender, EventArgs e)
|
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -50,7 +50,7 @@ namespace FuelAccounting.Forms
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buttonUpdate_Click(object sender, EventArgs e)
|
private void ButtonUpdate_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (!TryGetIdentifierFromSelectedRow(out var findId))
|
if (!TryGetIdentifierFromSelectedRow(out var findId))
|
||||||
{
|
{
|
||||||
@ -70,7 +70,7 @@ namespace FuelAccounting.Forms
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buttonDelete_Click(object sender, EventArgs e)
|
private void ButtonDelete_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (!TryGetIdentifierFromSelectedRow(out var findId))
|
if (!TryGetIdentifierFromSelectedRow(out var findId))
|
||||||
{
|
{
|
||||||
@ -93,7 +93,11 @@ namespace FuelAccounting.Forms
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
|
@ -106,6 +106,7 @@
|
|||||||
Controls.Add(dataGridViewData);
|
Controls.Add(dataGridViewData);
|
||||||
Controls.Add(panelButtons);
|
Controls.Add(panelButtons);
|
||||||
Name = "FormShifts";
|
Name = "FormShifts";
|
||||||
|
StartPosition = FormStartPosition.CenterScreen;
|
||||||
Text = "Смены";
|
Text = "Смены";
|
||||||
Load += FormShifts_Load;
|
Load += FormShifts_Load;
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
|
((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
|
||||||
|
@ -85,7 +85,11 @@ namespace FuelAccounting.Forms
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadList() => dataGridViewData.DataSource = _shiftRepository.ReadShifts();
|
private void LoadList()
|
||||||
|
{
|
||||||
|
dataGridViewData.DataSource = _shiftRepository.ReadShifts();
|
||||||
|
dataGridViewData.Columns["Id"].Visible = false;
|
||||||
|
}
|
||||||
|
|
||||||
private bool TryGetIdentifierFromSelectedRow(out int id)
|
private bool TryGetIdentifierFromSelectedRow(out int id)
|
||||||
{
|
{
|
||||||
|
@ -111,12 +111,13 @@ WHERE id = @id";
|
|||||||
{
|
{
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
var querySelect = @"
|
var querySelect = @"
|
||||||
SELECT
|
SELECT
|
||||||
id,
|
c.id,
|
||||||
model,
|
c.model,
|
||||||
category,
|
c.category,
|
||||||
driver_id AS DriverID
|
CONCAT(d.first_name, ' ', d.last_name) AS DriverName
|
||||||
FROM Cars";
|
FROM Cars c
|
||||||
|
LEFT JOIN Drivers d on d.id = c.driver_id";
|
||||||
var cars = connection.Query<Car>(querySelect);
|
var cars = connection.Query<Car>(querySelect);
|
||||||
_logger.LogDebug("Найденные объекты: {json}", JsonConvert.SerializeObject(cars));
|
_logger.LogDebug("Найденные объекты: {json}", JsonConvert.SerializeObject(cars));
|
||||||
return cars;
|
return cars;
|
||||||
|
@ -81,15 +81,43 @@ WHERE id = @id";
|
|||||||
{
|
{
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
var querySelect = @"
|
var querySelect = @"
|
||||||
SELECT e.id, e.car_id AS CarId, e.driver_id AS DriverId, e.shift_id AS ShiftId,
|
SELECT
|
||||||
e.equipage_date AS EquipageDate, re.route_id AS RouteId, re.count AS Count
|
e.id,
|
||||||
|
c.model AS CarModel,
|
||||||
|
CONCAT(d.first_name, ' ', last_name) AS DriverName,
|
||||||
|
s.description AS ShiftDescription,
|
||||||
|
e.equipage_date AS EquipageDate,
|
||||||
|
re.route_id AS RouteId,
|
||||||
|
r.description AS RouteDescription,
|
||||||
|
re.count AS Count
|
||||||
FROM Equipage e
|
FROM Equipage e
|
||||||
INNER JOIN RoutesEquipage re ON re.equipage_id = e.id";
|
INNER JOIN RoutesEquipage re ON re.equipage_id = e.id
|
||||||
var equipages = connection.Query<TempRoutesEquipage>(querySelect);
|
LEFT JOIN Cars c on c.id = e.car_id
|
||||||
|
LEFT JOIN Drivers d on d.id = e.driver_id
|
||||||
|
LEFT JOIN Shift s on s.id = e.shift_id
|
||||||
|
LEFT JOIN Routes r on r.id = re.route_id;";
|
||||||
|
var equipageDict = new Dictionary<int, List<RoutesEqipage>>();
|
||||||
|
|
||||||
|
var equipages = connection.Query<Equipage, RoutesEqipage, Equipage>(querySelect,
|
||||||
|
(equip, equipages) =>
|
||||||
|
{
|
||||||
|
if (!equipageDict.TryGetValue(equip.Id, out var re))
|
||||||
|
{
|
||||||
|
re = [];
|
||||||
|
equipageDict.Add(equip.Id, re);
|
||||||
|
}
|
||||||
|
|
||||||
|
re.Add(equipages);
|
||||||
|
return equip;
|
||||||
|
}, splitOn: "RouteId");
|
||||||
_logger.LogDebug("Найденные объекты: {json}", JsonConvert.SerializeObject(equipages));
|
_logger.LogDebug("Найденные объекты: {json}", JsonConvert.SerializeObject(equipages));
|
||||||
return equipages.GroupBy(x => x.Id, y => y,
|
|
||||||
(key, value) => Equipage.CreateOperation(value.First(),
|
return equipageDict.Select(x =>
|
||||||
value.Select(z => RoutesEqipage.CreateElement(0, z.RouteId, z.CarId)))).ToList();
|
{
|
||||||
|
var e = equipages.First(y => y.Id == x.Key);
|
||||||
|
e.SetRoutesEquipage(x.Value);
|
||||||
|
return e;
|
||||||
|
}).ToArray();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
@ -45,13 +45,14 @@ VALUES (@CarId, @Kilometers, @LitersSpent, @TypeOfFuel, @RefuelingDate)";
|
|||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
var querySelect = @"
|
var querySelect = @"
|
||||||
SELECT
|
SELECT
|
||||||
id,
|
r.id,
|
||||||
car_id AS CarId,
|
c.model AS CarModel,
|
||||||
km AS Kilometers,
|
r.km AS Kilometers,
|
||||||
liters_spent AS LitersSpent,
|
r.liters_spent AS LitersSpent,
|
||||||
type_of_fuel AS TypeOfFuel,
|
r.type_of_fuel AS TypeOfFuel,
|
||||||
refueling_date AS RefuelingDate
|
r.refueling_date AS RefuelingDate
|
||||||
FROM Refueling";
|
FROM Refueling r
|
||||||
|
LEFT JOIN Cars c on c.id = r.car_id";
|
||||||
var refuelings = connection.Query<Refueling>(querySelect);
|
var refuelings = connection.Query<Refueling>(querySelect);
|
||||||
_logger.LogDebug("Найденные объекты: {json}", JsonConvert.SerializeObject(refuelings));
|
_logger.LogDebug("Найденные объекты: {json}", JsonConvert.SerializeObject(refuelings));
|
||||||
return refuelings;
|
return refuelings;
|
||||||
|
Loading…
Reference in New Issue
Block a user