Esempio n. 1
0
        public bool Write_ShopC_Items(NavigationButtons.Navigation xnav)
        {
            string Currency_Name = null;
            string Currency_Abbreviation = null;
            string Currency_Symbol = null;
            int Currency_Code = 0;
            int Currency_DecimalPlaces = 2;

            if (f_Currency.Get(myOrg.Default_Currency_ID, ref Currency_Abbreviation, ref Currency_Name, ref Currency_Symbol, ref Currency_Code, ref Currency_DecimalPlaces))
            {

                xnav.ChildDialog = new Form_Items_Samples(xnav, lngRPM.s_Shop_C.s);
                xnav.bDoModal = false;
                xnav.ShowDialog();
                if (xnav.eExitResult == NavigationButtons.Navigation.eEvent.NEXT)
                {
                    if (((Form_Items_Samples)xnav.ChildDialog).bAutoGenerateDemoSampleItems)
                    {
                        int iNumberOfGroupsInLevel3 = ((Form_Items_Samples)xnav.ChildDialog).iNumberOfGroupsInLevel3;
                        int iNumberOfGroupsInLevel2 = ((Form_Items_Samples)xnav.ChildDialog).iNumberOfGroupsInLevel2;
                        int iNumberOfGroupsInLevel1 = ((Form_Items_Samples)xnav.ChildDialog).iNumberOfGroupsInLevel1;
                        int iNumberOfItemsPerGroup = ((Form_Items_Samples)xnav.ChildDialog).iNumberOfItemsPerGroup;
                        int iNumberOfAll = ((Form_Items_Samples)xnav.ChildDialog).iNumberOffAll();

                        SampleDB_Price_ShopC_Item[] SampleDB_Price_ShopC_Item_List = new SampleDB_Price_ShopC_Item[iNumberOfAll];
                        int j = 0;
                        string ShopC_Item_Abbreviation = null;
                        string ShopC_Item_Name = null;
                        string sl3 = null;
                        string sl2 = null;
                        string sl1 = null;
                        int i1 = 0;
                        int i2 = 0;
                        int i3 = 0;
                        int ig = 0;
                        if (iNumberOfGroupsInLevel3 > 0)
                        {
                            for (i3 = 0; i3 < iNumberOfGroupsInLevel3; i3++)
                            {
                                string sln3 = "L3g" + i3.ToString();
                                sl3 = "." + sln3;
                                for (i2 = 0; i2 < iNumberOfGroupsInLevel2; i2++)
                                {
                                    string sln2 = sln3 + "L2g" + i2.ToString();
                                    sl2 = "." + sln2;
                                    for (i1 = 0; i1 < iNumberOfGroupsInLevel1; i1++)
                                    {
                                        string sln1 = sln3 + sln2 + "L1g" + i1.ToString();
                                        sl1 = "." + sln1;
                                        for (ig = 0; ig < iNumberOfItemsPerGroup; ig++)
                                        {
                                            ShopC_Item_Abbreviation = lngRPMS.ShopC_Item_Abbreviation_SB.s + ig.ToString() + sln1;
                                            ShopC_Item_Name = lngRPMS.ShopC_Item_Name_Item.s + ig.ToString() + sln1;

                                            SampleDB_Price_ShopC_Item_List[j] = new SampleDB_Price_ShopC_Item(
                                                                           ShopC_Item_Name,
                                                                           ShopC_Item_Abbreviation,
                                                                           new int_v(1),
                                                                           sl1,
                                                                           sl2,
                                                                           sl3,
                                                                           lngRPMS.s_Piece.s,
                                                                           lngRPMS.s_PieceAbr.s,
                                                                           0,
                                                                           true,
                                                                           null,
                                                                           null,
                                                                           lngRPM.s_Description.s,
                                                                           180,
                                                                           60,
                                                                           10,
                                                                           null,
                                                                           -1,
                                                                           -1,
                                                                           null,
                                                                           null,
                                                                           true,
                                                                           lngRPMS.PriceList_Name.s,
                                                                           true,
                                                                           Currency_Abbreviation,
                                                                           Currency_Name,
                                                                           Currency_Symbol,
                                                                           Currency_Code,
                                                                           Currency_DecimalPlaces,
                                                                           null,
                                                                           null,
                                                                           new DateTime_v(DateTime.Now),
                                                                           null,
                                                                           "DDV 22%",
                                                                           0.22M,
                                                                           10M,
                                                                           new decimal_v(0)
                                                                           );

                                            j++;
                                        }
                                    }
                                    for (ig = 0; ig < iNumberOfItemsPerGroup; ig++)
                                    {
                                        ShopC_Item_Abbreviation = lngRPMS.ShopC_Item_Abbreviation_SB.s + ig.ToString() + sln2;
                                        ShopC_Item_Name = lngRPMS.ShopC_Item_Name_Item.s + ig.ToString() + sln2;
                                        SampleDB_Price_ShopC_Item_List[j] = new SampleDB_Price_ShopC_Item(
                                                                       ShopC_Item_Name,
                                                                       ShopC_Item_Abbreviation,
                                                                       new int_v(1),
                                                                       sl2,
                                                                       sl3,
                                                                       null,
                                                                       lngRPMS.s_Piece.s,
                                                                       lngRPMS.s_PieceAbr.s,
                                                                       0,
                                                                       true,
                                                                       null,
                                                                       null,
                                                                       lngRPM.s_Description.s,
                                                                       180,
                                                                       60,
                                                                       10,
                                                                       null,
                                                                       -1,
                                                                       -1,
                                                                       null,
                                                                       null,
                                                                       true,
                                                                       lngRPMS.PriceList_Name.s,
                                                                       true,
                                                                       Currency_Abbreviation,
                                                                       Currency_Name,
                                                                       Currency_Symbol,
                                                                       Currency_Code,
                                                                       Currency_DecimalPlaces,
                                                                       null,
                                                                       null,
                                                                       new DateTime_v(DateTime.Now),
                                                                       null,
                                                                       "DDV 22%",
                                                                       0.22M,
                                                                       10M,
                                                                       new decimal_v(0)
                                                                       );
                                        j++;
                                    }

                                }
                                for (ig = 0; ig < iNumberOfItemsPerGroup; ig++)
                                {

                                    ShopC_Item_Abbreviation = lngRPMS.ShopC_Item_Abbreviation_SB.s + ig.ToString() + sln3;
                                    ShopC_Item_Name = lngRPMS.ShopC_Item_Name_Item.s + ig.ToString() + sln3;
                                    SampleDB_Price_ShopC_Item_List[j] = new SampleDB_Price_ShopC_Item(
                                                                                                               ShopC_Item_Name,
                                                                                                               ShopC_Item_Abbreviation,
                                                                                                               new int_v(1),
                                                                                                               sl3,
                                                                                                               null,
                                                                                                               null,
                                                                                                               lngRPMS.s_Piece.s,
                                                                                                               lngRPMS.s_PieceAbr.s,
                                                                                                               0,
                                                                                                               true,
                                                                                                               null,
                                                                                                               null,
                                                                                                               lngRPM.s_Description.s,
                                                                                                               180,
                                                                                                               60,
                                                                                                               10,
                                                                                                               null,
                                                                                                               -1,
                                                                                                               -1,
                                                                                                               null,
                                                                                                               null,
                                                                                                               true,
                                                                                                               lngRPMS.PriceList_Name.s,
                                                                                                               true,
                                                                                                               Currency_Abbreviation,
                                                                                                               Currency_Name,
                                                                                                               Currency_Symbol,
                                                                                                               Currency_Code,
                                                                                                               Currency_DecimalPlaces,
                                                                                                               null,
                                                                                                               null,
                                                                                                               new DateTime_v(DateTime.Now),
                                                                                                               null,
                                                                                                               "DDV 22%",
                                                                                                               0.22M,
                                                                                                               10M,
                                                                                                               new decimal_v(0)
                                                                                                               ); j++;
                                }
                            }
                            for (ig = 0; ig < iNumberOfItemsPerGroup; ig++)
                            {
                                ShopC_Item_Abbreviation = lngRPMS.ShopC_Item_Abbreviation_SB.s + ig.ToString() + "noL1noL2noL3";
                                ShopC_Item_Name = lngRPMS.ShopC_Item_Name_Item.s + ig.ToString() + "noL1noL2noL3";
                                SampleDB_Price_ShopC_Item_List[j] = new SampleDB_Price_ShopC_Item(
                                                                                                           ShopC_Item_Name,
                                                                                                           ShopC_Item_Abbreviation,
                                                                                                           new int_v(1),
                                                                                                           null,
                                                                                                           null,
                                                                                                           null,
                                                                                                           lngRPMS.s_Piece.s,
                                                                                                           lngRPMS.s_PieceAbr.s,
                                                                                                           0,
                                                                                                           true,
                                                                                                           null,
                                                                                                           null,
                                                                                                           lngRPM.s_Description.s,
                                                                                                           180,
                                                                                                           60,
                                                                                                           10,
                                                                                                           null,
                                                                                                           -1,
                                                                                                           -1,
                                                                                                           null,
                                                                                                           null,
                                                                                                           true,
                                                                                                           lngRPMS.PriceList_Name.s,
                                                                                                           true,
                                                                                                           Currency_Abbreviation,
                                                                                                           Currency_Name,
                                                                                                           Currency_Symbol,
                                                                                                           Currency_Code,
                                                                                                           Currency_DecimalPlaces,
                                                                                                           null,
                                                                                                           null,
                                                                                                           new DateTime_v(DateTime.Now),
                                                                                                           null,
                                                                                                           "DDV 22%",
                                                                                                           0.22M,
                                                                                                           10M,
                                                                                                           new decimal_v(0)
                                                                                                           ); j++;
                            }
                        }
                        else if (iNumberOfGroupsInLevel2 > 0)
                        {
                            for (i2 = 0; i2 < iNumberOfGroupsInLevel2; i2++)
                            {
                                sl2 = ".L2g" + i2.ToString();
                                for (i1 = 0; i1 < iNumberOfGroupsInLevel1; i1++)
                                {
                                    sl1 = ".L1g" + i1.ToString();
                                    for (ig = 0; ig < iNumberOfItemsPerGroup; ig++)
                                    {
                                        ShopC_Item_Abbreviation = lngRPMS.ShopC_Item_Abbreviation_SB.s + ig.ToString() + sl2 + sl1;
                                        ShopC_Item_Name = lngRPMS.ShopC_Item_Name_Item.s + ig.ToString() + sl2 + sl1;
                                        SampleDB_Price_ShopC_Item_List[j] = new SampleDB_Price_ShopC_Item(
                                                                       ShopC_Item_Name,
                                                                       ShopC_Item_Abbreviation,
                                                                       new int_v(1),
                                                                       sl1,
                                                                       sl2,
                                                                       null,
                                                                       lngRPMS.s_Piece.s,
                                                                       lngRPMS.s_PieceAbr.s,
                                                                       0,
                                                                       true,
                                                                       null,
                                                                       null,
                                                                       lngRPM.s_Description.s,
                                                                       180,
                                                                       60,
                                                                       10,
                                                                       null,
                                                                       -1,
                                                                       -1,
                                                                       null,
                                                                       null,
                                                                       true,
                                                                       lngRPMS.PriceList_Name.s,
                                                                       true,
                                                                       Currency_Abbreviation,
                                                                       Currency_Name,
                                                                       Currency_Symbol,
                                                                       Currency_Code,
                                                                       Currency_DecimalPlaces,
                                                                       null,
                                                                       null,
                                                                       new DateTime_v(DateTime.Now),
                                                                       null,
                                                                       "DDV 22%",
                                                                       0.22M,
                                                                       10M,
                                                                       new decimal_v(0)
                                                                       );
                                        j++;
                                    }
                                }
                            }
                            for (i2 = 0; i2 < iNumberOfGroupsInLevel2; i2++)
                            {
                                sl2 = ".L2g" + i2.ToString() + "(...)";
                                for (ig = 0; ig < iNumberOfItemsPerGroup; ig++)
                                {
                                    ShopC_Item_Abbreviation = lngRPMS.ShopC_Item_Abbreviation_SB.s + ig.ToString() + sl2;
                                    ShopC_Item_Name = lngRPMS.ShopC_Item_Name_Item.s + ig.ToString() + sl2;
                                    SampleDB_Price_ShopC_Item_List[j] = new SampleDB_Price_ShopC_Item(
                                                                   ShopC_Item_Name,
                                                                   ShopC_Item_Abbreviation,
                                                                   new int_v(1),
                                                                   sl2,
                                                                   null,
                                                                   null,
                                                                   lngRPMS.s_Piece.s,
                                                                   lngRPMS.s_PieceAbr.s,
                                                                   0,
                                                                   true,
                                                                   null,
                                                                   null,
                                                                   lngRPM.s_Description.s,
                                                                   180,
                                                                   60,
                                                                   10,
                                                                   null,
                                                                   -1,
                                                                   -1,
                                                                   null,
                                                                   null,
                                                                   true,
                                                                   lngRPMS.PriceList_Name.s,
                                                                   true,
                                                                   Currency_Abbreviation,
                                                                   Currency_Name,
                                                                   Currency_Symbol,
                                                                   Currency_Code,
                                                                   Currency_DecimalPlaces,
                                                                   null,
                                                                   null,
                                                                   new DateTime_v(DateTime.Now),
                                                                   null,
                                                                   "DDV 22%",
                                                                   0.22M,
                                                                   10M,
                                                                   new decimal_v(0)
                                                                   );
                                    j++;
                                }
                            }
                            sl2 = "(...)";
                            for (ig = 0; ig < iNumberOfItemsPerGroup; ig++)
                            {
                                ShopC_Item_Abbreviation = lngRPMS.ShopC_Item_Abbreviation_SB.s + ig.ToString() + sl2;
                                ShopC_Item_Name = lngRPMS.ShopC_Item_Name_Item.s + ig.ToString() + sl2;
                                SampleDB_Price_ShopC_Item_List[j] = new SampleDB_Price_ShopC_Item(
                                                               ShopC_Item_Name,
                                                               ShopC_Item_Abbreviation,
                                                               new int_v(1),
                                                               null,
                                                               null,
                                                               null,
                                                               lngRPMS.s_Piece.s,
                                                               lngRPMS.s_PieceAbr.s,
                                                               0,
                                                               true,
                                                               null,
                                                               null,
                                                               lngRPM.s_Description.s,
                                                               180,
                                                               60,
                                                               10,
                                                               null,
                                                               -1,
                                                               -1,
                                                               null,
                                                               null,
                                                               true,
                                                               lngRPMS.PriceList_Name.s,
                                                               true,
                                                               Currency_Abbreviation,
                                                               Currency_Name,
                                                               Currency_Symbol,
                                                               Currency_Code,
                                                               Currency_DecimalPlaces,
                                                               null,
                                                               null,
                                                               new DateTime_v(DateTime.Now),
                                                               null,
                                                               "DDV 22%",
                                                               0.22M,
                                                               10M,
                                                               new decimal_v(0)
                                                               );

                                j++;
                            }
                        }
                        else if (iNumberOfGroupsInLevel1 > 0)
                        {
                            for (i1 = 0; i1 < iNumberOfGroupsInLevel1; i1++)
                            {
                                sl1 = ".L1g" + i1.ToString();
                                for (ig = 0; ig < iNumberOfItemsPerGroup; ig++)
                                {
                                    ShopC_Item_Abbreviation = lngRPMS.ShopC_Item_Abbreviation_SB.s + ig.ToString() + sl1;
                                    ShopC_Item_Name = lngRPMS.ShopC_Item_Name_Item.s + ig.ToString() + sl1;
                                    SampleDB_Price_ShopC_Item_List[j] = new SampleDB_Price_ShopC_Item(
                                                                                                  ShopC_Item_Name,
                                                                                                  ShopC_Item_Abbreviation,
                                                                                                  new int_v(1),
                                                                                                  sl1,
                                                                                                  null,
                                                                                                  null,
                                                                                                  lngRPMS.s_Piece.s,
                                                                                                  lngRPMS.s_PieceAbr.s,
                                                                                                  0,
                                                                                                  true,
                                                                                                  null,
                                                                                                  null,
                                                                                                  lngRPM.s_Description.s,
                                                                                                  180,
                                                                                                  60,
                                                                                                  10,
                                                                                                  null,
                                                                                                  -1,
                                                                                                  -1,
                                                                                                  null,
                                                                                                  null,
                                                                                                  true,
                                                                                                  lngRPMS.PriceList_Name.s,
                                                                                                  true,
                                                                                                  Currency_Abbreviation,
                                                                                                  Currency_Name,
                                                                                                  Currency_Symbol,
                                                                                                  Currency_Code,
                                                                                                  Currency_DecimalPlaces,
                                                                                                  null,
                                                                                                  null,
                                                                                                  new DateTime_v(DateTime.Now),
                                                                                                  null,
                                                                                                  "DDV 22%",
                                                                                                  0.22M,
                                                                                                  10M,
                                                                                                  new decimal_v(0)
                                                                                                  );
                                    j++;
                                }
                            }
                            sl1 = "(...)";
                            for (ig = 0; ig < iNumberOfItemsPerGroup; ig++)
                            {
                                ShopC_Item_Abbreviation = lngRPMS.ShopC_Item_Abbreviation_SB.s + ig.ToString() + sl1;
                                ShopC_Item_Name = lngRPMS.ShopC_Item_Name_Item.s + ig.ToString() + sl1;
                                SampleDB_Price_ShopC_Item_List[j] = new SampleDB_Price_ShopC_Item(
                                                                                              ShopC_Item_Name,
                                                                                              ShopC_Item_Abbreviation,
                                                                                              new int_v(1),
                                                                                              null,
                                                                                              null,
                                                                                              null,
                                                                                              lngRPMS.s_Piece.s,
                                                                                              lngRPMS.s_PieceAbr.s,
                                                                                              0,
                                                                                              true,
                                                                                              null,
                                                                                              null,
                                                                                              lngRPM.s_Description.s,
                                                                                              180,
                                                                                              60,
                                                                                              10,
                                                                                              null,
                                                                                              -1,
                                                                                              -1,
                                                                                              null,
                                                                                              null,
                                                                                              true,
                                                                                              lngRPMS.PriceList_Name.s,
                                                                                              true,
                                                                                              Currency_Abbreviation,
                                                                                              Currency_Name,
                                                                                              Currency_Symbol,
                                                                                              Currency_Code,
                                                                                              Currency_DecimalPlaces,
                                                                                              null,
                                                                                              null,
                                                                                              new DateTime_v(DateTime.Now),
                                                                                              null,
                                                                                              "DDV 22%",
                                                                                              0.22M,
                                                                                              10M,
                                                                                              new decimal_v(0)
                                                                                              );
                                j++;
                            }
                        }
                        else
                        {
                            sl1 = "(...)";
                            for (ig = 0; ig < iNumberOfItemsPerGroup; ig++)
                            {
                                ShopC_Item_Abbreviation = lngRPMS.ShopC_Item_Abbreviation_SB.s + ig.ToString() + sl1;
                                ShopC_Item_Name = lngRPMS.ShopC_Item_Name_Item.s + ig.ToString() + sl1;
                                SampleDB_Price_ShopC_Item_List[j] = new SampleDB_Price_ShopC_Item(
                                                                                                                             ShopC_Item_Name,
                                                                                                                             ShopC_Item_Abbreviation,
                                                                                                                             new int_v(1),
                                                                                                                             null,
                                                                                                                             null,
                                                                                                                             null,
                                                                                                                             lngRPMS.s_Piece.s,
                                                                                                                             lngRPMS.s_PieceAbr.s,
                                                                                                                             0,
                                                                                                                             true,
                                                                                                                             null,
                                                                                                                             null,
                                                                                                                             lngRPM.s_Description.s,
                                                                                                                             180,
                                                                                                                             60,
                                                                                                                             10,
                                                                                                                             null,
                                                                                                                             -1,
                                                                                                                             -1,
                                                                                                                             null,
                                                                                                                             null,
                                                                                                                             true,
                                                                                                                             lngRPMS.PriceList_Name.s,
                                                                                                                             true,
                                                                                                                             Currency_Abbreviation,
                                                                                                                             Currency_Name,
                                                                                                                             Currency_Symbol,
                                                                                                                             Currency_Code,
                                                                                                                             Currency_DecimalPlaces,
                                                                                                                             null,
                                                                                                                             null,
                                                                                                                             new DateTime_v(DateTime.Now),
                                                                                                                             null,
                                                                                                                             "DDV 22%",
                                                                                                                             0.22M,
                                                                                                                             10M,
                                                                                                                             new decimal_v(0)
                                                                                                                             ); j++;
                            }
                        }
                        //{new
                        if (j != iNumberOfAll)
                        {
                            LogFile.Error.Show("ERROR:SampleDB:Write_ShopB_Items:Calculated number of items " + iNumberOfAll.ToString() + " is not equal to iterating number j in loop:" + j.ToString());
                        }
                        int k = 0;
                        int SampleDB_Price_ShopC_Item_List_Count = SampleDB_Price_ShopC_Item_List.Count();
                        ProgressForm.Progress_Thread progress = new ProgressForm.Progress_Thread();
                        progress.sLabel1 = lngRPMS.s_WriteItemsToDatabase.s + SampleDB_Price_ShopC_Item_List_Count.ToString();
                        progress.Start();
                        f_Expiry.Expiry_v expiry_v = new f_Expiry.Expiry_v();
                        f_Warranty.Warranty_v warranty_v = new f_Warranty.Warranty_v();
                        f_Expiry.Expiry_v xexpiry_v = null;
                        f_Warranty.Warranty_v xwarranty_v = null;
                        for (k = 0; k < SampleDB_Price_ShopC_Item_List_Count; k++)
                        {
                            xexpiry_v = null;
                            xwarranty_v = null;
                            SampleDB_Price_ShopC_Item sample_ShopC_Item = SampleDB_Price_ShopC_Item_List[k];
                            if (sample_ShopC_Item.ShopC_Item_Expiry_ExpectedShelfLifeInDays >= 0)
                            {
                                expiry_v.ExpectedShelfLifeInDays = sample_ShopC_Item.ShopC_Item_Expiry_ExpectedShelfLifeInDays;
                                expiry_v.DiscardBeforeExpiryDateInDays = sample_ShopC_Item.ShopC_Item_Expiry_DiscardBeforeExpiryDateInDays;
                                expiry_v.SaleBeforeExpiryDateInDays = sample_ShopC_Item.ShopC_Item_Expiry_SaleBeforeExpiryDateInDays;
                                expiry_v.ExpiryDescription = sample_ShopC_Item.ShopC_Item_Expiry_ExpiryDescription;
                                xexpiry_v = expiry_v;

                            }
                            if (sample_ShopC_Item.ShopC_Item_Warranty_WarrantyDuration >= 0)
                            {
                                warranty_v.WarrantyDuration = sample_ShopC_Item.ShopC_Item_Warranty_WarrantyDuration;
                                warranty_v.WarrantyDurationType = sample_ShopC_Item.ShopC_Item_Warranty_WarrantyDurationType;
                                warranty_v.WarrantyConditions = sample_ShopC_Item.ShopC_Item_Warranty_WarrantyConditions;
                                xwarranty_v = warranty_v;
                            }

                            if (f_Item.Get(sample_ShopC_Item.ShopC_Item_Name,
                                           sample_ShopC_Item.ShopC_Item_UniqueName,
                                           sample_ShopC_Item.ShopC_Item_ToOffer,
                                           sample_ShopC_Item.ShopC_Item_Image,
                                           sample_ShopC_Item.ShopC_Item_Code,
                                           "komad",
                                           "kom.",
                                           0,
                                           true,
                                           "Artikli kot komadi.",
                                           null,
                                           null,
                                           xexpiry_v,
                                           xwarranty_v,
                                           sample_ShopC_Item.ShopC_Item_ParentGroup1,
                                           sample_ShopC_Item.ShopC_Item_ParentGroup2,
                                           sample_ShopC_Item.ShopC_Item_ParentGroup3,
                                           ref sample_ShopC_Item.ShopC_Item_Unit_ID,
                                           ref sample_ShopC_Item.ShopC_Price_Item_Item_ID
                                           ))
                            {

                                if (f_PriceList.Get(sample_ShopC_Item.ShopC_Price_Item_PriceList_Name,
                                                    sample_ShopC_Item.ShopC_Price_Item_PriceList_valid,
                                                    myOrg.Default_Currency_ID,
                                                    sample_ShopC_Item.ShopC_Price_Item_PriceList_ValidFrom_v,
                                                    sample_ShopC_Item.ShopC_Price_Item_PriceList_ValidTo_v,
                                                    sample_ShopC_Item.ShopC_Price_Item_PriceList_CreationDate_v,
                                                    sample_ShopC_Item.ShopC_Price_Item_PriceList_Description,
                                                    ref sample_ShopC_Item.ShopC_Price_Item_PriceList_ID))
                                {
                                    if (f_Taxation.Get(sample_ShopC_Item.ShopC_Price_Item_TaxationName,
                                                       sample_ShopC_Item.ShopC_Price_Item_TaxationRate,
                                                       ref sample_ShopC_Item.ShopC_Price_Item_Taxation_ID))
                                    {

                                        if (f_Price_Item.Get(sample_ShopC_Item.ShopC_Price_Item_RetailPricePerUnit,
                                                             sample_ShopC_Item.ShopC_Price_Item_Discount_v,
                                                             sample_ShopC_Item.ShopC_Price_Item_Taxation_ID,
                                                             sample_ShopC_Item.ShopC_Price_Item_Item_ID,
                                                             sample_ShopC_Item.ShopC_Price_Item_PriceList_ID,
                                                             ref sample_ShopC_Item.ShopC_Price_Item_ID
                                                             ))
                                        {
                                            if (k % 5 == 0)
                                            {
                                                GC.Collect();
                                                int iPercent = ((int)(k * 100) / SampleDB_Price_ShopC_Item_List_Count);
                                                progress.Message(null, lngRPMS.s_ItemsWrittenToDB.s + " " + k.ToString(), lngRPMS.s_JobInPercentDone.s + " " + iPercent.ToString() +"%", iPercent);
                                            }
                                            if (progress.bCancel || progress.bEnd)
                                            {
                                                return true;
                                            }
                                        }
                                        else
                                        {
                                            progress.End();
                                            return false;
                                        }
                                    }
                                    else
                                    {
                                        progress.End();
                                        return false;
                                    }
                                }
                                else
                                {
                                    progress.End();
                                    return false;
                                }
                            }
                            else
                            {
                                progress.End();
                                return false;
                            }
                            SampleDB_Price_ShopC_Item_List[k] = null;
                            sample_ShopC_Item = null;
                        }
                        progress.End();
                    }
                }
                return true;
            }
            else
            {
                return false;
            }
        }
Esempio n. 2
0
        public bool Write_ShopB_Items(NavigationButtons.Navigation xnav)
        {
            string Currency_Name = null;
            string Currency_Abbreviation = null;
            string Currency_Symbol = null;
            int Currency_Code = 0;
            int Currency_DecimalPlaces = 2;

            if (f_Currency.Get(myOrg.Default_Currency_ID, ref Currency_Abbreviation, ref Currency_Name, ref Currency_Symbol, ref Currency_Code, ref Currency_DecimalPlaces))
            {
                xnav.ChildDialog = new Form_Items_Samples(xnav, lngRPM.s_Shop_B.s);
                xnav.bDoModal = false;
                xnav.ShowDialog();
                if (xnav.eExitResult == NavigationButtons.Navigation.eEvent.NEXT)
                {
                    if (((Form_Items_Samples)xnav.ChildDialog).bAutoGenerateDemoSampleItems)
                    {
                        int iNumberOfGroupsInLevel3 = ((Form_Items_Samples)xnav.ChildDialog).iNumberOfGroupsInLevel3;
                        int iNumberOfGroupsInLevel2 = ((Form_Items_Samples)xnav.ChildDialog).iNumberOfGroupsInLevel2;
                        int iNumberOfGroupsInLevel1 = ((Form_Items_Samples)xnav.ChildDialog).iNumberOfGroupsInLevel1;
                        int iNumberOfItemsPerGroup = ((Form_Items_Samples)xnav.ChildDialog).iNumberOfItemsPerGroup;
                        int iNumberOfAll = ((Form_Items_Samples)xnav.ChildDialog).iNumberOffAll();
                        SampleDB_Price_ShopB_Item[] SampleDB_Price_ShopB_Item_List = new SampleDB_Price_ShopB_Item[iNumberOfAll];
                        int j = 0;
                        string ShopB_Item_Abbreviation = null;
                        string ShopB_Item_Name = null;
                        string sl3 = null;
                        string sl2 = null;
                        string sl1 = null;
                        int i1 = 0;
                        int i2 = 0;
                        int i3 = 0;
                        int ig = 0;
                        if (iNumberOfGroupsInLevel3 > 0)
                        {
                            for (i3 = 0; i3 < iNumberOfGroupsInLevel3; i3++)
                            {
                                string sln3 = "L3g" + i3.ToString();
                                sl3 = "." + sln3;
                                for (i2 = 0; i2 < iNumberOfGroupsInLevel2; i2++)
                                {
                                    string sln2 = sln3+"L2g" + i2.ToString();
                                    sl2 = "." + sln2;
                                    for (i1 = 0; i1 < iNumberOfGroupsInLevel1; i1++)
                                    {
                                        string sln1 = sln3 + sln2+ "L1g" + i1.ToString();
                                        sl1 = "."+ sln1;
                                        for (ig = 0; ig < iNumberOfItemsPerGroup; ig++)
                                        {
                                            ShopB_Item_Abbreviation = lngRPMS.ShopB_Item_Abbreviation_SB.s + ig.ToString() + sln1;
                                            ShopB_Item_Name = lngRPMS.ShopB_Item_Name_Item.s + ig.ToString() + sln1;
                                            SampleDB_Price_ShopB_Item_List[j] = new SampleDB_Price_ShopB_Item(ShopB_Item_Name,
                                                                    ShopB_Item_Abbreviation,
                                                                    true,
                                                                    null,
                                                                    null,
                                                                    sl1,
                                                                    sl2,
                                                                    sl3,
                                                                    lngRPMS.PriceList_Name.s,
                                                                    true,
                                                                    null,
                                                                    null,
                                                                    new DateTime_v(DateTime.Now),
                                                                    lngRPMS.PriceList_Description.s,
                                                                    Currency_Abbreviation,
                                                                    Currency_Name,
                                                                    Currency_Symbol,
                                                                    Currency_Code,
                                                                    Currency_DecimalPlaces,
                                                                    "DDV 22%",
                                                                    0.22M,
                                                                    2,
                                                                    null);
                                            j++;
                                        }
                                    }
                                    for (ig = 0; ig < iNumberOfItemsPerGroup; ig++)
                                    {
                                        ShopB_Item_Abbreviation = lngRPMS.ShopB_Item_Abbreviation_SB.s + ig.ToString() + sln2;
                                        ShopB_Item_Name = lngRPMS.ShopB_Item_Name_Item.s + ig.ToString() + sln2;
                                        SampleDB_Price_ShopB_Item_List[j] = new SampleDB_Price_ShopB_Item(ShopB_Item_Name,
                                                                ShopB_Item_Abbreviation,
                                                                true,
                                                                null,
                                                                null,
                                                                sl2,
                                                                sl3,
                                                                null,
                                                                lngRPMS.PriceList_Name.s,
                                                                true,
                                                                null,
                                                                null,
                                                                new DateTime_v(DateTime.Now),
                                                                lngRPMS.PriceList_Description.s,
                                                                Currency_Abbreviation,
                                                                Currency_Name,
                                                                Currency_Symbol,
                                                                Currency_Code,
                                                                Currency_DecimalPlaces,
                                                                "DDV 22%",
                                                                0.22M,
                                                                2,
                                                                null);
                                        j++;
                                    }

                                }
                                for (ig = 0; ig < iNumberOfItemsPerGroup; ig++)
                                {

                                    ShopB_Item_Abbreviation = lngRPMS.ShopB_Item_Abbreviation_SB.s + ig.ToString() + sln3;
                                    ShopB_Item_Name = lngRPMS.ShopB_Item_Name_Item.s + ig.ToString() + sln3;
                                    SampleDB_Price_ShopB_Item_List[j] = new SampleDB_Price_ShopB_Item(ShopB_Item_Name,
                                                        ShopB_Item_Abbreviation,
                                                        true,
                                                        null,
                                                        null,
                                                        sl3,
                                                        null,
                                                        null,
                                                        lngRPMS.PriceList_Name.s,
                                                        true,
                                                        null,
                                                        null,
                                                        new DateTime_v(DateTime.Now),
                                                        lngRPMS.PriceList_Description.s,
                                                        Currency_Abbreviation,
                                                        Currency_Name,
                                                        Currency_Symbol,
                                                        Currency_Code,
                                                        Currency_DecimalPlaces,
                                                        "DDV 22%",
                                                        0.22M,
                                                        2,
                                                        null);
                                    j++;
                                }
                            }
                            for (ig = 0; ig < iNumberOfItemsPerGroup; ig++)
                            {
                                ShopB_Item_Abbreviation = lngRPMS.ShopB_Item_Abbreviation_SB.s + ig.ToString() + "noL1noL2noL3";
                                ShopB_Item_Name = lngRPMS.ShopB_Item_Name_Item.s + ig.ToString() + "noL1noL2noL3";
                                SampleDB_Price_ShopB_Item_List[j] = new SampleDB_Price_ShopB_Item(ShopB_Item_Name,
                                                        ShopB_Item_Abbreviation,
                                                        true,
                                                        null,
                                                        null,
                                                        null,
                                                        null,
                                                        null,
                                                        lngRPMS.PriceList_Name.s,
                                                        true,
                                                        null,
                                                        null,
                                                        new DateTime_v(DateTime.Now),
                                                        lngRPMS.PriceList_Description.s,
                                                        Currency_Abbreviation,
                                                        Currency_Name,
                                                        Currency_Symbol,
                                                        Currency_Code,
                                                        Currency_DecimalPlaces,
                                                        "DDV 22%",
                                                        0.22M,
                                                        2,
                                                        null);
                                j++;
                            }
                        }
                        else if (iNumberOfGroupsInLevel2 > 0)
                        {
                            for (i2 = 0; i2 < iNumberOfGroupsInLevel2; i2++)
                            {
                                sl2 = ".L2g" + i2.ToString();
                                for (i1 = 0; i1 < iNumberOfGroupsInLevel1; i1++)
                                {
                                    sl1 = ".L1g" + i1.ToString();
                                    for (ig = 0; ig < iNumberOfItemsPerGroup; ig++)
                                    {
                                        ShopB_Item_Abbreviation = lngRPMS.ShopB_Item_Abbreviation_SB.s + ig.ToString() + sl2 + sl1;
                                        ShopB_Item_Name = lngRPMS.ShopB_Item_Name_Item.s + ig.ToString() +  sl2 + sl1;
                                        SampleDB_Price_ShopB_Item_List[j] = new SampleDB_Price_ShopB_Item(ShopB_Item_Name,
                                                                ShopB_Item_Abbreviation,
                                                                true,
                                                                null,
                                                                null,
                                                                sl1,
                                                                sl2,
                                                                null,
                                                                lngRPMS.PriceList_Name.s,
                                                                true,
                                                                null,
                                                                null,
                                                                new DateTime_v(DateTime.Now),
                                                                lngRPMS.PriceList_Description.s,
                                                                Currency_Abbreviation,
                                                                Currency_Name,
                                                                Currency_Symbol,
                                                                Currency_Code,
                                                                Currency_DecimalPlaces,
                                                                "DDV 22%",
                                                                0.22M,
                                                                2,
                                                                null);
                                        j++;
                                    }
                                }
                            }
                            for (i2 = 0; i2 < iNumberOfGroupsInLevel2; i2++)
                            {
                                sl2 = ".L2g" + i2.ToString() + "(...)";
                                for (ig = 0; ig < iNumberOfItemsPerGroup; ig++)
                                {
                                    ShopB_Item_Abbreviation = lngRPMS.ShopB_Item_Abbreviation_SB.s + ig.ToString() + sl2;
                                    ShopB_Item_Name = lngRPMS.ShopB_Item_Name_Item.s + ig.ToString() + sl2;
                                    SampleDB_Price_ShopB_Item_List[j] = new SampleDB_Price_ShopB_Item(ShopB_Item_Name,
                                                            ShopB_Item_Abbreviation,
                                                            true,
                                                            null,
                                                            null,
                                                            sl2,
                                                            null,
                                                            null,
                                                            lngRPMS.PriceList_Name.s,
                                                            true,
                                                            null,
                                                            null,
                                                            new DateTime_v(DateTime.Now),
                                                            lngRPMS.PriceList_Description.s,
                                                            Currency_Abbreviation,
                                                            Currency_Name,
                                                            Currency_Symbol,
                                                            Currency_Code,
                                                            Currency_DecimalPlaces,
                                                            "DDV 22%",
                                                            0.22M,
                                                            2,
                                                            null);
                                    j++;
                                }
                            }
                            sl2 = "(...)";
                            for (ig = 0; ig < iNumberOfItemsPerGroup; ig++)
                            {
                                ShopB_Item_Abbreviation = lngRPMS.ShopB_Item_Abbreviation_SB.s + ig.ToString() + sl2;
                                ShopB_Item_Name = lngRPMS.ShopB_Item_Name_Item.s + ig.ToString() + sl2;
                                SampleDB_Price_ShopB_Item_List[j] = new SampleDB_Price_ShopB_Item(ShopB_Item_Name,
                                                        ShopB_Item_Abbreviation,
                                                        true,
                                                        null,
                                                        null,
                                                        null,
                                                        null,
                                                        null,
                                                        lngRPMS.PriceList_Name.s,
                                                        true,
                                                        null,
                                                        null,
                                                        new DateTime_v(DateTime.Now),
                                                        lngRPMS.PriceList_Description.s,
                                                        Currency_Abbreviation,
                                                        Currency_Name,
                                                        Currency_Symbol,
                                                        Currency_Code,
                                                        Currency_DecimalPlaces,
                                                        "DDV 22%",
                                                        0.22M,
                                                        2,
                                                        null);
                                j++;
                            }
                        }
                        else if (iNumberOfGroupsInLevel1 > 0)
                        {
                            for (i1 = 0; i1 < iNumberOfGroupsInLevel1; i1++)
                            {
                                sl1 = ".L1g" + i1.ToString();
                                for (ig = 0; ig < iNumberOfItemsPerGroup; ig++)
                                {
                                    ShopB_Item_Abbreviation = lngRPMS.ShopB_Item_Abbreviation_SB.s + ig.ToString() + sl1;
                                    ShopB_Item_Name = lngRPMS.ShopB_Item_Name_Item.s + ig.ToString() + sl1;
                                    SampleDB_Price_ShopB_Item_List[j] = new SampleDB_Price_ShopB_Item(ShopB_Item_Name,
                                                            ShopB_Item_Abbreviation,
                                                            true,
                                                            null,
                                                            null,
                                                            sl1,
                                                            null,
                                                            null,
                                                            lngRPMS.PriceList_Name.s,
                                                            true,
                                                            null,
                                                            null,
                                                            new DateTime_v(DateTime.Now),
                                                            lngRPMS.PriceList_Description.s,
                                                            Currency_Abbreviation,
                                                            Currency_Name,
                                                            Currency_Symbol,
                                                            Currency_Code,
                                                            Currency_DecimalPlaces,
                                                            "DDV 22%",
                                                            0.22M,
                                                            2,
                                                            null);
                                    j++;
                                }
                            }
                            sl1 = "(...)";
                            for (ig = 0; ig < iNumberOfItemsPerGroup; ig++)
                            {
                                ShopB_Item_Abbreviation = lngRPMS.ShopB_Item_Abbreviation_SB.s + ig.ToString() + sl1;
                                ShopB_Item_Name = lngRPMS.ShopB_Item_Name_Item.s + ig.ToString() + sl1;
                                SampleDB_Price_ShopB_Item_List[j] = new SampleDB_Price_ShopB_Item(ShopB_Item_Name,
                                                        ShopB_Item_Abbreviation,
                                                        true,
                                                        null,
                                                        null,
                                                        null,
                                                        null,
                                                        null,
                                                        lngRPMS.PriceList_Name.s,
                                                        true,
                                                        null,
                                                        null,
                                                        new DateTime_v(DateTime.Now),
                                                        lngRPMS.PriceList_Description.s,
                                                        Currency_Abbreviation,
                                                        Currency_Name,
                                                        Currency_Symbol,
                                                        Currency_Code,
                                                        Currency_DecimalPlaces,
                                                        "DDV 22%",
                                                        0.22M,
                                                        2,
                                                        null);
                                j++;
                            }
                        }
                        else
                        {
                            sl1 = "(...)";
                            for (ig = 0; ig < iNumberOfItemsPerGroup; ig++)
                            {
                                ShopB_Item_Abbreviation = lngRPMS.ShopB_Item_Abbreviation_SB.s + ig.ToString() + sl1;
                                ShopB_Item_Name = lngRPMS.ShopB_Item_Name_Item.s + ig.ToString() + sl1;
                                SampleDB_Price_ShopB_Item_List[j] = new SampleDB_Price_ShopB_Item(ShopB_Item_Name,
                                                        ShopB_Item_Abbreviation,
                                                        true,
                                                        null,
                                                        null,
                                                        null,
                                                        null,
                                                        null,
                                                        lngRPMS.PriceList_Name.s,
                                                        true,
                                                        null,
                                                        null,
                                                        new DateTime_v(DateTime.Now),
                                                        lngRPMS.PriceList_Description.s,
                                                        Currency_Abbreviation,
                                                        Currency_Name,
                                                        Currency_Symbol,
                                                        Currency_Code,
                                                        Currency_DecimalPlaces,
                                                        "DDV 22%",
                                                        0.22M,
                                                        2,
                                                        null);
                                j++;
                            }
                        }
                        //{new
                        if (j!= iNumberOfAll)
                        {
                            LogFile.Error.Show("ERROR:SampleDB:Write_ShopB_Items:Calculated number of items " + iNumberOfAll.ToString() + " is not equal to iterating number j in loop:" + j.ToString());
                        }
                        int k = 0;
                        int SampleDB_Price_ShopB_Item_List_Count = SampleDB_Price_ShopB_Item_List.Count();
                        ProgressForm.Progress_Thread progress = new ProgressForm.Progress_Thread();
                        progress.sLabel1 = lngRPMS.s_WriteItemsToDatabase.s + SampleDB_Price_ShopB_Item_List_Count.ToString();
                        progress.Start();
                        for (k=0;k<SampleDB_Price_ShopB_Item_List_Count;k++)
                        {
                            SampleDB_Price_ShopB_Item sample_ShopB_Item = SampleDB_Price_ShopB_Item_List[k];
                            if (f_SimpleItem.Get(sample_ShopB_Item.ShopB_Item_Name,
                                                    sample_ShopB_Item.ShopB_Item_Abbreviation,
                                                    sample_ShopB_Item.ShopB_Item_bToOffer,
                                                    sample_ShopB_Item.ShopB_Item_Image,
                                                    sample_ShopB_Item.ShopB_Item_Code_v,
                                                    sample_ShopB_Item.ShopB_Item_ParentGroup1,
                                                    sample_ShopB_Item.ShopB_Item_ParentGroup2,
                                                    sample_ShopB_Item.ShopB_Item_ParentGroup3,
                                                    ref sample_ShopB_Item.ShopB_Item_ID))
                            {
                                if (f_PriceList.Get(sample_ShopB_Item.PriceList_Name,
                                                    sample_ShopB_Item.PriceList_valid,
                                                    myOrg.Default_Currency_ID,
                                                    sample_ShopB_Item.PriceList_ValidFrom_v,
                                                    sample_ShopB_Item.PriceList_ValidTo_v,
                                                    sample_ShopB_Item.PriceList_CreationDate_v,
                                                    sample_ShopB_Item.PriceList_Description,
                                                    ref sample_ShopB_Item.PriceList_ID))
                                {
                                    if (f_Taxation.Get(sample_ShopB_Item.TaxationName,
                                                       sample_ShopB_Item.TaxationRate,
                                                       ref sample_ShopB_Item.Taxation_ID))
                                    {
                                        if (f_Price_SimpleItem.Get(sample_ShopB_Item.RetailShopB_ItemPrice,
                                                                   sample_ShopB_Item.Discount_v,
                                                                   sample_ShopB_Item.Taxation_ID,
                                                                   sample_ShopB_Item.ShopB_Item_ID,
                                                                   sample_ShopB_Item.PriceList_ID,
                                                                   ref sample_ShopB_Item.Price_ShopB_Item_ID
                                                                   ))
                                        {
                                            if (k % 5 == 0)
                                            {
                                                GC.Collect();
                                                int iPercent = ((int)(k * 100) / SampleDB_Price_ShopB_Item_List_Count);
                                                progress.Message(null, lngRPMS.s_ItemsWrittenToDB.s+" "+ k.ToString(),lngRPMS.s_JobInPercentDone.s + " " + iPercent.ToString()+"%", iPercent);
                                            }
                                            if (progress.bCancel|| progress.bEnd)
                                            {
                                                return true;
                                            }
                                        }
                                        else
                                        {
                                            progress.End();
                                            return false;
                                        }
                                    }
                                    else
                                    {
                                        progress.End();
                                        return false;
                                    }
                                }
                                else
                                {
                                    progress.End();
                                    return false;
                                }
                            }
                            else
                            {
                                progress.End();
                                return false;
                            }
                            SampleDB_Price_ShopB_Item_List[k] = null;
                            sample_ShopB_Item = null;
                        }
                        progress.End();
                    }
                }
                return true;
            }
            else
            {
                return false;
            }
        }