Compare commits
No commits in common. "LabWork_3" and "main" have entirely different histories.
@ -1,35 +0,0 @@
|
|||||||
using Dapper;
|
|
||||||
using DocumentFormat.OpenXml.Office2010.Excel;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using Npgsql;
|
|
||||||
using ProjectGarage.Entities.Enums;
|
|
||||||
using ProjectGarage.Repositories;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectGarage.Entities;
|
|
||||||
|
|
||||||
public class Driver
|
|
||||||
{
|
|
||||||
public int Id { get;private set; }
|
|
||||||
|
|
||||||
public string Fname { get;private set; } = string.Empty;
|
|
||||||
|
|
||||||
public string Lname { get;private set; } = string.Empty;
|
|
||||||
|
|
||||||
public int TruckId { get;private set; }
|
|
||||||
|
|
||||||
public static Driver CreateDriver(int id, string fname, string lname, int truckid)
|
|
||||||
{
|
|
||||||
return new Driver
|
|
||||||
{
|
|
||||||
Id = id,
|
|
||||||
Fname = fname,
|
|
||||||
Lname = lname,
|
|
||||||
TruckId = truckid
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,19 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectGarage.Entities.Enums;
|
|
||||||
|
|
||||||
[Flags]
|
|
||||||
public enum FuelType
|
|
||||||
{
|
|
||||||
None = 0,
|
|
||||||
Petrol_92 = 1,
|
|
||||||
Petrol_95 = 2,
|
|
||||||
Petrol_98 = 4,
|
|
||||||
Petrol_100 = 8,
|
|
||||||
Diesel_Summer = 16,
|
|
||||||
Diesel_Winter = 32
|
|
||||||
}
|
|
@ -1,19 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectGarage.Entities.Enums
|
|
||||||
{
|
|
||||||
public enum TruckType
|
|
||||||
{
|
|
||||||
None = 0,
|
|
||||||
Mercedes = 1,
|
|
||||||
SCANIA = 2,
|
|
||||||
KAMAZ = 3,
|
|
||||||
MAN = 4,
|
|
||||||
Volvo = 5,
|
|
||||||
SITRAC = 6
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,31 +0,0 @@
|
|||||||
using ProjectGarage.Entities.Enums;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Reflection.Metadata.Ecma335;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectGarage.Entities;
|
|
||||||
|
|
||||||
public class Fuel
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
|
|
||||||
public string FuelName { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
public FuelType FuelType { get; set; }
|
|
||||||
|
|
||||||
public int Price { get; set; }
|
|
||||||
|
|
||||||
public static Fuel CreateFuel(int id, string name, FuelType type, int price)
|
|
||||||
{
|
|
||||||
return new Fuel
|
|
||||||
{
|
|
||||||
Id = id,
|
|
||||||
FuelName = name,
|
|
||||||
FuelType = type,
|
|
||||||
Price = price
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectGarage.Entities;
|
|
||||||
|
|
||||||
public class FuelFuelReplenishment
|
|
||||||
{
|
|
||||||
public int Id { get; private set; }
|
|
||||||
public int FuelId { get; private set; }
|
|
||||||
public int Amount { get; private set; }
|
|
||||||
public static FuelFuelReplenishment CreateElement(int id, int fuelId, int amount)
|
|
||||||
{
|
|
||||||
return new FuelFuelReplenishment
|
|
||||||
{
|
|
||||||
Id = id,
|
|
||||||
FuelId = fuelId,
|
|
||||||
Amount = amount
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,37 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectGarage.Entities;
|
|
||||||
|
|
||||||
public class FuelReplenishment
|
|
||||||
{
|
|
||||||
public int Id { get; private set; }
|
|
||||||
public int DriverId { get; private set; }
|
|
||||||
public DateTime ReplenishmentDate { get; private set; }
|
|
||||||
public IEnumerable<FuelFuelReplenishment> FuelFuelReplenishments { get; private set;} = [];
|
|
||||||
|
|
||||||
public static FuelReplenishment CreateOpeartion(int id, int driverId, IEnumerable<FuelFuelReplenishment> fuelFuelReplenishments)
|
|
||||||
{
|
|
||||||
return new FuelReplenishment
|
|
||||||
{
|
|
||||||
Id = id,
|
|
||||||
DriverId = driverId,
|
|
||||||
ReplenishmentDate = DateTime.Now,
|
|
||||||
FuelFuelReplenishments = fuelFuelReplenishments
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public static FuelReplenishment CreateOpeartion(TempFuelReplenishment tempFuelReplenishment, IEnumerable<FuelFuelReplenishment> fuelFuelReplenishments)
|
|
||||||
{
|
|
||||||
return new FuelReplenishment
|
|
||||||
{
|
|
||||||
Id = tempFuelReplenishment.Id,
|
|
||||||
DriverId = tempFuelReplenishment.DriverId,
|
|
||||||
ReplenishmentDate = tempFuelReplenishment.ReplenishmentDate,
|
|
||||||
FuelFuelReplenishments = fuelFuelReplenishments
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,31 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectGarage.Entities;
|
|
||||||
|
|
||||||
public class Route
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
|
|
||||||
public string RouteName { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
public string StartP { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
public string FinalP { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
public int Length { get; set; }
|
|
||||||
|
|
||||||
public static Route CreateRoute(int id,string name, string startp, string finalp, int len)
|
|
||||||
{
|
|
||||||
return new Route() {
|
|
||||||
Id = id,
|
|
||||||
RouteName = name,
|
|
||||||
StartP = startp,
|
|
||||||
FinalP = finalp,
|
|
||||||
Length = len
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,20 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectGarage.Entities;
|
|
||||||
|
|
||||||
public class TempFuelReplenishment
|
|
||||||
{
|
|
||||||
public int Id { get; private set; }
|
|
||||||
|
|
||||||
public int DriverId { get; private set; }
|
|
||||||
|
|
||||||
public DateTime ReplenishmentDate { get; private set; }
|
|
||||||
|
|
||||||
public int FuelId { get; private set; }
|
|
||||||
|
|
||||||
public int Amount { get; private set; }
|
|
||||||
}
|
|
@ -1,35 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectGarage.Entities;
|
|
||||||
|
|
||||||
public class Transportation
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
|
|
||||||
public int FuelId { get; set; }
|
|
||||||
|
|
||||||
public int RouteId { get; set; }
|
|
||||||
|
|
||||||
public int DriverId { get; set; }
|
|
||||||
|
|
||||||
public int Amount { get; set; }
|
|
||||||
|
|
||||||
public DateTime TransportationDate { get; set; }
|
|
||||||
|
|
||||||
public static Transportation CreateTransportation(int id, int fuel_id, int route_id, int driver_id, int amount)
|
|
||||||
{
|
|
||||||
return new Transportation
|
|
||||||
{
|
|
||||||
Id = id,
|
|
||||||
FuelId = fuel_id,
|
|
||||||
RouteId = route_id,
|
|
||||||
DriverId = driver_id,
|
|
||||||
Amount = amount,
|
|
||||||
TransportationDate = DateTime.Now
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,30 +0,0 @@
|
|||||||
using ProjectGarage.Entities.Enums;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectGarage.Entities;
|
|
||||||
|
|
||||||
public class Truck
|
|
||||||
{
|
|
||||||
public int Id { get; private set; }
|
|
||||||
|
|
||||||
public string Numbers { get; private set; } = string.Empty;
|
|
||||||
|
|
||||||
public TruckType Truck_Type { get; set; }
|
|
||||||
|
|
||||||
public int MaxFuel { get; private set; }
|
|
||||||
|
|
||||||
public static Truck CreateTruck(int id,string numbers, TruckType type, int maxFuel)
|
|
||||||
{
|
|
||||||
return new Truck()
|
|
||||||
{
|
|
||||||
Id = id,
|
|
||||||
Numbers = numbers,
|
|
||||||
Truck_Type = type,
|
|
||||||
MaxFuel = maxFuel
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
39
ProjectGarage/Form1.Designer.cs
generated
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
namespace ProjectGarage
|
||||||
|
{
|
||||||
|
partial class Form1
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.components = new System.ComponentModel.Container();
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||||
|
this.Text = "Form1";
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
10
ProjectGarage/Form1.cs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
namespace ProjectGarage
|
||||||
|
{
|
||||||
|
public partial class Form1 : Form
|
||||||
|
{
|
||||||
|
public Form1()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
178
ProjectGarage/FormGarage.Designer.cs
generated
@ -1,178 +0,0 @@
|
|||||||
namespace ProjectGarage
|
|
||||||
{
|
|
||||||
partial class FormGarage
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormGarage));
|
|
||||||
menuStripGarage = new MenuStrip();
|
|
||||||
справочникиToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
водителиToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
фурыToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
маршрутыToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
топливоToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
операцииToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
отправкаТопливаToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
получениеТопливаToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
отчетыToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
directorReportToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
fuelReportToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
DistributionReporToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
menuStripGarage.SuspendLayout();
|
|
||||||
SuspendLayout();
|
|
||||||
//
|
|
||||||
// menuStripGarage
|
|
||||||
//
|
|
||||||
menuStripGarage.ImageScalingSize = new Size(20, 20);
|
|
||||||
menuStripGarage.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, операцииToolStripMenuItem, отчетыToolStripMenuItem });
|
|
||||||
menuStripGarage.Location = new Point(0, 0);
|
|
||||||
menuStripGarage.Name = "menuStripGarage";
|
|
||||||
menuStripGarage.Size = new Size(612, 28);
|
|
||||||
menuStripGarage.TabIndex = 0;
|
|
||||||
menuStripGarage.Text = "menuStrip1";
|
|
||||||
//
|
|
||||||
// справочникиToolStripMenuItem
|
|
||||||
//
|
|
||||||
справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { водителиToolStripMenuItem, фурыToolStripMenuItem, маршрутыToolStripMenuItem, топливоToolStripMenuItem });
|
|
||||||
справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
|
|
||||||
справочникиToolStripMenuItem.Size = new Size(117, 24);
|
|
||||||
справочникиToolStripMenuItem.Text = "Справочники";
|
|
||||||
//
|
|
||||||
// водителиToolStripMenuItem
|
|
||||||
//
|
|
||||||
водителиToolStripMenuItem.Name = "водителиToolStripMenuItem";
|
|
||||||
водителиToolStripMenuItem.Size = new Size(167, 26);
|
|
||||||
водителиToolStripMenuItem.Text = "Водители";
|
|
||||||
водителиToolStripMenuItem.Click += DriversToolStripMenuItem_Click;
|
|
||||||
//
|
|
||||||
// фурыToolStripMenuItem
|
|
||||||
//
|
|
||||||
фурыToolStripMenuItem.Name = "фурыToolStripMenuItem";
|
|
||||||
фурыToolStripMenuItem.Size = new Size(167, 26);
|
|
||||||
фурыToolStripMenuItem.Text = "Фуры";
|
|
||||||
фурыToolStripMenuItem.Click += TrucksToolStripMenuItem_Click;
|
|
||||||
//
|
|
||||||
// маршрутыToolStripMenuItem
|
|
||||||
//
|
|
||||||
маршрутыToolStripMenuItem.Name = "маршрутыToolStripMenuItem";
|
|
||||||
маршрутыToolStripMenuItem.Size = new Size(167, 26);
|
|
||||||
маршрутыToolStripMenuItem.Text = "Маршруты";
|
|
||||||
маршрутыToolStripMenuItem.Click += RoutesToolStripMenuItem_Click;
|
|
||||||
//
|
|
||||||
// топливоToolStripMenuItem
|
|
||||||
//
|
|
||||||
топливоToolStripMenuItem.Name = "топливоToolStripMenuItem";
|
|
||||||
топливоToolStripMenuItem.Size = new Size(167, 26);
|
|
||||||
топливоToolStripMenuItem.Text = "Топливо";
|
|
||||||
топливоToolStripMenuItem.Click += FuelsToolStripMenuItem_Click;
|
|
||||||
//
|
|
||||||
// операцииToolStripMenuItem
|
|
||||||
//
|
|
||||||
операцииToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { отправкаТопливаToolStripMenuItem, получениеТопливаToolStripMenuItem });
|
|
||||||
операцииToolStripMenuItem.Name = "операцииToolStripMenuItem";
|
|
||||||
операцииToolStripMenuItem.Size = new Size(95, 24);
|
|
||||||
операцииToolStripMenuItem.Text = "Операции";
|
|
||||||
//
|
|
||||||
// отправкаТопливаToolStripMenuItem
|
|
||||||
//
|
|
||||||
отправкаТопливаToolStripMenuItem.Name = "отправкаТопливаToolStripMenuItem";
|
|
||||||
отправкаТопливаToolStripMenuItem.Size = new Size(230, 26);
|
|
||||||
отправкаТопливаToolStripMenuItem.Text = "Отправка топлива";
|
|
||||||
отправкаТопливаToolStripMenuItem.Click += TransportationToolStripMenuItem_Click;
|
|
||||||
//
|
|
||||||
// получениеТопливаToolStripMenuItem
|
|
||||||
//
|
|
||||||
получениеТопливаToolStripMenuItem.Name = "получениеТопливаToolStripMenuItem";
|
|
||||||
получениеТопливаToolStripMenuItem.Size = new Size(230, 26);
|
|
||||||
получениеТопливаToolStripMenuItem.Text = "Получение топлива";
|
|
||||||
получениеТопливаToolStripMenuItem.Click += ReplenishmentToolStripMenuItem_Click;
|
|
||||||
//
|
|
||||||
// отчетыToolStripMenuItem
|
|
||||||
//
|
|
||||||
отчетыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { directorReportToolStripMenuItem, fuelReportToolStripMenuItem, DistributionReporToolStripMenuItem });
|
|
||||||
отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
|
|
||||||
отчетыToolStripMenuItem.Size = new Size(73, 24);
|
|
||||||
отчетыToolStripMenuItem.Text = "Отчеты";
|
|
||||||
//
|
|
||||||
// directorReportToolStripMenuItem
|
|
||||||
//
|
|
||||||
directorReportToolStripMenuItem.Name = "directorReportToolStripMenuItem";
|
|
||||||
directorReportToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.W;
|
|
||||||
directorReportToolStripMenuItem.Size = new Size(350, 26);
|
|
||||||
directorReportToolStripMenuItem.Text = "Документ со справочниками";
|
|
||||||
directorReportToolStripMenuItem.Click += DirectoryReportToolStripMenuItem_Click;
|
|
||||||
//
|
|
||||||
// fuelReportToolStripMenuItem
|
|
||||||
//
|
|
||||||
fuelReportToolStripMenuItem.Name = "fuelReportToolStripMenuItem";
|
|
||||||
fuelReportToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.E;
|
|
||||||
fuelReportToolStripMenuItem.Size = new Size(350, 26);
|
|
||||||
fuelReportToolStripMenuItem.Text = "Движение топлива";
|
|
||||||
fuelReportToolStripMenuItem.Click += FuelReportToolStripMenuItem_Click;
|
|
||||||
//
|
|
||||||
// DistributionReporToolStripMenuItem
|
|
||||||
//
|
|
||||||
DistributionReporToolStripMenuItem.Name = "DistributionReporToolStripMenuItem";
|
|
||||||
DistributionReporToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.P;
|
|
||||||
DistributionReporToolStripMenuItem.Size = new Size(350, 26);
|
|
||||||
DistributionReporToolStripMenuItem.Text = "Распределение топлива";
|
|
||||||
DistributionReporToolStripMenuItem.Click += DistributionReportToolStripMenuItem_Click;
|
|
||||||
//
|
|
||||||
// FormGarage
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
|
||||||
BackgroundImage = (Image)resources.GetObject("$this.BackgroundImage");
|
|
||||||
BackgroundImageLayout = ImageLayout.Stretch;
|
|
||||||
ClientSize = new Size(612, 399);
|
|
||||||
Controls.Add(menuStripGarage);
|
|
||||||
Name = "FormGarage";
|
|
||||||
StartPosition = FormStartPosition.CenterScreen;
|
|
||||||
Text = "Гараж";
|
|
||||||
menuStripGarage.ResumeLayout(false);
|
|
||||||
menuStripGarage.PerformLayout();
|
|
||||||
ResumeLayout(false);
|
|
||||||
PerformLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private MenuStrip menuStripGarage;
|
|
||||||
private ToolStripMenuItem справочникиToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem водителиToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem фурыToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem маршрутыToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem топливоToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem операцииToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem отправкаТопливаToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem получениеТопливаToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem отчетыToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem directorReportToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem fuelReportToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem DistributionReporToolStripMenuItem;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,134 +0,0 @@
|
|||||||
using ProjectGarage.Forms;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using Unity;
|
|
||||||
|
|
||||||
namespace ProjectGarage
|
|
||||||
{
|
|
||||||
public partial class FormGarage : Form
|
|
||||||
{
|
|
||||||
private readonly IUnityContainer _container;
|
|
||||||
|
|
||||||
public FormGarage(IUnityContainer container)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_container = container ?? throw new ArgumentNullException(nameof(container));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void DriversToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_container.Resolve<FormDrivers>().ShowDialog();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void TrucksToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_container.Resolve<FormTrucks>().ShowDialog();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void RoutesToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_container.Resolve<FormRoutes>().ShowDialog();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void FuelsToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_container.Resolve<FormFuels>().ShowDialog();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void TransportationToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_container.Resolve<FormTransportations>().ShowDialog();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ReplenishmentToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_container.Resolve<FormReplenishments>().ShowDialog();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void DirectoryReportToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_container.Resolve<FormDirectorReport>().ShowDialog();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void FuelReportToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_container.Resolve<FormFuelReport>().ShowDialog();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void DistributionReportToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_container.Resolve<FormTransportationDistributionReport>().ShowDialog();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
112
ProjectGarage/Forms/FormDirectorReport.Designer.cs
generated
@ -1,112 +0,0 @@
|
|||||||
namespace ProjectGarage.Forms
|
|
||||||
{
|
|
||||||
partial class FormDirectorReport
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
checkBoxFuelReport = new CheckBox();
|
|
||||||
checkBoxRouteReport = new CheckBox();
|
|
||||||
checkBoxTruckReport = new CheckBox();
|
|
||||||
ButtonBuild = new Button();
|
|
||||||
checkBoxDriverReport = new CheckBox();
|
|
||||||
SuspendLayout();
|
|
||||||
//
|
|
||||||
// checkBoxFuelReport
|
|
||||||
//
|
|
||||||
checkBoxFuelReport.AutoSize = true;
|
|
||||||
checkBoxFuelReport.Location = new Point(29, 40);
|
|
||||||
checkBoxFuelReport.Name = "checkBoxFuelReport";
|
|
||||||
checkBoxFuelReport.Size = new Size(91, 24);
|
|
||||||
checkBoxFuelReport.TabIndex = 0;
|
|
||||||
checkBoxFuelReport.Text = "Топливо";
|
|
||||||
checkBoxFuelReport.UseVisualStyleBackColor = true;
|
|
||||||
//
|
|
||||||
// checkBoxRouteReport
|
|
||||||
//
|
|
||||||
checkBoxRouteReport.AutoSize = true;
|
|
||||||
checkBoxRouteReport.Location = new Point(29, 99);
|
|
||||||
checkBoxRouteReport.Name = "checkBoxRouteReport";
|
|
||||||
checkBoxRouteReport.Size = new Size(106, 24);
|
|
||||||
checkBoxRouteReport.TabIndex = 1;
|
|
||||||
checkBoxRouteReport.Text = "Маршруты";
|
|
||||||
checkBoxRouteReport.UseVisualStyleBackColor = true;
|
|
||||||
//
|
|
||||||
// checkBoxTruckReport
|
|
||||||
//
|
|
||||||
checkBoxTruckReport.AutoSize = true;
|
|
||||||
checkBoxTruckReport.Location = new Point(167, 40);
|
|
||||||
checkBoxTruckReport.Name = "checkBoxTruckReport";
|
|
||||||
checkBoxTruckReport.Size = new Size(69, 24);
|
|
||||||
checkBoxTruckReport.TabIndex = 2;
|
|
||||||
checkBoxTruckReport.Text = "Фуры";
|
|
||||||
checkBoxTruckReport.UseVisualStyleBackColor = true;
|
|
||||||
//
|
|
||||||
// ButtonBuild
|
|
||||||
//
|
|
||||||
ButtonBuild.Location = new Point(72, 138);
|
|
||||||
ButtonBuild.Name = "ButtonBuild";
|
|
||||||
ButtonBuild.Size = new Size(132, 40);
|
|
||||||
ButtonBuild.TabIndex = 3;
|
|
||||||
ButtonBuild.Text = "Сформировать";
|
|
||||||
ButtonBuild.UseVisualStyleBackColor = true;
|
|
||||||
ButtonBuild.Click += ButtonBuild_Click;
|
|
||||||
//
|
|
||||||
// checkBoxDriverReport
|
|
||||||
//
|
|
||||||
checkBoxDriverReport.AutoSize = true;
|
|
||||||
checkBoxDriverReport.Location = new Point(167, 99);
|
|
||||||
checkBoxDriverReport.Name = "checkBoxDriverReport";
|
|
||||||
checkBoxDriverReport.Size = new Size(97, 24);
|
|
||||||
checkBoxDriverReport.TabIndex = 4;
|
|
||||||
checkBoxDriverReport.Text = "Водители";
|
|
||||||
checkBoxDriverReport.UseVisualStyleBackColor = true;
|
|
||||||
//
|
|
||||||
// FormDirectorReport
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
|
||||||
ClientSize = new Size(300, 199);
|
|
||||||
Controls.Add(checkBoxDriverReport);
|
|
||||||
Controls.Add(ButtonBuild);
|
|
||||||
Controls.Add(checkBoxTruckReport);
|
|
||||||
Controls.Add(checkBoxRouteReport);
|
|
||||||
Controls.Add(checkBoxFuelReport);
|
|
||||||
Name = "FormDirectorReport";
|
|
||||||
Text = "FormDirectorReport";
|
|
||||||
ResumeLayout(false);
|
|
||||||
PerformLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private CheckBox checkBoxFuelReport;
|
|
||||||
private CheckBox checkBoxRouteReport;
|
|
||||||
private CheckBox checkBoxTruckReport;
|
|
||||||
private Button ButtonBuild;
|
|
||||||
private CheckBox checkBoxDriverReport;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,65 +0,0 @@
|
|||||||
using ProjectGarage.Reports;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Data;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
using Unity;
|
|
||||||
|
|
||||||
namespace ProjectGarage.Forms
|
|
||||||
{
|
|
||||||
public partial class FormDirectorReport : Form
|
|
||||||
{
|
|
||||||
private readonly IUnityContainer _container;
|
|
||||||
|
|
||||||
public FormDirectorReport(IUnityContainer container)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_container = container ?? throw new ArgumentNullException(nameof(container)); _container = container;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonBuild_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (!checkBoxFuelReport.Checked && !checkBoxTruckReport.Checked &&
|
|
||||||
!checkBoxDriverReport.Checked && !checkBoxRouteReport.Checked)
|
|
||||||
{
|
|
||||||
throw new Exception("Не выбран ни один справочник для выгрузки");
|
|
||||||
}
|
|
||||||
var sfd = new SaveFileDialog()
|
|
||||||
{
|
|
||||||
Filter = "Docx Files | *.docx"
|
|
||||||
};
|
|
||||||
if (sfd.ShowDialog() != DialogResult.OK)
|
|
||||||
{
|
|
||||||
throw new Exception("Не выбран файла для отчета");
|
|
||||||
}
|
|
||||||
if
|
|
||||||
(_container.Resolve<DocReport>().CreateDoc(sfd.FileName, checkBoxFuelReport.Checked,
|
|
||||||
checkBoxDriverReport.Checked, checkBoxRouteReport.Checked, checkBoxTruckReport.Checked))
|
|
||||||
{
|
|
||||||
MessageBox.Show("Документ сформирован",
|
|
||||||
"Формирование документа",
|
|
||||||
MessageBoxButtons.OK,
|
|
||||||
MessageBoxIcon.Information);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MessageBox.Show("Возникли ошибки при формировании документа.Подробности в логах",
|
|
||||||
"Формирование документа",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при создании отчета",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,120 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<root>
|
|
||||||
<!--
|
|
||||||
Microsoft ResX Schema
|
|
||||||
|
|
||||||
Version 2.0
|
|
||||||
|
|
||||||
The primary goals of this format is to allow a simple XML format
|
|
||||||
that is mostly human readable. The generation and parsing of the
|
|
||||||
various data types are done through the TypeConverter classes
|
|
||||||
associated with the data types.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
... ado.net/XML headers & schema ...
|
|
||||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
|
||||||
<resheader name="version">2.0</resheader>
|
|
||||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
|
||||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
|
||||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
|
||||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
|
||||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
|
||||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
|
||||||
</data>
|
|
||||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
|
||||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
|
||||||
<comment>This is a comment</comment>
|
|
||||||
</data>
|
|
||||||
|
|
||||||
There are any number of "resheader" rows that contain simple
|
|
||||||
name/value pairs.
|
|
||||||
|
|
||||||
Each data row contains a name, and value. The row also contains a
|
|
||||||
type or mimetype. Type corresponds to a .NET class that support
|
|
||||||
text/value conversion through the TypeConverter architecture.
|
|
||||||
Classes that don't support this are serialized and stored with the
|
|
||||||
mimetype set.
|
|
||||||
|
|
||||||
The mimetype is used for serialized objects, and tells the
|
|
||||||
ResXResourceReader how to depersist the object. This is currently not
|
|
||||||
extensible. For a given mimetype the value must be set accordingly:
|
|
||||||
|
|
||||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
|
||||||
that the ResXResourceWriter will generate, however the reader can
|
|
||||||
read any of the formats listed below.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.binary.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.soap.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
|
||||||
value : The object must be serialized into a byte array
|
|
||||||
: using a System.ComponentModel.TypeConverter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
-->
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
</root>
|
|
142
ProjectGarage/Forms/FormDriver.Designer.cs
generated
@ -1,142 +0,0 @@
|
|||||||
namespace ProjectGarage.Forms
|
|
||||||
{
|
|
||||||
partial class FormDriver
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
labelFirstName = new Label();
|
|
||||||
textBoxFirstName = new TextBox();
|
|
||||||
textBoxLastName = new TextBox();
|
|
||||||
labelLastName = new Label();
|
|
||||||
labelTruckID = new Label();
|
|
||||||
buttonSaveDriver = new Button();
|
|
||||||
buttonCancelDriver = new Button();
|
|
||||||
comboBoxTruckID = new ComboBox();
|
|
||||||
SuspendLayout();
|
|
||||||
//
|
|
||||||
// labelFirstName
|
|
||||||
//
|
|
||||||
labelFirstName.AutoSize = true;
|
|
||||||
labelFirstName.Location = new Point(34, 24);
|
|
||||||
labelFirstName.Name = "labelFirstName";
|
|
||||||
labelFirstName.Size = new Size(39, 20);
|
|
||||||
labelFirstName.TabIndex = 0;
|
|
||||||
labelFirstName.Text = "Имя";
|
|
||||||
//
|
|
||||||
// textBoxFirstName
|
|
||||||
//
|
|
||||||
textBoxFirstName.Location = new Point(120, 24);
|
|
||||||
textBoxFirstName.Name = "textBoxFirstName";
|
|
||||||
textBoxFirstName.Size = new Size(183, 27);
|
|
||||||
textBoxFirstName.TabIndex = 1;
|
|
||||||
//
|
|
||||||
// textBoxLastName
|
|
||||||
//
|
|
||||||
textBoxLastName.Location = new Point(120, 70);
|
|
||||||
textBoxLastName.Name = "textBoxLastName";
|
|
||||||
textBoxLastName.Size = new Size(183, 27);
|
|
||||||
textBoxLastName.TabIndex = 3;
|
|
||||||
//
|
|
||||||
// labelLastName
|
|
||||||
//
|
|
||||||
labelLastName.AutoSize = true;
|
|
||||||
labelLastName.Location = new Point(20, 73);
|
|
||||||
labelLastName.Name = "labelLastName";
|
|
||||||
labelLastName.Size = new Size(73, 20);
|
|
||||||
labelLastName.TabIndex = 2;
|
|
||||||
labelLastName.Text = "Фамилия";
|
|
||||||
//
|
|
||||||
// labelTruckID
|
|
||||||
//
|
|
||||||
labelTruckID.AutoSize = true;
|
|
||||||
labelTruckID.Location = new Point(34, 121);
|
|
||||||
labelTruckID.Name = "labelTruckID";
|
|
||||||
labelTruckID.Size = new Size(44, 20);
|
|
||||||
labelTruckID.TabIndex = 6;
|
|
||||||
labelTruckID.Text = "Фура";
|
|
||||||
//
|
|
||||||
// buttonSaveDriver
|
|
||||||
//
|
|
||||||
buttonSaveDriver.Location = new Point(20, 158);
|
|
||||||
buttonSaveDriver.Name = "buttonSaveDriver";
|
|
||||||
buttonSaveDriver.Size = new Size(128, 39);
|
|
||||||
buttonSaveDriver.TabIndex = 8;
|
|
||||||
buttonSaveDriver.Text = "Сохранить";
|
|
||||||
buttonSaveDriver.UseVisualStyleBackColor = true;
|
|
||||||
buttonSaveDriver.Click += ButtonSaveDriver_Click;
|
|
||||||
//
|
|
||||||
// buttonCancelDriver
|
|
||||||
//
|
|
||||||
buttonCancelDriver.Location = new Point(175, 158);
|
|
||||||
buttonCancelDriver.Name = "buttonCancelDriver";
|
|
||||||
buttonCancelDriver.Size = new Size(128, 39);
|
|
||||||
buttonCancelDriver.TabIndex = 9;
|
|
||||||
buttonCancelDriver.Text = "Отмена";
|
|
||||||
buttonCancelDriver.UseVisualStyleBackColor = true;
|
|
||||||
buttonCancelDriver.Click += ButtonCancelDriver_Click;
|
|
||||||
//
|
|
||||||
// comboBoxTruckID
|
|
||||||
//
|
|
||||||
comboBoxTruckID.DropDownStyle = ComboBoxStyle.DropDownList;
|
|
||||||
comboBoxTruckID.FormattingEnabled = true;
|
|
||||||
comboBoxTruckID.Location = new Point(120, 113);
|
|
||||||
comboBoxTruckID.Name = "comboBoxTruckID";
|
|
||||||
comboBoxTruckID.Size = new Size(183, 28);
|
|
||||||
comboBoxTruckID.TabIndex = 10;
|
|
||||||
//
|
|
||||||
// FormDriver
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
|
||||||
ClientSize = new Size(333, 218);
|
|
||||||
Controls.Add(comboBoxTruckID);
|
|
||||||
Controls.Add(buttonCancelDriver);
|
|
||||||
Controls.Add(buttonSaveDriver);
|
|
||||||
Controls.Add(labelTruckID);
|
|
||||||
Controls.Add(textBoxLastName);
|
|
||||||
Controls.Add(labelLastName);
|
|
||||||
Controls.Add(textBoxFirstName);
|
|
||||||
Controls.Add(labelFirstName);
|
|
||||||
Name = "FormDriver";
|
|
||||||
StartPosition = FormStartPosition.CenterParent;
|
|
||||||
Text = "Водитель";
|
|
||||||
ResumeLayout(false);
|
|
||||||
PerformLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private Label labelFirstName;
|
|
||||||
private TextBox textBoxFirstName;
|
|
||||||
private TextBox textBoxLastName;
|
|
||||||
private Label labelLastName;
|
|
||||||
private Label labelTruckID;
|
|
||||||
private Button buttonSaveDriver;
|
|
||||||
private Button buttonCancelDriver;
|
|
||||||
private ComboBox comboBoxTruckID;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,87 +0,0 @@
|
|||||||
using ProjectGarage.Entities;
|
|
||||||
using ProjectGarage.Entities.Enums;
|
|
||||||
using ProjectGarage.Repositories;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Data;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
namespace ProjectGarage.Forms
|
|
||||||
{
|
|
||||||
public partial class FormDriver : Form
|
|
||||||
{
|
|
||||||
private readonly IDriverRepository _driverRepository;
|
|
||||||
|
|
||||||
private int? _driverId;
|
|
||||||
|
|
||||||
public int Id
|
|
||||||
{
|
|
||||||
set
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var driver = _driverRepository.ReadDriverByID(value);
|
|
||||||
if (driver == null)
|
|
||||||
{
|
|
||||||
throw new
|
|
||||||
InvalidDataException(nameof(driver));
|
|
||||||
}
|
|
||||||
textBoxFirstName.Text = driver.Fname;
|
|
||||||
textBoxLastName.Text = driver.Lname;
|
|
||||||
comboBoxTruckID.SelectedItem = driver.TruckId;
|
|
||||||
_driverId = value;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public FormDriver(IDriverRepository driverRepository, ITruckRepository truckRepository)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_driverRepository = driverRepository ?? throw new ArgumentNullException(nameof(driverRepository));
|
|
||||||
comboBoxTruckID.DataSource = truckRepository.ReadTrucks();
|
|
||||||
comboBoxTruckID.DisplayMember = "Numbers";
|
|
||||||
comboBoxTruckID.ValueMember = "Id";
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonSaveDriver_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (string.IsNullOrWhiteSpace(textBoxFirstName.Text) || string.IsNullOrWhiteSpace(textBoxLastName.Text)
|
|
||||||
|| comboBoxTruckID.SelectedIndex < 0)
|
|
||||||
{
|
|
||||||
throw new Exception("Имеются незаполненные поля");
|
|
||||||
}
|
|
||||||
if (_driverId.HasValue)
|
|
||||||
{
|
|
||||||
_driverRepository.UpdateDriver(CreateDriver(_driverId.Value));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_driverRepository.CreateDriver(CreateDriver(0));
|
|
||||||
}
|
|
||||||
Close();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при сохранении",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonCancelDriver_Click(object sender, EventArgs e) => Close();
|
|
||||||
|
|
||||||
private Driver CreateDriver(int id) => Driver.CreateDriver(id, textBoxFirstName.Text,
|
|
||||||
textBoxLastName.Text, (int)comboBoxTruckID.SelectedIndex);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,120 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<root>
|
|
||||||
<!--
|
|
||||||
Microsoft ResX Schema
|
|
||||||
|
|
||||||
Version 2.0
|
|
||||||
|
|
||||||
The primary goals of this format is to allow a simple XML format
|
|
||||||
that is mostly human readable. The generation and parsing of the
|
|
||||||
various data types are done through the TypeConverter classes
|
|
||||||
associated with the data types.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
... ado.net/XML headers & schema ...
|
|
||||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
|
||||||
<resheader name="version">2.0</resheader>
|
|
||||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
|
||||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
|
||||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
|
||||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
|
||||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
|
||||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
|
||||||
</data>
|
|
||||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
|
||||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
|
||||||
<comment>This is a comment</comment>
|
|
||||||
</data>
|
|
||||||
|
|
||||||
There are any number of "resheader" rows that contain simple
|
|
||||||
name/value pairs.
|
|
||||||
|
|
||||||
Each data row contains a name, and value. The row also contains a
|
|
||||||
type or mimetype. Type corresponds to a .NET class that support
|
|
||||||
text/value conversion through the TypeConverter architecture.
|
|
||||||
Classes that don't support this are serialized and stored with the
|
|
||||||
mimetype set.
|
|
||||||
|
|
||||||
The mimetype is used for serialized objects, and tells the
|
|
||||||
ResXResourceReader how to depersist the object. This is currently not
|
|
||||||
extensible. For a given mimetype the value must be set accordingly:
|
|
||||||
|
|
||||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
|
||||||
that the ResXResourceWriter will generate, however the reader can
|
|
||||||
read any of the formats listed below.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.binary.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.soap.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
|
||||||
value : The object must be serialized into a byte array
|
|
||||||
: using a System.ComponentModel.TypeConverter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
-->
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
</root>
|
|
126
ProjectGarage/Forms/FormDrivers.Designer.cs
generated
@ -1,126 +0,0 @@
|
|||||||
namespace ProjectGarage.Forms
|
|
||||||
{
|
|
||||||
partial class FormDrivers
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
dataGridViewDrivers = new DataGridView();
|
|
||||||
panelFormDriversButtons = new Panel();
|
|
||||||
buttonUpdateDriver = new Button();
|
|
||||||
buttonDeleteDriver = new Button();
|
|
||||||
buttonAddDriver = new Button();
|
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridViewDrivers).BeginInit();
|
|
||||||
panelFormDriversButtons.SuspendLayout();
|
|
||||||
SuspendLayout();
|
|
||||||
//
|
|
||||||
// dataGridViewDrivers
|
|
||||||
//
|
|
||||||
dataGridViewDrivers.AllowUserToAddRows = false;
|
|
||||||
dataGridViewDrivers.AllowUserToDeleteRows = false;
|
|
||||||
dataGridViewDrivers.AllowUserToResizeColumns = false;
|
|
||||||
dataGridViewDrivers.AllowUserToResizeRows = false;
|
|
||||||
dataGridViewDrivers.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
|
||||||
dataGridViewDrivers.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
|
||||||
dataGridViewDrivers.Dock = DockStyle.Fill;
|
|
||||||
dataGridViewDrivers.Location = new Point(0, 0);
|
|
||||||
dataGridViewDrivers.Name = "dataGridViewDrivers";
|
|
||||||
dataGridViewDrivers.ReadOnly = true;
|
|
||||||
dataGridViewDrivers.RowHeadersVisible = false;
|
|
||||||
dataGridViewDrivers.RowHeadersWidth = 51;
|
|
||||||
dataGridViewDrivers.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
|
||||||
dataGridViewDrivers.Size = new Size(648, 367);
|
|
||||||
dataGridViewDrivers.TabIndex = 3;
|
|
||||||
//
|
|
||||||
// panelFormDriversButtons
|
|
||||||
//
|
|
||||||
panelFormDriversButtons.Controls.Add(buttonUpdateDriver);
|
|
||||||
panelFormDriversButtons.Controls.Add(buttonDeleteDriver);
|
|
||||||
panelFormDriversButtons.Controls.Add(buttonAddDriver);
|
|
||||||
panelFormDriversButtons.Dock = DockStyle.Right;
|
|
||||||
panelFormDriversButtons.Location = new Point(648, 0);
|
|
||||||
panelFormDriversButtons.Name = "panelFormDriversButtons";
|
|
||||||
panelFormDriversButtons.Size = new Size(161, 367);
|
|
||||||
panelFormDriversButtons.TabIndex = 2;
|
|
||||||
//
|
|
||||||
// buttonUpdateDriver
|
|
||||||
//
|
|
||||||
buttonUpdateDriver.BackgroundImage = Properties.Resources.каранд;
|
|
||||||
buttonUpdateDriver.BackgroundImageLayout = ImageLayout.Stretch;
|
|
||||||
buttonUpdateDriver.Location = new Point(35, 140);
|
|
||||||
buttonUpdateDriver.Name = "buttonUpdateDriver";
|
|
||||||
buttonUpdateDriver.Size = new Size(94, 75);
|
|
||||||
buttonUpdateDriver.TabIndex = 2;
|
|
||||||
buttonUpdateDriver.UseVisualStyleBackColor = true;
|
|
||||||
buttonUpdateDriver.Click += ButtonUpdateDriver_Click;
|
|
||||||
//
|
|
||||||
// buttonDeleteDriver
|
|
||||||
//
|
|
||||||
buttonDeleteDriver.BackgroundImage = Properties.Resources.минусик;
|
|
||||||
buttonDeleteDriver.BackgroundImageLayout = ImageLayout.Stretch;
|
|
||||||
buttonDeleteDriver.Location = new Point(35, 249);
|
|
||||||
buttonDeleteDriver.Name = "buttonDeleteDriver";
|
|
||||||
buttonDeleteDriver.Size = new Size(94, 78);
|
|
||||||
buttonDeleteDriver.TabIndex = 1;
|
|
||||||
buttonDeleteDriver.UseVisualStyleBackColor = true;
|
|
||||||
buttonDeleteDriver.Click += ButtonDeleteDriver_Click;
|
|
||||||
//
|
|
||||||
// buttonAddDriver
|
|
||||||
//
|
|
||||||
buttonAddDriver.BackgroundImage = Properties.Resources.плюсик;
|
|
||||||
buttonAddDriver.BackgroundImageLayout = ImageLayout.Stretch;
|
|
||||||
buttonAddDriver.Location = new Point(35, 23);
|
|
||||||
buttonAddDriver.Name = "buttonAddDriver";
|
|
||||||
buttonAddDriver.Size = new Size(94, 75);
|
|
||||||
buttonAddDriver.TabIndex = 0;
|
|
||||||
buttonAddDriver.UseVisualStyleBackColor = true;
|
|
||||||
buttonAddDriver.Click += ButtonAddDriver_Click;
|
|
||||||
//
|
|
||||||
// FormDrivers
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
|
||||||
ClientSize = new Size(809, 367);
|
|
||||||
Controls.Add(dataGridViewDrivers);
|
|
||||||
Controls.Add(panelFormDriversButtons);
|
|
||||||
Name = "FormDrivers";
|
|
||||||
Text = "FormDrivers";
|
|
||||||
Load += FormDrivers_Load;
|
|
||||||
Click += FormDrivers_Load;
|
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridViewDrivers).EndInit();
|
|
||||||
panelFormDriversButtons.ResumeLayout(false);
|
|
||||||
ResumeLayout(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private DataGridView dataGridViewDrivers;
|
|
||||||
private Panel panelFormDriversButtons;
|
|
||||||
private Button buttonUpdateDriver;
|
|
||||||
private Button buttonDeleteDriver;
|
|
||||||
private Button buttonAddDriver;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,112 +0,0 @@
|
|||||||
using ProjectGarage.Repositories;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Data;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
using Unity;
|
|
||||||
|
|
||||||
namespace ProjectGarage.Forms
|
|
||||||
{
|
|
||||||
public partial class FormDrivers : Form
|
|
||||||
{
|
|
||||||
private readonly IUnityContainer _container;
|
|
||||||
private readonly IDriverRepository _driverRepository;
|
|
||||||
|
|
||||||
public FormDrivers(IUnityContainer container, IDriverRepository driverRepository)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_container = container ?? throw new ArgumentNullException(nameof(container));
|
|
||||||
_driverRepository = driverRepository ?? throw new ArgumentNullException(nameof(driverRepository));
|
|
||||||
}
|
|
||||||
private void FormDrivers_Load(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
LoadList();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при загрузке",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonAddDriver_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_container.Resolve<FormDriver>().ShowDialog();
|
|
||||||
LoadList();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при добавлении",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonUpdateDriver_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (!TryGetIdentifierFromSelectedRow(out var findId))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var form = _container.Resolve<FormDriver>();
|
|
||||||
form.Id = findId;
|
|
||||||
form.ShowDialog();
|
|
||||||
LoadList();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при изменении",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonDeleteDriver_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (!TryGetIdentifierFromSelectedRow(out var findId))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (MessageBox.Show("Удалить запись?", "Удаление",
|
|
||||||
MessageBoxButtons.YesNo) != DialogResult.Yes)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_driverRepository.DeleteDriver(findId);
|
|
||||||
LoadList();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при удалении",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void LoadList() => dataGridViewDrivers.DataSource = _driverRepository.ReadDrivers();
|
|
||||||
|
|
||||||
private bool TryGetIdentifierFromSelectedRow(out int id)
|
|
||||||
{
|
|
||||||
id = 0;
|
|
||||||
if (dataGridViewDrivers.SelectedRows.Count < 1)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Нет выбранной записи", "Ошибка",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
id = Convert.ToInt32(dataGridViewDrivers.SelectedRows[0].Cells["Id"].Value);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,120 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<root>
|
|
||||||
<!--
|
|
||||||
Microsoft ResX Schema
|
|
||||||
|
|
||||||
Version 2.0
|
|
||||||
|
|
||||||
The primary goals of this format is to allow a simple XML format
|
|
||||||
that is mostly human readable. The generation and parsing of the
|
|
||||||
various data types are done through the TypeConverter classes
|
|
||||||
associated with the data types.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
... ado.net/XML headers & schema ...
|
|
||||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
|
||||||
<resheader name="version">2.0</resheader>
|
|
||||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
|
||||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
|
||||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
|
||||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
|
||||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
|
||||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
|
||||||
</data>
|
|
||||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
|
||||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
|
||||||
<comment>This is a comment</comment>
|
|
||||||
</data>
|
|
||||||
|
|
||||||
There are any number of "resheader" rows that contain simple
|
|
||||||
name/value pairs.
|
|
||||||
|
|
||||||
Each data row contains a name, and value. The row also contains a
|
|
||||||
type or mimetype. Type corresponds to a .NET class that support
|
|
||||||
text/value conversion through the TypeConverter architecture.
|
|
||||||
Classes that don't support this are serialized and stored with the
|
|
||||||
mimetype set.
|
|
||||||
|
|
||||||
The mimetype is used for serialized objects, and tells the
|
|
||||||
ResXResourceReader how to depersist the object. This is currently not
|
|
||||||
extensible. For a given mimetype the value must be set accordingly:
|
|
||||||
|
|
||||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
|
||||||
that the ResXResourceWriter will generate, however the reader can
|
|
||||||
read any of the formats listed below.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.binary.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.soap.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
|
||||||
value : The object must be serialized into a byte array
|
|
||||||
: using a System.ComponentModel.TypeConverter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
-->
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
</root>
|
|
144
ProjectGarage/Forms/FormFuel.Designer.cs
generated
@ -1,144 +0,0 @@
|
|||||||
namespace ProjectGarage.Forms
|
|
||||||
{
|
|
||||||
partial class FormFuel
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
checkedListBoxFuel = new CheckedListBox();
|
|
||||||
labelFuelType = new Label();
|
|
||||||
labelFuelName = new Label();
|
|
||||||
textBoxFuelName = new TextBox();
|
|
||||||
numericUpDownFuelPrice = new NumericUpDown();
|
|
||||||
labelFuelPrice = new Label();
|
|
||||||
buttonFuelSave = new Button();
|
|
||||||
buttonFuelCancel = new Button();
|
|
||||||
((System.ComponentModel.ISupportInitialize)numericUpDownFuelPrice).BeginInit();
|
|
||||||
SuspendLayout();
|
|
||||||
//
|
|
||||||
// checkedListBoxFuel
|
|
||||||
//
|
|
||||||
checkedListBoxFuel.FormattingEnabled = true;
|
|
||||||
checkedListBoxFuel.Location = new Point(121, 12);
|
|
||||||
checkedListBoxFuel.Name = "checkedListBoxFuel";
|
|
||||||
checkedListBoxFuel.Size = new Size(150, 114);
|
|
||||||
checkedListBoxFuel.TabIndex = 0;
|
|
||||||
//
|
|
||||||
// labelFuelType
|
|
||||||
//
|
|
||||||
labelFuelType.AutoSize = true;
|
|
||||||
labelFuelType.Location = new Point(12, 12);
|
|
||||||
labelFuelType.Name = "labelFuelType";
|
|
||||||
labelFuelType.Size = new Size(96, 20);
|
|
||||||
labelFuelType.TabIndex = 1;
|
|
||||||
labelFuelType.Text = "Тип топлива";
|
|
||||||
//
|
|
||||||
// labelFuelName
|
|
||||||
//
|
|
||||||
labelFuelName.AutoSize = true;
|
|
||||||
labelFuelName.Location = new Point(21, 138);
|
|
||||||
labelFuelName.Name = "labelFuelName";
|
|
||||||
labelFuelName.Size = new Size(77, 20);
|
|
||||||
labelFuelName.TabIndex = 2;
|
|
||||||
labelFuelName.Text = "Название";
|
|
||||||
//
|
|
||||||
// textBoxFuelName
|
|
||||||
//
|
|
||||||
textBoxFuelName.Location = new Point(121, 138);
|
|
||||||
textBoxFuelName.Name = "textBoxFuelName";
|
|
||||||
textBoxFuelName.Size = new Size(150, 27);
|
|
||||||
textBoxFuelName.TabIndex = 3;
|
|
||||||
//
|
|
||||||
// numericUpDownFuelPrice
|
|
||||||
//
|
|
||||||
numericUpDownFuelPrice.Location = new Point(121, 180);
|
|
||||||
numericUpDownFuelPrice.Minimum = new decimal(new int[] { 1, 0, 0, 0 });
|
|
||||||
numericUpDownFuelPrice.Name = "numericUpDownFuelPrice";
|
|
||||||
numericUpDownFuelPrice.Size = new Size(150, 27);
|
|
||||||
numericUpDownFuelPrice.TabIndex = 4;
|
|
||||||
numericUpDownFuelPrice.Value = new decimal(new int[] { 1, 0, 0, 0 });
|
|
||||||
//
|
|
||||||
// labelFuelPrice
|
|
||||||
//
|
|
||||||
labelFuelPrice.AutoSize = true;
|
|
||||||
labelFuelPrice.Location = new Point(8, 182);
|
|
||||||
labelFuelPrice.Name = "labelFuelPrice";
|
|
||||||
labelFuelPrice.Size = new Size(100, 20);
|
|
||||||
labelFuelPrice.TabIndex = 5;
|
|
||||||
labelFuelPrice.Text = "Цена за литр";
|
|
||||||
//
|
|
||||||
// buttonFuelSave
|
|
||||||
//
|
|
||||||
buttonFuelSave.Location = new Point(8, 219);
|
|
||||||
buttonFuelSave.Name = "buttonFuelSave";
|
|
||||||
buttonFuelSave.Size = new Size(121, 29);
|
|
||||||
buttonFuelSave.TabIndex = 6;
|
|
||||||
buttonFuelSave.Text = "Сохранить";
|
|
||||||
buttonFuelSave.UseVisualStyleBackColor = true;
|
|
||||||
buttonFuelSave.Click += ButtonFuelSave_Click;
|
|
||||||
//
|
|
||||||
// buttonFuelCancel
|
|
||||||
//
|
|
||||||
buttonFuelCancel.Location = new Point(152, 219);
|
|
||||||
buttonFuelCancel.Name = "buttonFuelCancel";
|
|
||||||
buttonFuelCancel.Size = new Size(119, 29);
|
|
||||||
buttonFuelCancel.TabIndex = 7;
|
|
||||||
buttonFuelCancel.Text = "Отмена";
|
|
||||||
buttonFuelCancel.UseVisualStyleBackColor = true;
|
|
||||||
buttonFuelCancel.Click += ButtonFuelCancel_Click;
|
|
||||||
//
|
|
||||||
// FormFuel
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
|
||||||
ClientSize = new Size(292, 260);
|
|
||||||
Controls.Add(buttonFuelCancel);
|
|
||||||
Controls.Add(buttonFuelSave);
|
|
||||||
Controls.Add(labelFuelPrice);
|
|
||||||
Controls.Add(numericUpDownFuelPrice);
|
|
||||||
Controls.Add(textBoxFuelName);
|
|
||||||
Controls.Add(labelFuelName);
|
|
||||||
Controls.Add(labelFuelType);
|
|
||||||
Controls.Add(checkedListBoxFuel);
|
|
||||||
Name = "FormFuel";
|
|
||||||
Text = "FormFuel";
|
|
||||||
((System.ComponentModel.ISupportInitialize)numericUpDownFuelPrice).EndInit();
|
|
||||||
ResumeLayout(false);
|
|
||||||
PerformLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private CheckedListBox checkedListBoxFuel;
|
|
||||||
private Label labelFuelType;
|
|
||||||
private Label labelFuelName;
|
|
||||||
private TextBox textBoxFuelName;
|
|
||||||
private NumericUpDown numericUpDownFuelPrice;
|
|
||||||
private Label labelFuelPrice;
|
|
||||||
private Button buttonFuelSave;
|
|
||||||
private Button buttonFuelCancel;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,103 +0,0 @@
|
|||||||
using Microsoft.VisualBasic.FileIO;
|
|
||||||
using ProjectGarage.Entities;
|
|
||||||
using ProjectGarage.Entities.Enums;
|
|
||||||
using ProjectGarage.Repositories;
|
|
||||||
using ProjectGarage.Repositories.Implementations;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Data;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
namespace ProjectGarage.Forms
|
|
||||||
{
|
|
||||||
public partial class FormFuel : Form
|
|
||||||
{
|
|
||||||
private readonly IFuelRepository _fuelRepository;
|
|
||||||
|
|
||||||
private int? _fuelId;
|
|
||||||
|
|
||||||
public int Id
|
|
||||||
{
|
|
||||||
set
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var fuel = _fuelRepository.ReadFuelByID(value);
|
|
||||||
if (fuel == null)
|
|
||||||
{
|
|
||||||
throw new InvalidDataException(nameof(fuel));
|
|
||||||
}
|
|
||||||
foreach (FuelType elem in Enum.GetValues(typeof(FuelType)))
|
|
||||||
{
|
|
||||||
if ((elem & fuel.FuelType) != 0)
|
|
||||||
{
|
|
||||||
checkedListBoxFuel.SetItemChecked(checkedListBoxFuel.Items.IndexOf(elem), true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
textBoxFuelName.Text = fuel.FuelName;
|
|
||||||
numericUpDownFuelPrice.Value = fuel.Price;
|
|
||||||
_fuelId = value;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public FormFuel(IFuelRepository fuelRepository)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_fuelRepository = fuelRepository ?? throw new ArgumentNullException(nameof(fuelRepository));
|
|
||||||
foreach (var elem in Enum.GetValues(typeof(FuelType)))
|
|
||||||
{
|
|
||||||
checkedListBoxFuel.Items.Add(elem);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonFuelSave_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (string.IsNullOrWhiteSpace(textBoxFuelName.Text) ||
|
|
||||||
checkedListBoxFuel.CheckedItems.Count == 0)
|
|
||||||
{
|
|
||||||
throw new Exception("Имеются незаполненные поля");
|
|
||||||
}
|
|
||||||
if (_fuelId.HasValue)
|
|
||||||
{
|
|
||||||
_fuelRepository.UpdateFuel(CreateFuel(_fuelId.Value));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_fuelRepository.CreateFuel(CreateFuel(0));
|
|
||||||
}
|
|
||||||
Close();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при сохранении",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonFuelCancel_Click(object sender, EventArgs e) => Close();
|
|
||||||
|
|
||||||
private Fuel CreateFuel(int id)
|
|
||||||
{
|
|
||||||
FuelType fuelType = FuelType.None;
|
|
||||||
foreach (var elem in checkedListBoxFuel.CheckedItems)
|
|
||||||
{
|
|
||||||
fuelType |= (FuelType)elem;
|
|
||||||
}
|
|
||||||
return Fuel.CreateFuel(id, textBoxFuelName.Text, fuelType, Convert.ToInt32(numericUpDownFuelPrice.Value));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
162
ProjectGarage/Forms/FormFuelReport.Designer.cs
generated
@ -1,162 +0,0 @@
|
|||||||
namespace ProjectGarage.Forms
|
|
||||||
{
|
|
||||||
partial class FormFuelReport
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
dateTimePickerStart = new DateTimePicker();
|
|
||||||
dateTimePickerFinal = new DateTimePicker();
|
|
||||||
buttonMakeReport = new Button();
|
|
||||||
labelPathToFile = new Label();
|
|
||||||
labelFuel = new Label();
|
|
||||||
labelDateStart = new Label();
|
|
||||||
label4 = new Label();
|
|
||||||
buttonSelectFilePath = new Button();
|
|
||||||
textBoxFilePath = new TextBox();
|
|
||||||
comboBoxFuelReport = new ComboBox();
|
|
||||||
SuspendLayout();
|
|
||||||
//
|
|
||||||
// dateTimePickerStart
|
|
||||||
//
|
|
||||||
dateTimePickerStart.Location = new Point(180, 150);
|
|
||||||
dateTimePickerStart.Name = "dateTimePickerStart";
|
|
||||||
dateTimePickerStart.Size = new Size(250, 27);
|
|
||||||
dateTimePickerStart.TabIndex = 0;
|
|
||||||
//
|
|
||||||
// dateTimePickerFinal
|
|
||||||
//
|
|
||||||
dateTimePickerFinal.Location = new Point(180, 201);
|
|
||||||
dateTimePickerFinal.Name = "dateTimePickerFinal";
|
|
||||||
dateTimePickerFinal.Size = new Size(250, 27);
|
|
||||||
dateTimePickerFinal.TabIndex = 1;
|
|
||||||
//
|
|
||||||
// buttonMakeReport
|
|
||||||
//
|
|
||||||
buttonMakeReport.Location = new Point(141, 249);
|
|
||||||
buttonMakeReport.Name = "buttonMakeReport";
|
|
||||||
buttonMakeReport.Size = new Size(145, 38);
|
|
||||||
buttonMakeReport.TabIndex = 2;
|
|
||||||
buttonMakeReport.Text = "Сформировать";
|
|
||||||
buttonMakeReport.UseVisualStyleBackColor = true;
|
|
||||||
buttonMakeReport.Click += ButtonMakeReport_Click;
|
|
||||||
//
|
|
||||||
// labelPathToFile
|
|
||||||
//
|
|
||||||
labelPathToFile.AutoSize = true;
|
|
||||||
labelPathToFile.Location = new Point(34, 44);
|
|
||||||
labelPathToFile.Name = "labelPathToFile";
|
|
||||||
labelPathToFile.Size = new Size(112, 20);
|
|
||||||
labelPathToFile.TabIndex = 3;
|
|
||||||
labelPathToFile.Text = "Путь до файла:";
|
|
||||||
//
|
|
||||||
// labelFuel
|
|
||||||
//
|
|
||||||
labelFuel.AutoSize = true;
|
|
||||||
labelFuel.Location = new Point(34, 94);
|
|
||||||
labelFuel.Name = "labelFuel";
|
|
||||||
labelFuel.Size = new Size(72, 20);
|
|
||||||
labelFuel.TabIndex = 4;
|
|
||||||
labelFuel.Text = "Топливо:";
|
|
||||||
//
|
|
||||||
// labelDateStart
|
|
||||||
//
|
|
||||||
labelDateStart.AutoSize = true;
|
|
||||||
labelDateStart.Location = new Point(34, 150);
|
|
||||||
labelDateStart.Name = "labelDateStart";
|
|
||||||
labelDateStart.Size = new Size(97, 20);
|
|
||||||
labelDateStart.TabIndex = 5;
|
|
||||||
labelDateStart.Text = "Дата начала:";
|
|
||||||
//
|
|
||||||
// label4
|
|
||||||
//
|
|
||||||
label4.AutoSize = true;
|
|
||||||
label4.Location = new Point(34, 201);
|
|
||||||
label4.Name = "label4";
|
|
||||||
label4.Size = new Size(90, 20);
|
|
||||||
label4.TabIndex = 6;
|
|
||||||
label4.Text = "Дата конца:";
|
|
||||||
//
|
|
||||||
// buttonSelectFilePath
|
|
||||||
//
|
|
||||||
buttonSelectFilePath.Location = new Point(405, 44);
|
|
||||||
buttonSelectFilePath.Name = "buttonSelectFilePath";
|
|
||||||
buttonSelectFilePath.Size = new Size(25, 24);
|
|
||||||
buttonSelectFilePath.TabIndex = 7;
|
|
||||||
buttonSelectFilePath.Text = "...";
|
|
||||||
buttonSelectFilePath.UseVisualStyleBackColor = true;
|
|
||||||
buttonSelectFilePath.Click += ButtonSelectFilePath_Click;
|
|
||||||
//
|
|
||||||
// textBoxFilePath
|
|
||||||
//
|
|
||||||
textBoxFilePath.Location = new Point(180, 43);
|
|
||||||
textBoxFilePath.Name = "textBoxFilePath";
|
|
||||||
textBoxFilePath.Size = new Size(219, 27);
|
|
||||||
textBoxFilePath.TabIndex = 8;
|
|
||||||
//
|
|
||||||
// comboBoxFuelReport
|
|
||||||
//
|
|
||||||
comboBoxFuelReport.FormattingEnabled = true;
|
|
||||||
comboBoxFuelReport.Location = new Point(180, 94);
|
|
||||||
comboBoxFuelReport.Name = "comboBoxFuelReport";
|
|
||||||
comboBoxFuelReport.Size = new Size(250, 28);
|
|
||||||
comboBoxFuelReport.TabIndex = 9;
|
|
||||||
//
|
|
||||||
// FormFuelReport
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
|
||||||
ClientSize = new Size(454, 311);
|
|
||||||
Controls.Add(comboBoxFuelReport);
|
|
||||||
Controls.Add(textBoxFilePath);
|
|
||||||
Controls.Add(buttonSelectFilePath);
|
|
||||||
Controls.Add(label4);
|
|
||||||
Controls.Add(labelDateStart);
|
|
||||||
Controls.Add(labelFuel);
|
|
||||||
Controls.Add(labelPathToFile);
|
|
||||||
Controls.Add(buttonMakeReport);
|
|
||||||
Controls.Add(dateTimePickerFinal);
|
|
||||||
Controls.Add(dateTimePickerStart);
|
|
||||||
Name = "FormFuelReport";
|
|
||||||
Text = "FormFuelReport";
|
|
||||||
ResumeLayout(false);
|
|
||||||
PerformLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private DateTimePicker dateTimePickerStart;
|
|
||||||
private DateTimePicker dateTimePickerFinal;
|
|
||||||
private Button buttonMakeReport;
|
|
||||||
private Label labelPathToFile;
|
|
||||||
private Label labelFuel;
|
|
||||||
private Label labelDateStart;
|
|
||||||
private Label label4;
|
|
||||||
private Button buttonSelectFilePath;
|
|
||||||
private TextBox textBoxFilePath;
|
|
||||||
private ComboBox comboBoxFuelReport;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,82 +0,0 @@
|
|||||||
using ProjectGarage.Reports;
|
|
||||||
using ProjectGarage.Repositories;
|
|
||||||
using ProjectGarage.Repositories.Implementations;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Data;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
using Unity;
|
|
||||||
|
|
||||||
namespace ProjectGarage.Forms
|
|
||||||
{
|
|
||||||
public partial class FormFuelReport : Form
|
|
||||||
{
|
|
||||||
private readonly IUnityContainer _container;
|
|
||||||
|
|
||||||
public FormFuelReport(IUnityContainer container, IFuelRepository fuelRepository)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_container = container ?? throw new ArgumentNullException(nameof(container));
|
|
||||||
comboBoxFuelReport.DataSource = fuelRepository.ReadFuels();
|
|
||||||
comboBoxFuelReport.DisplayMember = "FuelName";
|
|
||||||
comboBoxFuelReport.ValueMember = "Id";
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonMakeReport_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (string.IsNullOrWhiteSpace(textBoxFilePath.Text))
|
|
||||||
{
|
|
||||||
throw new Exception("Отсутствует имя файла для отчета");
|
|
||||||
}
|
|
||||||
if (comboBoxFuelReport.SelectedIndex < 0)
|
|
||||||
{
|
|
||||||
throw new Exception("Не выбран корм");
|
|
||||||
}
|
|
||||||
if (dateTimePickerFinal.Value <= dateTimePickerStart.Value)
|
|
||||||
{
|
|
||||||
throw new Exception("Дата начала должна быть раньше даты окончания");
|
|
||||||
}
|
|
||||||
if (_container.Resolve<TableReport>().CreateTable(textBoxFilePath.Text,
|
|
||||||
(int)comboBoxFuelReport.SelectedValue!,
|
|
||||||
dateTimePickerStart.Value, dateTimePickerFinal.Value))
|
|
||||||
{
|
|
||||||
MessageBox.Show("Документ сформирован",
|
|
||||||
"Формирование документа",
|
|
||||||
MessageBoxButtons.OK,
|
|
||||||
MessageBoxIcon.Information);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MessageBox.Show("Возникли ошибки при формировании документа.Подробности в логах",
|
|
||||||
"Формирование документа",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при создании очета",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonSelectFilePath_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
var sfd = new SaveFileDialog()
|
|
||||||
{
|
|
||||||
Filter = "Excel Files | *.xlsx"
|
|
||||||
};
|
|
||||||
if (sfd.ShowDialog() != DialogResult.OK)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
textBoxFilePath.Text = sfd.FileName;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,120 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<root>
|
|
||||||
<!--
|
|
||||||
Microsoft ResX Schema
|
|
||||||
|
|
||||||
Version 2.0
|
|
||||||
|
|
||||||
The primary goals of this format is to allow a simple XML format
|
|
||||||
that is mostly human readable. The generation and parsing of the
|
|
||||||
various data types are done through the TypeConverter classes
|
|
||||||
associated with the data types.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
... ado.net/XML headers & schema ...
|
|
||||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
|
||||||
<resheader name="version">2.0</resheader>
|
|
||||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
|
||||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
|
||||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
|
||||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
|
||||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
|
||||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
|
||||||
</data>
|
|
||||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
|
||||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
|
||||||
<comment>This is a comment</comment>
|
|
||||||
</data>
|
|
||||||
|
|
||||||
There are any number of "resheader" rows that contain simple
|
|
||||||
name/value pairs.
|
|
||||||
|
|
||||||
Each data row contains a name, and value. The row also contains a
|
|
||||||
type or mimetype. Type corresponds to a .NET class that support
|
|
||||||
text/value conversion through the TypeConverter architecture.
|
|
||||||
Classes that don't support this are serialized and stored with the
|
|
||||||
mimetype set.
|
|
||||||
|
|
||||||
The mimetype is used for serialized objects, and tells the
|
|
||||||
ResXResourceReader how to depersist the object. This is currently not
|
|
||||||
extensible. For a given mimetype the value must be set accordingly:
|
|
||||||
|
|
||||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
|
||||||
that the ResXResourceWriter will generate, however the reader can
|
|
||||||
read any of the formats listed below.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.binary.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.soap.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
|
||||||
value : The object must be serialized into a byte array
|
|
||||||
: using a System.ComponentModel.TypeConverter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
-->
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
</root>
|
|
125
ProjectGarage/Forms/FormFuels.Designer.cs
generated
@ -1,125 +0,0 @@
|
|||||||
namespace ProjectGarage.Forms
|
|
||||||
{
|
|
||||||
partial class FormFuels
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
dataGridViewFuels = new DataGridView();
|
|
||||||
panelFormFuelsButtons = new Panel();
|
|
||||||
buttonUpdateFuel = new Button();
|
|
||||||
buttonDeleteFuel = new Button();
|
|
||||||
buttonAddFuel = new Button();
|
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridViewFuels).BeginInit();
|
|
||||||
panelFormFuelsButtons.SuspendLayout();
|
|
||||||
SuspendLayout();
|
|
||||||
//
|
|
||||||
// dataGridViewFuels
|
|
||||||
//
|
|
||||||
dataGridViewFuels.AllowUserToAddRows = false;
|
|
||||||
dataGridViewFuels.AllowUserToDeleteRows = false;
|
|
||||||
dataGridViewFuels.AllowUserToResizeColumns = false;
|
|
||||||
dataGridViewFuels.AllowUserToResizeRows = false;
|
|
||||||
dataGridViewFuels.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
|
||||||
dataGridViewFuels.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
|
||||||
dataGridViewFuels.Dock = DockStyle.Fill;
|
|
||||||
dataGridViewFuels.Location = new Point(0, 0);
|
|
||||||
dataGridViewFuels.Name = "dataGridViewFuels";
|
|
||||||
dataGridViewFuels.ReadOnly = true;
|
|
||||||
dataGridViewFuels.RowHeadersVisible = false;
|
|
||||||
dataGridViewFuels.RowHeadersWidth = 51;
|
|
||||||
dataGridViewFuels.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
|
||||||
dataGridViewFuels.Size = new Size(648, 367);
|
|
||||||
dataGridViewFuels.TabIndex = 5;
|
|
||||||
//
|
|
||||||
// panelFormFuelsButtons
|
|
||||||
//
|
|
||||||
panelFormFuelsButtons.Controls.Add(buttonUpdateFuel);
|
|
||||||
panelFormFuelsButtons.Controls.Add(buttonDeleteFuel);
|
|
||||||
panelFormFuelsButtons.Controls.Add(buttonAddFuel);
|
|
||||||
panelFormFuelsButtons.Dock = DockStyle.Right;
|
|
||||||
panelFormFuelsButtons.Location = new Point(648, 0);
|
|
||||||
panelFormFuelsButtons.Name = "panelFormFuelsButtons";
|
|
||||||
panelFormFuelsButtons.Size = new Size(161, 367);
|
|
||||||
panelFormFuelsButtons.TabIndex = 4;
|
|
||||||
//
|
|
||||||
// buttonUpdateFuel
|
|
||||||
//
|
|
||||||
buttonUpdateFuel.BackgroundImage = Properties.Resources.каранд;
|
|
||||||
buttonUpdateFuel.BackgroundImageLayout = ImageLayout.Stretch;
|
|
||||||
buttonUpdateFuel.Location = new Point(35, 140);
|
|
||||||
buttonUpdateFuel.Name = "buttonUpdateFuel";
|
|
||||||
buttonUpdateFuel.Size = new Size(94, 75);
|
|
||||||
buttonUpdateFuel.TabIndex = 2;
|
|
||||||
buttonUpdateFuel.UseVisualStyleBackColor = true;
|
|
||||||
buttonUpdateFuel.Click += ButtonUpdateFuel_Click;
|
|
||||||
//
|
|
||||||
// buttonDeleteFuel
|
|
||||||
//
|
|
||||||
buttonDeleteFuel.BackgroundImage = Properties.Resources.минусик;
|
|
||||||
buttonDeleteFuel.BackgroundImageLayout = ImageLayout.Stretch;
|
|
||||||
buttonDeleteFuel.Location = new Point(35, 249);
|
|
||||||
buttonDeleteFuel.Name = "buttonDeleteFuel";
|
|
||||||
buttonDeleteFuel.Size = new Size(94, 78);
|
|
||||||
buttonDeleteFuel.TabIndex = 1;
|
|
||||||
buttonDeleteFuel.UseVisualStyleBackColor = true;
|
|
||||||
buttonDeleteFuel.Click += ButtonDeleteFuel_Click;
|
|
||||||
//
|
|
||||||
// buttonAddFuel
|
|
||||||
//
|
|
||||||
buttonAddFuel.BackgroundImage = Properties.Resources.плюсик;
|
|
||||||
buttonAddFuel.BackgroundImageLayout = ImageLayout.Stretch;
|
|
||||||
buttonAddFuel.Location = new Point(35, 23);
|
|
||||||
buttonAddFuel.Name = "buttonAddFuel";
|
|
||||||
buttonAddFuel.Size = new Size(94, 75);
|
|
||||||
buttonAddFuel.TabIndex = 0;
|
|
||||||
buttonAddFuel.UseVisualStyleBackColor = true;
|
|
||||||
buttonAddFuel.Click += ButtonAddFuel_Click;
|
|
||||||
//
|
|
||||||
// FormFuels
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
|
||||||
ClientSize = new Size(809, 367);
|
|
||||||
Controls.Add(dataGridViewFuels);
|
|
||||||
Controls.Add(panelFormFuelsButtons);
|
|
||||||
Name = "FormFuels";
|
|
||||||
Text = "FormFuels";
|
|
||||||
Load += FormFeeds_Load;
|
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridViewFuels).EndInit();
|
|
||||||
panelFormFuelsButtons.ResumeLayout(false);
|
|
||||||
ResumeLayout(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private DataGridView dataGridViewFuels;
|
|
||||||
private Panel panelFormFuelsButtons;
|
|
||||||
private Button buttonUpdateFuel;
|
|
||||||
private Button buttonDeleteFuel;
|
|
||||||
private Button buttonAddFuel;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,114 +0,0 @@
|
|||||||
using ProjectGarage.Repositories;
|
|
||||||
using ProjectGarage.Repositories.Implementations;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Data;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
using Unity;
|
|
||||||
|
|
||||||
namespace ProjectGarage.Forms
|
|
||||||
{
|
|
||||||
public partial class FormFuels : Form
|
|
||||||
{
|
|
||||||
private readonly IUnityContainer _container;
|
|
||||||
private readonly IFuelRepository _fuelRepository;
|
|
||||||
|
|
||||||
public FormFuels(IUnityContainer container, IFuelRepository fuelRepository)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_container = container ?? throw new ArgumentNullException(nameof(container));
|
|
||||||
_fuelRepository = fuelRepository ?? throw new ArgumentNullException(nameof(fuelRepository));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void FormFeeds_Load(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
LoadList();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при загрузке",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonAddFuel_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_container.Resolve<FormFuel>().ShowDialog();
|
|
||||||
LoadList();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при добавлении",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonUpdateFuel_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (!TryGetIdentifierFromSelectedRow(out var findId))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var form = _container.Resolve<FormFuel>();
|
|
||||||
form.Id = findId;
|
|
||||||
form.ShowDialog();
|
|
||||||
LoadList();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при изменении",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonDeleteFuel_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (!TryGetIdentifierFromSelectedRow(out var findId))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (MessageBox.Show("Удалить запись?", "Удаление",
|
|
||||||
MessageBoxButtons.YesNo) != DialogResult.Yes)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_fuelRepository.DeleteFuel(findId);
|
|
||||||
LoadList();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при удалении",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void LoadList() => dataGridViewFuels.DataSource = _fuelRepository.ReadFuels();
|
|
||||||
|
|
||||||
private bool TryGetIdentifierFromSelectedRow(out int id)
|
|
||||||
{
|
|
||||||
id = 0;
|
|
||||||
if (dataGridViewFuels.SelectedRows.Count < 1)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Нет выбранной записи", "Ошибка",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
id = Convert.ToInt32(dataGridViewFuels.SelectedRows[0].Cells["Id"].Value);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,120 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<root>
|
|
||||||
<!--
|
|
||||||
Microsoft ResX Schema
|
|
||||||
|
|
||||||
Version 2.0
|
|
||||||
|
|
||||||
The primary goals of this format is to allow a simple XML format
|
|
||||||
that is mostly human readable. The generation and parsing of the
|
|
||||||
various data types are done through the TypeConverter classes
|
|
||||||
associated with the data types.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
... ado.net/XML headers & schema ...
|
|
||||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
|
||||||
<resheader name="version">2.0</resheader>
|
|
||||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
|
||||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
|
||||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
|
||||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
|
||||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
|
||||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
|
||||||
</data>
|
|
||||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
|
||||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
|
||||||
<comment>This is a comment</comment>
|
|
||||||
</data>
|
|
||||||
|
|
||||||
There are any number of "resheader" rows that contain simple
|
|
||||||
name/value pairs.
|
|
||||||
|
|
||||||
Each data row contains a name, and value. The row also contains a
|
|
||||||
type or mimetype. Type corresponds to a .NET class that support
|
|
||||||
text/value conversion through the TypeConverter architecture.
|
|
||||||
Classes that don't support this are serialized and stored with the
|
|
||||||
mimetype set.
|
|
||||||
|
|
||||||
The mimetype is used for serialized objects, and tells the
|
|
||||||
ResXResourceReader how to depersist the object. This is currently not
|
|
||||||
extensible. For a given mimetype the value must be set accordingly:
|
|
||||||
|
|
||||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
|
||||||
that the ResXResourceWriter will generate, however the reader can
|
|
||||||
read any of the formats listed below.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.binary.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.soap.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
|
||||||
value : The object must be serialized into a byte array
|
|
||||||
: using a System.ComponentModel.TypeConverter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
-->
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
</root>
|
|
148
ProjectGarage/Forms/FormReplenishment.Designer.cs
generated
@ -1,148 +0,0 @@
|
|||||||
namespace ProjectGarage.Forms
|
|
||||||
{
|
|
||||||
partial class FormReplenishment
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
comboBoxReplenishmentDriver = new ComboBox();
|
|
||||||
labelReplenishmentDriver = new Label();
|
|
||||||
groupBoxReplenishment = new GroupBox();
|
|
||||||
dataGridViewReplenishment = new DataGridView();
|
|
||||||
ColumnFuel = new DataGridViewComboBoxColumn();
|
|
||||||
ColumnAmount = new DataGridViewTextBoxColumn();
|
|
||||||
ButtonReplenishmentSave = new Button();
|
|
||||||
ButtonReplenishmentCancel = new Button();
|
|
||||||
groupBoxReplenishment.SuspendLayout();
|
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridViewReplenishment).BeginInit();
|
|
||||||
SuspendLayout();
|
|
||||||
//
|
|
||||||
// comboBoxReplenishmentDriver
|
|
||||||
//
|
|
||||||
comboBoxReplenishmentDriver.DropDownStyle = ComboBoxStyle.DropDownList;
|
|
||||||
comboBoxReplenishmentDriver.FormattingEnabled = true;
|
|
||||||
comboBoxReplenishmentDriver.Location = new Point(141, 16);
|
|
||||||
comboBoxReplenishmentDriver.Name = "comboBoxReplenishmentDriver";
|
|
||||||
comboBoxReplenishmentDriver.Size = new Size(151, 28);
|
|
||||||
comboBoxReplenishmentDriver.TabIndex = 9;
|
|
||||||
//
|
|
||||||
// labelReplenishmentDriver
|
|
||||||
//
|
|
||||||
labelReplenishmentDriver.AutoSize = true;
|
|
||||||
labelReplenishmentDriver.Location = new Point(21, 19);
|
|
||||||
labelReplenishmentDriver.Name = "labelReplenishmentDriver";
|
|
||||||
labelReplenishmentDriver.Size = new Size(74, 20);
|
|
||||||
labelReplenishmentDriver.TabIndex = 8;
|
|
||||||
labelReplenishmentDriver.Text = "Водитель";
|
|
||||||
//
|
|
||||||
// groupBoxReplenishment
|
|
||||||
//
|
|
||||||
groupBoxReplenishment.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
|
||||||
groupBoxReplenishment.Controls.Add(dataGridViewReplenishment);
|
|
||||||
groupBoxReplenishment.Location = new Point(21, 66);
|
|
||||||
groupBoxReplenishment.Name = "groupBoxReplenishment";
|
|
||||||
groupBoxReplenishment.Size = new Size(271, 288);
|
|
||||||
groupBoxReplenishment.TabIndex = 10;
|
|
||||||
groupBoxReplenishment.TabStop = false;
|
|
||||||
groupBoxReplenishment.Text = "Пополнение топлива";
|
|
||||||
//
|
|
||||||
// dataGridViewReplenishment
|
|
||||||
//
|
|
||||||
dataGridViewReplenishment.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
|
||||||
dataGridViewReplenishment.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
|
||||||
dataGridViewReplenishment.Columns.AddRange(new DataGridViewColumn[] { ColumnFuel, ColumnAmount });
|
|
||||||
dataGridViewReplenishment.Dock = DockStyle.Fill;
|
|
||||||
dataGridViewReplenishment.Location = new Point(3, 23);
|
|
||||||
dataGridViewReplenishment.Name = "dataGridViewReplenishment";
|
|
||||||
dataGridViewReplenishment.RowHeadersVisible = false;
|
|
||||||
dataGridViewReplenishment.RowHeadersWidth = 51;
|
|
||||||
dataGridViewReplenishment.Size = new Size(265, 262);
|
|
||||||
dataGridViewReplenishment.TabIndex = 0;
|
|
||||||
//
|
|
||||||
// ColumnFuel
|
|
||||||
//
|
|
||||||
ColumnFuel.HeaderText = "Топливо";
|
|
||||||
ColumnFuel.MinimumWidth = 6;
|
|
||||||
ColumnFuel.Name = "ColumnFuel";
|
|
||||||
//
|
|
||||||
// ColumnAmount
|
|
||||||
//
|
|
||||||
ColumnAmount.HeaderText = "Кол-во";
|
|
||||||
ColumnAmount.MinimumWidth = 6;
|
|
||||||
ColumnAmount.Name = "ColumnAmount";
|
|
||||||
//
|
|
||||||
// ButtonReplenishmentSave
|
|
||||||
//
|
|
||||||
ButtonReplenishmentSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
|
||||||
ButtonReplenishmentSave.Location = new Point(21, 360);
|
|
||||||
ButtonReplenishmentSave.Name = "ButtonReplenishmentSave";
|
|
||||||
ButtonReplenishmentSave.Size = new Size(134, 29);
|
|
||||||
ButtonReplenishmentSave.TabIndex = 11;
|
|
||||||
ButtonReplenishmentSave.Text = "Сохранить";
|
|
||||||
ButtonReplenishmentSave.UseVisualStyleBackColor = true;
|
|
||||||
ButtonReplenishmentSave.Click += ButtonReplenishmentSave_Click;
|
|
||||||
//
|
|
||||||
// ButtonReplenishmentCancel
|
|
||||||
//
|
|
||||||
ButtonReplenishmentCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
|
||||||
ButtonReplenishmentCancel.Location = new Point(161, 360);
|
|
||||||
ButtonReplenishmentCancel.Name = "ButtonReplenishmentCancel";
|
|
||||||
ButtonReplenishmentCancel.Size = new Size(131, 29);
|
|
||||||
ButtonReplenishmentCancel.TabIndex = 13;
|
|
||||||
ButtonReplenishmentCancel.Text = "Отмена";
|
|
||||||
ButtonReplenishmentCancel.UseVisualStyleBackColor = true;
|
|
||||||
ButtonReplenishmentCancel.Click += ButtonReplenishmentCancel_Click;
|
|
||||||
//
|
|
||||||
// FormReplenishment
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
|
||||||
ClientSize = new Size(315, 401);
|
|
||||||
Controls.Add(ButtonReplenishmentCancel);
|
|
||||||
Controls.Add(ButtonReplenishmentSave);
|
|
||||||
Controls.Add(groupBoxReplenishment);
|
|
||||||
Controls.Add(comboBoxReplenishmentDriver);
|
|
||||||
Controls.Add(labelReplenishmentDriver);
|
|
||||||
Name = "FormReplenishment";
|
|
||||||
Text = "FormReplenishment";
|
|
||||||
groupBoxReplenishment.ResumeLayout(false);
|
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridViewReplenishment).EndInit();
|
|
||||||
ResumeLayout(false);
|
|
||||||
PerformLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private ComboBox comboBoxReplenishmentDriver;
|
|
||||||
private Label labelReplenishmentDriver;
|
|
||||||
private GroupBox groupBoxReplenishment;
|
|
||||||
private DataGridView dataGridViewReplenishment;
|
|
||||||
private Button ButtonReplenishmentSave;
|
|
||||||
private Button ButtonReplenishmentCancel;
|
|
||||||
private DataGridViewComboBoxColumn ColumnFuel;
|
|
||||||
private DataGridViewTextBoxColumn ColumnAmount;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,73 +0,0 @@
|
|||||||
using ProjectGarage.Entities;
|
|
||||||
using ProjectGarage.Repositories;
|
|
||||||
using ProjectGarage.Repositories.Implementations;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Data;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
namespace ProjectGarage.Forms
|
|
||||||
{
|
|
||||||
public partial class FormReplenishment : Form
|
|
||||||
{
|
|
||||||
private readonly IReplenishmentRepository _replenishmentRepository;
|
|
||||||
|
|
||||||
|
|
||||||
public FormReplenishment(IReplenishmentRepository replenishmentRepository,
|
|
||||||
IDriverRepository driverRepository, IFuelRepository fuelRepository)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_replenishmentRepository = replenishmentRepository ??
|
|
||||||
throw new ArgumentNullException(nameof(replenishmentRepository));
|
|
||||||
comboBoxReplenishmentDriver.DataSource = driverRepository.ReadDrivers();
|
|
||||||
comboBoxReplenishmentDriver.DisplayMember = "Fname";
|
|
||||||
comboBoxReplenishmentDriver.ValueMember = "Id";
|
|
||||||
ColumnFuel.DataSource = fuelRepository.ReadFuels();
|
|
||||||
ColumnFuel.DisplayMember = "FuelName";
|
|
||||||
ColumnFuel.ValueMember = "Id";
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonReplenishmentSave_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (dataGridViewReplenishment.RowCount < 1 ||
|
|
||||||
comboBoxReplenishmentDriver.SelectedIndex < 0)
|
|
||||||
{
|
|
||||||
throw new Exception("Имеются незаполненные поля");
|
|
||||||
}
|
|
||||||
_replenishmentRepository.CreateFuelReplenishment(FuelReplenishment.CreateOpeartion(0,
|
|
||||||
(int)comboBoxReplenishmentDriver.SelectedValue!, CreateListFuelFuelReplenishmentsFromDataGrid()));
|
|
||||||
Close();
|
|
||||||
}
|
|
||||||
catch(Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonReplenishmentCancel_Click(object sender, EventArgs e) => Close();
|
|
||||||
|
|
||||||
private List<FuelFuelReplenishment> CreateListFuelFuelReplenishmentsFromDataGrid()
|
|
||||||
{
|
|
||||||
var list = new List<FuelFuelReplenishment>();
|
|
||||||
foreach (DataGridViewRow row in dataGridViewReplenishment.Rows)
|
|
||||||
{
|
|
||||||
if (row.Cells["ColumnFuel"].Value == null ||
|
|
||||||
row.Cells["ColumnAmount"].Value == null)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
list.Add(FuelFuelReplenishment.CreateElement(0, Convert.ToInt32(row.Cells["ColumnFuel"].Value),
|
|
||||||
Convert.ToInt32(row.Cells["ColumnAmount"].Value)));
|
|
||||||
}
|
|
||||||
return list.GroupBy(x => x.FuelId, x => x.Amount,
|
|
||||||
(id, counts) => FuelFuelReplenishment.CreateElement(0, id, counts.Sum())).ToList();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,132 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<root>
|
|
||||||
<!--
|
|
||||||
Microsoft ResX Schema
|
|
||||||
|
|
||||||
Version 2.0
|
|
||||||
|
|
||||||
The primary goals of this format is to allow a simple XML format
|
|
||||||
that is mostly human readable. The generation and parsing of the
|
|
||||||
various data types are done through the TypeConverter classes
|
|
||||||
associated with the data types.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
... ado.net/XML headers & schema ...
|
|
||||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
|
||||||
<resheader name="version">2.0</resheader>
|
|
||||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
|
||||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
|
||||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
|
||||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
|
||||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
|
||||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
|
||||||
</data>
|
|
||||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
|
||||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
|
||||||
<comment>This is a comment</comment>
|
|
||||||
</data>
|
|
||||||
|
|
||||||
There are any number of "resheader" rows that contain simple
|
|
||||||
name/value pairs.
|
|
||||||
|
|
||||||
Each data row contains a name, and value. The row also contains a
|
|
||||||
type or mimetype. Type corresponds to a .NET class that support
|
|
||||||
text/value conversion through the TypeConverter architecture.
|
|
||||||
Classes that don't support this are serialized and stored with the
|
|
||||||
mimetype set.
|
|
||||||
|
|
||||||
The mimetype is used for serialized objects, and tells the
|
|
||||||
ResXResourceReader how to depersist the object. This is currently not
|
|
||||||
extensible. For a given mimetype the value must be set accordingly:
|
|
||||||
|
|
||||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
|
||||||
that the ResXResourceWriter will generate, however the reader can
|
|
||||||
read any of the formats listed below.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.binary.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.soap.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
|
||||||
value : The object must be serialized into a byte array
|
|
||||||
: using a System.ComponentModel.TypeConverter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
-->
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<metadata name="ColumnFuel.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
|
||||||
<value>True</value>
|
|
||||||
</metadata>
|
|
||||||
<metadata name="ColumnAmount.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
|
||||||
<value>True</value>
|
|
||||||
</metadata>
|
|
||||||
<metadata name="ColumnFuel.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
|
||||||
<value>True</value>
|
|
||||||
</metadata>
|
|
||||||
<metadata name="ColumnAmount.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
|
||||||
<value>True</value>
|
|
||||||
</metadata>
|
|
||||||
</root>
|
|
109
ProjectGarage/Forms/FormReplenishments.Designer.cs
generated
@ -1,109 +0,0 @@
|
|||||||
namespace ProjectGarage.Forms
|
|
||||||
{
|
|
||||||
partial class FormReplenishments
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Обязательная переменная конструктора.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Освободить все используемые ресурсы.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Код, автоматически созданный конструктором компонентов
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Требуемый метод для поддержки конструктора — не изменяйте
|
|
||||||
/// содержимое этого метода с помощью редактора кода.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
buttonAddReplenishment = new Button();
|
|
||||||
buttonDeleteReplenishment = new Button();
|
|
||||||
panelFormReplenishmentssButtons = new Panel();
|
|
||||||
dataGridViewReplenishments = new DataGridView();
|
|
||||||
panelFormReplenishmentssButtons.SuspendLayout();
|
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridViewReplenishments).BeginInit();
|
|
||||||
SuspendLayout();
|
|
||||||
//
|
|
||||||
// buttonAddReplenishment
|
|
||||||
//
|
|
||||||
buttonAddReplenishment.BackgroundImage = Properties.Resources.плюсик;
|
|
||||||
buttonAddReplenishment.BackgroundImageLayout = ImageLayout.Stretch;
|
|
||||||
buttonAddReplenishment.Location = new Point(35, 23);
|
|
||||||
buttonAddReplenishment.Name = "buttonAddReplenishment";
|
|
||||||
buttonAddReplenishment.Size = new Size(94, 75);
|
|
||||||
buttonAddReplenishment.TabIndex = 0;
|
|
||||||
buttonAddReplenishment.UseVisualStyleBackColor = true;
|
|
||||||
buttonAddReplenishment.Click += ButtonAddReplenishment_Click;
|
|
||||||
//
|
|
||||||
// buttonDeleteReplenishment
|
|
||||||
//
|
|
||||||
buttonDeleteReplenishment.BackgroundImage = Properties.Resources.минусик;
|
|
||||||
buttonDeleteReplenishment.BackgroundImageLayout = ImageLayout.Stretch;
|
|
||||||
buttonDeleteReplenishment.Location = new Point(35, 115);
|
|
||||||
buttonDeleteReplenishment.Name = "buttonDeleteReplenishment";
|
|
||||||
buttonDeleteReplenishment.Size = new Size(94, 78);
|
|
||||||
buttonDeleteReplenishment.TabIndex = 1;
|
|
||||||
buttonDeleteReplenishment.UseVisualStyleBackColor = true;
|
|
||||||
buttonDeleteReplenishment.Click += ButtonDeleteReplenishment_Click;
|
|
||||||
//
|
|
||||||
// panelFormReplenishmentssButtons
|
|
||||||
//
|
|
||||||
panelFormReplenishmentssButtons.Controls.Add(buttonDeleteReplenishment);
|
|
||||||
panelFormReplenishmentssButtons.Controls.Add(buttonAddReplenishment);
|
|
||||||
panelFormReplenishmentssButtons.Dock = DockStyle.Right;
|
|
||||||
panelFormReplenishmentssButtons.Location = new Point(641, 0);
|
|
||||||
panelFormReplenishmentssButtons.Name = "panelFormReplenishmentssButtons";
|
|
||||||
panelFormReplenishmentssButtons.Size = new Size(161, 406);
|
|
||||||
panelFormReplenishmentssButtons.TabIndex = 6;
|
|
||||||
//
|
|
||||||
// dataGridViewReplenishments
|
|
||||||
//
|
|
||||||
dataGridViewReplenishments.AllowUserToAddRows = false;
|
|
||||||
dataGridViewReplenishments.AllowUserToDeleteRows = false;
|
|
||||||
dataGridViewReplenishments.AllowUserToResizeColumns = false;
|
|
||||||
dataGridViewReplenishments.AllowUserToResizeRows = false;
|
|
||||||
dataGridViewReplenishments.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
|
||||||
dataGridViewReplenishments.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
|
||||||
dataGridViewReplenishments.Dock = DockStyle.Fill;
|
|
||||||
dataGridViewReplenishments.Location = new Point(0, 0);
|
|
||||||
dataGridViewReplenishments.Name = "dataGridViewReplenishments";
|
|
||||||
dataGridViewReplenishments.ReadOnly = true;
|
|
||||||
dataGridViewReplenishments.RowHeadersVisible = false;
|
|
||||||
dataGridViewReplenishments.RowHeadersWidth = 51;
|
|
||||||
dataGridViewReplenishments.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
|
||||||
dataGridViewReplenishments.Size = new Size(641, 406);
|
|
||||||
dataGridViewReplenishments.TabIndex = 7;
|
|
||||||
//
|
|
||||||
// FormReplenishments
|
|
||||||
//
|
|
||||||
ClientSize = new Size(802, 406);
|
|
||||||
Controls.Add(dataGridViewReplenishments);
|
|
||||||
Controls.Add(panelFormReplenishmentssButtons);
|
|
||||||
Name = "FormReplenishments";
|
|
||||||
Text = "Пополнения";
|
|
||||||
Load += FormReplenishments_Load;
|
|
||||||
panelFormReplenishmentssButtons.ResumeLayout(false);
|
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridViewReplenishments).EndInit();
|
|
||||||
ResumeLayout(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private Button buttonAddReplenishment;
|
|
||||||
private Button buttonDeleteReplenishment;
|
|
||||||
private Panel panelFormReplenishmentssButtons;
|
|
||||||
private DataGridView dataGridViewReplenishments;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,96 +0,0 @@
|
|||||||
using ProjectGarage.Repositories;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Unity;
|
|
||||||
|
|
||||||
namespace ProjectGarage.Forms
|
|
||||||
{
|
|
||||||
public partial class FormReplenishments : Form
|
|
||||||
{
|
|
||||||
private readonly IUnityContainer _container;
|
|
||||||
private readonly IReplenishmentRepository _replenishmentRepository;
|
|
||||||
|
|
||||||
public FormReplenishments(IUnityContainer container, IReplenishmentRepository replenishmentRepository)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_container = container ??
|
|
||||||
throw new ArgumentNullException(nameof(container));
|
|
||||||
_replenishmentRepository = replenishmentRepository ??
|
|
||||||
throw new ArgumentNullException(nameof(replenishmentRepository));
|
|
||||||
}
|
|
||||||
private void FormReplenishments_Load(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
LoadList();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при загрузке",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public FormReplenishments(IContainer container)
|
|
||||||
{
|
|
||||||
container.Add(this);
|
|
||||||
|
|
||||||
InitializeComponent();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonAddReplenishment_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_container.Resolve<FormReplenishment>().ShowDialog();
|
|
||||||
LoadList();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonDeleteReplenishment_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (!TryGetIdentifierFromSelectedRow(out var findId))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_replenishmentRepository.DeleteFuelReplenishment(findId);
|
|
||||||
LoadList();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при удалении",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void LoadList() => dataGridViewReplenishments.DataSource = _replenishmentRepository.ReadFuelReplenishment();
|
|
||||||
|
|
||||||
private bool TryGetIdentifierFromSelectedRow(out int id)
|
|
||||||
{
|
|
||||||
id = 0;
|
|
||||||
if (dataGridViewReplenishments.SelectedRows.Count < 1)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Нет выбранной записи", "Ошибка",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
id =
|
|
||||||
Convert.ToInt32(dataGridViewReplenishments.SelectedRows[0].Cells["Id"].Value);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,120 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<root>
|
|
||||||
<!--
|
|
||||||
Microsoft ResX Schema
|
|
||||||
|
|
||||||
Version 2.0
|
|
||||||
|
|
||||||
The primary goals of this format is to allow a simple XML format
|
|
||||||
that is mostly human readable. The generation and parsing of the
|
|
||||||
various data types are done through the TypeConverter classes
|
|
||||||
associated with the data types.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
... ado.net/XML headers & schema ...
|
|
||||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
|
||||||
<resheader name="version">2.0</resheader>
|
|
||||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
|
||||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
|
||||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
|
||||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
|
||||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
|
||||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
|
||||||
</data>
|
|
||||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
|
||||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
|
||||||
<comment>This is a comment</comment>
|
|
||||||
</data>
|
|
||||||
|
|
||||||
There are any number of "resheader" rows that contain simple
|
|
||||||
name/value pairs.
|
|
||||||
|
|
||||||
Each data row contains a name, and value. The row also contains a
|
|
||||||
type or mimetype. Type corresponds to a .NET class that support
|
|
||||||
text/value conversion through the TypeConverter architecture.
|
|
||||||
Classes that don't support this are serialized and stored with the
|
|
||||||
mimetype set.
|
|
||||||
|
|
||||||
The mimetype is used for serialized objects, and tells the
|
|
||||||
ResXResourceReader how to depersist the object. This is currently not
|
|
||||||
extensible. For a given mimetype the value must be set accordingly:
|
|
||||||
|
|
||||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
|
||||||
that the ResXResourceWriter will generate, however the reader can
|
|
||||||
read any of the formats listed below.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.binary.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.soap.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
|
||||||
value : The object must be serialized into a byte array
|
|
||||||
: using a System.ComponentModel.TypeConverter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
-->
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
</root>
|
|
166
ProjectGarage/Forms/FormRoute.Designer.cs
generated
@ -1,166 +0,0 @@
|
|||||||
namespace ProjectGarage.Forms
|
|
||||||
{
|
|
||||||
partial class FormRoute
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
labelRouteStart = new Label();
|
|
||||||
labelRouteFinal = new Label();
|
|
||||||
numericUpDownRouteLen = new NumericUpDown();
|
|
||||||
labelRouteLen = new Label();
|
|
||||||
buttonRouteSave = new Button();
|
|
||||||
buttonRouteFinal = new Button();
|
|
||||||
textBoxRouteStart = new TextBox();
|
|
||||||
textBoxRouteFinal = new TextBox();
|
|
||||||
textBoxRouteName = new TextBox();
|
|
||||||
labelRouteName = new Label();
|
|
||||||
((System.ComponentModel.ISupportInitialize)numericUpDownRouteLen).BeginInit();
|
|
||||||
SuspendLayout();
|
|
||||||
//
|
|
||||||
// labelRouteStart
|
|
||||||
//
|
|
||||||
labelRouteStart.AutoSize = true;
|
|
||||||
labelRouteStart.Location = new Point(22, 62);
|
|
||||||
labelRouteStart.Name = "labelRouteStart";
|
|
||||||
labelRouteStart.Size = new Size(135, 20);
|
|
||||||
labelRouteStart.TabIndex = 0;
|
|
||||||
labelRouteStart.Text = "Начало маршрута";
|
|
||||||
//
|
|
||||||
// labelRouteFinal
|
|
||||||
//
|
|
||||||
labelRouteFinal.AutoSize = true;
|
|
||||||
labelRouteFinal.Location = new Point(22, 104);
|
|
||||||
labelRouteFinal.Name = "labelRouteFinal";
|
|
||||||
labelRouteFinal.Size = new Size(127, 20);
|
|
||||||
labelRouteFinal.TabIndex = 1;
|
|
||||||
labelRouteFinal.Text = "Конец маршрута";
|
|
||||||
//
|
|
||||||
// numericUpDownRouteLen
|
|
||||||
//
|
|
||||||
numericUpDownRouteLen.Location = new Point(170, 145);
|
|
||||||
numericUpDownRouteLen.Maximum = new decimal(new int[] { 10000, 0, 0, 0 });
|
|
||||||
numericUpDownRouteLen.Minimum = new decimal(new int[] { 1, 0, 0, 0 });
|
|
||||||
numericUpDownRouteLen.Name = "numericUpDownRouteLen";
|
|
||||||
numericUpDownRouteLen.Size = new Size(150, 27);
|
|
||||||
numericUpDownRouteLen.TabIndex = 2;
|
|
||||||
numericUpDownRouteLen.Value = new decimal(new int[] { 1, 0, 0, 0 });
|
|
||||||
//
|
|
||||||
// labelRouteLen
|
|
||||||
//
|
|
||||||
labelRouteLen.AutoSize = true;
|
|
||||||
labelRouteLen.Location = new Point(22, 145);
|
|
||||||
labelRouteLen.Name = "labelRouteLen";
|
|
||||||
labelRouteLen.Size = new Size(127, 20);
|
|
||||||
labelRouteLen.TabIndex = 3;
|
|
||||||
labelRouteLen.Text = "Длина маршрута";
|
|
||||||
//
|
|
||||||
// buttonRouteSave
|
|
||||||
//
|
|
||||||
buttonRouteSave.Location = new Point(22, 191);
|
|
||||||
buttonRouteSave.Name = "buttonRouteSave";
|
|
||||||
buttonRouteSave.Size = new Size(135, 29);
|
|
||||||
buttonRouteSave.TabIndex = 4;
|
|
||||||
buttonRouteSave.Text = "Сохранить";
|
|
||||||
buttonRouteSave.UseVisualStyleBackColor = true;
|
|
||||||
buttonRouteSave.Click += ButtonRouteSave_Click;
|
|
||||||
//
|
|
||||||
// buttonRouteFinal
|
|
||||||
//
|
|
||||||
buttonRouteFinal.Location = new Point(170, 191);
|
|
||||||
buttonRouteFinal.Name = "buttonRouteFinal";
|
|
||||||
buttonRouteFinal.Size = new Size(150, 29);
|
|
||||||
buttonRouteFinal.TabIndex = 5;
|
|
||||||
buttonRouteFinal.Text = "Отмена";
|
|
||||||
buttonRouteFinal.UseVisualStyleBackColor = true;
|
|
||||||
buttonRouteFinal.Click += ButtonRouteFinal_Click;
|
|
||||||
//
|
|
||||||
// textBoxRouteStart
|
|
||||||
//
|
|
||||||
textBoxRouteStart.Location = new Point(170, 62);
|
|
||||||
textBoxRouteStart.Name = "textBoxRouteStart";
|
|
||||||
textBoxRouteStart.Size = new Size(150, 27);
|
|
||||||
textBoxRouteStart.TabIndex = 6;
|
|
||||||
//
|
|
||||||
// textBoxRouteFinal
|
|
||||||
//
|
|
||||||
textBoxRouteFinal.Location = new Point(170, 104);
|
|
||||||
textBoxRouteFinal.Name = "textBoxRouteFinal";
|
|
||||||
textBoxRouteFinal.Size = new Size(150, 27);
|
|
||||||
textBoxRouteFinal.TabIndex = 7;
|
|
||||||
//
|
|
||||||
// textBoxRouteName
|
|
||||||
//
|
|
||||||
textBoxRouteName.Location = new Point(179, 12);
|
|
||||||
textBoxRouteName.Name = "textBoxRouteName";
|
|
||||||
textBoxRouteName.Size = new Size(141, 27);
|
|
||||||
textBoxRouteName.TabIndex = 9;
|
|
||||||
//
|
|
||||||
// labelRouteName
|
|
||||||
//
|
|
||||||
labelRouteName.AutoSize = true;
|
|
||||||
labelRouteName.Location = new Point(22, 19);
|
|
||||||
labelRouteName.Name = "labelRouteName";
|
|
||||||
labelRouteName.Size = new Size(151, 20);
|
|
||||||
labelRouteName.TabIndex = 8;
|
|
||||||
labelRouteName.Text = "Название маршрута";
|
|
||||||
//
|
|
||||||
// FormRoute
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
|
||||||
ClientSize = new Size(332, 240);
|
|
||||||
Controls.Add(textBoxRouteName);
|
|
||||||
Controls.Add(labelRouteName);
|
|
||||||
Controls.Add(textBoxRouteFinal);
|
|
||||||
Controls.Add(textBoxRouteStart);
|
|
||||||
Controls.Add(buttonRouteFinal);
|
|
||||||
Controls.Add(buttonRouteSave);
|
|
||||||
Controls.Add(labelRouteLen);
|
|
||||||
Controls.Add(numericUpDownRouteLen);
|
|
||||||
Controls.Add(labelRouteFinal);
|
|
||||||
Controls.Add(labelRouteStart);
|
|
||||||
Name = "FormRoute";
|
|
||||||
Text = "FormRoute";
|
|
||||||
((System.ComponentModel.ISupportInitialize)numericUpDownRouteLen).EndInit();
|
|
||||||
ResumeLayout(false);
|
|
||||||
PerformLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private Label labelRouteStart;
|
|
||||||
private Label labelRouteFinal;
|
|
||||||
private NumericUpDown numericUpDownRouteLen;
|
|
||||||
private Label labelRouteLen;
|
|
||||||
private Button buttonRouteSave;
|
|
||||||
private Button buttonRouteFinal;
|
|
||||||
private TextBox textBoxRouteStart;
|
|
||||||
private TextBox textBoxRouteFinal;
|
|
||||||
private TextBox textBoxRouteName;
|
|
||||||
private Label labelRouteName;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,86 +0,0 @@
|
|||||||
using ProjectGarage.Entities;
|
|
||||||
using ProjectGarage.Entities.Enums;
|
|
||||||
using ProjectGarage.Repositories;
|
|
||||||
using ProjectGarage.Repositories.Implementations;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Data;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
namespace ProjectGarage.Forms
|
|
||||||
{
|
|
||||||
public partial class FormRoute : Form
|
|
||||||
{
|
|
||||||
private readonly IRouteRepository _routeRepository;
|
|
||||||
private int? _routeId;
|
|
||||||
|
|
||||||
public int Id
|
|
||||||
{
|
|
||||||
set
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var route = _routeRepository.ReadRouteByID(value);
|
|
||||||
if (route == null)
|
|
||||||
{
|
|
||||||
throw new InvalidDataException(nameof(route));
|
|
||||||
}
|
|
||||||
|
|
||||||
textBoxRouteName.Text = route.RouteName;
|
|
||||||
textBoxRouteStart.Text = route.StartP;
|
|
||||||
textBoxRouteFinal.Text = route.FinalP;
|
|
||||||
numericUpDownRouteLen.Value = route.Length;
|
|
||||||
_routeId = value;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public FormRoute(IRouteRepository routeRepository)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_routeRepository = routeRepository ??
|
|
||||||
throw new ArgumentNullException(nameof(routeRepository));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonRouteSave_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (string.IsNullOrWhiteSpace(textBoxRouteStart.Text)
|
|
||||||
|| string.IsNullOrWhiteSpace(textBoxRouteFinal.Text))
|
|
||||||
{
|
|
||||||
throw new Exception("Имеются незаполненные поля");
|
|
||||||
}
|
|
||||||
if (_routeId.HasValue)
|
|
||||||
{
|
|
||||||
_routeRepository.UpdateRoute(CreateRoute(_routeId.Value));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_routeRepository.CreateRoute(CreateRoute(0));
|
|
||||||
}
|
|
||||||
Close();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonRouteFinal_Click(object sender, EventArgs e) => Close();
|
|
||||||
|
|
||||||
private Route CreateRoute(int id) => Route.CreateRoute(id, textBoxRouteName.Text, textBoxRouteStart.Text,
|
|
||||||
textBoxRouteFinal.Text, Convert.ToInt32(numericUpDownRouteLen.Value));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,120 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<root>
|
|
||||||
<!--
|
|
||||||
Microsoft ResX Schema
|
|
||||||
|
|
||||||
Version 2.0
|
|
||||||
|
|
||||||
The primary goals of this format is to allow a simple XML format
|
|
||||||
that is mostly human readable. The generation and parsing of the
|
|
||||||
various data types are done through the TypeConverter classes
|
|
||||||
associated with the data types.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
... ado.net/XML headers & schema ...
|
|
||||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
|
||||||
<resheader name="version">2.0</resheader>
|
|
||||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
|
||||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
|
||||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
|
||||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
|
||||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
|
||||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
|
||||||
</data>
|
|
||||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
|
||||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
|
||||||
<comment>This is a comment</comment>
|
|
||||||
</data>
|
|
||||||
|
|
||||||
There are any number of "resheader" rows that contain simple
|
|
||||||
name/value pairs.
|
|
||||||
|
|
||||||
Each data row contains a name, and value. The row also contains a
|
|
||||||
type or mimetype. Type corresponds to a .NET class that support
|
|
||||||
text/value conversion through the TypeConverter architecture.
|
|
||||||
Classes that don't support this are serialized and stored with the
|
|
||||||
mimetype set.
|
|
||||||
|
|
||||||
The mimetype is used for serialized objects, and tells the
|
|
||||||
ResXResourceReader how to depersist the object. This is currently not
|
|
||||||
extensible. For a given mimetype the value must be set accordingly:
|
|
||||||
|
|
||||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
|
||||||
that the ResXResourceWriter will generate, however the reader can
|
|
||||||
read any of the formats listed below.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.binary.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.soap.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
|
||||||
value : The object must be serialized into a byte array
|
|
||||||
: using a System.ComponentModel.TypeConverter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
-->
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
</root>
|
|
125
ProjectGarage/Forms/FormRoutes.Designer.cs
generated
@ -1,125 +0,0 @@
|
|||||||
namespace ProjectGarage.Forms
|
|
||||||
{
|
|
||||||
partial class FormRoutes
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
dataGridViewRoutes = new DataGridView();
|
|
||||||
panelFormRoutesButtons = new Panel();
|
|
||||||
buttonUpdateRoute = new Button();
|
|
||||||
buttonDeleteRoute = new Button();
|
|
||||||
buttonAddRoute = new Button();
|
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridViewRoutes).BeginInit();
|
|
||||||
panelFormRoutesButtons.SuspendLayout();
|
|
||||||
SuspendLayout();
|
|
||||||
//
|
|
||||||
// dataGridViewRoutes
|
|
||||||
//
|
|
||||||
dataGridViewRoutes.AllowUserToAddRows = false;
|
|
||||||
dataGridViewRoutes.AllowUserToDeleteRows = false;
|
|
||||||
dataGridViewRoutes.AllowUserToResizeColumns = false;
|
|
||||||
dataGridViewRoutes.AllowUserToResizeRows = false;
|
|
||||||
dataGridViewRoutes.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
|
||||||
dataGridViewRoutes.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
|
||||||
dataGridViewRoutes.Dock = DockStyle.Fill;
|
|
||||||
dataGridViewRoutes.Location = new Point(0, 0);
|
|
||||||
dataGridViewRoutes.Name = "dataGridViewRoutes";
|
|
||||||
dataGridViewRoutes.ReadOnly = true;
|
|
||||||
dataGridViewRoutes.RowHeadersVisible = false;
|
|
||||||
dataGridViewRoutes.RowHeadersWidth = 51;
|
|
||||||
dataGridViewRoutes.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
|
||||||
dataGridViewRoutes.Size = new Size(584, 355);
|
|
||||||
dataGridViewRoutes.TabIndex = 5;
|
|
||||||
//
|
|
||||||
// panelFormRoutesButtons
|
|
||||||
//
|
|
||||||
panelFormRoutesButtons.Controls.Add(buttonUpdateRoute);
|
|
||||||
panelFormRoutesButtons.Controls.Add(buttonDeleteRoute);
|
|
||||||
panelFormRoutesButtons.Controls.Add(buttonAddRoute);
|
|
||||||
panelFormRoutesButtons.Dock = DockStyle.Right;
|
|
||||||
panelFormRoutesButtons.Location = new Point(584, 0);
|
|
||||||
panelFormRoutesButtons.Name = "panelFormRoutesButtons";
|
|
||||||
panelFormRoutesButtons.Size = new Size(161, 355);
|
|
||||||
panelFormRoutesButtons.TabIndex = 4;
|
|
||||||
//
|
|
||||||
// buttonUpdateRoute
|
|
||||||
//
|
|
||||||
buttonUpdateRoute.BackgroundImage = Properties.Resources.каранд;
|
|
||||||
buttonUpdateRoute.BackgroundImageLayout = ImageLayout.Stretch;
|
|
||||||
buttonUpdateRoute.Location = new Point(35, 140);
|
|
||||||
buttonUpdateRoute.Name = "buttonUpdateRoute";
|
|
||||||
buttonUpdateRoute.Size = new Size(94, 75);
|
|
||||||
buttonUpdateRoute.TabIndex = 2;
|
|
||||||
buttonUpdateRoute.UseVisualStyleBackColor = true;
|
|
||||||
buttonUpdateRoute.Click += ButtonUpdateRoute_Click;
|
|
||||||
//
|
|
||||||
// buttonDeleteRoute
|
|
||||||
//
|
|
||||||
buttonDeleteRoute.BackgroundImage = Properties.Resources.минусик;
|
|
||||||
buttonDeleteRoute.BackgroundImageLayout = ImageLayout.Stretch;
|
|
||||||
buttonDeleteRoute.Location = new Point(35, 249);
|
|
||||||
buttonDeleteRoute.Name = "buttonDeleteRoute";
|
|
||||||
buttonDeleteRoute.Size = new Size(94, 78);
|
|
||||||
buttonDeleteRoute.TabIndex = 1;
|
|
||||||
buttonDeleteRoute.UseVisualStyleBackColor = true;
|
|
||||||
buttonDeleteRoute.Click += ButtonDeleteRoute_Click;
|
|
||||||
//
|
|
||||||
// buttonAddRoute
|
|
||||||
//
|
|
||||||
buttonAddRoute.BackgroundImage = Properties.Resources.плюсик;
|
|
||||||
buttonAddRoute.BackgroundImageLayout = ImageLayout.Stretch;
|
|
||||||
buttonAddRoute.Location = new Point(35, 23);
|
|
||||||
buttonAddRoute.Name = "buttonAddRoute";
|
|
||||||
buttonAddRoute.Size = new Size(94, 75);
|
|
||||||
buttonAddRoute.TabIndex = 0;
|
|
||||||
buttonAddRoute.UseVisualStyleBackColor = true;
|
|
||||||
buttonAddRoute.Click += ButtonAddRoute_Click;
|
|
||||||
//
|
|
||||||
// FormRoutes
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
|
||||||
ClientSize = new Size(745, 355);
|
|
||||||
Controls.Add(dataGridViewRoutes);
|
|
||||||
Controls.Add(panelFormRoutesButtons);
|
|
||||||
Name = "FormRoutes";
|
|
||||||
Text = "FormRoutes";
|
|
||||||
Load += FormRoutes_Load;
|
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridViewRoutes).EndInit();
|
|
||||||
panelFormRoutesButtons.ResumeLayout(false);
|
|
||||||
ResumeLayout(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private DataGridView dataGridViewRoutes;
|
|
||||||
private Panel panelFormRoutesButtons;
|
|
||||||
private Button buttonUpdateRoute;
|
|
||||||
private Button buttonDeleteRoute;
|
|
||||||
private Button buttonAddRoute;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,115 +0,0 @@
|
|||||||
using ProjectGarage.Repositories;
|
|
||||||
using ProjectGarage.Repositories.Implementations;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Data;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
using System.Xml.Linq;
|
|
||||||
using Unity;
|
|
||||||
|
|
||||||
namespace ProjectGarage.Forms
|
|
||||||
{
|
|
||||||
public partial class FormRoutes : Form
|
|
||||||
{
|
|
||||||
private readonly IUnityContainer _container;
|
|
||||||
private readonly IRouteRepository _routeRepository;
|
|
||||||
|
|
||||||
public FormRoutes(IUnityContainer container, IRouteRepository routeRepository)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_container = container ?? throw new ArgumentNullException(nameof(container));
|
|
||||||
_routeRepository = routeRepository ?? throw new ArgumentNullException(nameof(routeRepository));
|
|
||||||
}
|
|
||||||
private void ButtonAddRoute_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_container.Resolve<FormRoute>().ShowDialog();
|
|
||||||
LoadList();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при добавлении",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
private void FormRoutes_Load(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
LoadList();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при загрузке",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void ButtonDeleteRoute_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (!TryGetIdentifierFromSelectedRow(out var findId))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (MessageBox.Show("Удалить запись?", "Удаление",
|
|
||||||
MessageBoxButtons.YesNo) != DialogResult.Yes)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_routeRepository.DeleteRoute(findId);
|
|
||||||
LoadList();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при удалении",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonUpdateRoute_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (!TryGetIdentifierFromSelectedRow(out var findId))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var form = _container.Resolve<FormRoute>();
|
|
||||||
form.Id = findId;
|
|
||||||
form.ShowDialog();
|
|
||||||
LoadList();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при изменении",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void LoadList() => dataGridViewRoutes.DataSource = _routeRepository.ReadRoute();
|
|
||||||
|
|
||||||
private bool TryGetIdentifierFromSelectedRow(out int id)
|
|
||||||
{
|
|
||||||
id = 0;
|
|
||||||
if (dataGridViewRoutes.SelectedRows.Count < 1)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Нет выбранной записи", "Ошибка",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
id =
|
|
||||||
Convert.ToInt32(dataGridViewRoutes.SelectedRows[0].Cells["Id"].Value);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,120 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<root>
|
|
||||||
<!--
|
|
||||||
Microsoft ResX Schema
|
|
||||||
|
|
||||||
Version 2.0
|
|
||||||
|
|
||||||
The primary goals of this format is to allow a simple XML format
|
|
||||||
that is mostly human readable. The generation and parsing of the
|
|
||||||
various data types are done through the TypeConverter classes
|
|
||||||
associated with the data types.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
... ado.net/XML headers & schema ...
|
|
||||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
|
||||||
<resheader name="version">2.0</resheader>
|
|
||||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
|
||||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
|
||||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
|
||||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
|
||||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
|
||||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
|
||||||
</data>
|
|
||||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
|
||||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
|
||||||
<comment>This is a comment</comment>
|
|
||||||
</data>
|
|
||||||
|
|
||||||
There are any number of "resheader" rows that contain simple
|
|
||||||
name/value pairs.
|
|
||||||
|
|
||||||
Each data row contains a name, and value. The row also contains a
|
|
||||||
type or mimetype. Type corresponds to a .NET class that support
|
|
||||||
text/value conversion through the TypeConverter architecture.
|
|
||||||
Classes that don't support this are serialized and stored with the
|
|
||||||
mimetype set.
|
|
||||||
|
|
||||||
The mimetype is used for serialized objects, and tells the
|
|
||||||
ResXResourceReader how to depersist the object. This is currently not
|
|
||||||
extensible. For a given mimetype the value must be set accordingly:
|
|
||||||
|
|
||||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
|
||||||
that the ResXResourceWriter will generate, however the reader can
|
|
||||||
read any of the formats listed below.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.binary.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.soap.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
|
||||||
value : The object must be serialized into a byte array
|
|
||||||
: using a System.ComponentModel.TypeConverter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
-->
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
</root>
|
|
171
ProjectGarage/Forms/FormTransportation.Designer.cs
generated
@ -1,171 +0,0 @@
|
|||||||
namespace ProjectGarage.Forms
|
|
||||||
{
|
|
||||||
partial class FormTransportation
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
labelFuel = new Label();
|
|
||||||
labelDriver = new Label();
|
|
||||||
labelRoute = new Label();
|
|
||||||
label1 = new Label();
|
|
||||||
numericUpDownAmountFuel = new NumericUpDown();
|
|
||||||
comboBoxFuel = new ComboBox();
|
|
||||||
comboBoxRoute = new ComboBox();
|
|
||||||
comboBoxDriver = new ComboBox();
|
|
||||||
buttonTransportationSave = new Button();
|
|
||||||
buttonTransportationCancel = new Button();
|
|
||||||
((System.ComponentModel.ISupportInitialize)numericUpDownAmountFuel).BeginInit();
|
|
||||||
SuspendLayout();
|
|
||||||
//
|
|
||||||
// labelFuel
|
|
||||||
//
|
|
||||||
labelFuel.AutoSize = true;
|
|
||||||
labelFuel.Location = new Point(32, 26);
|
|
||||||
labelFuel.Name = "labelFuel";
|
|
||||||
labelFuel.Size = new Size(69, 20);
|
|
||||||
labelFuel.TabIndex = 0;
|
|
||||||
labelFuel.Text = "Топливо";
|
|
||||||
//
|
|
||||||
// labelDriver
|
|
||||||
//
|
|
||||||
labelDriver.AutoSize = true;
|
|
||||||
labelDriver.Location = new Point(32, 70);
|
|
||||||
labelDriver.Name = "labelDriver";
|
|
||||||
labelDriver.Size = new Size(74, 20);
|
|
||||||
labelDriver.TabIndex = 1;
|
|
||||||
labelDriver.Text = "Водитель";
|
|
||||||
//
|
|
||||||
// labelRoute
|
|
||||||
//
|
|
||||||
labelRoute.AutoSize = true;
|
|
||||||
labelRoute.Location = new Point(32, 116);
|
|
||||||
labelRoute.Name = "labelRoute";
|
|
||||||
labelRoute.Size = new Size(73, 20);
|
|
||||||
labelRoute.TabIndex = 2;
|
|
||||||
labelRoute.Text = "Маршрут";
|
|
||||||
//
|
|
||||||
// label1
|
|
||||||
//
|
|
||||||
label1.AutoSize = true;
|
|
||||||
label1.Location = new Point(12, 157);
|
|
||||||
label1.Name = "label1";
|
|
||||||
label1.Size = new Size(118, 20);
|
|
||||||
label1.TabIndex = 3;
|
|
||||||
label1.Text = "Объем топлива";
|
|
||||||
//
|
|
||||||
// numericUpDownAmountFuel
|
|
||||||
//
|
|
||||||
numericUpDownAmountFuel.Location = new Point(152, 155);
|
|
||||||
numericUpDownAmountFuel.Minimum = new decimal(new int[] { 1, 0, 0, 0 });
|
|
||||||
numericUpDownAmountFuel.Name = "numericUpDownAmountFuel";
|
|
||||||
numericUpDownAmountFuel.Size = new Size(150, 27);
|
|
||||||
numericUpDownAmountFuel.TabIndex = 4;
|
|
||||||
numericUpDownAmountFuel.Value = new decimal(new int[] { 1, 0, 0, 0 });
|
|
||||||
//
|
|
||||||
// comboBoxFuel
|
|
||||||
//
|
|
||||||
comboBoxFuel.DropDownStyle = ComboBoxStyle.DropDownList;
|
|
||||||
comboBoxFuel.FormattingEnabled = true;
|
|
||||||
comboBoxFuel.Location = new Point(151, 23);
|
|
||||||
comboBoxFuel.Name = "comboBoxFuel";
|
|
||||||
comboBoxFuel.Size = new Size(151, 28);
|
|
||||||
comboBoxFuel.TabIndex = 5;
|
|
||||||
//
|
|
||||||
// comboBoxRoute
|
|
||||||
//
|
|
||||||
comboBoxRoute.DropDownStyle = ComboBoxStyle.DropDownList;
|
|
||||||
comboBoxRoute.FormattingEnabled = true;
|
|
||||||
comboBoxRoute.Location = new Point(151, 113);
|
|
||||||
comboBoxRoute.Name = "comboBoxRoute";
|
|
||||||
comboBoxRoute.Size = new Size(151, 28);
|
|
||||||
comboBoxRoute.TabIndex = 6;
|
|
||||||
//
|
|
||||||
// comboBoxDriver
|
|
||||||
//
|
|
||||||
comboBoxDriver.DropDownStyle = ComboBoxStyle.DropDownList;
|
|
||||||
comboBoxDriver.FormattingEnabled = true;
|
|
||||||
comboBoxDriver.Location = new Point(152, 67);
|
|
||||||
comboBoxDriver.Name = "comboBoxDriver";
|
|
||||||
comboBoxDriver.Size = new Size(151, 28);
|
|
||||||
comboBoxDriver.TabIndex = 7;
|
|
||||||
//
|
|
||||||
// buttonTransportationSave
|
|
||||||
//
|
|
||||||
buttonTransportationSave.Location = new Point(12, 194);
|
|
||||||
buttonTransportationSave.Name = "buttonTransportationSave";
|
|
||||||
buttonTransportationSave.Size = new Size(135, 29);
|
|
||||||
buttonTransportationSave.TabIndex = 8;
|
|
||||||
buttonTransportationSave.Text = "Сохранить";
|
|
||||||
buttonTransportationSave.UseVisualStyleBackColor = true;
|
|
||||||
buttonTransportationSave.Click += ButtonTransportationSave_Click;
|
|
||||||
//
|
|
||||||
// buttonTransportationCancel
|
|
||||||
//
|
|
||||||
buttonTransportationCancel.Location = new Point(163, 194);
|
|
||||||
buttonTransportationCancel.Name = "buttonTransportationCancel";
|
|
||||||
buttonTransportationCancel.Size = new Size(140, 29);
|
|
||||||
buttonTransportationCancel.TabIndex = 9;
|
|
||||||
buttonTransportationCancel.Text = "Отмена";
|
|
||||||
buttonTransportationCancel.UseVisualStyleBackColor = true;
|
|
||||||
buttonTransportationCancel.Click += ButtonTransportationCancel_Click;
|
|
||||||
//
|
|
||||||
// FormTransportation
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
|
||||||
ClientSize = new Size(324, 244);
|
|
||||||
Controls.Add(buttonTransportationCancel);
|
|
||||||
Controls.Add(buttonTransportationSave);
|
|
||||||
Controls.Add(comboBoxDriver);
|
|
||||||
Controls.Add(comboBoxRoute);
|
|
||||||
Controls.Add(comboBoxFuel);
|
|
||||||
Controls.Add(numericUpDownAmountFuel);
|
|
||||||
Controls.Add(label1);
|
|
||||||
Controls.Add(labelRoute);
|
|
||||||
Controls.Add(labelDriver);
|
|
||||||
Controls.Add(labelFuel);
|
|
||||||
Name = "FormTransportation";
|
|
||||||
Text = "FormTransportation";
|
|
||||||
((System.ComponentModel.ISupportInitialize)numericUpDownAmountFuel).EndInit();
|
|
||||||
ResumeLayout(false);
|
|
||||||
PerformLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private Label labelFuel;
|
|
||||||
private Label labelDriver;
|
|
||||||
private Label labelRoute;
|
|
||||||
private Label label1;
|
|
||||||
private NumericUpDown numericUpDownAmountFuel;
|
|
||||||
private ComboBox comboBoxFuel;
|
|
||||||
private ComboBox comboBoxRoute;
|
|
||||||
private ComboBox comboBoxDriver;
|
|
||||||
private Button buttonTransportationSave;
|
|
||||||
private Button buttonTransportationCancel;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,63 +0,0 @@
|
|||||||
using ProjectGarage.Entities;
|
|
||||||
using ProjectGarage.Repositories;
|
|
||||||
using ProjectGarage.Repositories.Implementations;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Data;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
namespace ProjectGarage.Forms
|
|
||||||
{
|
|
||||||
public partial class FormTransportation : Form
|
|
||||||
{
|
|
||||||
private readonly ITransportationRepository _transportationRepository;
|
|
||||||
|
|
||||||
public FormTransportation(ITransportationRepository transportationRepository,
|
|
||||||
IFuelRepository fuelRepository, IDriverRepository driverRepository, IRouteRepository routeRepository)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_transportationRepository = transportationRepository ??
|
|
||||||
throw new ArgumentNullException(nameof(transportationRepository));
|
|
||||||
|
|
||||||
comboBoxDriver.DataSource = driverRepository.ReadDrivers();
|
|
||||||
comboBoxDriver.DisplayMember = "Fname";
|
|
||||||
comboBoxDriver.ValueMember = "Id";
|
|
||||||
|
|
||||||
comboBoxFuel.DataSource = fuelRepository.ReadFuels();
|
|
||||||
comboBoxFuel.DisplayMember = "FuelName";
|
|
||||||
comboBoxFuel.ValueMember = "Id";
|
|
||||||
|
|
||||||
comboBoxRoute.DataSource = routeRepository.ReadRoute();
|
|
||||||
comboBoxRoute.DisplayMember = "RouteName";
|
|
||||||
comboBoxRoute.ValueMember = "Id";
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonTransportationSave_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (comboBoxFuel.SelectedIndex < 0 || comboBoxDriver.SelectedIndex < 0 ||
|
|
||||||
comboBoxRoute.SelectedIndex < 0)
|
|
||||||
{
|
|
||||||
throw new Exception("Имеются незаполненные поля");
|
|
||||||
}
|
|
||||||
_transportationRepository.CreateTransportation(Transportation.CreateTransportation(0,
|
|
||||||
(int)comboBoxFuel.SelectedValue!, (int)comboBoxRoute.SelectedValue!,
|
|
||||||
(int)comboBoxDriver.SelectedValue!, Convert.ToInt32(numericUpDownAmountFuel.Value)));
|
|
||||||
Close();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при сохранении",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonTransportationCancel_Click(object sender, EventArgs e) => Close();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,120 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<root>
|
|
||||||
<!--
|
|
||||||
Microsoft ResX Schema
|
|
||||||
|
|
||||||
Version 2.0
|
|
||||||
|
|
||||||
The primary goals of this format is to allow a simple XML format
|
|
||||||
that is mostly human readable. The generation and parsing of the
|
|
||||||
various data types are done through the TypeConverter classes
|
|
||||||
associated with the data types.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
... ado.net/XML headers & schema ...
|
|
||||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
|
||||||
<resheader name="version">2.0</resheader>
|
|
||||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
|
||||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
|
||||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
|
||||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
|
||||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
|
||||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
|
||||||
</data>
|
|
||||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
|
||||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
|
||||||
<comment>This is a comment</comment>
|
|
||||||
</data>
|
|
||||||
|
|
||||||
There are any number of "resheader" rows that contain simple
|
|
||||||
name/value pairs.
|
|
||||||
|
|
||||||
Each data row contains a name, and value. The row also contains a
|
|
||||||
type or mimetype. Type corresponds to a .NET class that support
|
|
||||||
text/value conversion through the TypeConverter architecture.
|
|
||||||
Classes that don't support this are serialized and stored with the
|
|
||||||
mimetype set.
|
|
||||||
|
|
||||||
The mimetype is used for serialized objects, and tells the
|
|
||||||
ResXResourceReader how to depersist the object. This is currently not
|
|
||||||
extensible. For a given mimetype the value must be set accordingly:
|
|
||||||
|
|
||||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
|
||||||
that the ResXResourceWriter will generate, however the reader can
|
|
||||||
read any of the formats listed below.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.binary.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.soap.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
|
||||||
value : The object must be serialized into a byte array
|
|
||||||
: using a System.ComponentModel.TypeConverter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
-->
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
</root>
|
|
@ -1,107 +0,0 @@
|
|||||||
namespace ProjectGarage.Forms
|
|
||||||
{
|
|
||||||
partial class FormTransportationDistributionReport
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
buttonSelectFileName = new Button();
|
|
||||||
dateTimePickerReport = new DateTimePicker();
|
|
||||||
buttonCreate = new Button();
|
|
||||||
labelFileName = new Label();
|
|
||||||
labelDate = new Label();
|
|
||||||
SuspendLayout();
|
|
||||||
//
|
|
||||||
// buttonSelectFileName
|
|
||||||
//
|
|
||||||
buttonSelectFileName.Location = new Point(28, 28);
|
|
||||||
buttonSelectFileName.Name = "buttonSelectFileName";
|
|
||||||
buttonSelectFileName.Size = new Size(94, 29);
|
|
||||||
buttonSelectFileName.TabIndex = 0;
|
|
||||||
buttonSelectFileName.Text = "Выбрать";
|
|
||||||
buttonSelectFileName.UseVisualStyleBackColor = true;
|
|
||||||
buttonSelectFileName.Click += ButtonSelectFileName_Click;
|
|
||||||
//
|
|
||||||
// dateTimePickerReport
|
|
||||||
//
|
|
||||||
dateTimePickerReport.Location = new Point(90, 81);
|
|
||||||
dateTimePickerReport.Name = "dateTimePickerReport";
|
|
||||||
dateTimePickerReport.Size = new Size(250, 27);
|
|
||||||
dateTimePickerReport.TabIndex = 1;
|
|
||||||
//
|
|
||||||
// buttonCreate
|
|
||||||
//
|
|
||||||
buttonCreate.Location = new Point(101, 126);
|
|
||||||
buttonCreate.Name = "buttonCreate";
|
|
||||||
buttonCreate.Size = new Size(123, 29);
|
|
||||||
buttonCreate.TabIndex = 2;
|
|
||||||
buttonCreate.Text = "Сформировать";
|
|
||||||
buttonCreate.UseVisualStyleBackColor = true;
|
|
||||||
buttonCreate.Click += ButtonCreate_Click;
|
|
||||||
//
|
|
||||||
// labelFileName
|
|
||||||
//
|
|
||||||
labelFileName.AutoSize = true;
|
|
||||||
labelFileName.Location = new Point(142, 32);
|
|
||||||
labelFileName.Name = "labelFileName";
|
|
||||||
labelFileName.Size = new Size(45, 20);
|
|
||||||
labelFileName.TabIndex = 3;
|
|
||||||
labelFileName.Text = "Файл";
|
|
||||||
//
|
|
||||||
// labelDate
|
|
||||||
//
|
|
||||||
labelDate.AutoSize = true;
|
|
||||||
labelDate.Location = new Point(28, 86);
|
|
||||||
labelDate.Name = "labelDate";
|
|
||||||
labelDate.Size = new Size(44, 20);
|
|
||||||
labelDate.TabIndex = 4;
|
|
||||||
labelDate.Text = "Дата:";
|
|
||||||
//
|
|
||||||
// FormTransportationDistributionReport
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
|
||||||
ClientSize = new Size(357, 178);
|
|
||||||
Controls.Add(labelDate);
|
|
||||||
Controls.Add(labelFileName);
|
|
||||||
Controls.Add(buttonCreate);
|
|
||||||
Controls.Add(dateTimePickerReport);
|
|
||||||
Controls.Add(buttonSelectFileName);
|
|
||||||
Name = "FormTransportationDistributionReport";
|
|
||||||
Text = "FormTransportationDistributionReport";
|
|
||||||
ResumeLayout(false);
|
|
||||||
PerformLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private Button buttonSelectFileName;
|
|
||||||
private DateTimePicker dateTimePickerReport;
|
|
||||||
private Button buttonCreate;
|
|
||||||
private Label labelFileName;
|
|
||||||
private Label labelDate;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,71 +0,0 @@
|
|||||||
using ProjectGarage.Reports;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Data;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
using Unity;
|
|
||||||
|
|
||||||
namespace ProjectGarage.Forms
|
|
||||||
{
|
|
||||||
public partial class FormTransportationDistributionReport : Form
|
|
||||||
{
|
|
||||||
private string _fileName = string.Empty;
|
|
||||||
private readonly IUnityContainer _container;
|
|
||||||
|
|
||||||
public FormTransportationDistributionReport(IUnityContainer container)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_container = container ?? throw new ArgumentNullException(nameof(container));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonSelectFileName_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
var sfd = new SaveFileDialog()
|
|
||||||
{
|
|
||||||
Filter = "Pdf Files | *.pdf"
|
|
||||||
};
|
|
||||||
if (sfd.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
_fileName = sfd.FileName;
|
|
||||||
labelFileName.Text = Path.GetFileName(_fileName);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonCreate_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (string.IsNullOrWhiteSpace(_fileName))
|
|
||||||
{
|
|
||||||
throw new Exception("Отсутствует имя файла для отчета");
|
|
||||||
}
|
|
||||||
if
|
|
||||||
(_container.Resolve<ChartReport>().CreateChart(_fileName, dateTimePickerReport.Value))
|
|
||||||
{
|
|
||||||
MessageBox.Show("Документ сформирован",
|
|
||||||
"Формирование документа",
|
|
||||||
MessageBoxButtons.OK,
|
|
||||||
MessageBoxIcon.Information);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MessageBox.Show("Возникли ошибки при формировании документа.Подробности в логах",
|
|
||||||
"Формирование документа",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при создании очета",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,120 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<root>
|
|
||||||
<!--
|
|
||||||
Microsoft ResX Schema
|
|
||||||
|
|
||||||
Version 2.0
|
|
||||||
|
|
||||||
The primary goals of this format is to allow a simple XML format
|
|
||||||
that is mostly human readable. The generation and parsing of the
|
|
||||||
various data types are done through the TypeConverter classes
|
|
||||||
associated with the data types.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
... ado.net/XML headers & schema ...
|
|
||||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
|
||||||
<resheader name="version">2.0</resheader>
|
|
||||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
|
||||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
|
||||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
|
||||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
|
||||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
|
||||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
|
||||||
</data>
|
|
||||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
|
||||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
|
||||||
<comment>This is a comment</comment>
|
|
||||||
</data>
|
|
||||||
|
|
||||||
There are any number of "resheader" rows that contain simple
|
|
||||||
name/value pairs.
|
|
||||||
|
|
||||||
Each data row contains a name, and value. The row also contains a
|
|
||||||
type or mimetype. Type corresponds to a .NET class that support
|
|
||||||
text/value conversion through the TypeConverter architecture.
|
|
||||||
Classes that don't support this are serialized and stored with the
|
|
||||||
mimetype set.
|
|
||||||
|
|
||||||
The mimetype is used for serialized objects, and tells the
|
|
||||||
ResXResourceReader how to depersist the object. This is currently not
|
|
||||||
extensible. For a given mimetype the value must be set accordingly:
|
|
||||||
|
|
||||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
|
||||||
that the ResXResourceWriter will generate, however the reader can
|
|
||||||
read any of the formats listed below.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.binary.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.soap.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
|
||||||
value : The object must be serialized into a byte array
|
|
||||||
: using a System.ComponentModel.TypeConverter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
-->
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
</root>
|
|
97
ProjectGarage/Forms/FormTransportations.Designer.cs
generated
@ -1,97 +0,0 @@
|
|||||||
namespace ProjectGarage.Forms
|
|
||||||
{
|
|
||||||
partial class FormTransportations
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
buttonAddTransportation = new Button();
|
|
||||||
dataGridViewTransportations = new DataGridView();
|
|
||||||
panelFormTransportationsButtons = new Panel();
|
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridViewTransportations).BeginInit();
|
|
||||||
panelFormTransportationsButtons.SuspendLayout();
|
|
||||||
SuspendLayout();
|
|
||||||
//
|
|
||||||
// buttonAddTransportation
|
|
||||||
//
|
|
||||||
buttonAddTransportation.BackgroundImage = Properties.Resources.плюсик;
|
|
||||||
buttonAddTransportation.BackgroundImageLayout = ImageLayout.Stretch;
|
|
||||||
buttonAddTransportation.Location = new Point(35, 23);
|
|
||||||
buttonAddTransportation.Name = "buttonAddTransportation";
|
|
||||||
buttonAddTransportation.Size = new Size(94, 75);
|
|
||||||
buttonAddTransportation.TabIndex = 0;
|
|
||||||
buttonAddTransportation.UseVisualStyleBackColor = true;
|
|
||||||
buttonAddTransportation.Click += ButtonAddTransportation_Click;
|
|
||||||
//
|
|
||||||
// dataGridViewTransportations
|
|
||||||
//
|
|
||||||
dataGridViewTransportations.AllowUserToAddRows = false;
|
|
||||||
dataGridViewTransportations.AllowUserToDeleteRows = false;
|
|
||||||
dataGridViewTransportations.AllowUserToResizeColumns = false;
|
|
||||||
dataGridViewTransportations.AllowUserToResizeRows = false;
|
|
||||||
dataGridViewTransportations.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
|
||||||
dataGridViewTransportations.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
|
||||||
dataGridViewTransportations.Dock = DockStyle.Fill;
|
|
||||||
dataGridViewTransportations.Location = new Point(0, 0);
|
|
||||||
dataGridViewTransportations.Name = "dataGridViewTransportations";
|
|
||||||
dataGridViewTransportations.ReadOnly = true;
|
|
||||||
dataGridViewTransportations.RowHeadersVisible = false;
|
|
||||||
dataGridViewTransportations.RowHeadersWidth = 51;
|
|
||||||
dataGridViewTransportations.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
|
||||||
dataGridViewTransportations.Size = new Size(847, 450);
|
|
||||||
dataGridViewTransportations.TabIndex = 7;
|
|
||||||
//
|
|
||||||
// panelFormTransportationsButtons
|
|
||||||
//
|
|
||||||
panelFormTransportationsButtons.Controls.Add(buttonAddTransportation);
|
|
||||||
panelFormTransportationsButtons.Dock = DockStyle.Right;
|
|
||||||
panelFormTransportationsButtons.Location = new Point(847, 0);
|
|
||||||
panelFormTransportationsButtons.Name = "panelFormTransportationsButtons";
|
|
||||||
panelFormTransportationsButtons.Size = new Size(161, 450);
|
|
||||||
panelFormTransportationsButtons.TabIndex = 6;
|
|
||||||
//
|
|
||||||
// FormTransportations
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
|
||||||
ClientSize = new Size(1008, 450);
|
|
||||||
Controls.Add(dataGridViewTransportations);
|
|
||||||
Controls.Add(panelFormTransportationsButtons);
|
|
||||||
Name = "FormTransportations";
|
|
||||||
Text = "FormTransportations";
|
|
||||||
Load += FormTransportations_Load;
|
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridViewTransportations).EndInit();
|
|
||||||
panelFormTransportationsButtons.ResumeLayout(false);
|
|
||||||
ResumeLayout(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private Button buttonAddTransportation;
|
|
||||||
private DataGridView dataGridViewTransportations;
|
|
||||||
private Panel panelFormTransportationsButtons;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,57 +0,0 @@
|
|||||||
using ProjectGarage.Repositories;
|
|
||||||
using ProjectGarage.Repositories.Implementations;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Data;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
using Unity;
|
|
||||||
|
|
||||||
namespace ProjectGarage.Forms
|
|
||||||
{
|
|
||||||
public partial class FormTransportations : Form
|
|
||||||
{
|
|
||||||
private readonly IUnityContainer _container;
|
|
||||||
private readonly ITransportationRepository _transportationRepository;
|
|
||||||
|
|
||||||
public FormTransportations(IUnityContainer container, ITransportationRepository transportationRepository)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_container = container ?? throw new ArgumentNullException(nameof(container));
|
|
||||||
_transportationRepository = transportationRepository ??
|
|
||||||
throw new
|
|
||||||
ArgumentNullException(nameof(transportationRepository));
|
|
||||||
}
|
|
||||||
private void FormTransportations_Load(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
LoadList();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при загрузке",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonAddTransportation_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_container.Resolve<FormTransportation>().ShowDialog();
|
|
||||||
LoadList();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void LoadList() => dataGridViewTransportations.DataSource = _transportationRepository.ReadTransportation();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,120 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<root>
|
|
||||||
<!--
|
|
||||||
Microsoft ResX Schema
|
|
||||||
|
|
||||||
Version 2.0
|
|
||||||
|
|
||||||
The primary goals of this format is to allow a simple XML format
|
|
||||||
that is mostly human readable. The generation and parsing of the
|
|
||||||
various data types are done through the TypeConverter classes
|
|
||||||
associated with the data types.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
... ado.net/XML headers & schema ...
|
|
||||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
|
||||||
<resheader name="version">2.0</resheader>
|
|
||||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
|
||||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
|
||||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
|
||||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
|
||||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
|
||||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
|
||||||
</data>
|
|
||||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
|
||||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
|
||||||
<comment>This is a comment</comment>
|
|
||||||
</data>
|
|
||||||
|
|
||||||
There are any number of "resheader" rows that contain simple
|
|
||||||
name/value pairs.
|
|
||||||
|
|
||||||
Each data row contains a name, and value. The row also contains a
|
|
||||||
type or mimetype. Type corresponds to a .NET class that support
|
|
||||||
text/value conversion through the TypeConverter architecture.
|
|
||||||
Classes that don't support this are serialized and stored with the
|
|
||||||
mimetype set.
|
|
||||||
|
|
||||||
The mimetype is used for serialized objects, and tells the
|
|
||||||
ResXResourceReader how to depersist the object. This is currently not
|
|
||||||
extensible. For a given mimetype the value must be set accordingly:
|
|
||||||
|
|
||||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
|
||||||
that the ResXResourceWriter will generate, however the reader can
|
|
||||||
read any of the formats listed below.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.binary.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.soap.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
|
||||||
value : The object must be serialized into a byte array
|
|
||||||
: using a System.ComponentModel.TypeConverter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
-->
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
</root>
|
|
146
ProjectGarage/Forms/FormTruck.Designer.cs
generated
@ -1,146 +0,0 @@
|
|||||||
namespace ProjectGarage.Forms
|
|
||||||
{
|
|
||||||
partial class FormTruck
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
labelTruckBrand = new Label();
|
|
||||||
textBoxTruckNumbers = new TextBox();
|
|
||||||
labelTruckNumbers = new Label();
|
|
||||||
labelMaxFuel = new Label();
|
|
||||||
numericUpDownMaxFuel = new NumericUpDown();
|
|
||||||
buttonTruckSave = new Button();
|
|
||||||
buttonTruckCancel = new Button();
|
|
||||||
comboBoxTruckType = new ComboBox();
|
|
||||||
((System.ComponentModel.ISupportInitialize)numericUpDownMaxFuel).BeginInit();
|
|
||||||
SuspendLayout();
|
|
||||||
//
|
|
||||||
// labelTruckBrand
|
|
||||||
//
|
|
||||||
labelTruckBrand.AutoSize = true;
|
|
||||||
labelTruckBrand.Location = new Point(43, 76);
|
|
||||||
labelTruckBrand.Name = "labelTruckBrand";
|
|
||||||
labelTruckBrand.Size = new Size(54, 20);
|
|
||||||
labelTruckBrand.TabIndex = 10;
|
|
||||||
labelTruckBrand.Text = "Марка";
|
|
||||||
//
|
|
||||||
// textBoxTruckNumbers
|
|
||||||
//
|
|
||||||
textBoxTruckNumbers.Location = new Point(158, 30);
|
|
||||||
textBoxTruckNumbers.Name = "textBoxTruckNumbers";
|
|
||||||
textBoxTruckNumbers.Size = new Size(183, 27);
|
|
||||||
textBoxTruckNumbers.TabIndex = 9;
|
|
||||||
//
|
|
||||||
// labelTruckNumbers
|
|
||||||
//
|
|
||||||
labelTruckNumbers.AutoSize = true;
|
|
||||||
labelTruckNumbers.Location = new Point(26, 30);
|
|
||||||
labelTruckNumbers.Name = "labelTruckNumbers";
|
|
||||||
labelTruckNumbers.Size = new Size(106, 20);
|
|
||||||
labelTruckNumbers.TabIndex = 8;
|
|
||||||
labelTruckNumbers.Text = "Номера фуры";
|
|
||||||
//
|
|
||||||
// labelMaxFuel
|
|
||||||
//
|
|
||||||
labelMaxFuel.AutoSize = true;
|
|
||||||
labelMaxFuel.Location = new Point(12, 122);
|
|
||||||
labelMaxFuel.Name = "labelMaxFuel";
|
|
||||||
labelMaxFuel.Size = new Size(129, 20);
|
|
||||||
labelMaxFuel.TabIndex = 14;
|
|
||||||
labelMaxFuel.Text = "Объем цистерны";
|
|
||||||
//
|
|
||||||
// numericUpDownMaxFuel
|
|
||||||
//
|
|
||||||
numericUpDownMaxFuel.Location = new Point(158, 115);
|
|
||||||
numericUpDownMaxFuel.Maximum = new decimal(new int[] { 3000, 0, 0, 0 });
|
|
||||||
numericUpDownMaxFuel.Minimum = new decimal(new int[] { 1, 0, 0, 0 });
|
|
||||||
numericUpDownMaxFuel.Name = "numericUpDownMaxFuel";
|
|
||||||
numericUpDownMaxFuel.Size = new Size(183, 27);
|
|
||||||
numericUpDownMaxFuel.TabIndex = 15;
|
|
||||||
numericUpDownMaxFuel.Value = new decimal(new int[] { 1, 0, 0, 0 });
|
|
||||||
//
|
|
||||||
// buttonTruckSave
|
|
||||||
//
|
|
||||||
buttonTruckSave.Location = new Point(12, 170);
|
|
||||||
buttonTruckSave.Name = "buttonTruckSave";
|
|
||||||
buttonTruckSave.Size = new Size(156, 37);
|
|
||||||
buttonTruckSave.TabIndex = 16;
|
|
||||||
buttonTruckSave.Text = "Сохранить";
|
|
||||||
buttonTruckSave.UseVisualStyleBackColor = true;
|
|
||||||
buttonTruckSave.Click += ButtonTruckSave_Click;
|
|
||||||
//
|
|
||||||
// buttonTruckCancel
|
|
||||||
//
|
|
||||||
buttonTruckCancel.Location = new Point(196, 170);
|
|
||||||
buttonTruckCancel.Name = "buttonTruckCancel";
|
|
||||||
buttonTruckCancel.Size = new Size(156, 37);
|
|
||||||
buttonTruckCancel.TabIndex = 17;
|
|
||||||
buttonTruckCancel.Text = "Отмена";
|
|
||||||
buttonTruckCancel.UseVisualStyleBackColor = true;
|
|
||||||
buttonTruckCancel.Click += ButtonTruckCancel_Click;
|
|
||||||
//
|
|
||||||
// comboBoxTruckType
|
|
||||||
//
|
|
||||||
comboBoxTruckType.DropDownStyle = ComboBoxStyle.DropDownList;
|
|
||||||
comboBoxTruckType.FormattingEnabled = true;
|
|
||||||
comboBoxTruckType.Location = new Point(158, 68);
|
|
||||||
comboBoxTruckType.Name = "comboBoxTruckType";
|
|
||||||
comboBoxTruckType.Size = new Size(183, 28);
|
|
||||||
comboBoxTruckType.TabIndex = 18;
|
|
||||||
//
|
|
||||||
// FormTruck
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
|
||||||
ClientSize = new Size(364, 222);
|
|
||||||
Controls.Add(comboBoxTruckType);
|
|
||||||
Controls.Add(buttonTruckCancel);
|
|
||||||
Controls.Add(buttonTruckSave);
|
|
||||||
Controls.Add(numericUpDownMaxFuel);
|
|
||||||
Controls.Add(labelMaxFuel);
|
|
||||||
Controls.Add(labelTruckBrand);
|
|
||||||
Controls.Add(textBoxTruckNumbers);
|
|
||||||
Controls.Add(labelTruckNumbers);
|
|
||||||
Name = "FormTruck";
|
|
||||||
StartPosition = FormStartPosition.CenterParent;
|
|
||||||
Text = "Фура";
|
|
||||||
((System.ComponentModel.ISupportInitialize)numericUpDownMaxFuel).EndInit();
|
|
||||||
ResumeLayout(false);
|
|
||||||
PerformLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
private Label labelTruckBrand;
|
|
||||||
private TextBox textBoxTruckNumbers;
|
|
||||||
private Label labelTruckNumbers;
|
|
||||||
private Label labelMaxFuel;
|
|
||||||
private NumericUpDown numericUpDownMaxFuel;
|
|
||||||
private Button buttonTruckSave;
|
|
||||||
private Button buttonTruckCancel;
|
|
||||||
private ComboBox comboBoxTruckType;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,75 +0,0 @@
|
|||||||
using ProjectGarage.Entities;
|
|
||||||
using ProjectGarage.Entities.Enums;
|
|
||||||
using ProjectGarage.Repositories;
|
|
||||||
|
|
||||||
namespace ProjectGarage.Forms
|
|
||||||
{
|
|
||||||
public partial class FormTruck : Form
|
|
||||||
{
|
|
||||||
|
|
||||||
private readonly ITruckRepository _truckRepository;
|
|
||||||
private int? _truckId;
|
|
||||||
public int Id
|
|
||||||
{
|
|
||||||
set
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var truck = _truckRepository.ReadTruckByID(value);
|
|
||||||
if (truck == null)
|
|
||||||
{
|
|
||||||
throw new InvalidDataException(nameof(truck));
|
|
||||||
}
|
|
||||||
|
|
||||||
textBoxTruckNumbers.Text = truck.Numbers;
|
|
||||||
comboBoxTruckType.SelectedItem = truck.Truck_Type;
|
|
||||||
numericUpDownMaxFuel.Value = truck.MaxFuel;
|
|
||||||
_truckId = value;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public FormTruck(ITruckRepository truckRepository)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_truckRepository = truckRepository ??
|
|
||||||
throw new ArgumentNullException(nameof(truckRepository));
|
|
||||||
comboBoxTruckType.DataSource = Enum.GetValues(typeof(TruckType));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonTruckSave_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (string.IsNullOrWhiteSpace(textBoxTruckNumbers.Text)
|
|
||||||
|| comboBoxTruckType.SelectedIndex < 1)
|
|
||||||
{
|
|
||||||
throw new Exception("Имеются незаполненные поля");
|
|
||||||
}
|
|
||||||
if (_truckId.HasValue)
|
|
||||||
{
|
|
||||||
_truckRepository.UpdateTruck(CreateTruck(_truckId.Value));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_truckRepository.CreateTruck(CreateTruck(0));
|
|
||||||
}
|
|
||||||
Close();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonTruckCancel_Click(object sender, EventArgs e) => Close();
|
|
||||||
|
|
||||||
private Truck CreateTruck(int id) => Truck.CreateTruck(id, textBoxTruckNumbers.Text,
|
|
||||||
(TruckType)comboBoxTruckType.SelectedItem!, Convert.ToInt32(numericUpDownMaxFuel.Value));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,120 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<root>
|
|
||||||
<!--
|
|
||||||
Microsoft ResX Schema
|
|
||||||
|
|
||||||
Version 2.0
|
|
||||||
|
|
||||||
The primary goals of this format is to allow a simple XML format
|
|
||||||
that is mostly human readable. The generation and parsing of the
|
|
||||||
various data types are done through the TypeConverter classes
|
|
||||||
associated with the data types.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
... ado.net/XML headers & schema ...
|
|
||||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
|
||||||
<resheader name="version">2.0</resheader>
|
|
||||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
|
||||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
|
||||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
|
||||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
|
||||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
|
||||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
|
||||||
</data>
|
|
||||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
|
||||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
|
||||||
<comment>This is a comment</comment>
|
|
||||||
</data>
|
|
||||||
|
|
||||||
There are any number of "resheader" rows that contain simple
|
|
||||||
name/value pairs.
|
|
||||||
|
|
||||||
Each data row contains a name, and value. The row also contains a
|
|
||||||
type or mimetype. Type corresponds to a .NET class that support
|
|
||||||
text/value conversion through the TypeConverter architecture.
|
|
||||||
Classes that don't support this are serialized and stored with the
|
|
||||||
mimetype set.
|
|
||||||
|
|
||||||
The mimetype is used for serialized objects, and tells the
|
|
||||||
ResXResourceReader how to depersist the object. This is currently not
|
|
||||||
extensible. For a given mimetype the value must be set accordingly:
|
|
||||||
|
|
||||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
|
||||||
that the ResXResourceWriter will generate, however the reader can
|
|
||||||
read any of the formats listed below.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.binary.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.soap.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
|
||||||
value : The object must be serialized into a byte array
|
|
||||||
: using a System.ComponentModel.TypeConverter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
-->
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
</root>
|
|
126
ProjectGarage/Forms/FormTrucks.Designer.cs
generated
@ -1,126 +0,0 @@
|
|||||||
namespace ProjectGarage.Forms
|
|
||||||
{
|
|
||||||
partial class FormTrucks
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
panelFormTrucksButtons = new Panel();
|
|
||||||
buttonUpdateTruck = new Button();
|
|
||||||
buttonDeleteTruck = new Button();
|
|
||||||
buttonAddTruck = new Button();
|
|
||||||
dataGridViewTrucks = new DataGridView();
|
|
||||||
panelFormTrucksButtons.SuspendLayout();
|
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridViewTrucks).BeginInit();
|
|
||||||
SuspendLayout();
|
|
||||||
//
|
|
||||||
// panelFormTrucksButtons
|
|
||||||
//
|
|
||||||
panelFormTrucksButtons.Controls.Add(buttonUpdateTruck);
|
|
||||||
panelFormTrucksButtons.Controls.Add(buttonDeleteTruck);
|
|
||||||
panelFormTrucksButtons.Controls.Add(buttonAddTruck);
|
|
||||||
panelFormTrucksButtons.Dock = DockStyle.Right;
|
|
||||||
panelFormTrucksButtons.Location = new Point(565, 0);
|
|
||||||
panelFormTrucksButtons.Name = "panelFormTrucksButtons";
|
|
||||||
panelFormTrucksButtons.Size = new Size(161, 360);
|
|
||||||
panelFormTrucksButtons.TabIndex = 0;
|
|
||||||
//
|
|
||||||
// buttonUpdateTruck
|
|
||||||
//
|
|
||||||
buttonUpdateTruck.BackgroundImage = Properties.Resources.каранд;
|
|
||||||
buttonUpdateTruck.BackgroundImageLayout = ImageLayout.Stretch;
|
|
||||||
buttonUpdateTruck.Location = new Point(35, 140);
|
|
||||||
buttonUpdateTruck.Name = "buttonUpdateTruck";
|
|
||||||
buttonUpdateTruck.Size = new Size(94, 75);
|
|
||||||
buttonUpdateTruck.TabIndex = 2;
|
|
||||||
buttonUpdateTruck.UseVisualStyleBackColor = true;
|
|
||||||
buttonUpdateTruck.Click += ButtonUpdateTruck_Click;
|
|
||||||
//
|
|
||||||
// buttonDeleteTruck
|
|
||||||
//
|
|
||||||
buttonDeleteTruck.BackgroundImage = Properties.Resources.минусик;
|
|
||||||
buttonDeleteTruck.BackgroundImageLayout = ImageLayout.Stretch;
|
|
||||||
buttonDeleteTruck.Location = new Point(35, 247);
|
|
||||||
buttonDeleteTruck.Name = "buttonDeleteTruck";
|
|
||||||
buttonDeleteTruck.Size = new Size(94, 78);
|
|
||||||
buttonDeleteTruck.TabIndex = 1;
|
|
||||||
buttonDeleteTruck.UseVisualStyleBackColor = true;
|
|
||||||
buttonDeleteTruck.Click += ButtonDeleteTruck_Click;
|
|
||||||
//
|
|
||||||
// buttonAddTruck
|
|
||||||
//
|
|
||||||
buttonAddTruck.BackgroundImage = Properties.Resources.плюсик;
|
|
||||||
buttonAddTruck.BackgroundImageLayout = ImageLayout.Stretch;
|
|
||||||
buttonAddTruck.Location = new Point(35, 23);
|
|
||||||
buttonAddTruck.Name = "buttonAddTruck";
|
|
||||||
buttonAddTruck.Size = new Size(94, 75);
|
|
||||||
buttonAddTruck.TabIndex = 0;
|
|
||||||
buttonAddTruck.UseVisualStyleBackColor = true;
|
|
||||||
buttonAddTruck.Click += ButtonAddTruck_Click;
|
|
||||||
//
|
|
||||||
// dataGridViewTrucks
|
|
||||||
//
|
|
||||||
dataGridViewTrucks.AllowUserToAddRows = false;
|
|
||||||
dataGridViewTrucks.AllowUserToDeleteRows = false;
|
|
||||||
dataGridViewTrucks.AllowUserToResizeColumns = false;
|
|
||||||
dataGridViewTrucks.AllowUserToResizeRows = false;
|
|
||||||
dataGridViewTrucks.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
|
||||||
dataGridViewTrucks.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
|
||||||
dataGridViewTrucks.Dock = DockStyle.Fill;
|
|
||||||
dataGridViewTrucks.Location = new Point(0, 0);
|
|
||||||
dataGridViewTrucks.Name = "dataGridViewTrucks";
|
|
||||||
dataGridViewTrucks.ReadOnly = true;
|
|
||||||
dataGridViewTrucks.RowHeadersVisible = false;
|
|
||||||
dataGridViewTrucks.RowHeadersWidth = 51;
|
|
||||||
dataGridViewTrucks.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
|
||||||
dataGridViewTrucks.Size = new Size(565, 360);
|
|
||||||
dataGridViewTrucks.TabIndex = 1;
|
|
||||||
//
|
|
||||||
// FormTrucks
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
|
||||||
ClientSize = new Size(726, 360);
|
|
||||||
Controls.Add(dataGridViewTrucks);
|
|
||||||
Controls.Add(panelFormTrucksButtons);
|
|
||||||
Name = "FormTrucks";
|
|
||||||
StartPosition = FormStartPosition.CenterParent;
|
|
||||||
Text = "Фуры";
|
|
||||||
Load += FormTrucks_Load;
|
|
||||||
panelFormTrucksButtons.ResumeLayout(false);
|
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridViewTrucks).EndInit();
|
|
||||||
ResumeLayout(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private Panel panelFormTrucksButtons;
|
|
||||||
private Button buttonUpdateTruck;
|
|
||||||
private Button buttonDeleteTruck;
|
|
||||||
private Button buttonAddTruck;
|
|
||||||
private DataGridView dataGridViewTrucks;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,110 +0,0 @@
|
|||||||
using ProjectGarage.Repositories;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Data;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
using Unity;
|
|
||||||
|
|
||||||
namespace ProjectGarage.Forms
|
|
||||||
{
|
|
||||||
public partial class FormTrucks : Form
|
|
||||||
{
|
|
||||||
private readonly IUnityContainer _container;
|
|
||||||
|
|
||||||
private readonly ITruckRepository _truckRepository;
|
|
||||||
|
|
||||||
public FormTrucks(IUnityContainer container, ITruckRepository truckRepository)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_container = container ?? throw new ArgumentNullException(nameof(container));
|
|
||||||
_truckRepository = truckRepository ?? throw new ArgumentNullException(nameof(truckRepository));
|
|
||||||
}
|
|
||||||
private void FormTrucks_Load(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
LoadList();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonAddTruck_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_container.Resolve<FormTruck>().ShowDialog();
|
|
||||||
LoadList();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonDeleteTruck_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (!TryGetIDFromSelectedRow(out var findid))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_truckRepository.DeleteTruck(findid);
|
|
||||||
LoadList();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonUpdateTruck_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (!TryGetIDFromSelectedRow(out var findid))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var form = _container.Resolve<FormTruck>();
|
|
||||||
form.Id = findid;
|
|
||||||
form.ShowDialog();
|
|
||||||
LoadList();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void LoadList() => dataGridViewTrucks.DataSource = _truckRepository.ReadTrucks();
|
|
||||||
|
|
||||||
private bool TryGetIDFromSelectedRow(out int id)
|
|
||||||
{
|
|
||||||
id = 0;
|
|
||||||
if (dataGridViewTrucks.SelectedRows.Count < 1)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
id = Convert.ToInt32(dataGridViewTrucks.SelectedRows[0].Cells["Id"].Value);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,120 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<root>
|
|
||||||
<!--
|
|
||||||
Microsoft ResX Schema
|
|
||||||
|
|
||||||
Version 2.0
|
|
||||||
|
|
||||||
The primary goals of this format is to allow a simple XML format
|
|
||||||
that is mostly human readable. The generation and parsing of the
|
|
||||||
various data types are done through the TypeConverter classes
|
|
||||||
associated with the data types.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
... ado.net/XML headers & schema ...
|
|
||||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
|
||||||
<resheader name="version">2.0</resheader>
|
|
||||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
|
||||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
|
||||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
|
||||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
|
||||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
|
||||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
|
||||||
</data>
|
|
||||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
|
||||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
|
||||||
<comment>This is a comment</comment>
|
|
||||||
</data>
|
|
||||||
|
|
||||||
There are any number of "resheader" rows that contain simple
|
|
||||||
name/value pairs.
|
|
||||||
|
|
||||||
Each data row contains a name, and value. The row also contains a
|
|
||||||
type or mimetype. Type corresponds to a .NET class that support
|
|
||||||
text/value conversion through the TypeConverter architecture.
|
|
||||||
Classes that don't support this are serialized and stored with the
|
|
||||||
mimetype set.
|
|
||||||
|
|
||||||
The mimetype is used for serialized objects, and tells the
|
|
||||||
ResXResourceReader how to depersist the object. This is currently not
|
|
||||||
extensible. For a given mimetype the value must be set accordingly:
|
|
||||||
|
|
||||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
|
||||||
that the ResXResourceWriter will generate, however the reader can
|
|
||||||
read any of the formats listed below.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.binary.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.soap.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
|
||||||
value : The object must be serialized into a byte array
|
|
||||||
: using a System.ComponentModel.TypeConverter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
-->
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
</root>
|
|
@ -1,12 +1,3 @@
|
|||||||
using ProjectGarage.Repositories;
|
|
||||||
using ProjectGarage.Repositories.Implementations;
|
|
||||||
using Unity.Lifetime;
|
|
||||||
using Unity;
|
|
||||||
using Unity.Microsoft.Logging;
|
|
||||||
using Microsoft.Extensions.Configuration;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using Serilog;
|
|
||||||
|
|
||||||
namespace ProjectGarage
|
namespace ProjectGarage
|
||||||
{
|
{
|
||||||
internal static class Program
|
internal static class Program
|
||||||
@ -20,36 +11,7 @@ namespace ProjectGarage
|
|||||||
// To customize application configuration such as set high DPI settings or default font,
|
// To customize application configuration such as set high DPI settings or default font,
|
||||||
// see https://aka.ms/applicationconfiguration.
|
// see https://aka.ms/applicationconfiguration.
|
||||||
ApplicationConfiguration.Initialize();
|
ApplicationConfiguration.Initialize();
|
||||||
Application.Run(CreateContainer().Resolve<FormGarage>());
|
Application.Run(new Form1());
|
||||||
}
|
|
||||||
|
|
||||||
private static IUnityContainer CreateContainer()
|
|
||||||
{
|
|
||||||
var container = new UnityContainer();
|
|
||||||
container.AddExtension(new LoggingExtension(CreateLoggerFactory()));
|
|
||||||
|
|
||||||
container.RegisterType<ITruckRepository, TruckRepository>();
|
|
||||||
container.RegisterType<IFuelRepository, FuelRepository>();
|
|
||||||
container.RegisterType<IRouteRepository, RouteRepository>();
|
|
||||||
container.RegisterType<IDriverRepository, DriverRepository>();
|
|
||||||
container.RegisterType<ITransportationRepository, TransportationRepository>();
|
|
||||||
container.RegisterType<IReplenishmentRepository, ReplenishmentRepository>();
|
|
||||||
|
|
||||||
container.RegisterType<IConnectionString, ConnectionString>();
|
|
||||||
|
|
||||||
return container;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static LoggerFactory CreateLoggerFactory()
|
|
||||||
{
|
|
||||||
var loggerFactory = new LoggerFactory();
|
|
||||||
loggerFactory.AddSerilog(new LoggerConfiguration()
|
|
||||||
.ReadFrom.Configuration(new ConfigurationBuilder()
|
|
||||||
.SetBasePath(Directory.GetCurrentDirectory())
|
|
||||||
.AddJsonFile("appsettings.json")
|
|
||||||
.Build())
|
|
||||||
.CreateLogger());
|
|
||||||
return loggerFactory;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -8,43 +8,4 @@
|
|||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Dapper" Version="2.1.35" />
|
|
||||||
<PackageReference Include="DocumentFormat.OpenXml" Version="3.2.0" />
|
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="9.0.0" />
|
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.0" />
|
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="9.0.0" />
|
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
|
||||||
<PackageReference Include="Npgsql" Version="9.0.1" />
|
|
||||||
<PackageReference Include="PdfSharp.MigraDoc.Standard" Version="1.51.15" />
|
|
||||||
<PackageReference Include="Serilog" Version="4.0.2" />
|
|
||||||
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" />
|
|
||||||
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.4" />
|
|
||||||
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
|
|
||||||
<PackageReference Include="System.Data.SqlClient" Version="4.9.0" />
|
|
||||||
<PackageReference Include="Unity" Version="5.11.10" />
|
|
||||||
<PackageReference Include="Unity.Microsoft.Logging" Version="5.11.1" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Compile Update="Properties\Resources.Designer.cs">
|
|
||||||
<DesignTime>True</DesignTime>
|
|
||||||
<AutoGen>True</AutoGen>
|
|
||||||
<DependentUpon>Resources.resx</DependentUpon>
|
|
||||||
</Compile>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<EmbeddedResource Update="Properties\Resources.resx">
|
|
||||||
<Generator>ResXFileCodeGenerator</Generator>
|
|
||||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
|
||||||
</EmbeddedResource>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<None Update="appsettings.json">
|
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
|
||||||
</None>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
</Project>
|
93
ProjectGarage/Properties/Resources.Designer.cs
generated
@ -1,93 +0,0 @@
|
|||||||
//------------------------------------------------------------------------------
|
|
||||||
// <auto-generated>
|
|
||||||
// Этот код создан программой.
|
|
||||||
// Исполняемая версия:4.0.30319.42000
|
|
||||||
//
|
|
||||||
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
|
|
||||||
// повторной генерации кода.
|
|
||||||
// </auto-generated>
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
namespace ProjectGarage.Properties {
|
|
||||||
using System;
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д.
|
|
||||||
/// </summary>
|
|
||||||
// Этот класс создан автоматически классом StronglyTypedResourceBuilder
|
|
||||||
// с помощью такого средства, как ResGen или Visual Studio.
|
|
||||||
// Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen
|
|
||||||
// с параметром /str или перестройте свой проект VS.
|
|
||||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
|
||||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
|
||||||
internal class Resources {
|
|
||||||
|
|
||||||
private static global::System.Resources.ResourceManager resourceMan;
|
|
||||||
|
|
||||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
|
||||||
|
|
||||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
|
||||||
internal Resources() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом.
|
|
||||||
/// </summary>
|
|
||||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
|
||||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
|
||||||
get {
|
|
||||||
if (object.ReferenceEquals(resourceMan, null)) {
|
|
||||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ProjectGarage.Properties.Resources", typeof(Resources).Assembly);
|
|
||||||
resourceMan = temp;
|
|
||||||
}
|
|
||||||
return resourceMan;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Перезаписывает свойство CurrentUICulture текущего потока для всех
|
|
||||||
/// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией.
|
|
||||||
/// </summary>
|
|
||||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
|
||||||
internal static global::System.Globalization.CultureInfo Culture {
|
|
||||||
get {
|
|
||||||
return resourceCulture;
|
|
||||||
}
|
|
||||||
set {
|
|
||||||
resourceCulture = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
|
||||||
/// </summary>
|
|
||||||
internal static System.Drawing.Bitmap каранд {
|
|
||||||
get {
|
|
||||||
object obj = ResourceManager.GetObject("каранд", resourceCulture);
|
|
||||||
return ((System.Drawing.Bitmap)(obj));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
|
||||||
/// </summary>
|
|
||||||
internal static System.Drawing.Bitmap минусик {
|
|
||||||
get {
|
|
||||||
object obj = ResourceManager.GetObject("минусик", resourceCulture);
|
|
||||||
return ((System.Drawing.Bitmap)(obj));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
|
||||||
/// </summary>
|
|
||||||
internal static System.Drawing.Bitmap плюсик {
|
|
||||||
get {
|
|
||||||
object obj = ResourceManager.GetObject("плюсик", resourceCulture);
|
|
||||||
return ((System.Drawing.Bitmap)(obj));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,130 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<root>
|
|
||||||
<!--
|
|
||||||
Microsoft ResX Schema
|
|
||||||
|
|
||||||
Version 2.0
|
|
||||||
|
|
||||||
The primary goals of this format is to allow a simple XML format
|
|
||||||
that is mostly human readable. The generation and parsing of the
|
|
||||||
various data types are done through the TypeConverter classes
|
|
||||||
associated with the data types.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
... ado.net/XML headers & schema ...
|
|
||||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
|
||||||
<resheader name="version">2.0</resheader>
|
|
||||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
|
||||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
|
||||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
|
||||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
|
||||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
|
||||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
|
||||||
</data>
|
|
||||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
|
||||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
|
||||||
<comment>This is a comment</comment>
|
|
||||||
</data>
|
|
||||||
|
|
||||||
There are any number of "resheader" rows that contain simple
|
|
||||||
name/value pairs.
|
|
||||||
|
|
||||||
Each data row contains a name, and value. The row also contains a
|
|
||||||
type or mimetype. Type corresponds to a .NET class that support
|
|
||||||
text/value conversion through the TypeConverter architecture.
|
|
||||||
Classes that don't support this are serialized and stored with the
|
|
||||||
mimetype set.
|
|
||||||
|
|
||||||
The mimetype is used for serialized objects, and tells the
|
|
||||||
ResXResourceReader how to depersist the object. This is currently not
|
|
||||||
extensible. For a given mimetype the value must be set accordingly:
|
|
||||||
|
|
||||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
|
||||||
that the ResXResourceWriter will generate, however the reader can
|
|
||||||
read any of the formats listed below.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.binary.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.soap.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
|
||||||
value : The object must be serialized into a byte array
|
|
||||||
: using a System.ComponentModel.TypeConverter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
-->
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
|
||||||
<data name="минусик" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
|
||||||
<value>..\Resources\минусик.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
|
||||||
</data>
|
|
||||||
<data name="плюсик" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
|
||||||
<value>..\Resources\плюсик.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
|
||||||
</data>
|
|
||||||
<data name="каранд" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
|
||||||
<value>..\Resources\каранд.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
|
||||||
</data>
|
|
||||||
</root>
|
|
@ -1,51 +0,0 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using ProjectGarage.Repositories;
|
|
||||||
using ProjectGarage.Repositories.Implementations;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectGarage.Reports;
|
|
||||||
|
|
||||||
public class ChartReport
|
|
||||||
{
|
|
||||||
private readonly ITransportationRepository _transportationRepository;
|
|
||||||
private readonly ILogger<ChartReport> _logger;
|
|
||||||
public ChartReport(ITransportationRepository transportationRepository, ILogger<ChartReport> logger)
|
|
||||||
{
|
|
||||||
_transportationRepository = transportationRepository ??
|
|
||||||
throw new ArgumentNullException(nameof(transportationRepository));
|
|
||||||
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
|
||||||
}
|
|
||||||
public bool CreateChart(string filePath, DateTime dateTime)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
new PdfBuilder(filePath)
|
|
||||||
.AddHeader("Транспортировка топлива")
|
|
||||||
.AddPieChart("Отправленное топливо", GetData(dateTime))
|
|
||||||
.Build();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка при формировании документа");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private List<(string Caption, double Value)> GetData(DateTime dateTime)
|
|
||||||
{
|
|
||||||
return _transportationRepository
|
|
||||||
.ReadTransportation()
|
|
||||||
.Where(x => x.TransportationDate.Date == dateTime.Date)
|
|
||||||
.GroupBy(x => x.FuelId, (key, group) => new {
|
|
||||||
Id = key,
|
|
||||||
Amount = group.Sum(x => x.Amount)
|
|
||||||
})
|
|
||||||
.Select(x => (x.Id.ToString(), (double)x.Amount))
|
|
||||||
.ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,114 +0,0 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using ProjectGarage.Repositories;
|
|
||||||
using ProjectGarage.Repositories.Implementations;
|
|
||||||
using Serilog.Core;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectGarage.Reports;
|
|
||||||
|
|
||||||
public class DocReport
|
|
||||||
{
|
|
||||||
private readonly IFuelRepository _fuelRepository;
|
|
||||||
private readonly IDriverRepository _driverRepository;
|
|
||||||
private readonly IRouteRepository _routeRepository;
|
|
||||||
private readonly ITruckRepository _truckRepository;
|
|
||||||
|
|
||||||
private readonly ILogger<DocReport> _logger;
|
|
||||||
|
|
||||||
|
|
||||||
public DocReport(IFuelRepository fuelRepository, IDriverRepository driverRepository,
|
|
||||||
IRouteRepository routeRepository,ITruckRepository truckRepository,IConnectionString connectionstring,
|
|
||||||
ILogger<DocReport> logger)
|
|
||||||
{
|
|
||||||
_fuelRepository = fuelRepository ?? throw new ArgumentNullException(nameof(fuelRepository));
|
|
||||||
_driverRepository = driverRepository ?? throw new ArgumentNullException(nameof(driverRepository));
|
|
||||||
_routeRepository = routeRepository ?? throw new ArgumentNullException(nameof(routeRepository));
|
|
||||||
_truckRepository = truckRepository ?? throw new ArgumentNullException(nameof(truckRepository));
|
|
||||||
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool CreateDoc(string filePath, bool includeFuels, bool includeDrivers,
|
|
||||||
bool includeRoutes, bool includeTrucks)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var builder = new WordBuilder(filePath)
|
|
||||||
.AddHeader("Документ со справочниками");
|
|
||||||
if (includeTrucks)
|
|
||||||
{
|
|
||||||
builder.AddParagraph("Фуры")
|
|
||||||
.AddTable([2400, 2400, 2400],
|
|
||||||
GetTrucks());
|
|
||||||
}
|
|
||||||
if (includeFuels)
|
|
||||||
{
|
|
||||||
builder.AddParagraph("Топлива")
|
|
||||||
.AddTable([2400, 1200, 1200],
|
|
||||||
GetFuels());
|
|
||||||
}
|
|
||||||
if (includeDrivers)
|
|
||||||
{
|
|
||||||
builder.AddParagraph("Водители")
|
|
||||||
.AddTable([2400, 2400, 2400],
|
|
||||||
GetDrivers());
|
|
||||||
}
|
|
||||||
if (includeRoutes)
|
|
||||||
{
|
|
||||||
builder.AddParagraph("Маршруты")
|
|
||||||
.AddTable([2400, 2400, 2400],
|
|
||||||
GetRoutes());
|
|
||||||
}
|
|
||||||
builder.Build();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка при формировании документа");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<string[]> GetTrucks()
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
["Тип топлива", "Название топлива", "Цена"],
|
|
||||||
.. _fuelRepository
|
|
||||||
.ReadFuels()
|
|
||||||
.Select(x => new string[] { x.FuelType.ToString(), x.FuelName, x.Price.ToString() }),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<string[]> GetFuels()
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
["Тип топлива", "Название топлива", "Цена"],
|
|
||||||
.. _fuelRepository
|
|
||||||
.ReadFuels()
|
|
||||||
.Select(x => new string[] { x.FuelType.ToString(), x.FuelName, x.Price.ToString() }),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<string[]> GetDrivers()
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
["Имя", "Фамилия", "Номера машины"],
|
|
||||||
.. _driverRepository
|
|
||||||
.ReadDrivers()
|
|
||||||
.Select(x => new string[] { x.Fname, x.Lname, x.TruckId.ToString() }),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<string[]> GetRoutes()
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
["Начальная т.", "Конечная т.", "Протяженность"],
|
|
||||||
.. _routeRepository
|
|
||||||
.ReadRoute()
|
|
||||||
.Select(x => new string[] { x.StartP, x.FinalP, x.Length.ToString() }),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,321 +0,0 @@
|
|||||||
using DocumentFormat.OpenXml.Packaging;
|
|
||||||
using DocumentFormat.OpenXml.Spreadsheet;
|
|
||||||
using DocumentFormat.OpenXml;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectGarage.Reports;
|
|
||||||
|
|
||||||
public class ExcelBuilder
|
|
||||||
{
|
|
||||||
private readonly string _filePath;
|
|
||||||
private readonly SheetData _sheetData;
|
|
||||||
private readonly MergeCells _mergeCells;
|
|
||||||
private readonly Columns _columns;
|
|
||||||
private uint _rowIndex = 0;
|
|
||||||
public ExcelBuilder(string filePath)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrWhiteSpace(filePath))
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(filePath));
|
|
||||||
}
|
|
||||||
if (File.Exists(filePath))
|
|
||||||
{
|
|
||||||
File.Delete(filePath);
|
|
||||||
}
|
|
||||||
_filePath = filePath;
|
|
||||||
_sheetData = new SheetData();
|
|
||||||
_mergeCells = new MergeCells();
|
|
||||||
_columns = new Columns();
|
|
||||||
_rowIndex = 1;
|
|
||||||
}
|
|
||||||
public ExcelBuilder AddHeader(string header, int startIndex, int count)
|
|
||||||
{
|
|
||||||
CreateCell(startIndex, _rowIndex, header,
|
|
||||||
StyleIndex.SimpleTextWithoutBorder);
|
|
||||||
for (int i = startIndex + 1; i < startIndex + count; ++i)
|
|
||||||
{
|
|
||||||
CreateCell(i, _rowIndex, "",
|
|
||||||
StyleIndex.SimpleTextWithoutBorder);
|
|
||||||
}
|
|
||||||
_mergeCells.Append(new MergeCell()
|
|
||||||
{
|
|
||||||
Reference =
|
|
||||||
new
|
|
||||||
StringValue($"{GetExcelColumnName(startIndex)}{_rowIndex}:{GetExcelColumnName(startIndex
|
|
||||||
+ count - 1)}{_rowIndex}")
|
|
||||||
});
|
|
||||||
_rowIndex++;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
public ExcelBuilder AddParagraph(string text, int columnIndex)
|
|
||||||
{
|
|
||||||
CreateCell(columnIndex, _rowIndex++, text,
|
|
||||||
StyleIndex.SimpleTextWithoutBorder);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
public ExcelBuilder AddTable(int[] columnsWidths, List<string[]> data)
|
|
||||||
{
|
|
||||||
if (columnsWidths == null || columnsWidths.Length == 0)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(columnsWidths));
|
|
||||||
}
|
|
||||||
if (data == null || data.Count == 0)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(data));
|
|
||||||
}
|
|
||||||
if (data.Any(x => x.Length != columnsWidths.Length))
|
|
||||||
{
|
|
||||||
throw new InvalidOperationException("widths.Length != data.Length");
|
|
||||||
}
|
|
||||||
uint counter = 1;
|
|
||||||
int coef = 2;
|
|
||||||
_columns.Append(columnsWidths.Select(x => new Column
|
|
||||||
{
|
|
||||||
Min = counter,
|
|
||||||
Max = counter++,
|
|
||||||
Width = x * coef,
|
|
||||||
CustomWidth = true
|
|
||||||
}));
|
|
||||||
for (var j = 0; j < data.First().Length; ++j)
|
|
||||||
{
|
|
||||||
CreateCell(j, _rowIndex, data.First()[j],
|
|
||||||
StyleIndex.SimpleTextWithoutBorder);
|
|
||||||
}
|
|
||||||
_rowIndex++;
|
|
||||||
for (var i = 1; i < data.Count - 1; ++i)
|
|
||||||
{
|
|
||||||
for (var j = 0; j < data[i].Length; ++j)
|
|
||||||
{
|
|
||||||
CreateCell(j, _rowIndex, data[i][j],
|
|
||||||
StyleIndex.SimpleTextWithoutBorder);
|
|
||||||
}
|
|
||||||
_rowIndex++;
|
|
||||||
}
|
|
||||||
for (var j = 0; j < data.Last().Length; ++j)
|
|
||||||
{
|
|
||||||
CreateCell(j, _rowIndex, data.Last()[j],
|
|
||||||
StyleIndex.SimpleTextWithoutBorder);
|
|
||||||
}
|
|
||||||
_rowIndex++;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
public void Build()
|
|
||||||
{
|
|
||||||
using var spreadsheetDocument = SpreadsheetDocument.Create(_filePath,
|
|
||||||
SpreadsheetDocumentType.Workbook);
|
|
||||||
var workbookpart = spreadsheetDocument.AddWorkbookPart();
|
|
||||||
GenerateStyle(workbookpart);
|
|
||||||
workbookpart.Workbook = new Workbook();
|
|
||||||
var worksheetPart = workbookpart.AddNewPart<WorksheetPart>();
|
|
||||||
worksheetPart.Worksheet = new Worksheet();
|
|
||||||
if (_columns.HasChildren)
|
|
||||||
{
|
|
||||||
worksheetPart.Worksheet.Append(_columns);
|
|
||||||
}
|
|
||||||
worksheetPart.Worksheet.Append(_sheetData);
|
|
||||||
var sheets =
|
|
||||||
spreadsheetDocument.WorkbookPart!.Workbook.AppendChild(new Sheets());
|
|
||||||
var sheet = new Sheet()
|
|
||||||
{
|
|
||||||
Id =
|
|
||||||
spreadsheetDocument.WorkbookPart.GetIdOfPart(worksheetPart),
|
|
||||||
SheetId = 1,
|
|
||||||
Name = "Лист 1"
|
|
||||||
};
|
|
||||||
sheets.Append(sheet);
|
|
||||||
if (_mergeCells.HasChildren)
|
|
||||||
{
|
|
||||||
worksheetPart.Worksheet.InsertAfter(_mergeCells,
|
|
||||||
worksheetPart.Worksheet.Elements<SheetData>().First());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private static void GenerateStyle(WorkbookPart workbookPart)
|
|
||||||
{
|
|
||||||
var workbookStylesPart =
|
|
||||||
workbookPart.AddNewPart<WorkbookStylesPart>();
|
|
||||||
workbookStylesPart.Stylesheet = new Stylesheet();
|
|
||||||
var fonts = new Fonts()
|
|
||||||
{
|
|
||||||
Count = 2,
|
|
||||||
KnownFonts = BooleanValue.FromBoolean(true)
|
|
||||||
};
|
|
||||||
fonts.Append(new DocumentFormat.OpenXml.Spreadsheet.Font
|
|
||||||
{
|
|
||||||
FontSize = new FontSize() { Val = 11 },
|
|
||||||
FontName = new FontName() { Val = "Calibri" },
|
|
||||||
FontFamilyNumbering = new FontFamilyNumbering() { Val = 2 },
|
|
||||||
FontScheme = new FontScheme()
|
|
||||||
{
|
|
||||||
Val = new EnumValue<FontSchemeValues>(FontSchemeValues.Minor)
|
|
||||||
}
|
|
||||||
});
|
|
||||||
fonts.Append(new DocumentFormat.OpenXml.Spreadsheet.Font
|
|
||||||
{
|
|
||||||
FontSize = new FontSize() { Val = 11 },
|
|
||||||
FontName = new FontName() { Val = "Calibri" },
|
|
||||||
FontFamilyNumbering = new FontFamilyNumbering() { Val = 2 },
|
|
||||||
FontScheme = new FontScheme()
|
|
||||||
{
|
|
||||||
Val = new EnumValue<FontSchemeValues>(FontSchemeValues.Minor)
|
|
||||||
},
|
|
||||||
Bold = new Bold() { Val = true }
|
|
||||||
});
|
|
||||||
workbookStylesPart.Stylesheet.Append(fonts);
|
|
||||||
// Default Fill
|
|
||||||
var fills = new Fills() { Count = 1 };
|
|
||||||
fills.Append(new Fill
|
|
||||||
{
|
|
||||||
PatternFill = new PatternFill()
|
|
||||||
{
|
|
||||||
PatternType = new
|
|
||||||
EnumValue<PatternValues>(PatternValues.None)
|
|
||||||
}
|
|
||||||
});
|
|
||||||
workbookStylesPart.Stylesheet.Append(fills);
|
|
||||||
// Default Border
|
|
||||||
var borders = new Borders() { Count = 2 };
|
|
||||||
borders.Append(new Border
|
|
||||||
{
|
|
||||||
LeftBorder = new LeftBorder(),
|
|
||||||
RightBorder = new RightBorder(),
|
|
||||||
TopBorder = new TopBorder(),
|
|
||||||
BottomBorder = new BottomBorder(),
|
|
||||||
DiagonalBorder = new DiagonalBorder()
|
|
||||||
});
|
|
||||||
// TODO добавить настройку с границами
|
|
||||||
borders.Append(new Border
|
|
||||||
{
|
|
||||||
LeftBorder = new LeftBorder() { Style = BorderStyleValues.Thin },
|
|
||||||
RightBorder = new RightBorder() { Style = BorderStyleValues.Thin },
|
|
||||||
TopBorder = new TopBorder() { Style = BorderStyleValues.Thin },
|
|
||||||
BottomBorder = new BottomBorder() { Style = BorderStyleValues.Thin },
|
|
||||||
DiagonalBorder = new DiagonalBorder()
|
|
||||||
});
|
|
||||||
workbookStylesPart.Stylesheet.Append(borders);
|
|
||||||
// Default cell format and a date cell format
|
|
||||||
var cellFormats = new CellFormats() { Count = 4 };
|
|
||||||
cellFormats.Append(new CellFormat
|
|
||||||
{
|
|
||||||
NumberFormatId = 0,
|
|
||||||
FormatId = 0,
|
|
||||||
FontId = 0,
|
|
||||||
BorderId = 0,
|
|
||||||
FillId = 0,
|
|
||||||
Alignment = new Alignment()
|
|
||||||
{
|
|
||||||
Horizontal = HorizontalAlignmentValues.Left,
|
|
||||||
Vertical = VerticalAlignmentValues.Center,
|
|
||||||
WrapText = true
|
|
||||||
}
|
|
||||||
});
|
|
||||||
// TODO дополнить форматы
|
|
||||||
cellFormats.Append(new CellFormat
|
|
||||||
{
|
|
||||||
NumberFormatId = 0,
|
|
||||||
FormatId = 0,
|
|
||||||
FontId = 1,
|
|
||||||
BorderId = 0,
|
|
||||||
FillId = 0,
|
|
||||||
Alignment = new Alignment()
|
|
||||||
{
|
|
||||||
Horizontal = HorizontalAlignmentValues.Left,
|
|
||||||
Vertical = VerticalAlignmentValues.Center,
|
|
||||||
WrapText = true
|
|
||||||
}
|
|
||||||
});
|
|
||||||
cellFormats.Append(new CellFormat
|
|
||||||
{
|
|
||||||
NumberFormatId = 0,
|
|
||||||
FormatId = 0,
|
|
||||||
FontId = 0,
|
|
||||||
BorderId = 1,
|
|
||||||
FillId = 0,
|
|
||||||
Alignment = new Alignment()
|
|
||||||
{
|
|
||||||
Horizontal = HorizontalAlignmentValues.Left,
|
|
||||||
Vertical = VerticalAlignmentValues.Center,
|
|
||||||
WrapText = true
|
|
||||||
}
|
|
||||||
});
|
|
||||||
cellFormats.Append(new CellFormat
|
|
||||||
{
|
|
||||||
NumberFormatId = 0,
|
|
||||||
FormatId = 0,
|
|
||||||
FontId = 1,
|
|
||||||
BorderId = 1,
|
|
||||||
FillId = 0,
|
|
||||||
Alignment = new Alignment()
|
|
||||||
{
|
|
||||||
Horizontal = HorizontalAlignmentValues.Left,
|
|
||||||
Vertical = VerticalAlignmentValues.Center,
|
|
||||||
WrapText = true
|
|
||||||
}
|
|
||||||
});
|
|
||||||
workbookStylesPart.Stylesheet.Append(cellFormats);
|
|
||||||
}
|
|
||||||
private enum StyleIndex
|
|
||||||
{
|
|
||||||
SimpleTextWithoutBorder = 0,
|
|
||||||
// TODO дополнить стили
|
|
||||||
BoldTextWithoutBorder = 1,
|
|
||||||
SimpleTextWithBorder = 2,
|
|
||||||
BoldTextWithBorder = 3,
|
|
||||||
}
|
|
||||||
private void CreateCell(int columnIndex, uint rowIndex, string text,
|
|
||||||
StyleIndex styleIndex)
|
|
||||||
{
|
|
||||||
var columnName = GetExcelColumnName(columnIndex);
|
|
||||||
var cellReference = columnName + rowIndex;
|
|
||||||
var row = _sheetData.Elements<Row>().FirstOrDefault(r => r.RowIndex!
|
|
||||||
== rowIndex);
|
|
||||||
if (row == null)
|
|
||||||
{
|
|
||||||
row = new Row() { RowIndex = rowIndex };
|
|
||||||
_sheetData.Append(row);
|
|
||||||
}
|
|
||||||
var newCell = row.Elements<Cell>()
|
|
||||||
.FirstOrDefault(c => c.CellReference != null &&
|
|
||||||
c.CellReference.Value == columnName + rowIndex);
|
|
||||||
if (newCell == null)
|
|
||||||
{
|
|
||||||
Cell? refCell = null;
|
|
||||||
foreach (Cell cell in row.Elements<Cell>())
|
|
||||||
{
|
|
||||||
if (cell.CellReference?.Value != null &&
|
|
||||||
cell.CellReference.Value.Length == cellReference.Length)
|
|
||||||
{
|
|
||||||
if (string.Compare(cell.CellReference.Value,
|
|
||||||
cellReference, true) > 0)
|
|
||||||
{
|
|
||||||
refCell = cell;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
newCell = new Cell() { CellReference = cellReference };
|
|
||||||
row.InsertBefore(newCell, refCell);
|
|
||||||
}
|
|
||||||
newCell.CellValue = new CellValue(text);
|
|
||||||
newCell.DataType = CellValues.String;
|
|
||||||
newCell.StyleIndex = (uint)styleIndex;
|
|
||||||
}
|
|
||||||
private static string GetExcelColumnName(int columnNumber)
|
|
||||||
{
|
|
||||||
columnNumber += 1;
|
|
||||||
int dividend = columnNumber;
|
|
||||||
string columnName = string.Empty;
|
|
||||||
int modulo;
|
|
||||||
while (dividend > 0)
|
|
||||||
{
|
|
||||||
modulo = (dividend - 1) % 26;
|
|
||||||
columnName = Convert.ToChar(65 + modulo).ToString() +
|
|
||||||
columnName;
|
|
||||||
dividend = (dividend - modulo) / 26;
|
|
||||||
}
|
|
||||||
return columnName;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,91 +0,0 @@
|
|||||||
using MigraDoc.DocumentObjectModel;
|
|
||||||
using MigraDoc.DocumentObjectModel.Shapes.Charts;
|
|
||||||
using MigraDoc.Rendering;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectGarage.Reports;
|
|
||||||
|
|
||||||
public class PdfBuilder
|
|
||||||
{
|
|
||||||
private readonly string _filePath;
|
|
||||||
|
|
||||||
private readonly Document _document;
|
|
||||||
|
|
||||||
public PdfBuilder(string filePath)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrWhiteSpace(filePath))
|
|
||||||
throw new ArgumentNullException(nameof(filePath));
|
|
||||||
|
|
||||||
if (File.Exists(filePath))
|
|
||||||
File.Delete(filePath);
|
|
||||||
|
|
||||||
_filePath = filePath;
|
|
||||||
_document = new Document();
|
|
||||||
DefineStyles();
|
|
||||||
}
|
|
||||||
|
|
||||||
public PdfBuilder AddHeader(string header)
|
|
||||||
{
|
|
||||||
_document.AddSection().AddParagraph(header, "NormalBold");
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PdfBuilder AddPieChart(string title, List<(string Caption, double Value)> data)
|
|
||||||
{
|
|
||||||
if (data == null || data.Count == 0)
|
|
||||||
return this;
|
|
||||||
|
|
||||||
var chart = new Chart(ChartType.Pie2D);
|
|
||||||
var series = chart.SeriesCollection.AddSeries();
|
|
||||||
series.Add(data.Select(x => x.Value).ToArray());
|
|
||||||
|
|
||||||
var xseries = chart.XValues.AddXSeries();
|
|
||||||
xseries.Add(data.Select(x => x.Caption).ToArray());
|
|
||||||
|
|
||||||
chart.DataLabel.Type = DataLabelType.Percent;
|
|
||||||
chart.DataLabel.Position = DataLabelPosition.OutsideEnd;
|
|
||||||
|
|
||||||
chart.Width = Unit.FromCentimeter(16);
|
|
||||||
chart.Height = Unit.FromCentimeter(12);
|
|
||||||
|
|
||||||
chart.TopArea.AddParagraph(title);
|
|
||||||
|
|
||||||
chart.XAxis.MajorTickMark = TickMarkType.Outside;
|
|
||||||
|
|
||||||
chart.YAxis.MajorTickMark = TickMarkType.Outside;
|
|
||||||
chart.YAxis.HasMajorGridlines = true;
|
|
||||||
|
|
||||||
chart.PlotArea.LineFormat.Width = 1;
|
|
||||||
chart.PlotArea.LineFormat.Visible = true;
|
|
||||||
|
|
||||||
chart.TopArea.AddLegend();
|
|
||||||
|
|
||||||
_document.LastSection.Add(chart);
|
|
||||||
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Build()
|
|
||||||
{
|
|
||||||
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
|
|
||||||
|
|
||||||
var renderer = new PdfDocumentRenderer(true)
|
|
||||||
{
|
|
||||||
Document = _document
|
|
||||||
};
|
|
||||||
|
|
||||||
renderer.RenderDocument();
|
|
||||||
renderer.PdfDocument.Save(_filePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void DefineStyles()
|
|
||||||
{
|
|
||||||
var headerStyle = _document.Styles.AddStyle("NormalBold", "Normal");
|
|
||||||
headerStyle.Font.Bold = true;
|
|
||||||
headerStyle.Font.Size = 14;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,83 +0,0 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using ProjectGarage.Repositories;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectGarage.Reports;
|
|
||||||
|
|
||||||
public class TableReport
|
|
||||||
{
|
|
||||||
private readonly IReplenishmentRepository _replenishmentRepository;
|
|
||||||
private readonly ITransportationRepository _transportationRepository;
|
|
||||||
private readonly ILogger<TableReport> _logger;
|
|
||||||
internal static readonly string[] item = ["Водитель", "Дата", " пришло", "Количество ушло"];
|
|
||||||
public TableReport(IReplenishmentRepository replenishmentRepository,
|
|
||||||
ITransportationRepository transportationRepository, ILogger<TableReport> logger)
|
|
||||||
{
|
|
||||||
_replenishmentRepository = replenishmentRepository ??
|
|
||||||
throw new ArgumentNullException(nameof(replenishmentRepository));
|
|
||||||
_transportationRepository = transportationRepository ??
|
|
||||||
throw new ArgumentNullException(nameof(transportationRepository));
|
|
||||||
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
|
||||||
}
|
|
||||||
public bool CreateTable(string filePath, int fuelId, DateTime startDate, DateTime endDate)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
new ExcelBuilder(filePath)
|
|
||||||
.AddHeader("Сводка по движению топлива", 0, 4)
|
|
||||||
.AddParagraph("за период", 0)
|
|
||||||
.AddTable([10, 10, 15, 15], GetData(fuelId, startDate,
|
|
||||||
endDate))
|
|
||||||
.Build();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка при формировании документа");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<string[]> GetData(int fuelId, DateTime startDate, DateTime
|
|
||||||
endDate)
|
|
||||||
{
|
|
||||||
var data = _replenishmentRepository
|
|
||||||
.ReadFuelReplenishment()
|
|
||||||
.Where(x => x.ReplenishmentDate >= startDate && x.ReplenishmentDate <= endDate &&
|
|
||||||
x.FuelFuelReplenishments.Any(y => y.FuelId == fuelId))
|
|
||||||
.Select(x => new {
|
|
||||||
x.DriverId,
|
|
||||||
Date = x.ReplenishmentDate,
|
|
||||||
CountIn = x.FuelFuelReplenishments.
|
|
||||||
FirstOrDefault(y => y.FuelId == fuelId)?.Amount,
|
|
||||||
CountOut = (int?)null
|
|
||||||
})
|
|
||||||
.Union(
|
|
||||||
_transportationRepository
|
|
||||||
.ReadTransportation()
|
|
||||||
.Where(x => x.TransportationDate >= startDate &&
|
|
||||||
x.TransportationDate <= endDate && x.FuelId == fuelId)
|
|
||||||
.Select(x => new {
|
|
||||||
x.DriverId,
|
|
||||||
Date = x.TransportationDate,
|
|
||||||
CountIn = (int?)null,
|
|
||||||
CountOut = (int?)x.Amount
|
|
||||||
}))
|
|
||||||
.OrderBy(x => x.Date);
|
|
||||||
return
|
|
||||||
new List<string[]>() { item }
|
|
||||||
.Union(
|
|
||||||
data
|
|
||||||
.Select(x => new string[] {
|
|
||||||
x.DriverId.ToString(), x.Date.ToString(), x.CountIn?.ToString() ??
|
|
||||||
string.Empty, x.CountOut?.ToString() ?? string.Empty}))
|
|
||||||
.Union(
|
|
||||||
[["Всего", "", data.Sum(x => x.CountIn ?? 0).ToString(),
|
|
||||||
data.Sum(x => x.CountOut ?? 0).ToString()]])
|
|
||||||
.ToList();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,135 +0,0 @@
|
|||||||
using DocumentFormat.OpenXml;
|
|
||||||
using DocumentFormat.OpenXml.Packaging;
|
|
||||||
using DocumentFormat.OpenXml.Wordprocessing;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectGarage.Reports;
|
|
||||||
|
|
||||||
public class WordBuilder
|
|
||||||
{
|
|
||||||
private readonly string _filePath;
|
|
||||||
private readonly Document _document;
|
|
||||||
private readonly Body _body;
|
|
||||||
|
|
||||||
public WordBuilder(string filePath)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrWhiteSpace(filePath))
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(filePath));
|
|
||||||
}
|
|
||||||
if (File.Exists(filePath))
|
|
||||||
{
|
|
||||||
File.Delete(filePath);
|
|
||||||
}
|
|
||||||
_filePath = filePath;
|
|
||||||
_document = new Document();
|
|
||||||
_body = _document.AppendChild(new Body());
|
|
||||||
}
|
|
||||||
|
|
||||||
public WordBuilder AddHeader(string header)
|
|
||||||
{
|
|
||||||
var paragraph = _body.AppendChild(new Paragraph());
|
|
||||||
var run = paragraph.AppendChild(new Run());
|
|
||||||
var runProperties = run.AppendChild(new RunProperties());
|
|
||||||
runProperties.AppendChild(new Bold());
|
|
||||||
run.AppendChild(new Text(header));
|
|
||||||
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
public WordBuilder AddParagraph(string text)
|
|
||||||
{
|
|
||||||
var paragraph = _body.AppendChild(new Paragraph());
|
|
||||||
var run = paragraph.AppendChild(new Run());
|
|
||||||
run.AppendChild(new Text(text));
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
public WordBuilder AddTable(int[] widths, List<string[]> data)
|
|
||||||
{
|
|
||||||
if (widths == null || widths.Length == 0)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(widths));
|
|
||||||
}
|
|
||||||
if (data == null || data.Count == 0)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(data));
|
|
||||||
}
|
|
||||||
if (data.Any(x => x.Length != widths.Length))
|
|
||||||
{
|
|
||||||
throw new InvalidOperationException("widths.Length != data.Length");
|
|
||||||
}
|
|
||||||
|
|
||||||
var table = new Table();
|
|
||||||
table.AppendChild(new TableProperties( new TableBorders( new TopBorder()
|
|
||||||
{
|
|
||||||
Val = new
|
|
||||||
EnumValue<BorderValues>(BorderValues.Single),
|
|
||||||
Size = 12
|
|
||||||
},
|
|
||||||
new BottomBorder()
|
|
||||||
{
|
|
||||||
Val = new
|
|
||||||
EnumValue<BorderValues>(BorderValues.Single),
|
|
||||||
Size = 12
|
|
||||||
},
|
|
||||||
new LeftBorder()
|
|
||||||
{
|
|
||||||
Val = new
|
|
||||||
EnumValue<BorderValues>(BorderValues.Single),
|
|
||||||
Size = 12
|
|
||||||
},
|
|
||||||
new RightBorder()
|
|
||||||
{
|
|
||||||
Val = new
|
|
||||||
EnumValue<BorderValues>(BorderValues.Single),
|
|
||||||
Size = 12
|
|
||||||
},
|
|
||||||
new InsideHorizontalBorder()
|
|
||||||
{
|
|
||||||
Val = new
|
|
||||||
EnumValue<BorderValues>(BorderValues.Single),
|
|
||||||
Size = 12
|
|
||||||
},
|
|
||||||
new InsideVerticalBorder()
|
|
||||||
{
|
|
||||||
Val = new
|
|
||||||
EnumValue<BorderValues>(BorderValues.Single),
|
|
||||||
Size = 12
|
|
||||||
}
|
|
||||||
)
|
|
||||||
));
|
|
||||||
|
|
||||||
// Заголовок
|
|
||||||
var tr = new TableRow();
|
|
||||||
for (var j = 0; j < widths.Length; ++j)
|
|
||||||
{
|
|
||||||
tr.Append(new TableCell(
|
|
||||||
new TableCellProperties(new TableCellWidth()
|
|
||||||
{
|
|
||||||
Width =
|
|
||||||
widths[j].ToString()
|
|
||||||
}),
|
|
||||||
new Paragraph(new Run(new RunProperties(new Bold()), new
|
|
||||||
Text(data.First()[j])))));
|
|
||||||
}
|
|
||||||
|
|
||||||
table.Append(tr);
|
|
||||||
// Данные
|
|
||||||
table.Append(data.Skip(1).Select(x =>
|
|
||||||
new TableRow(x.Select(y => new TableCell(new Paragraph(new
|
|
||||||
Run(new Text(y))))))));
|
|
||||||
_body.Append(table);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Build()
|
|
||||||
{
|
|
||||||
using var wordDocument = WordprocessingDocument.Create(_filePath,
|
|
||||||
WordprocessingDocumentType.Document);
|
|
||||||
var mainPart = wordDocument.AddMainDocumentPart();
|
|
||||||
mainPart.Document = _document;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,12 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectGarage.Repositories;
|
|
||||||
|
|
||||||
public interface IConnectionString
|
|
||||||
{
|
|
||||||
public string ConnectionString { get; }
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
using ProjectGarage.Entities;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectGarage.Repositories;
|
|
||||||
|
|
||||||
public interface IDriverRepository
|
|
||||||
{
|
|
||||||
IEnumerable<Driver> ReadDrivers();
|
|
||||||
|
|
||||||
Driver ReadDriverByID(int id);
|
|
||||||
|
|
||||||
void CreateDriver(Driver driver);
|
|
||||||
|
|
||||||
void UpdateDriver(Driver driver);
|
|
||||||
|
|
||||||
void DeleteDriver(int id);
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
using ProjectGarage.Entities;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectGarage.Repositories;
|
|
||||||
|
|
||||||
public interface IFuelRepository
|
|
||||||
{
|
|
||||||
IEnumerable<Fuel> ReadFuels();
|
|
||||||
|
|
||||||
Fuel ReadFuelByID(int id);
|
|
||||||
|
|
||||||
void CreateFuel(Fuel fuel);
|
|
||||||
|
|
||||||
void UpdateFuel(Fuel fuel);
|
|
||||||
|
|
||||||
void DeleteFuel(int id);
|
|
||||||
}
|
|
@ -1,17 +0,0 @@
|
|||||||
using ProjectGarage.Entities;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectGarage.Repositories;
|
|
||||||
|
|
||||||
public interface IReplenishmentRepository
|
|
||||||
{
|
|
||||||
IEnumerable<FuelReplenishment> ReadFuelReplenishment(DateTime? dateForm = null, DateTime? dateTo = null, int? fuelId = null,
|
|
||||||
int? driverId = null, int? routeId = null);
|
|
||||||
void CreateFuelReplenishment(FuelReplenishment fuelReplenishment);
|
|
||||||
|
|
||||||
void DeleteFuelReplenishment(int id);
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
using ProjectGarage.Entities;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectGarage.Repositories;
|
|
||||||
|
|
||||||
public interface IRouteRepository
|
|
||||||
{
|
|
||||||
IEnumerable<Route> ReadRoute(string? startPoint = null,string? finalPoint = null);
|
|
||||||
|
|
||||||
Route ReadRouteByID(int id);
|
|
||||||
|
|
||||||
void CreateRoute(Route route);
|
|
||||||
|
|
||||||
void UpdateRoute(Route route);
|
|
||||||
|
|
||||||
void DeleteRoute(int id);
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
using ProjectGarage.Entities;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectGarage.Repositories;
|
|
||||||
|
|
||||||
public interface ITransportationRepository
|
|
||||||
{
|
|
||||||
IEnumerable<Transportation> ReadTransportation(DateTime? dateForm = null, DateTime? dateTo = null, int? fuelId = null,
|
|
||||||
int? driverId = null, int? routeId = null);
|
|
||||||
void CreateTransportation(Transportation transportation);
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
using ProjectGarage.Entities;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectGarage.Repositories;
|
|
||||||
|
|
||||||
public interface ITruckRepository
|
|
||||||
{
|
|
||||||
IEnumerable<Truck> ReadTrucks();
|
|
||||||
|
|
||||||
Truck ReadTruckByID(int id);
|
|
||||||
|
|
||||||
void CreateTruck(Truck truck);
|
|
||||||
|
|
||||||
void UpdateTruck(Truck truck);
|
|
||||||
|
|
||||||
void DeleteTruck(int id);
|
|
||||||
}
|
|
@ -1,12 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectGarage.Repositories.Implementations;
|
|
||||||
|
|
||||||
public class ConnectionString : IConnectionString
|
|
||||||
{
|
|
||||||
string IConnectionString.ConnectionString => "Host=localhost;Port=5432;Username=postgres;Password=postgres;Database=garage";
|
|
||||||
}
|
|
@ -1,131 +0,0 @@
|
|||||||
using Dapper;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using Npgsql;
|
|
||||||
using ProjectGarage.Entities;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Data.SqlClient;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectGarage.Repositories.Implementations;
|
|
||||||
|
|
||||||
public class DriverRepository : IDriverRepository
|
|
||||||
{
|
|
||||||
public readonly IConnectionString _connectionString;
|
|
||||||
|
|
||||||
private readonly ILogger<DriverRepository> _logger;
|
|
||||||
|
|
||||||
public DriverRepository(IConnectionString connectionString, ILogger<DriverRepository> logger)
|
|
||||||
{
|
|
||||||
_connectionString = connectionString;
|
|
||||||
_logger = logger;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void CreateDriver(Driver driver)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Добавление объект");
|
|
||||||
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(driver));
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
|
||||||
var queryInsert = @"
|
|
||||||
INSERT INTO driver (Fname, Lname, TruckId) VALUES
|
|
||||||
(@Fname, @Lname, @TruckId);";
|
|
||||||
connection.Execute(queryInsert, driver);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка при добавлении объекта");
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void UpdateDriver(Driver driver)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Редактирование объекта");
|
|
||||||
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(driver));
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
|
||||||
var queryUpdate = @"
|
|
||||||
UPDATE driver
|
|
||||||
SET
|
|
||||||
Fname=@Fname,
|
|
||||||
Lname=@Lname,
|
|
||||||
TruckId=@TruckId
|
|
||||||
WHERE Id=@Id";
|
|
||||||
connection.Execute(queryUpdate, driver);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка при редактировании объекта");
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void DeleteDriver(int id)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Удаление объекта");
|
|
||||||
_logger.LogDebug("Объект: {id}", id);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
|
||||||
var queryDelete = @"
|
|
||||||
DELETE FROM driver
|
|
||||||
WHERE Id=@id";
|
|
||||||
connection.Execute(queryDelete, new { id });
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка при удалении объекта");
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Driver ReadDriverByID(int id)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Получение объекта по идентификатору");
|
|
||||||
_logger.LogDebug("Объект: {id}", id);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
|
||||||
var querySelect = @"
|
|
||||||
SELECT * FROM driver
|
|
||||||
WHERE Id=@id";
|
|
||||||
var driver = connection.QueryFirst<Driver>(querySelect, new { id });
|
|
||||||
_logger.LogDebug("Найденный объект: {json}", JsonConvert.SerializeObject(driver));
|
|
||||||
|
|
||||||
return driver;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка при поиске объекта");
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerable<Driver> ReadDrivers()
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Получение всех объектов");
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
|
||||||
var querySelect = @"SELECT * FROM driver";
|
|
||||||
var drivers = connection.Query<Driver>(querySelect);
|
|
||||||
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(drivers));
|
|
||||||
return drivers;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка при чтении объектов");
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,129 +0,0 @@
|
|||||||
using Dapper;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using Npgsql;
|
|
||||||
using ProjectGarage.Entities;
|
|
||||||
using ProjectGarage.Entities.Enums;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectGarage.Repositories.Implementations;
|
|
||||||
|
|
||||||
public class FuelRepository : IFuelRepository
|
|
||||||
{
|
|
||||||
public readonly IConnectionString _connectionString;
|
|
||||||
|
|
||||||
private readonly ILogger<FuelRepository> _logger;
|
|
||||||
|
|
||||||
public FuelRepository(IConnectionString connectionString, ILogger<FuelRepository> logger)
|
|
||||||
{
|
|
||||||
_connectionString = connectionString;
|
|
||||||
_logger = logger;
|
|
||||||
}
|
|
||||||
public void CreateFuel(Fuel fuel)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Добавление объект");
|
|
||||||
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(fuel));
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
|
||||||
var queryInsert = @"
|
|
||||||
INSERT INTO fuel (FuelName, FuelType, Price) VALUES
|
|
||||||
(@FuelName, @FuelType, @Price);";
|
|
||||||
connection.Execute(queryInsert, fuel);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка при добавлении объекта");
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public void UpdateFuel(Fuel fuel)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Редактирование объекта");
|
|
||||||
_logger.LogDebug("Объект: {json}",
|
|
||||||
JsonConvert.SerializeObject(fuel));
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
|
||||||
var queryUpdate = @"
|
|
||||||
UPDATE fuel
|
|
||||||
SET
|
|
||||||
FuelName=@FuelName,
|
|
||||||
FuelType=@FuelType,
|
|
||||||
Price=@Price
|
|
||||||
WHERE Id=@Id";
|
|
||||||
connection.Execute(queryUpdate, fuel);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка при редактировании объекта");
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void DeleteFuel(int id)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Удаление объекта");
|
|
||||||
_logger.LogDebug("Объект: {id}", id);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
|
||||||
var queryDelete = @"
|
|
||||||
DELETE FROM fuel
|
|
||||||
WHERE Id=@id";
|
|
||||||
connection.Execute(queryDelete, new { id });
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка при удалении объекта");
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Fuel ReadFuelByID(int id)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Получение объекта по идентификатору");
|
|
||||||
_logger.LogDebug("Объект: {id}", id);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
|
||||||
var querySelect = @"
|
|
||||||
SELECT * FROM fuel
|
|
||||||
WHERE Id=@id";
|
|
||||||
var fuel = connection.QueryFirst<Fuel>(querySelect, new { id });
|
|
||||||
_logger.LogDebug("Найденный объект: {json}", JsonConvert.SerializeObject(fuel));
|
|
||||||
|
|
||||||
return fuel;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка при поиске объекта");
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerable<Fuel> ReadFuels()
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Получение всех объектов");
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
|
||||||
var querySelect = @"SELECT * FROM fuel";
|
|
||||||
var fuels = connection.Query<Fuel>(querySelect);
|
|
||||||
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(fuels));
|
|
||||||
return fuels;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка при чтении объектов");
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,105 +0,0 @@
|
|||||||
using Dapper;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using Npgsql;
|
|
||||||
using ProjectGarage.Entities;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Data.SqlClient;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectGarage.Repositories.Implementations;
|
|
||||||
|
|
||||||
public class ReplenishmentRepository : IReplenishmentRepository
|
|
||||||
{
|
|
||||||
private readonly IConnectionString _connectionString;
|
|
||||||
|
|
||||||
private readonly ILogger<ReplenishmentRepository> _logger;
|
|
||||||
|
|
||||||
public ReplenishmentRepository(IConnectionString connectionString, ILogger<ReplenishmentRepository> logger)
|
|
||||||
{
|
|
||||||
_connectionString = connectionString;
|
|
||||||
_logger = logger;
|
|
||||||
}
|
|
||||||
public void CreateFuelReplenishment(FuelReplenishment replenishment)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Добавление объекта");
|
|
||||||
_logger.LogDebug("Объект: {json}",
|
|
||||||
JsonConvert.SerializeObject(replenishment));
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
|
||||||
connection.Open();
|
|
||||||
using var transaction = connection.BeginTransaction();
|
|
||||||
var queryInsert = @"
|
|
||||||
INSERT INTO fuelreplenishment (DriverId, ReplenishmentDate)
|
|
||||||
VALUES (@DriverId, @ReplenishmentDate);
|
|
||||||
SELECT MAX(Id) FROM fuelreplenishment";
|
|
||||||
var ReplenishmentId = connection.QueryFirst<int>(queryInsert, replenishment, transaction);
|
|
||||||
var querySubInsert = @"
|
|
||||||
INSERT INTO fuel_fuelreplenishment (ReplenishmentId, FuelId, Amount)
|
|
||||||
VALUES (@ReplenishmentId, @FuelId, @Amount)";
|
|
||||||
foreach (var elem in replenishment.FuelFuelReplenishments)
|
|
||||||
{
|
|
||||||
connection.Execute(querySubInsert, new
|
|
||||||
{
|
|
||||||
ReplenishmentId,
|
|
||||||
elem.FuelId,
|
|
||||||
elem.Amount
|
|
||||||
}, transaction);
|
|
||||||
}
|
|
||||||
transaction.Commit();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка при добавлении объекта");
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void DeleteFuelReplenishment(int id)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Удаление объекта");
|
|
||||||
_logger.LogDebug("Объект: {id}", id);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
|
||||||
var queryDelete = @"
|
|
||||||
DELETE FROM fuelreplenishment
|
|
||||||
WHERE Id=@id";
|
|
||||||
connection.Execute(queryDelete, new { id });
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка при удалении объекта");
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerable<FuelReplenishment> ReadFuelReplenishment(DateTime? dateForm = null,
|
|
||||||
DateTime? dateTo = null, int? fuelId = null, int? driverId = null, int? routeId = null)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Получение всех объектов");
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var connection = new
|
|
||||||
NpgsqlConnection(_connectionString.ConnectionString);
|
|
||||||
var querySelect = @"SELECT fr.*, ffr.FuelId, ffr.Amount
|
|
||||||
FROM fuelreplenishment fr
|
|
||||||
INNER JOIN fuel_fuelReplenishment ffr ON ffr.ReplenishmentId = fr.Id";
|
|
||||||
var replenishments = connection.Query<TempFuelReplenishment>(querySelect);
|
|
||||||
_logger.LogDebug("Полученные объекты: {json}",
|
|
||||||
JsonConvert.SerializeObject(replenishments));
|
|
||||||
return replenishments.GroupBy(x => x.Id, y => y,
|
|
||||||
(key, value) => FuelReplenishment.CreateOpeartion(value.First(),
|
|
||||||
value.Select(z => FuelFuelReplenishment.CreateElement(0, z.FuelId, z.Amount)))).ToList();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка при чтении объектов");
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,129 +0,0 @@
|
|||||||
using Dapper;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using Npgsql;
|
|
||||||
using ProjectGarage.Entities;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectGarage.Repositories.Implementations;
|
|
||||||
|
|
||||||
public class RouteRepository : IRouteRepository
|
|
||||||
{
|
|
||||||
public readonly IConnectionString _connectionString;
|
|
||||||
|
|
||||||
private readonly ILogger<RouteRepository> _logger;
|
|
||||||
|
|
||||||
public RouteRepository(IConnectionString connectionString, ILogger<RouteRepository> logger)
|
|
||||||
{
|
|
||||||
_connectionString = connectionString;
|
|
||||||
_logger = logger;
|
|
||||||
}
|
|
||||||
public void CreateRoute(Route route)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Добавление объект");
|
|
||||||
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(route));
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
|
||||||
var queryInsert = @"
|
|
||||||
INSERT INTO route (RouteName, Startp, Finalp, Length) VALUES
|
|
||||||
(@RouteName, @Startp, @Finalp, @Length);";
|
|
||||||
connection.Execute(queryInsert, route);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка при добавлении объекта");
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public void UpdateRoute(Route route)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Редактирование объекта");
|
|
||||||
_logger.LogDebug("Объект: {json}",
|
|
||||||
JsonConvert.SerializeObject(route));
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
|
||||||
var queryUpdate = @"
|
|
||||||
UPDATE route
|
|
||||||
SET
|
|
||||||
RouteName=@RouteName,
|
|
||||||
Startp=@Startp,
|
|
||||||
Finalp=@Finalp,
|
|
||||||
Length=@Length
|
|
||||||
WHERE Id=@Id";
|
|
||||||
connection.Execute(queryUpdate, route);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка при редактировании объекта");
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void DeleteRoute(int id)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Удаление объекта");
|
|
||||||
_logger.LogDebug("Объект: {id}", id);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
|
||||||
var queryDelete = @"
|
|
||||||
DELETE FROM route
|
|
||||||
WHERE Id=@id";
|
|
||||||
connection.Execute(queryDelete, new { id });
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка при удалении объекта");
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Route ReadRouteByID(int id)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Получение объекта по идентификатору");
|
|
||||||
_logger.LogDebug("Объект: {id}", id);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
|
||||||
var querySelect = @"
|
|
||||||
SELECT * FROM route
|
|
||||||
WHERE Id=@id";
|
|
||||||
var route = connection.QueryFirst<Route>(querySelect, new { id });
|
|
||||||
_logger.LogDebug("Найденный объект: {json}", JsonConvert.SerializeObject(route));
|
|
||||||
|
|
||||||
return route;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка при поиске объекта");
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerable<Route> ReadRoute(string? startPoint = null, string? finalPoint = null)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Получение всех объектов");
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
|
||||||
var querySelect = @"SELECT * FROM route";
|
|
||||||
var routes = connection.Query<Route>(querySelect);
|
|
||||||
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(routes));
|
|
||||||
return routes;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка при чтении объектов");
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,67 +0,0 @@
|
|||||||
using Dapper;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using Npgsql;
|
|
||||||
using ProjectGarage.Entities;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Data.SqlClient;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectGarage.Repositories.Implementations;
|
|
||||||
|
|
||||||
public class TransportationRepository : ITransportationRepository
|
|
||||||
{
|
|
||||||
private readonly IConnectionString _connectionString;
|
|
||||||
|
|
||||||
private readonly ILogger<TransportationRepository> _logger;
|
|
||||||
|
|
||||||
public TransportationRepository(IConnectionString connectionString, ILogger<TransportationRepository> logger)
|
|
||||||
{
|
|
||||||
_connectionString = connectionString;
|
|
||||||
_logger = logger;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void CreateTransportation(Transportation transportation)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Добавление объекта");
|
|
||||||
_logger.LogDebug("Объект: {json}",
|
|
||||||
JsonConvert.SerializeObject(transportation));
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
|
||||||
var queryInsert = @"
|
|
||||||
INSERT INTO transportation (DriverId, RouteId, FuelId, Amount, TransportationDate)
|
|
||||||
VALUES (@DriverId, @RouteId, @FuelId, @Amount, @TransportationDate)";
|
|
||||||
connection.Execute(queryInsert, transportation);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка при добавлении объекта");
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerable<Transportation> ReadTransportation(DateTime? dateForm = null, DateTime? dateTo = null,
|
|
||||||
int? fuelId = null, int? driverId = null, int? routeId = null)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Получение всех объектов");
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
|
||||||
var querySelect = "SELECT * FROM transportation";
|
|
||||||
var transportations = connection.Query<Transportation>(querySelect);
|
|
||||||
_logger.LogDebug("Полученные объекты: {json}",
|
|
||||||
JsonConvert.SerializeObject(transportations));
|
|
||||||
return transportations;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка при чтении объектов");
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,130 +0,0 @@
|
|||||||
using Dapper;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using Npgsql;
|
|
||||||
using ProjectGarage.Entities;
|
|
||||||
using ProjectGarage.Entities.Enums;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectGarage.Repositories.Implementations;
|
|
||||||
|
|
||||||
public class TruckRepository : ITruckRepository
|
|
||||||
{
|
|
||||||
public readonly IConnectionString _connectionString;
|
|
||||||
|
|
||||||
private readonly ILogger<TruckRepository> _logger;
|
|
||||||
|
|
||||||
public TruckRepository(IConnectionString connectionString, ILogger<TruckRepository> logger)
|
|
||||||
{
|
|
||||||
_connectionString = connectionString;
|
|
||||||
_logger = logger;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void CreateTruck(Truck truck)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Добавление объект");
|
|
||||||
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(truck));
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
|
||||||
var queryInsert = @"
|
|
||||||
INSERT INTO truck (Numbers, Truck_Type, MaxFuel) VALUES
|
|
||||||
(@Numbers, @Truck_Type, @MaxFuel);";
|
|
||||||
connection.Execute(queryInsert, truck);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка при добавлении объекта");
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public void UpdateTruck(Truck truck)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Редактирование объекта");
|
|
||||||
_logger.LogDebug("Объект: {json}",
|
|
||||||
JsonConvert.SerializeObject(truck));
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
|
||||||
var queryUpdate = @"
|
|
||||||
UPDATE truck
|
|
||||||
SET
|
|
||||||
Numbers=@Numbers,
|
|
||||||
Truck_Type=@Truck_Type,
|
|
||||||
MaxFuel=@MaxFuel
|
|
||||||
WHERE Id=@Id";
|
|
||||||
connection.Execute(queryUpdate, truck);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка при редактировании объекта");
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void DeleteTruck(int id)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Удаление объекта");
|
|
||||||
_logger.LogDebug("Объект: {id}", id);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
|
||||||
var queryDelete = @"
|
|
||||||
DELETE FROM truck
|
|
||||||
WHERE Id=@id";
|
|
||||||
connection.Execute(queryDelete, new { id });
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка при удалении объекта");
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Truck ReadTruckByID(int id)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Получение объекта по идентификатору");
|
|
||||||
_logger.LogDebug("Объект: {id}", id);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
|
||||||
var querySelect = @"
|
|
||||||
SELECT * FROM truck
|
|
||||||
WHERE Id=@id";
|
|
||||||
var truck = connection.QueryFirst<Truck>(querySelect, new { id });
|
|
||||||
_logger.LogDebug("Найденный объект: {json}", JsonConvert.SerializeObject(truck));
|
|
||||||
|
|
||||||
return truck;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка при поиске объекта");
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerable<Truck> ReadTrucks()
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Получение всех объектов");
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
|
||||||
var querySelect = @"SELECT * FROM truck";
|
|
||||||
var trucks = connection.Query<Truck>(querySelect);
|
|
||||||
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(trucks));
|
|
||||||
return trucks;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка при чтении объектов");
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Before Width: | Height: | Size: 30 KiB |
Before Width: | Height: | Size: 32 KiB |
Before Width: | Height: | Size: 35 KiB |
@ -1,15 +0,0 @@
|
|||||||
{
|
|
||||||
"Serilog": {
|
|
||||||
"Using": [ "Serilog.Sinks.File" ],
|
|
||||||
"MinimumLevel": "Debug",
|
|
||||||
"WriteTo": [
|
|
||||||
{
|
|
||||||
"Name": "File",
|
|
||||||
"Args": {
|
|
||||||
"path": "Logs/garage.txt",
|
|
||||||
"rollingInterval": "Day"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
BIN
каранд.jpg
Before Width: | Height: | Size: 30 KiB |
BIN
минусик.jpg
Before Width: | Height: | Size: 32 KiB |
BIN
плюсик.jpg
Before Width: | Height: | Size: 35 KiB |
BIN
филмор1.jpg
Before Width: | Height: | Size: 61 KiB |