Jgrebnev d1c303353f Обновить 'readme.md' | 6 сар өмнө | |
---|---|---|
WpfApp1 | 6 сар өмнө | |
img | 6 сар өмнө | |
.gitignore.txt | 9 сар өмнө | |
WpfApp1.sln | 6 сар өмнө | |
readme.md | 6 сар өмнө |
namespace WpfApp2.model
{
public class Spares
{
public string name { get; set; }
public int price { get; set; }
public string detail { get; set; }
public string type { get; set; }
public List<SparesDetail> SparesDetailList { get; set; }
public List<SparesPrice> SparesPriceList { get; set; }
public List<SparesType> SparesTypeList { get; set; }
}
}
namespace WpfApp2.model
{
class Globals
{
public static IDataProvider dataProvider;
}
}
namespace WpfApp2.model
{
public class SparesDetail
{
public string title { get; set; }
}
public class SparesPrice
{
public string title { get; set; }
public int PriceFrom { get; set; }
public int PriceTo { get; set; }
}
public class SparesType
{
public string title { get; set; }
}
}
Добавил пару строчек для отображения информации
<DataGridTextColumn
Header="Дата завоза"
Binding="{Binding date,StringFormat='dd.MM.yyyy'}"/>
<DataGridTextColumn
Header="Наличие"
Binding="{Binding available}"/>
Заменил CSV на JSON
InitializeComponent();
DataContext = this;
Globals.dataProvider = new JSONDataProvider();
SparesList = Globals.dataProvider.getSpares();
SparesDetailList = Globals.dataProvider.getDetail().ToList();
SparesDetailList.Insert(0, new SparesDetail { title = "Деталь" });
SparesPriceList = Globals.dataProvider.getPrice().ToList();
SparesTypeList = Globals.dataProvider.getType().ToList();
SparesTypeList.Insert(0, new SparesType { title = "Тип ТС" });
public class JSONDataProvider : LocalDataProvider, IDataProvider
{
private List<Spares> _SparesList;
public JSONDataProvider()
{
var serializer = new DataContractJsonSerializer(typeof(Spares[]));
using (var sr = new StreamReader("./data.json"))
{
_SparesList = ((Spares[])serializer.ReadObject(sr.BaseStream)).ToList();
}
}
public IEnumerable<Spares> getSpares()
{
return _SparesList;
}
}
private bool sortAsc = true;
using System;
using System.Collections.Generic;
using System.Formats.Asn1;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
using CsvHelper;
using WpfApp2;
namespace WpfApp2.model
{
[DataContract]
public class Spares
{
[DataMember]
public string name { get; set; }
[DataMember]
public string detail { get; set; }
[DataMember]
public int price { get; set; }
[DataMember]
public string type { get; set; }
[DataMember]
public bool available { get; set; }
[DataMember(Name = "date")]
private string? stringdate { get; set; }
[IgnoreDataMember]
public DateTime? date
{
get
{
return stringdate == null ? null : DateTime.Parse(stringdate);
}
set
{
stringdate = value.ToString();
}
}
}
}