Готовая лабораторная работа 6
This commit is contained in:
parent
347736eff9
commit
040c8b243c
@ -20,9 +20,9 @@ namespace FurnitureAssemblyFileImplement
|
|||||||
|
|
||||||
private readonly string ClientFileName = "Client.xml";
|
private readonly string ClientFileName = "Client.xml";
|
||||||
|
|
||||||
private readonly string ImplementerFileName = "Implementer.xml";
|
private readonly string ImplementerFileName = "Implementer.xml";
|
||||||
|
|
||||||
public List<WorkPiece> WorkPieces { get; private set; }
|
public List<WorkPiece> WorkPieces { get; private set; }
|
||||||
|
|
||||||
public List<Order> Orders { get; private set; }
|
public List<Order> Orders { get; private set; }
|
||||||
|
|
||||||
@ -30,9 +30,9 @@ namespace FurnitureAssemblyFileImplement
|
|||||||
|
|
||||||
public List<Client> Clients { get; private set; }
|
public List<Client> Clients { get; private set; }
|
||||||
|
|
||||||
public List<Implementer> Implementers { get; private set; }
|
public List<Implementer> Implementers { get; private set; }
|
||||||
|
|
||||||
public static DataFileSingleton GetInstance()
|
public static DataFileSingleton GetInstance()
|
||||||
{
|
{
|
||||||
if (instance == null)
|
if (instance == null)
|
||||||
{
|
{
|
||||||
@ -50,7 +50,7 @@ namespace FurnitureAssemblyFileImplement
|
|||||||
|
|
||||||
public void SaveClients() => SaveData(Clients, ClientFileName, "Clients", x => x.GetXElement);
|
public void SaveClients() => SaveData(Clients, ClientFileName, "Clients", x => x.GetXElement);
|
||||||
|
|
||||||
public void SaveImplementers() => SaveData(Implementers, ImplementerFileName, "Implementers", x => x.GetXElement);
|
public void SaveImplementers() => SaveData(Implementers, ImplementerFileName, "Implementers", x => x.GetXElement);
|
||||||
|
|
||||||
|
|
||||||
private DataFileSingleton()
|
private DataFileSingleton()
|
||||||
@ -59,8 +59,8 @@ namespace FurnitureAssemblyFileImplement
|
|||||||
Furnitures = LoadData(FurnitureFileName, "Furniture", x => Furniture.Create(x)!)!;
|
Furnitures = LoadData(FurnitureFileName, "Furniture", x => Furniture.Create(x)!)!;
|
||||||
Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!;
|
Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!;
|
||||||
Clients = LoadData(ClientFileName, "Client", x => Client.Create(x)!)!;
|
Clients = LoadData(ClientFileName, "Client", x => Client.Create(x)!)!;
|
||||||
Implementers = LoadData(ImplementerFileName, "Implementer", x => Implementer.Create(x)!)!;
|
Implementers = LoadData(ImplementerFileName, "Implementer", x => Implementer.Create(x)!)!;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<T>? LoadData<T>(string filename, string xmlNodeName, Func<XElement, T> selectFunction)
|
private static List<T>? LoadData<T>(string filename, string xmlNodeName, Func<XElement, T> selectFunction)
|
||||||
{
|
{
|
||||||
@ -74,7 +74,7 @@ namespace FurnitureAssemblyFileImplement
|
|||||||
|
|
||||||
private static void SaveData<T>(List<T> data, string filename, string xmlNodeName, Func<T, XElement> selectFunction)
|
private static void SaveData<T>(List<T> data, string filename, string xmlNodeName, Func<T, XElement> selectFunction)
|
||||||
{
|
{
|
||||||
if(data != null)
|
if (data != null)
|
||||||
{
|
{
|
||||||
new XDocument(new XElement(xmlNodeName, data.Select(selectFunction).ToArray())).Save(filename);
|
new XDocument(new XElement(xmlNodeName, data.Select(selectFunction).ToArray())).Save(filename);
|
||||||
}
|
}
|
||||||
|
@ -20,9 +20,9 @@ namespace FurnitureAssemblyFileImplement.Models
|
|||||||
|
|
||||||
public int ClientId { get; private set; }
|
public int ClientId { get; private set; }
|
||||||
|
|
||||||
public int? ImplementerId { get; private set; }
|
public int? ImplementerId { get; private set; }
|
||||||
|
|
||||||
public int Count { get; private set; }
|
public int Count { get; private set; }
|
||||||
|
|
||||||
public double Sum { get; private set; }
|
public double Sum { get; private set; }
|
||||||
|
|
||||||
@ -44,8 +44,8 @@ namespace FurnitureAssemblyFileImplement.Models
|
|||||||
Id = model.Id,
|
Id = model.Id,
|
||||||
FurnitureId = model.FurnitureId,
|
FurnitureId = model.FurnitureId,
|
||||||
ClientId = model.ClientId,
|
ClientId = model.ClientId,
|
||||||
ImplementerId = model.ImplementerId,
|
ImplementerId = model.ImplementerId,
|
||||||
Count = model.Count,
|
Count = model.Count,
|
||||||
Sum = model.Sum,
|
Sum = model.Sum,
|
||||||
Status = model.Status,
|
Status = model.Status,
|
||||||
DateCreate = model.DateCreate,
|
DateCreate = model.DateCreate,
|
||||||
@ -65,8 +65,8 @@ namespace FurnitureAssemblyFileImplement.Models
|
|||||||
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
||||||
FurnitureId = Convert.ToInt32(element.Element("FurnitureId")!.Value),
|
FurnitureId = Convert.ToInt32(element.Element("FurnitureId")!.Value),
|
||||||
ClientId = Convert.ToInt32(element.Attribute("Id")!.Value),
|
ClientId = Convert.ToInt32(element.Attribute("Id")!.Value),
|
||||||
ImplementerId = Convert.ToInt32(element.Attribute("ImplementerId")!.Value),
|
ImplementerId = Convert.ToInt32(element.Attribute("ImplementerId")!.Value),
|
||||||
Count = Convert.ToInt32(element.Element("Count")!.Value),
|
Count = Convert.ToInt32(element.Element("Count")!.Value),
|
||||||
Sum = Convert.ToDouble(element.Element("Sum")!.Value),
|
Sum = Convert.ToDouble(element.Element("Sum")!.Value),
|
||||||
Status = (OrderStatus)Enum.Parse(typeof(OrderStatus), element.Element("Status")!.Value),
|
Status = (OrderStatus)Enum.Parse(typeof(OrderStatus), element.Element("Status")!.Value),
|
||||||
DateCreate = Convert.ToDateTime(element.Element("DateCreate")!.Value),
|
DateCreate = Convert.ToDateTime(element.Element("DateCreate")!.Value),
|
||||||
@ -91,8 +91,8 @@ namespace FurnitureAssemblyFileImplement.Models
|
|||||||
Id = Id,
|
Id = Id,
|
||||||
FurnitureId = FurnitureId,
|
FurnitureId = FurnitureId,
|
||||||
ClientId = ClientId,
|
ClientId = ClientId,
|
||||||
ImplementerId = ImplementerId,
|
ImplementerId = ImplementerId,
|
||||||
Count = Count,
|
Count = Count,
|
||||||
Sum = Sum,
|
Sum = Sum,
|
||||||
Status = Status,
|
Status = Status,
|
||||||
DateCreate = DateCreate,
|
DateCreate = DateCreate,
|
||||||
@ -103,8 +103,8 @@ namespace FurnitureAssemblyFileImplement.Models
|
|||||||
new XAttribute("Id", Id),
|
new XAttribute("Id", Id),
|
||||||
new XElement("FurnitureId", FurnitureId.ToString()),
|
new XElement("FurnitureId", FurnitureId.ToString()),
|
||||||
new XElement("ClientId", ClientId.ToString()),
|
new XElement("ClientId", ClientId.ToString()),
|
||||||
new XElement("ImplementerId", ImplementerId.ToString()),
|
new XElement("ImplementerId", ImplementerId.ToString()),
|
||||||
new XElement("Count", Count.ToString()),
|
new XElement("Count", Count.ToString()),
|
||||||
new XElement("Sum", Sum.ToString()),
|
new XElement("Sum", Sum.ToString()),
|
||||||
new XElement("Status", Status.ToString()),
|
new XElement("Status", Status.ToString()),
|
||||||
new XElement("DateCreate", DateCreate.ToString()),
|
new XElement("DateCreate", DateCreate.ToString()),
|
||||||
|
@ -38,7 +38,7 @@ namespace FurnitureAssemblyListImplement
|
|||||||
|
|
||||||
public static DataListSingleton GetInstance()
|
public static DataListSingleton GetInstance()
|
||||||
{
|
{
|
||||||
if(_instance == null)
|
if (_instance == null)
|
||||||
{
|
{
|
||||||
_instance = new DataListSingleton();
|
_instance = new DataListSingleton();
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ namespace FurnitureAssemblyListImplement.Models
|
|||||||
|
|
||||||
public static Order? Create(OrderBindingModel? model)
|
public static Order? Create(OrderBindingModel? model)
|
||||||
{
|
{
|
||||||
if(model == null)
|
if (model == null)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -45,8 +45,8 @@ namespace FurnitureAssemblyListImplement.Models
|
|||||||
Id = model.Id,
|
Id = model.Id,
|
||||||
FurnitureId = model.FurnitureId,
|
FurnitureId = model.FurnitureId,
|
||||||
ClientId = model.ClientId,
|
ClientId = model.ClientId,
|
||||||
ImplementerId = model.ImplementerId,
|
ImplementerId = model.ImplementerId,
|
||||||
Count = model.Count,
|
Count = model.Count,
|
||||||
Sum = model.Sum,
|
Sum = model.Sum,
|
||||||
Status = model.Status,
|
Status = model.Status,
|
||||||
DateCreate = model.DateCreate,
|
DateCreate = model.DateCreate,
|
||||||
@ -57,7 +57,7 @@ namespace FurnitureAssemblyListImplement.Models
|
|||||||
// Метод изменения существующего объекта
|
// Метод изменения существующего объекта
|
||||||
public void Update(OrderBindingModel? model)
|
public void Update(OrderBindingModel? model)
|
||||||
{
|
{
|
||||||
if(model == null)
|
if (model == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -72,8 +72,8 @@ namespace FurnitureAssemblyListImplement.Models
|
|||||||
Id = Id,
|
Id = Id,
|
||||||
FurnitureId = FurnitureId,
|
FurnitureId = FurnitureId,
|
||||||
ClientId = ClientId,
|
ClientId = ClientId,
|
||||||
ImplementerId = ImplementerId,
|
ImplementerId = ImplementerId,
|
||||||
Count = Count,
|
Count = Count,
|
||||||
Sum = Sum,
|
Sum = Sum,
|
||||||
Status = Status,
|
Status = Status,
|
||||||
DateCreate = DateCreate,
|
DateCreate = DateCreate,
|
||||||
|
@ -52,8 +52,8 @@ namespace FurnitureAssemblyView
|
|||||||
dataGridView.DataSource = list;
|
dataGridView.DataSource = list;
|
||||||
dataGridView.Columns["FurnitureId"].Visible = false;
|
dataGridView.Columns["FurnitureId"].Visible = false;
|
||||||
dataGridView.Columns["ClientId"].Visible = false;
|
dataGridView.Columns["ClientId"].Visible = false;
|
||||||
dataGridView.Columns["ImplementerId"].Visible = false;
|
dataGridView.Columns["ImplementerId"].Visible = false;
|
||||||
dataGridView.Columns["FurnitureName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
dataGridView.Columns["FurnitureName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
dataGridView.Columns["ClientFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
dataGridView.Columns["ClientFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
dataGridView.Columns["ImplementerFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
dataGridView.Columns["ImplementerFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user