Nincs leírás

Jgrebnev d1c303353f Обновить 'readme.md' 6 hónapja
WpfApp1 ac444216e1 5com 6 hónapja
img ac444216e1 5com 6 hónapja
.gitignore.txt 62ee81afd3 1st commit 9 hónapja
WpfApp1.sln ac444216e1 5com 6 hónapja
readme.md d1c303353f Обновить 'readme.md' 6 hónapja

readme.md

Классы

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; }
    }
}

Mainwindow.xaml(Изменения с прошлой работы)

Добавил пару строчек для отображения информации

   <DataGridTextColumn
            Header="Дата завоза"
            Binding="{Binding date,StringFormat='dd.MM.yyyy'}"/>
                <DataGridTextColumn
            Header="Наличие"
            Binding="{Binding available}"/>

Mainwindow.xaml.cs(Изменения с прошлой работы)

Заменил 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;

поменял новый класс(json)

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();
            }
        }
    }
   


}


Скрины работы