Example #1
0
        private static void PopulateConceptHeader(ref Concept con, ConceptCSV csv)
        {
            log4net.Config.XmlConfigurator.ConfigureAndWatch(new FileInfo(Path.GetDirectoryName(Assembly.GetAssembly(typeof(ConceptCSV)).Location) + @"\" + "log4net.config"));
            log.Debug($"Populating concept header with {String.Join(",",csv)}");

            try
            {
                con.batch = JDE.GetNextBatchNumber().ToString();
                DataRow r = csv.DT.Rows[0];
                con.BillToAddress   = Double.Parse(r["CUSTOMER NUMBER"].ToString());
                con.ConceptID       = JDE.GetConceptID(con.BillToAddress);
                con.JulianOrderDate = CommonFunctions.DateStringToJulian(System.DateTime.Today.ToString());
                con.OrderDetails    = new List <ConceptLine>();
                con.PONumber        = r["PO NUMBER"].ToString();
                con.OrderedBy       = r["ORDERED BY"].ToString();
                con.ShippingVendor  = Double.Parse(r["SHIPPING VENDOR"].ToString());
                con.ShippingMode    = r["SHIPPING METHOD"].ToString();
            }
            catch (Exception eBLL)
            {
                log.Error($"Error populating concept header" + eBLL.Message);
                throw;
            }

            return;
        }
Example #2
0
        public void ReturnSoldTos_NotFound()
        {
            List <string> list = new List <string>();

            list.Add("2020PH1");
            list.Add("ACUARIO");
            list.Add("ALL TEMP");
            list.Add("ECOLAB");
            list.Add("DONT FIND ME");
            list.Add("DONT FIND ME 1");
            list.Add("DONT FIND ME 2");

            List <string> expected = new List <string>();

            expected.Add("DONT FIND ME");
            expected.Add("DONT FIND ME 1");
            expected.Add("DONT FIND ME 2");

            List <string> NotFound = JDE.FindMissingShipTos(list);


            Assert.IsTrue(3 == NotFound.Count &&
                          NotFound.Contains("DONT FIND ME") &&
                          NotFound.Contains("DONT FIND ME 1") &&
                          NotFound.Contains("DONT FIND ME 2"));
        }
Example #3
0
        private static ConceptLine PopulateConceptLine(double DocumentNumber, string StoreNumber, decimal LineNumber, string PartNumber, double Quantity, decimal RequestedJulian, Concept concept)
        {
            log4net.Config.XmlConfigurator.ConfigureAndWatch(new FileInfo(Path.GetDirectoryName(Assembly.GetAssembly(typeof(ConceptCSV)).Location) + @"\" + "log4net.config"));
            log.Debug($"Populating concept line with {DocumentNumber.ToString()},{StoreNumber},{LineNumber.ToString()},{PartNumber},{Quantity.ToString()},{RequestedJulian.ToString()},{StoreNumber}-{concept.ConceptID}");

            ConceptLine line;

            try
            {
                line = new ConceptLine();
                line.DocumentNumber = DocumentNumber;
                line.BranchPlant    = BranchPlant;
                string alky = StoreNumber + "-" + concept.ConceptID;
                line.ShipToAddress       = (double)JDE.GetAddressFromALKY(alky);
                line.LineNumber          = LineNumber;
                line.JDEPartNumber       = PartNumber;
                line.Quantity            = Quantity;
                line.JulianRequestedDate = RequestedJulian;
            }
            catch (Exception eBLL)
            {
                log.Error($"Error writing concept line " + eBLL.Message);
                throw;
            }
            return(line);
        }
Example #4
0
        } // PopulateFreightLine

        #endregion

        #region public_methods
        /// <summary>
        /// Populate the Freight data structure
        /// </summary>
        /// <param name="csv"></param>
        /// <returns>Populated Freight data structure</returns>
        public static Freight CSVToFreight(FreightCSV csv)
        {
            double  pkgnumber     = 0;
            Freight freightUpdate = new Freight();

            freightUpdate.freight_lines = new List <FreightLine>();
            /* Get a list of the order numbers */
            List <string> orders = csv.DT.AsEnumerable().Select(n => n.Field <String>("ORDER #")).Distinct().ToList();

            /* Loop through each order number */
            foreach (string order in orders)
            {
                pkgnumber = 0;
                /* Now grab all the orders with the same order number */
                List <DataRow> orderList = csv.DT.AsEnumerable().Where(n => order == n.Field <String>("ORDER #")).ToList();
                foreach (DataRow r in orderList)
                {
                    pkgnumber++;
                    FreightLine line = PopulateFreightLine(r, pkgnumber);
                    freightUpdate.freight_lines.Add(line);
                }
            }
            // Now populate all the shipment numbers based on the order numbers
            JDE.GetShipmentNumbers(ref freightUpdate, orders);
            return(freightUpdate);
        } // CSVToFreight
Example #5
0
        public void TestNextNumber()
        {
            double NextBatch    = JDE.GetNextBatchNumber();
            double NextDocument = JDE.GetDocumentNumbers(10);

            NextBatch    = JDE.GetNextBatchNumber();
            NextDocument = JDE.GetDocumentNumbers(1);
        }
Example #6
0
        public void GetConceptID_byABALKY()
        {
            string name     = "2020PH1";
            string expected = "DN";
            string result   = JDE.GetConceptID(name);

            Assert.IsTrue(0 == String.Compare(expected, result));
        }
Example #7
0
        public void GetConceptID_byABAN8()
        {
            float  address  = 4590;
            string expected = "DN";
            string result   = JDE.GetConceptID(address);

            Assert.IsTrue(0 == String.Compare(expected, result));
        }
Example #8
0
        public void TestSteps()
        {
            bool SkipF0101  = true;
            bool SkipF03012 = true;
            // 1.) Read the concept
            ConceptCSV TestConceptCSV = new ConceptCSV(@"E:\gitHub\Rollout\TestFiles\SageRolloutExample1.csv", ",");

            TestConceptCSV.ReadConcept();
            // 2.) Test for missing entries
            List <string> TestMissing = TestConceptCSV.CheckForMissingShipToAddresses();

            // 3.) If entries are missing, do the following:
            if (0 < TestMissing.Count && !SkipF0101)
            {
                // 4.) Populate the missing CSV using the list of missing items
                ShipToCSV MissingShipToCSV = new ShipToCSV(@"E:\gitHub\Rollout\TestFiles\SageRolloutMissing.csv", ",");
                MissingShipToCSV.PopulateSpreadsheet(TestMissing, TestConceptCSV);
                // 5.) Populate the transformed data structure
                ShipTo MissingShipTo = XfrmShipTo.CSVToShipTo(MissingShipToCSV, false); // Don't look up JDE Addresses
                // 6.) Upload the transformed data structure to the F0101 Z-File
                JDE.PopulateF0101Z2(MissingShipTo);
                // 7.) Now write the CSV to disk
                MissingShipToCSV.WriteCSV();
                // 8.) Now, someone must run R01010Z to load the data into JDE.
                // Popup window
            }
            else if (!SkipF03012)
            {
                // TODO: 9.) Check for F03012 records
                // 10.) If F03012 records are missing:
                ShipToCSV MissingShipToCSV = new ShipToCSV(@"E:\gitHub\Rollout\TestFiles\SageRolloutMissing.csv", ",");
                MissingShipToCSV.ReadShipTo();
                if (MissingShipToCSV.ValidateHeader() &&  // Required row is all there
                    MissingShipToCSV.ValidateRows(false)) // We can't have an empty tax area code
                {
                    // 11.) Convert the CSV into a data structure we can upload
                    ShipTo PopulatedShipTo = XfrmShipTo.CSVToShipTo(MissingShipToCSV, true); // Lookup JDE Address
                    // 12.) Upload the data structure into JDE
                    JDE.PopulateF03012Z1(PopulatedShipTo);
                    // 13.) Now someone must run R03010Z to load the data into JDE.
                }
                else
                {
                    //TODO: Say we don't have a valid spreadsheet
                    int x = 0;
                    x++;
                }
            }
            else
            {
                Concept TestConcept = XfrmConcept.CSVtoConcept(TestConceptCSV);
                JDE.PopulateF47011(TestConcept);
                JDE.PopulateF47012(TestConcept);
            }
        }
Example #9
0
        public void ReadShipToCSVandPopulateF0101Z2()
        {
            ShipToCSV PopulatedCSV = new ShipToCSV(@"E:\gitHub\Rollout\TestFiles\SageRolloutMissing.csv", ",");

            PopulatedCSV.ReadShipTo();
            PopulatedCSV.ValidateHeader();
            PopulatedCSV.ValidateRows(true);
            ShipTo PopulatedShipTo = XfrmShipTo.CSVToShipTo(PopulatedCSV, false); // Dont lookup JDE address

            JDE.PopulateF0101Z2(PopulatedShipTo);
        }
Example #10
0
        public void PopulateF03012Z1()
        {
            ShipToCSV PopulatedCSV = new ShipToCSV(@"E:\gitHub\Rollout\TestFiles\SageRolloutMissing.csv", ",");

            PopulatedCSV.ReadShipTo();
            PopulatedCSV.ValidateHeader();
            PopulatedCSV.ValidateRows(false);                                    // Force non-empty tax area code
            ShipTo PopulatedShipTo = XfrmShipTo.CSVToShipTo(PopulatedCSV, true); // Lookup JDE address

            JDE.PopulateF03012Z1(PopulatedShipTo);
        }
Example #11
0
        /// <summary>
        /// See if any of the item numbers in the CSV don't exist in JDE
        /// </summary>
        /// <returns>List of part numbers that don't exist in JDE</returns>
        public List <string> CheckForMissingItemNumbers()
        {
            List <string> AllItemNumbers = new List <string>();

            foreach (DataRow r in DT.Rows)
            {
                AllItemNumbers.Add(r.Field <string>("PART NUMBER").Trim());
            }
            List <string> missing = JDE.GetMissingItems(AllItemNumbers.Distinct().ToList(), BranchPlant);

            return(missing);
        }
Example #12
0
        public void ItemsInBranch_All()
        {
            string        branch   = "1A";
            List <string> itemList = new List <string>();

            itemList.Add("1010");
            itemList.Add("11007");
            itemList.Add("11000");

            List <string> returned = JDE.GetMissingItems(itemList, branch);

            Assert.IsTrue(0 == returned.Count);
        }
Example #13
0
        } // WriteConcept

        public List <string> CheckForMissingShipToAddresses()
        {
            List <string> AllShipToNames = new List <string>();
            double        SoldTo         = double.Parse(DT.Rows[0].Field <string>("CUSTOMER NUMBER"), System.Globalization.CultureInfo.InvariantCulture);
            string        ConceptID      = JDE.GetConceptID(SoldTo);

            foreach (DataRow r in DT.Rows)
            {
                AllShipToNames.Add(r.Field <string>("STORE NUMBER").Trim()
                                   + "-"
                                   + ConceptID.Trim());
            }
            List <string> missing = JDE.FindMissingShipTos(AllShipToNames.Distinct().ToList());

            return(missing);
        }
Example #14
0
        /// <summary>
        /// Verify that the shipping vendor is a vendor (V or V3) in JDE.
        /// </summary>
        /// <returns></returns>
        public bool CheckShippingVendor()
        {
            double Vendor = Double.Parse(DT.Rows[0].Field <string>("SHIPPING VENDOR").Trim());

            if (true == JDE.DoesAddressExist(Vendor, "V"))
            {
                return(true);
            }
            else if (true == JDE.DoesAddressExist(Vendor, "V3"))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #15
0
        public void ItemsInBranch_Good()
        {
            string        branch   = "1A";
            List <string> itemList = new List <string>();

            itemList.Add("1010");
            itemList.Add("11007");
            itemList.Add("11000");
            itemList.Add("10175");

            List <string> expected = new List <string>();

            expected.Add("10175");

            List <string> returned = JDE.GetMissingItems(itemList, branch);

            Assert.IsTrue(returned.Contains("10175") && 1 == returned.Count);
        }
Example #16
0
 /// <summary>
 /// Populate the empty ShipToCSV object
 /// </summary>
 /// <param name="missing"></param>
 /// <param name="concept"></param>
 public void PopulateSpreadsheet(List <string> missing, ConceptCSV concept)
 {
     if (null == DT)
     {
         DT = new DataTable();
         PopulateColumns();
         string conceptID = JDE.GetConceptID(Double.Parse(concept.DT.Rows[0].Field <string>("CUSTOMER NUMBER")));
         foreach (string shipto in missing)
         {
             PopulateDataRow(shipto, concept, conceptID);
         }
     }
     else
     {
         log.Error("The DataTable for ShipToCSV already exists.");
         throw new System.AggregateException("Error, the DataTable for ShipToCSV already exists & must be deleted first.");
     }
 }
Example #17
0
        /// <summary>
        /// Convert a csv object into a concept object
        /// </summary>
        /// <param name="csv"></param>
        /// <returns></returns>
        public static Concept CSVtoConcept(ConceptCSV csv)
        {
            Concept        con = new Concept();
            ConceptLine    entry;
            int            linenumber;
            DataRow        r1;
            List <DataRow> rows     = new List <DataRow>();
            double         document = JDE.GetDocumentNumbers(csv.DT.Rows.Count); // reserve a set of document numbers

            PopulateConceptHeader(ref con, csv);
            // Get a list of unique store numbers
            List <string> stores = csv.DT.AsEnumerable().Select(n => n.Field <string>("STORE NUMBER")).Distinct().ToList();

            // Loop through that customer and add all of that customer's lines to the datatable
            foreach (string store in stores)
            {
                rows       = csv.DT.AsEnumerable().Where(n => store == n.Field <string>("STORE NUMBER")).ToList();
                linenumber = 1;  // Start at linenumber 1
                foreach (DataRow r in rows)
                {
                    entry = PopulateConceptLine(document,
                                                r["STORE NUMBER"].ToString(),
                                                linenumber,                  // Line #
                                                r["PART NUMBER"].ToString(), // The part number
                                                Double.Parse(r["ORDER QTY"].ToString()),
                                                CommonFunctions.DateStringToJulian(r["REQ'D SHIP DATE"].ToString()),
                                                con);
                    con.OrderDetails.Add(entry);
                    linenumber++;
                }
                // Now add the freight line for this customer
                r1    = rows[0]; // get the first row
                entry = PopulateConceptLine(document,
                                            r1["STORE NUMBER"].ToString(),
                                            linenumber, // Line #2 is the freight line
                                            "9227",     // The freight part number
                                            1,          // Qty of 1
                                            CommonFunctions.DateStringToJulian(r1["REQ'D SHIP DATE"].ToString()),
                                            con);
                con.OrderDetails.Add(entry);
                document++;
            }
            return(con);
        } // CSVtoConcept
Example #18
0
        /// <summary>
        /// Populate a single ship-to line from the CSV
        /// </summary>
        /// <param name="r"></param>
        /// <param name="LookupJDEAddress"></param>
        /// <returns></returns>
        private static ShipToLine PopulateShipToLine(DataRow r, bool LookupJDEaddress)
        {
            ShipToLine line = new ShipToLine();

            line.StoreName          = (null == r["SHIP TO NAME"].ToString()) ? "" : r.Field <String>("SHIP TO NAME").ToUpper();
            line.Address1           = (null == r.Field <String>("ADDRESS 1")) ? "" : r.Field <String>("ADDRESS 1").ToUpper();
            line.Address2           = (null == r.Field <String>("ADDRESS 2")) ? "" : r.Field <String>("ADDRESS 2").ToUpper();
            line.City               = (null == r.Field <String>("CITY")) ? "" : r.Field <String>("CITY").ToUpper();
            line.State              = (null == r.Field <String>("STATE")) ? "" : r.Field <String>("STATE").ToUpper();
            line.Zip                = (null == r.Field <String>("ZIP")) ? "" : r.Field <String>("ZIP").ToUpper();
            line.TaxAreaCode        = (null == r.Field <String>("TAX AREA CODE")) ? "" : r.Field <String>("TAX AREA CODE").ToUpper();
            line.TaxExplanationCode = (null == r.Field <String>("TAX EXPLANATION CODE")) ? "" : r.Field <String>("TAX EXPLANATION CODE").ToUpper();
            line.Concept            = (null == r.Field <String>("CONCEPT CODE")) ? "" : r.Field <String>("CONCEPT CODE").ToUpper();
            line.StoreNumber        = (null == r.Field <String>("STORE NUMBER")) ? "" : r.Field <String>("STORE NUMBER").ToUpper();
            if (true == LookupJDEaddress)
            {
                try
                {
                    string alky       = line.StoreNumber + "-" + line.Concept;
                    double?jdeaddress = JDE.GetAddressFromALKY(alky);
                    line.JDEAddress = (null == jdeaddress) ? 0 : (double)jdeaddress;
                }
                catch
                {
                    throw;
                }
            }
            else
            {
                line.JDEAddress = 0;
            }
            try
            {
                line.County = JDE.GetCounty(r.Field <String>("ZIP").ToUpper());
            }
            catch
            {
                throw;
            }
            return(line);
        }
Example #19
0
        /// <summary>
        /// Populate the top common ship to information
        /// </summary>
        /// <param name="shipTo"></param>
        /// <param name="csv"></param>
        /// <returns></returns>
        private static bool PopulateShipToHeader(ref ShipTo shipTo, ShipToCSV csv)
        {
            bool   success = true;
            Random random  = new Random();

            shipTo.batch = random.Next().ToString(); // 32-bit integer
            DataRow r = csv.DT.Rows[0];

            shipTo.ConceptID = r["CONCEPT CODE"].ToString();
            double?parent = JDE.GetParentFromConcept(shipTo.ConceptID);

            if (null != parent)
            {
                shipTo.ParentAddress = (double)parent;
            }
            else
            {
                log.Debug($"Couldn't find parent for {r["CONCEPT CODE"].ToString()}");
                success = false;
            }
            return(success);
        }
Example #20
0
        } // ValidateTaxExplanations

        /// <summary>
        /// Verify a valid concept code exists in JDE for this customer.
        /// </summary>
        /// <param name="conceptCSV"></param>
        /// <returns></returns>
        private bool ConceptCodeExists(ConceptCSV conceptCSV)
        {
            bool   result;
            string concept = JDE.GetConceptID(Double.Parse(conceptCSV.DT.Rows[0].Field <string>("CUSTOMER NUMBER"))).Trim();

            if (String.Empty == concept)
            {
                log.Error($"Customer Number {conceptCSV.DT.Rows[0].Field<string>("CUSTOMER NUMBER")} does not have a concept code populated in F0101.ABAC08");
                using (new CenterDialog(this))
                {
                    MessageBoxButtons buttons = MessageBoxButtons.OK;
                    MessageBox.Show($"Customer Number {conceptCSV.DT.Rows[0].Field<string>("CUSTOMER NUMBER")} does not have a concept code populated in the Address Book.\r\nPlease fix this in the spreadsheet or JDE before continuing.", "Data Error", buttons);
                }
                result = false;
            }
            else
            {
                log.Debug($"Customer Number {conceptCSV.DT.Rows[0].Field<string>("CUSTOMER NUMBER")} has a concept.");
                result = true;
            }
            return(result);
        } // ConceptCodeExists
Example #21
0
        } // AddressBookFlow

        /// <summary>
        /// Control flow for the customer master data load
        /// </summary>
        private void CustomerMasterFlow()
        {
            log4net.Config.XmlConfigurator.ConfigureAndWatch(new FileInfo(Path.GetDirectoryName(Assembly.GetAssembly(typeof(FileIO)).Location) + @"\" + "log4net.config"));
            log.Debug($"Beginning customer master F03012 Z-File Load flow.");
            using (LoadingForm frm = new LoadingForm())
            {
                frm.Visible      = true;
                MissingShipToCSV = null; // make sure to clear this out each time we load a spreadsheet
                // 1.) Get the file to load
                frm.AddText("Get file name to load.");
                string FileToLoad = FileIO.GetFileName(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), FileFilter);
                if (String.Empty != FileToLoad)
                {
                    try
                    {
                        // 2.) Load the file
                        log.Debug($"Attempting to load file {FileToLoad} using <tab> as a delimiter");
                        frm.AddText($"Attempting to load file {FileToLoad} using <tab> as a delimiter.");
                        MissingShipToCSV = new ShipToCSV(FileToLoad, "\t");
                        MissingShipToCSV.ReadShipTo();
                        frm.AddText($"Successfully read file {FileToLoad}.");
                        // 3.) Validate the required columns exist in the spreadsheet
                        log.Debug($"Attempting to validate all required columns exist in the file.");
                        frm.AddText("Validating required columns exist in the file.");
                        if (!ValidateShipToHeader(ref MissingShipToCSV))
                        {
                            return;
                        }
                        // 4.) Validate the data in the rows match the column requirements
                        frm.AddText("Validate data is in the correct format for each row and column.");
                        log.Debug("Validating all row data in all required columns");
                        if (!ValidateShipToRows(ref MissingShipToCSV, false))
                        {
                            return;
                        }                                                                 // No Blank tax area codes allowed
                        // 5.) Either populate the data table for viewing or load the data into JDE
                        using (new CenterDialog(this))
                        {
                            DialogResult result = MessageBox.Show($"All {MissingShipToCSV.DT.Rows.Count} rows of data appear to be valid -- Further checks required.\r\nTry to Load the Data into JDE?\r\nSelect No to preview the detail data before load.",
                                                                  "Load Data?",
                                                                  MessageBoxButtons.YesNoCancel,
                                                                  MessageBoxIcon.Information);

                            if (DialogResult.Cancel == result)
                            {
                                return;
                            }

                            ShipTo ship = null;
                            // 5a.) Save the data into a ShipTo & save that to JDE
                            log.Debug($"Tranform the ShipToCSV into a ShipTo object");
                            frm.AddText($"Converting CSV file to a JDE loadable object.");
                            ship = XfrmShipTo.CSVToShipTo(MissingShipToCSV, true); // Get the JDE address, since we need it
                                                                                   // 5a.1) Verify there aren't any unfound addresses
                            log.Debug($"Checking that all JDE addresses are > 0");
                            frm.AddText($"Validating JDE Addresses were found for all rows.");
                            if (AnyZeroAddresses(ship))
                            {
                                return;
                            }
                            // 5a.2) Verify all tax codes are valid
                            log.Debug($"Verifying all tax codes are valid entries in F4008");
                            frm.AddText($"Validating Tax codes are active in JDE.");
                            if (!ValidateTaxCodes(ship))
                            {
                                return;
                            }
                            // 5a.2.a) Verify all tax code explanations are valid
                            log.Debug($"Verifying all tax code explanations are valid entries in UDC 00/EX");
                            frm.AddText($"Validating Tax Explanations are valid in JDE.");
                            if (!ValidateTaxExplanations(ship))
                            {
                                return;
                            }

                            if (DialogResult.Yes == result)
                            {
                                // 5a.3) Populate the Z file
                                log.Debug($"Populating F03012Z1 with data");
                                frm.AddText("Loading JDE F03012Z1 with data.");
                                JDE.PopulateF03012Z1(ship);
                                // 5b.) Prompt the user to go to JDE
                                log.Debug($"Successfully processed the Ship To information into F03012Z1 with batch number {ship.batch}.");
                                frm.AddText($"Successfully processed bactch number: {ship.batch}.");
                                using (new CenterDialog(this))
                                {
                                    MessageBox.Show($"Your BATCH NUMBER is: {ship.batch}\r\n\r\nThe CUSTOMER MASTER information was successfully loaded into JDE.\r\nPlease go to JDE, and run the CUSTOMER MASTER load UBE.\r\n",
                                                    "Success!",
                                                    MessageBoxButtons.OK,
                                                    MessageBoxIcon.Information);
                                }
                            }
                            else if (DialogResult.No == result)
                            {
                                // 5c.3) Populate the datatable with concept information
                                frm.AddText("Successfully created JDE loadable object.");
                                this.dgv_DataDisplay.DataSource = ship.NewShipTos;
                            }
                        }
                    }
                    catch (Exception er)
                    {
                        log.Error($"{er.Message} + {er.InnerException} + {er.StackTrace}");
                        using (new CenterDialog(this))
                        {
                            MessageBox.Show($"{er.Message} + {er.InnerException} + {er.StackTrace}",
                                            "Error in Rollout",
                                            MessageBoxButtons.OK,
                                            MessageBoxIcon.Error);
                        }
                    }
                }
            }
            return;
        } // CustomerMasterFlow
Example #22
0
        } // FollowMissingShipToPath

        /// <summary>
        /// The control flow for loading a rollout spreadsheet.
        /// </summary>
        private void LoadRolloutFlow()
        {
            log4net.Config.XmlConfigurator.ConfigureAndWatch(new FileInfo(Path.GetDirectoryName(Assembly.GetAssembly(typeof(FileIO)).Location) + @"\" + "log4net.config"));
            this.dgv_DataDisplay.DataSource = null;
            MissingShipToCSV = null; // make sure to clear this out each time we load a spreadsheet
            // 1.) Get the file to load
            string FileToLoad = FileIO.GetFileName(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), FileFilter);

            if (String.Empty != FileToLoad)
            {
                try
                {
                    // 2.) Load the file
                    log.Debug($"Attempting to load file {FileToLoad} using \t as a delimiter");
                    conceptCSV = new ConceptCSV(FileToLoad, "\t");
                    using (LoadingForm frm = new LoadingForm())
                    {
                        frm.AddText("Loading Concept Spreadsheet.");
                        frm.Visible = true;
                        conceptCSV.ReadConcept();
                        // 3.) Validate the required columns exist in the spreadsheet
                        log.Debug($"Attempting to validate all required columns exist in the file.");
                        frm.AddText("Validating Concept Required Columns Exist.");
                        if (!ValidateConceptHeader(ref conceptCSV))
                        {
                            return;
                        }
                        // 4a.) Validate the data in the rows match the column requirements
                        log.Debug("Validating all row data in all required columns.");
                        frm.AddText("Validating data in concept spreadsheet.");
                        if (!ValidateConceptRows(ref conceptCSV))
                        {
                            return;
                        }
                        // 4b.) Validate the Shipping Vendor
                        log.Debug("Validating the shipping vendor is V or V3.");
                        frm.AddText("Validating the shipping vendor is a vendor in JDE.");
                        if (!CheckShippingVendor(conceptCSV))
                        {
                            return;
                        }
                        // 4c.) Validate the concept ID exists for the Customer C3 Record
                        log.Debug("Validating the Customer Number has a concept in ABAC08.");
                        frm.AddText("Validating the Customer Number has a concept code.");
                        if (!ConceptCodeExists(conceptCSV))
                        {
                            return;
                        }
                        // 5.) Verify the ship to addresses exist
                        log.Debug("Verify all Ship To addresses exist");
                        frm.AddText("Checking for missing ship to addresses in JDE.");
                        List <string> MissingShipTo = conceptCSV.CheckForMissingShipToAddresses();
                        if (0 < MissingShipTo.Count)
                        {
                            // 6a.) We found new ship to addresses, so start down that path
                            log.Debug("There are Ship To addresses that are missing.  Should we add them?");
                            frm.AddText("Found missing ship to addresses.");
                            FollowMissingShipToPath(MissingShipTo, conceptCSV, frm);
                            frm.Visible = false;
                        }
                        else
                        {
                            // 6b.) All ship to addresses exist.  So, verify the item numbers are valid
                            log.Debug("Verify all items exist in JDE.");
                            frm.AddText("No missing ship to addresses.");
                            frm.AddText("Checking for missing item numbers.");
                            List <string> MissingItems = conceptCSV.CheckForMissingItemNumbers();
                            if (0 < MissingItems.Count)
                            {
                                log.Debug("There are item numbers that don't exist in JDE.");
                                using (new CenterDialog(this))
                                {
                                    MessageBox.Show($"The following part numbers don't exist in JDE.  Please change them or add them to the 3SUW branch plant: {String.Join(",", MissingItems)}",
                                                    "Data Error!!",
                                                    MessageBoxButtons.OK,
                                                    MessageBoxIcon.Error);
                                }
                                frm.Close();
                                return;
                            }
                            else
                            {
                                log.Debug("All items exist in JDE");
                                frm.AddText("All items exist in JDE.");
                                using (new CenterDialog(this))
                                {
                                    DialogResult result = MessageBox.Show($"All {conceptCSV.DT.Rows.Count} rows of data are valid in JDE.\r\nLoad the EDI Data into JDE?\r\nSelect No to preview the detail data before load.",
                                                                          "Load EDI Data?",
                                                                          MessageBoxButtons.YesNoCancel,
                                                                          MessageBoxIcon.Information);
                                    if (DialogResult.Cancel == result)
                                    {
                                        return;
                                    }

                                    // 7.) Save the data into a concept & save that to JDE
                                    log.Debug($"Tranform the conceptCSV into a concept");
                                    frm.AddText("Transforming the spreadsheet into a concept object.");
                                    Concept concept = XfrmConcept.CSVtoConcept(conceptCSV);
                                    if (DialogResult.Yes == result)
                                    {
                                        log.Debug($"Populating header file F47011 with data");
                                        frm.AddText("Populating the EDI header file with concept data.");
                                        JDE.PopulateF47011(concept);
                                        log.Debug($"Populating detail file F47012 with data");
                                        frm.AddText("Populating the EDI detail file with concept data & freight lines.");
                                        JDE.PopulateF47012(concept);
                                        frm.AddText("Success!");
                                        // 8.) Prompt the user to go to JDE
                                        log.Debug($"Successfully processed the EDI information into F47011 and F47012");
                                        MessageBox.Show("The concept was successfully loaded into JDE.\r\nPlease go to JDE, review the data, and run the Rollout Order Import report.",
                                                        "Success!",
                                                        MessageBoxButtons.OK,
                                                        MessageBoxIcon.Information);
                                        frm.Close();
                                    }
                                    else if (DialogResult.No == result)
                                    {
                                        frm.AddText("Success!");
                                        frm.Close();
                                        this.dgv_DataDisplay.DataSource = concept.OrderDetails;
                                    }
                                }
                            }
                        }
                    }
                }
                catch (Exception er)
                {
                    log.Error($"{er.Message} + {er.InnerException} + {er.StackTrace}");
                    using (new CenterDialog(this))
                    {
                        MessageBox.Show($"{er.Message} + {er.InnerException} + {er.StackTrace}",
                                        "Error in Rollout",
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Error);
                    }
                }
            }
        } // LoadRolloutFlow
Example #23
0
        } // SaveCSVFlow

        /// <summary>
        /// The control flow for uploading and saving a Ship To CSV address book file.
        /// This data flow doesn't need the tax information.
        /// </summary>
        private void AddressBookFlow()
        {
            log4net.Config.XmlConfigurator.ConfigureAndWatch(new FileInfo(Path.GetDirectoryName(Assembly.GetAssembly(typeof(FileIO)).Location) + @"\" + "log4net.config"));
            log.Debug($"Beginning address book F0101 Z-File Load flow.");
            using (LoadingForm frm = new LoadingForm())
            {
                frm.Visible      = true;
                MissingShipToCSV = null; // make sure to clear this out each time we load a spreadsheet
                // 1.) Get the file to load
                frm.AddText("Get file name to load.");
                string FileToLoad = FileIO.GetFileName(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), FileFilter);
                if (String.Empty != FileToLoad)
                {
                    try
                    {
                        // 2.) Load the file
                        log.Debug($"Attempting to load file {FileToLoad} using <tab> as a delimiter");
                        frm.AddText($"Attempting to load file {FileToLoad} using <tab> as a delimiter.");
                        MissingShipToCSV = new ShipToCSV(FileToLoad, "\t");
                        MissingShipToCSV.ReadShipTo();
                        frm.AddText($"Successfully read file {FileToLoad}.");
                        // 3.) Validate the required columns exist in the spreadsheet
                        log.Debug($"Attempting to validate all required columns exist in the file.");
                        frm.AddText("Validating required columns exist in the file.");
                        if (!ValidateShipToHeader(ref MissingShipToCSV))
                        {
                            return;
                        }
                        // 4.) Validate the data in the rows match the column requirements
                        frm.AddText("Validate data is in the correct format for each row and column.");
                        log.Debug("Validating all row data in all required columns");
                        if (!ValidateShipToRows(ref MissingShipToCSV, true))
                        {
                            return;
                        }                                                                // Allow blank TankAreaCode
                        // 5.) Either populate the data table for viewing or load the data into JDE
                        using (new CenterDialog(this))
                        {
                            DialogResult result = MessageBox.Show($"All {MissingShipToCSV.DT.Rows.Count} rows of data are valid.\r\nLoad the Data into JDE?\r\nSelect No to preview the detail data before load.",
                                                                  "Load Data?",
                                                                  MessageBoxButtons.YesNoCancel,
                                                                  MessageBoxIcon.Information);
                            if (DialogResult.Cancel == result)
                            {
                                return;
                            }

                            // 5a.) Save the data into a ShipTo & save that to JDE
                            log.Debug($"Tranform the ShipToCSV into a ShipTo object");
                            frm.AddText($"Converting CSV file to a JDE loadable object.");
                            ShipTo ship = XfrmShipTo.CSVToShipTo(MissingShipToCSV, false); // Don't look up the JDE address, because you don't have any yet

                            if (DialogResult.Yes == result)
                            {
                                log.Debug($"Populating F0101Z2 with data");
                                frm.AddText("Loading JDE F0101Z2 with data.");
                                JDE.PopulateF0101Z2(ship);
                                // 5b.) Prompt the user to go to JDE
                                log.Debug($"Successfully processed the Ship To information into F0101Z2 with batch number {ship.batch}.");
                                frm.AddText($"Successfully processed bactch number: {ship.batch}.");
                                using (new CenterDialog(this))
                                {
                                    MessageBox.Show($"Your BATCH NUMBER is: {ship.batch}\r\n\r\nThe ship to information was successfully loaded into JDE.\r\nPlease go to JDE, and run the address book load UBE.\r\nThen come back and load the customer master information.\r\n\r\n",
                                                    "Success!",
                                                    MessageBoxButtons.OK,
                                                    MessageBoxIcon.Information);
                                }
                            }
                            else if (DialogResult.No == result)
                            {
                                frm.AddText("Successfully created JDE loadable object.");
                                this.dgv_DataDisplay.DataSource = ship.NewShipTos;
                            }
                        }
                    }
                    catch (Exception er)
                    {
                        log.Error($"{er.Message} + {er.InnerException} + {er.StackTrace}");
                        using (new CenterDialog(this))
                        {
                            MessageBox.Show($"{er.Message} + {er.InnerException} + {er.StackTrace}",
                                            "Error in Rollout",
                                            MessageBoxButtons.OK,
                                            MessageBoxIcon.Error);
                        }
                    }
                }
            }
            return;
        } // AddressBookFlow
Example #24
0
 public bool ValidateTaxExplanations()
 {
     return(JDE.ValidateTaxExplanations(this.NewShipTos.Select(n => n.TaxExplanationCode.Trim()).Distinct().ToList()));
 }
Example #25
0
        } // CustomerMasterFlow

        /// <summary>
        /// Control flow for Freight Data update
        /// </summary>
        public void FreightUpdateFlow()
        {
            log4net.Config.XmlConfigurator.ConfigureAndWatch(new FileInfo(Path.GetDirectoryName(Assembly.GetAssembly(typeof(FileIO)).Location) + @"\" + "log4net.config"));
            this.dgv_DataDisplay.DataSource = null;
            using (LoadingForm frm = new LoadingForm())
            {
                frm.Visible = true;
                freightCSV  = null;
                // 1.) Get the file to load
                string FileToLoad = FileIO.GetFileName(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), FileFilter);
                if (String.Empty != FileToLoad)
                {
                    try
                    {
                        // 2.) Load the file
                        log.Debug($"Attempting to load file {FileToLoad} using <tab> as a delimiter");
                        frm.AddText($"Attempting to load file {FileToLoad} using <tab> as a delimiter.");
                        freightCSV = new FreightCSV(FileToLoad, "\t");
                        freightCSV.ReadFreight();
                        frm.AddText($"Successfully read file {FileToLoad}.");
                        // 3.) Validate the required columns exist in the spreadsheet
                        log.Debug($"Attempting to validate all required columns exist in the file.");
                        frm.AddText("Validating required columns exist in the file.");
                        if (!ValidateFreightHeaders(ref freightCSV))
                        {
                            return;
                        }
                        // 4.) Validate the data in the rows match the column requirements
                        frm.AddText("Validate data is in the correct format for each row and column.");
                        log.Debug("Validating all row data in all required columns");
                        if (!ValidateFreightRows(ref freightCSV))
                        {
                            return;
                        }
                        // 5.) Either populate the data table for viewing or load the data into JDE
                        using (new CenterDialog(this))
                        {
                            DialogResult result = MessageBox.Show($"All {freightCSV.DT.Rows.Count} rows of data appear to be valid -- Further checks required.\r\nTry to Load the Data into JDE?\r\nSelect No to preview the detail data before load.",
                                                                  "Load Data?",
                                                                  MessageBoxButtons.YesNoCancel,
                                                                  MessageBoxIcon.Information);
                            if (DialogResult.Cancel == result)
                            {
                                return;
                            }

                            // 6.) Save the data into a Freight structure & save that to JDE
                            log.Debug($"Tranform the FreightCSV into a Freight object");
                            frm.AddText($"Converting CSV file to a JDE loadable object.");
                            Freight freight = XfrmFreight.CSVToFreight(freightCSV);
                            // 7.) Validate all shipments exist
                            log.Debug($"Validating that there aren't any 0 shipment numbers");
                            frm.AddText($"Validating that all shipments exist");
                            if (freight.freight_lines.Any(n => 0 == n.shipment))
                            {
                                log.Error($"There are {freight.freight_lines.Count(n => 0 == n.shipment)} freight lines with a 0 shipment");
                                return;
                            }
                            log.Info($"All {freight.freight_lines.Count} lines have shipments");


                            if (DialogResult.Yes == result)
                            {
                                log.Debug($"Update Shipment Reference Numbers in F4217");
                                frm.AddText($"Updating Shipment Tracking Numbers in JDE");
                                JDE.PopulateF4217(freight);
                                log.Debug($"Update Package Information in F4943");
                                frm.AddText($"Updating package information in JDE");
                                JDE.PopulateF4943(freight);
                                log.Debug($"Updating freight prices in F4211");
                                frm.AddText($"Updating freight prices on sales orders");
                                JDE.UpdateFreightF4211(freight);
                                using (new CenterDialog(this))
                                {
                                    MessageBox.Show($"The Freight information was successfully loaded into JDE.\r\n",
                                                    "Success!",
                                                    MessageBoxButtons.OK,
                                                    MessageBoxIcon.Information);
                                }
                            }
                            else if (DialogResult.No == result)
                            {
                                log.Info($"Loading data grid view for the freight lines");
                                this.dgv_DataDisplay.DataSource = freight.freight_lines;
                            }
                        } // using
                    }     // try
                    catch (Exception er)
                    {
                        log.Error($"{er.Message} + {er.InnerException} + {er.StackTrace}");
                        using (new CenterDialog(this))
                        {
                            MessageBox.Show($"{er.Message} + {er.InnerException} + {er.StackTrace}",
                                            "Error in Freight Update",
                                            MessageBoxButtons.OK,
                                            MessageBoxIcon.Error);
                        }
                    } // catch
                }
            }
            return;
        } // FreightUpdateFlow
Example #26
0
 public bool ValidateTaxCodes()
 {
     return(JDE.ValidateTaxCodes(this.NewShipTos.Select(n => n.TaxAreaCode.Trim()).Distinct().ToList()));
 }