Готовая лабораторная работа 6

This commit is contained in:
nikbel2004@outlook.com 2024-05-11 23:36:23 +04:00
parent 347736eff9
commit 040c8b243c
5 changed files with 28 additions and 28 deletions

View File

@ -20,9 +20,9 @@ namespace FurnitureAssemblyFileImplement
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; }
@ -30,9 +30,9 @@ namespace FurnitureAssemblyFileImplement
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)
{
@ -50,17 +50,17 @@ namespace FurnitureAssemblyFileImplement
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()
{
WorkPieces = LoadData(WorkPieceFileName, "WorkPiece", x => WorkPiece.Create(x)!)!;
Furnitures = LoadData(FurnitureFileName, "Furniture", x => Furniture.Create(x)!)!;
Orders = LoadData(OrderFileName, "Order", x => Order.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)
{
@ -74,7 +74,7 @@ namespace FurnitureAssemblyFileImplement
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);
}

View File

@ -20,9 +20,9 @@ namespace FurnitureAssemblyFileImplement.Models
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; }
@ -44,8 +44,8 @@ namespace FurnitureAssemblyFileImplement.Models
Id = model.Id,
FurnitureId = model.FurnitureId,
ClientId = model.ClientId,
ImplementerId = model.ImplementerId,
Count = model.Count,
ImplementerId = model.ImplementerId,
Count = model.Count,
Sum = model.Sum,
Status = model.Status,
DateCreate = model.DateCreate,
@ -65,8 +65,8 @@ namespace FurnitureAssemblyFileImplement.Models
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
FurnitureId = Convert.ToInt32(element.Element("FurnitureId")!.Value),
ClientId = Convert.ToInt32(element.Attribute("Id")!.Value),
ImplementerId = Convert.ToInt32(element.Attribute("ImplementerId")!.Value),
Count = Convert.ToInt32(element.Element("Count")!.Value),
ImplementerId = Convert.ToInt32(element.Attribute("ImplementerId")!.Value),
Count = Convert.ToInt32(element.Element("Count")!.Value),
Sum = Convert.ToDouble(element.Element("Sum")!.Value),
Status = (OrderStatus)Enum.Parse(typeof(OrderStatus), element.Element("Status")!.Value),
DateCreate = Convert.ToDateTime(element.Element("DateCreate")!.Value),
@ -91,8 +91,8 @@ namespace FurnitureAssemblyFileImplement.Models
Id = Id,
FurnitureId = FurnitureId,
ClientId = ClientId,
ImplementerId = ImplementerId,
Count = Count,
ImplementerId = ImplementerId,
Count = Count,
Sum = Sum,
Status = Status,
DateCreate = DateCreate,
@ -103,8 +103,8 @@ namespace FurnitureAssemblyFileImplement.Models
new XAttribute("Id", Id),
new XElement("FurnitureId", FurnitureId.ToString()),
new XElement("ClientId", ClientId.ToString()),
new XElement("ImplementerId", ImplementerId.ToString()),
new XElement("Count", Count.ToString()),
new XElement("ImplementerId", ImplementerId.ToString()),
new XElement("Count", Count.ToString()),
new XElement("Sum", Sum.ToString()),
new XElement("Status", Status.ToString()),
new XElement("DateCreate", DateCreate.ToString()),

View File

@ -38,7 +38,7 @@ namespace FurnitureAssemblyListImplement
public static DataListSingleton GetInstance()
{
if(_instance == null)
if (_instance == null)
{
_instance = new DataListSingleton();
}

View File

@ -35,7 +35,7 @@ namespace FurnitureAssemblyListImplement.Models
public static Order? Create(OrderBindingModel? model)
{
if(model == null)
if (model == null)
{
return null;
}
@ -45,8 +45,8 @@ namespace FurnitureAssemblyListImplement.Models
Id = model.Id,
FurnitureId = model.FurnitureId,
ClientId = model.ClientId,
ImplementerId = model.ImplementerId,
Count = model.Count,
ImplementerId = model.ImplementerId,
Count = model.Count,
Sum = model.Sum,
Status = model.Status,
DateCreate = model.DateCreate,
@ -57,7 +57,7 @@ namespace FurnitureAssemblyListImplement.Models
// Метод изменения существующего объекта
public void Update(OrderBindingModel? model)
{
if(model == null)
if (model == null)
{
return;
}
@ -72,8 +72,8 @@ namespace FurnitureAssemblyListImplement.Models
Id = Id,
FurnitureId = FurnitureId,
ClientId = ClientId,
ImplementerId = ImplementerId,
Count = Count,
ImplementerId = ImplementerId,
Count = Count,
Sum = Sum,
Status = Status,
DateCreate = DateCreate,

View File

@ -52,8 +52,8 @@ namespace FurnitureAssemblyView
dataGridView.DataSource = list;
dataGridView.Columns["FurnitureId"].Visible = false;
dataGridView.Columns["ClientId"].Visible = false;
dataGridView.Columns["ImplementerId"].Visible = false;
dataGridView.Columns["FurnitureName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
dataGridView.Columns["ImplementerId"].Visible = false;
dataGridView.Columns["FurnitureName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
dataGridView.Columns["ClientFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
dataGridView.Columns["ImplementerFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
}