Ejemplo n.º 1
0
        private void productCategoriesComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (productCategoriesComboBox.SelectedValue.Equals("perfume"))
            {
                perfumeCategoriesComboBox.SelectedValue = comboxCurrentSelectedPerfumeCategory;
                perfumeCategoryLabel.Enabled            = true;
                perfumeCategoriesComboBox.Enabled       = true;
                perfumeCategoriesComboBox_SelectedIndexChanged(null, null);
            }
            else
            {
                perfumeCategoriesComboBox.SelectedValue = "";
                perfumeCategoryLabel.Enabled            = false;
                perfumeCategoriesComboBox.Enabled       = false;

                productDataGridView.Rows.Clear();
                productDataGridView.Refresh();

                if (productCategoriesComboBox.SelectedValue.Equals("bottle"))
                {
                    List <Bottle> list = pbda.getAllProductBottles(Language.getLanguageCode(), conn);
                    foreach (Bottle bottle in list)
                    {
                        productDataGridView.Rows.Add(
                            bottle.getProductID(),
                            bottle.getProductName(),
                            bottle.getQtyInStock());
                    }
                }
                else if (productCategoriesComboBox.SelectedValue.Equals("package"))
                {
                    List <Package> list = ppgda.getAllProductPackages(Language.getLanguageCode(), conn);
                    foreach (Package package in list)
                    {
                        productDataGridView.Rows.Add(
                            package.getProductID(),
                            package.getProductName(),
                            package.getQtyInStock());
                    }
                }

                productDataGridView.ClearSelection();
            }
        }
Ejemplo n.º 2
0
        private void productCategoriesComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (productCategoriesComboBox.SelectedValue.Equals("perfume"))
            {
                perfumeCategoriesComboBox.SelectedValue = comboxCurrentSelectedPerfumeCategory;
                perfumeCategoryLabel.Enabled            = true;
                perfumeCategoriesComboBox.Enabled       = true;
                perfumeCategoriesComboBox_SelectedIndexChanged(null, null);
            }
            else
            {
                perfumeCategoriesComboBox.SelectedValue = "";
                perfumeCategoryLabel.Enabled            = false;
                perfumeCategoriesComboBox.Enabled       = false;

                nonDiscountProductDataGridView.Rows.Clear();
                nonDiscountProductDataGridView.Refresh();

                List <ProductDiscount> discountList = null;
                if (productCategoriesComboBox.SelectedValue.Equals("bottle"))
                {
                    if (!string.IsNullOrEmpty(selectedDiscountCode))
                    {
                        discountList = pbdda.getOneProductDiscountByCode(selectedDiscountCode, Language.getLanguageCode(), conn);
                        List <Bottle> list = pbda.getAllProductBottles(Language.getLanguageCode(), conn);
                        foreach (Bottle bottle in list)
                        {
                            int discountIndex = discountList.FindIndex(pd => bottle.getProductID().Equals(pd.getProductID()));
                            if (discountIndex == -1)
                            {
                                nonDiscountProductDataGridView.Rows.Add(false, bottle.getProductID(), bottle.getProductName());
                            }
                        }
                    }
                }
                else if (productCategoriesComboBox.SelectedValue.Equals("package"))
                {
                    if (!string.IsNullOrEmpty(selectedDiscountCode))
                    {
                        discountList = ppgdda.getOneProductDiscountByCode(selectedDiscountCode, Language.getLanguageCode(), conn);
                        List <Package> list = ppgda.getAllProductPackages(Language.getLanguageCode(), conn);
                        foreach (Package package in list)
                        {
                            int discountIndex = discountList.FindIndex(pd => package.getProductID().Equals(pd.getProductID()));
                            if (discountIndex == -1)
                            {
                                nonDiscountProductDataGridView.Rows.Add(false, package.getProductID(), package.getProductName());
                            }
                        }
                    }
                }

                if (nonDiscountProductDataGridView.Rows.Count > 0)
                {
                    nonDiscountSelectAllButton.Enabled   = true;
                    nonDiscountDeselectAllButton.Enabled = true;
                    nonDiscountAddButton.Enabled         = true;
                }
                else
                {
                    nonDiscountSelectAllButton.Enabled   = false;
                    nonDiscountDeselectAllButton.Enabled = false;
                    nonDiscountAddButton.Enabled         = false;
                }

                nonDiscountProductDataGridView.ClearSelection();

                //=======================================
                discountProductDataGridView.Rows.Clear();
                discountProductDataGridView.Refresh();

                if (productCategoriesComboBox.SelectedValue.Equals("bottle"))
                {
                    if (!string.IsNullOrEmpty(selectedDiscountCode))
                    {
                        foreach (ProductDiscount bottle in discountList)
                        {
                            discountProductDataGridView.Rows.Add(false, bottle.getProductID(), bottle.getProductName());
                        }
                    }
                }
                else if (productCategoriesComboBox.SelectedValue.Equals("package"))
                {
                    if (!string.IsNullOrEmpty(selectedDiscountCode))
                    {
                        foreach (ProductDiscount package in discountList)
                        {
                            discountProductDataGridView.Rows.Add(false, package.getProductID(), package.getProductName());
                        }
                    }
                }

                if (discountProductDataGridView.Rows.Count > 0)
                {
                    discountSelectAllButton.Enabled   = true;
                    discountDeselectAllButton.Enabled = true;
                    discountDeleteButton.Enabled      = true;
                }
                else
                {
                    discountSelectAllButton.Enabled   = false;
                    discountDeselectAllButton.Enabled = false;
                    discountDeleteButton.Enabled      = false;
                }

                discountProductDataGridView.ClearSelection();
            }
        }