using DevExpress.PivotGrid.QueryMode;
using DxBlazorApplication2.AS400Kommunikation;
using System.Text;

namespace DxBlazorApplication2.Data.Produktion
{
    /// <summary>
    /// Produktionsauftrag
    /// </summary>
    public class PSDLItem
    {
        /// <summary>
        /// Firma
        /// </summary>
        public double PDFIRM { get; set; }
        /// <summary>
        /// Werk
        /// </summary>
        public double PDWERK { get; set; }
        /// <summary>
        /// Auftragsnummer
        /// </summary>
        public double PDPANR { get; set; }
        /// <summary>
        /// Artikelnummer
        /// </summary>
        public string PDARNR { get; set; }
        /// <summary>
        /// Artikelbezeichnung
        /// </summary>
        public string PDARBZ { get; set; }
        /// <summary>
        /// Menge Plan
        /// </summary>
        public double PDMGPL { get; set; }
        /// <summary>
        /// Menge Ist
        /// </summary>
        public double PDMGIS { get; set; }
        /// <summary>
        /// Gewicht Plan
        /// </summary>
        public double PDGWPL { get; set; }
        /// <summary>
        /// Gewicht Ist
        /// </summary>
        public double PDGWIS { get; set; }
        /// <summary>
        /// Produktionsdatum
        /// </summary>
        public DateTime PDPRDT { get; set; }
        /// <summary>
        /// Kalenderdatum
        /// </summary>
        public DateTime PDKLDT { get; set; }
        /// <summary>
        /// Zeit von
        /// </summary>
        public DateTime PDTIMV { get; set; }
        /// <summary>
        /// Zeit bis
        /// </summary>
        public DateTime PDTIMB { get; set; }
        /// <summary>
        /// Linie
        /// </summary>
        public string PDLINI { get; set; }
        /// <summary>
        /// Schicht (1=Früh, 2=Spät, 3=Nacht)
        /// </summary>
        public string PDSCHI { get; set; }
        /// <summary>
        /// Charge
        /// </summary>
        public string PDCHAR { get; set; }
        /// <summary>
        /// Produktnummer
        /// </summary>
        public string PDPDNR { get; set; }
        /// <summary>
        /// MHD
        /// </summary>
        public DateTime PDMHD { get; set; }
        /// <summary>
        /// Letztes Buchungsdatum/Zeit
        /// </summary>
        public DateTime PDBUDT { get; set; }

        public PSDLItem(AS400Connector loader)
        {
            Load(loader);
        }
        public void Load(AS400Connector loader) 
        {
            PDFIRM = loader.GetDouble("A1FIRM");
            PDWERK = loader.GetDouble("A1WERK");
            PDPANR = loader.GetDouble("A1PANR");
            PDARNR = loader.GetString("A1ARNR");
            PDARBZ = loader.GetString("A1ARBZ");
            PDMGPL = loader.GetDouble("A1MGPL");
            PDMGIS = loader.GetDouble("A1MGIS");
            PDGWPL = loader.GetDouble("A1GWPL");
            PDGWIS = loader.GetDouble("A1GWIS");
            PDPRDT = loader.GetDate("A1PRDT");
            PDKLDT = loader.GetDate("A1KLDT");
            PDTIMV = loader.GetTime("A1TIMV");
            PDTIMB = loader.GetTime("A1TIMB");
            PDLINI = loader.GetString("A1LINI");
            PDSCHI = loader.GetString("A1SCHI");
            PDCHAR = loader.GetString("A1CHAR");
            PDPDNR = loader.GetString("A1PDNR");
            PDMHD = loader.GetDate("A1MHD");
            PDBUDT = DateTime.Parse($"{loader.GetString("A1BUDT")} {loader.GetString("A1BUTM")}");
        }
    }
}
