This commit is contained in:
m1aksim1 2023-03-05 02:09:04 +04:00
parent 712140a156
commit 9a42abc8fc
7 changed files with 8 additions and 29 deletions

View File

@ -24,7 +24,6 @@ namespace SoftwareInstallationFileImplement.Implements
return new(); return new();
} }
return source.Components.Where(x => x.ComponentName.Contains(model.ComponentName)).Select(x => x.GetViewModel).ToList(); return source.Components.Where(x => x.ComponentName.Contains(model.ComponentName)).Select(x => x.GetViewModel).ToList();
} }
public ComponentViewModel? GetElement(ComponentSearchModel model) public ComponentViewModel? GetElement(ComponentSearchModel model)
{ {
@ -71,7 +70,6 @@ namespace SoftwareInstallationFileImplement.Implements
return element.GetViewModel; return element.GetViewModel;
} }
return null; return null;
} }
} }
} }

View File

@ -1,8 +1,6 @@
using SoftwareInstallationFileImplement.Models; using SoftwareInstallationFileImplement.Models;
using System.Xml.Linq; using System.Xml.Linq;
namespace SoftwareInstallationFileImplement namespace SoftwareInstallationFileImplement
{ {
public class DataFileSingleton public class DataFileSingleton
@ -14,6 +12,7 @@ namespace SoftwareInstallationFileImplement
public List<Component> Components { get; private set; } public List<Component> Components { get; private set; }
public List<Order> Orders { get; private set; } public List<Order> Orders { get; private set; }
public List<Package> Packages { get; private set; } public List<Package> Packages { get; private set; }
public static DataFileSingleton GetInstance() public static DataFileSingleton GetInstance()
{ {
if (instance == null) if (instance == null)
@ -25,6 +24,7 @@ namespace SoftwareInstallationFileImplement
public void SaveComponents() => SaveData(Components, ComponentFileName,"Components", x => x.GetXElement); public void SaveComponents() => SaveData(Components, ComponentFileName,"Components", x => x.GetXElement);
public void SavePackages() => SaveData(Packages, PackageFileName, "Packages", x => x.GetXElement); public void SavePackages() => SaveData(Packages, PackageFileName, "Packages", x => x.GetXElement);
public void SaveOrders() => SaveData(Orders, OrderFileName, "Orders", x => x.GetXElement); public void SaveOrders() => SaveData(Orders, OrderFileName, "Orders", x => x.GetXElement);
private DataFileSingleton() private DataFileSingleton()
{ {
Components = LoadData(ComponentFileName, "Component", x => Component.Create(x)!)!; Components = LoadData(ComponentFileName, "Component", x => Component.Create(x)!)!;
@ -47,4 +47,4 @@ namespace SoftwareInstallationFileImplement
} }
} }
} }
} }

View File

@ -37,7 +37,6 @@ namespace SoftwareInstallationFileImplement.Models
DateCreate = model.DateCreate, DateCreate = model.DateCreate,
DateImplement = model.DateImplement, DateImplement = model.DateImplement,
Id = model.Id, Id = model.Id,
}; };
} }
@ -72,6 +71,7 @@ namespace SoftwareInstallationFileImplement.Models
public OrderViewModel GetViewModel => new() public OrderViewModel GetViewModel => new()
{ {
PackageName = DataFileSingleton.GetInstance().Packages.FirstOrDefault(x => x.Id == PackageId)?.PackageName ?? string.Empty,
PackageId = PackageId, PackageId = PackageId,
Count = Count, Count = Count,
Sum = Sum, Sum = Sum,

View File

@ -39,16 +39,7 @@ namespace SoftwareInstallationFileImplement.Implements
} }
public List<OrderViewModel> GetFullList() public List<OrderViewModel> GetFullList()
{ {
var a = new List<OrderViewModel>(); return _source.Orders.Select(x => x.GetViewModel).ToList();
//var result = _source.Orders
// .Select(x => x.GetViewModel)
// .ToList();
//TODO
foreach (var order in _source.Orders)
{
a.Add(GetViewModel(order));
}
return a;
} }
public OrderViewModel? Insert(OrderBindingModel model) public OrderViewModel? Insert(OrderBindingModel model)
{ {
@ -73,18 +64,5 @@ namespace SoftwareInstallationFileImplement.Implements
_source.SaveOrders(); _source.SaveOrders();
return order.GetViewModel; return order.GetViewModel;
} }
private OrderViewModel GetViewModel(Order model)
{
var res = model.GetViewModel;
foreach (var package in _source.Packages)
{
if (package.Id == model.PackageId)
{
res.PackageName = package.PackageName;
break;
}
}
return res;
}
} }
} }

View File

@ -102,6 +102,7 @@
this.Controls.Add(this.buttonAdd); this.Controls.Add(this.buttonAdd);
this.Name = "FormComponents"; this.Name = "FormComponents";
this.Text = "Компоненты"; this.Text = "Компоненты";
this.Load += new System.EventHandler(this.FormComponents_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
this.ResumeLayout(false); this.ResumeLayout(false);

View File

@ -157,6 +157,7 @@
this.Controls.Add(this.menuStrip1); this.Controls.Add(this.menuStrip1);
this.Name = "FormMain"; this.Name = "FormMain";
this.Text = "Установка ПО"; this.Text = "Установка ПО";
this.Load += new System.EventHandler(this.FormMain_Load);
this.menuStrip1.ResumeLayout(false); this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout(); this.menuStrip1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();

View File

@ -105,6 +105,7 @@
this.Controls.Add(this.dataGridView); this.Controls.Add(this.dataGridView);
this.Name = "FormPackages"; this.Name = "FormPackages";
this.Text = "Изделия"; this.Text = "Изделия";
this.Load += new System.EventHandler(this.FormViewPackage_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
this.ResumeLayout(false); this.ResumeLayout(false);