Example #1
0
        public void BomToSql(string debnr, List <cicntp> cicntp, List <cicmpy> cicmpy, string uwRef, string oms, DateTime dateTime)
        {
            // when the code enters this method firstly the method WriteHeader will be executed. Which means that alle the code above in this file will be executed firstly
            // and after that the code below. The code below converts all the lists that have been filled to arrays and adds extra data that could no be read from the xml file
            // such as dateTime class and the orderNr.
            WriteHeader();

            //---------------------------------------------------------HEAD----------------------------------------------------------
            string   debNr         = debnr;
            byte     orderAfdracht = 0;
            DateTime orderDate     = dateTime;
            DateTime aflDate       = dateTime;
            byte     orderbv_afgd  = 0;
            byte     afgehandeld   = 0;
            byte     nettoPris     = 0;
            byte     inv_in_vv     = 0;
            byte     betaald       = 0;
            DateTime sysCreated    = DateTime.Now;
            string   docTitle      = uwRef;

            //---------------------------------------------------------HEAD----------------------------------------------------------

            //---------------------------------------------------------BODY----------------------------------------------------------
            orkrgs = orderHeeaderController.GetAllOrderNr();

            foreach (var item in orkrgs)
            {
                if (item.ord_soort == "V")
                {
                    orderNrs.Add(item.ordernr);
                }
            }

            string[] aOrdNrs = orderNrs.ToArray();

            int    ordersCount = aOrdNrs.Count();
            int    iOrderNr    = Convert.ToInt32(aOrdNrs[ordersCount - 1]) + 1;
            string orderNr     = iOrderNr.ToString();

            string[] aRegel = regel.ToArray();                      // wordt gevuld
            DateTime afldat = new DateTime();

            afldat = dateTime;                                  // nullable
            string[] aArtCode = artCode.ToArray();
            string[] aOms45   = oms45.ToArray();
            string   oms45_f  = oms;
            float    magCode  = 1;                                  // Altijd INDU

            float[] aEsr_Aantal  = esr_aantal.ToArray();
            float[] aEsr_aantal2 = esr_aantal2.ToArray();
            string  aBtw_code    = "21";
            float   aKorting     = 0;
            int     aSyscreator  = 1;

            float[] aCSRekRegelVal  = CSRekRegelVal.ToArray();
            float[] aCSRekRegelVal2 = CSRekRegelVal2.ToArray();
            float[] aCSRekRegelVal3 = CSRekRegelVal3.ToArray();

            float    CSFactor = 0;
            DateTime sysMod   = new DateTime();                     // Altijd Vandaag

            float[] aCSRekRegelValPlaat  = CSRekRegelValPlaat.ToArray();
            float[] aCSRekRegelVal2Plaat = CSRekRegelVal2Plaat.ToArray();
            sysMod = DateTime.Now;

            float[] aCsRekregValProfile  = CSRekRegelValProfiel.ToArray();
            float[] aCsRekRegVal2Profile = CSRekRegelVal2Profiel.ToArray();
            float[] aCsRekregVal3Profile = CSRekRegelVal3Profiel.ToArray();

            float[] aCsRekRegValPlaat   = CSRekRegelValPlaat.ToArray();
            float[] aCsRekRegVal2Plaat  = CSRekRegelVal2Plaat.ToArray();
            float[] aCsRekReglVal3plaat = CSRekRegelVal3Plaat.ToArray();
            //---------------------------------------------------------BODY----------------------------------------------------------

            //---------------------------------------------------------SUB-REGEL----------------------------------------------------------

            string[] aSubRegel   = snowflakeRgel.ToArray();
            string[] aSubArtCode = snowflakeArtCode.ToArray();
            string[] aSubOms45   = snowflakeOms45.ToArray();
            //---------------------------------------------------------SUB-REGEL----------------------------------------------------------

            //-------------------------------------------------------CHECK PARAMETERS-----------------------------------------------------
            int           plaatCounter2 = 0;
            int           p             = 0;
            int           pr            = 0;
            int           profReken     = 0;
            int           art           = 0;
            int           artcounter2   = aCSRekRegelVal.Count();
            int           s             = 0;
            List <string> regels        = new List <string>();

            //-------------------------------------------------------CHECK PARAMETERS-----------------------------------------------------
            // CREATE HEADER
            Db.CreateOrderHeader(cicntp, cicmpy, debnr, orderAfdracht, orderNr, debnr, debnr, debnr, oms45_f, "17", orderbv_afgd, afgehandeld, nettoPris, inv_in_vv, betaald, orderDate, afldat, sysCreated, sysMod, docTitle);

            for (int a = 0; a <= regelCount; a++)
            {
                int record = 0;
                regels.Clear();
                foreach (var item in refinedBody)
                {
                    if (item.Contains("OrderLine lineNo"))
                    {
                        regels.Add(item);
                    }

                    if (item.Contains("Profile") && record == 0 && pr < profileCounter || item.Contains("profile") && record == 0 && pr < profileCounter)
                    {
                        if (aArtCode[a].Contains("/"))
                        {
                            profReken++;
                        }

                        if (regels.Last().Contains(".") && record == 0 && s < specialCounter)
                        {
                            Db.CreateSubLines(orderNr, aSubRegel[s], aSubArtCode[s], aSubOms45[s]);
                            s++;
                        }

                        else
                        {
                            Db.CreateOrderBodyProfiel(orderNr, aRegel[a], afldat, aArtCode[a], aOms45[a], oms45_f, "INDU", aEsr_aantal2[profReken - 1], aEsr_Aantal[a], aBtw_code,
                                                      aKorting, aSyscreator, aCsRekregValProfile[profReken - 1], aCsRekRegVal2Profile[profReken - 1], sysMod, sysMod);
                            pr++;
                        }
                        record++;
                    }

                    if (record == 0 && item.Contains("<Description>") && !item.Contains("SIZE:") && !item.Contains("Profile") && art < artcounter2 && !item.Contains("profile"))
                    {
                        if (regels.Last().Contains(".") && record == 0 && s < specialCounter)
                        {
                            Db.CreateSubLines(orderNr, aSubRegel[s], aSubArtCode[s], aSubOms45[s]);
                            s++;
                        }

                        else
                        {
                            Db.CreateOrderBodyACC(orderNr, aRegel[a], afldat, aArtCode[a], aOms45[a], oms45_f, "INDU", aEsr_Aantal[a],
                                                  aBtw_code, aKorting, aSyscreator, aCSRekRegelVal[art], sysMod, sysMod);
                            art++;
                        }
                        record++;
                    }

                    if (item.Contains("SIZE:") && record == 0 && p < plaatCounter)
                    {
                        if (regels.Last().Contains(".") && record == 0 && s < specialCounter)
                        {
                            Db.CreateSubLines(orderNr, aSubRegel[s], aSubArtCode[s], aSubOms45[s]);
                            s++;
                        }

                        else
                        {
                            Db.CreateOrderBodyPlaat(orderNr, aRegel[a], afldat, aArtCode[a], aOms45[a], oms45_f, "INDU", aEsr_aantal2[p], aEsr_Aantal[a], aBtw_code,
                                                    aKorting, aSyscreator, aCSRekRegelValPlaat[p], aCSRekRegelVal2Plaat[p], aCsRekReglVal3plaat[p], sysMod, sysMod);
                            plaatCounter2++;
                            p++;
                        }

                        // CREATE BODY
                        record++;
                    }
                }
            }

            for (int i = 0; i < specialCounter; i++)
            {
                Db.CreateSubLines(orderNr, aSubRegel[i], aSubArtCode[i], aSubOms45[i]);
            }

            Db.SaveOrder();
            MessageBox.Show("data is in db geggoid");
        }