예제 #1
0
        private void ReadFromData()
        {
            DistributorOrderingProfile distributorOrderingProfile =
                DistributorOrderingProfileProvider.GetProfile(DistributorID, CountryCode);

            _distributorId = DistributorID;
            _apfDueDate    = distributorOrderingProfile.ApfDueDate;
            if (_testing)
            {
                APFDueProvider.UpdateAPFDuePaid(_distributorId, _apfDueDate);
            }
            _apfSku                   = APFDueProvider.GetAPFSku();
            _cart                     = (Page as ProductsBase).ShoppingCart;
            _apfIsDue                 = APFDueProvider.IsAPFDueAndNotPaid(_distributorId, HLConfigManager.Configurations.Locale);
            _apfDueWithinOneYear      = APFDueProvider.IsAPFDueWithinOneYear(_distributorId, CountryCode);
            _apfDueGreaterThanOneYear = APFDueProvider.IsAPFDueGreaterThanOneYear(_distributorId, CountryCode);
            if (_apfIsDue)
            {
                _apfsDue = APFDueProvider.APFQuantityDue(_distributorId, HLConfigManager.Configurations.Locale);
            }
            List <ShoppingCartItem_V01> item = (from c in _cart.CartItems where c.SKU == _apfSku select c).ToList();

            _apfsInCart = 0;
            if (item.Count > 0)
            {
                _apfsInCart = item[0].Quantity;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            DistributorOrderingProfile dsProfile = DistributorOrderingProfileProvider.GetProfile(DistributorID, CountryCode);
            string DSType = dsProfile.OrderSubType;


            //lblProductType.Visible = false;
            if (!IsPostBack)
            {
                if (ShoppingCart.OrderCategory == OrderCategoryType.ETO)
                {
                    trOrderType.Visible            = false;
                    trRemainingVal.Visible         = false;
                    ShoppingCart.SelectedDSSubType = "D2";
                    PurchasingLimitProvider.GetPurchasingLimits(DistributorID, "ETO");
                    return;
                }
                else
                {
                    if (ShoppingCart.SelectedDSSubType == "ETO")
                    {
                        ShoppingCart.SelectedDSSubType = String.Empty;
                    }
                }

                //lblPickupLocation.Visible = ddlPickup.Visible = false;
                bool noConsignmentOrdersAllowed = false;
                if (DSType.Equals("A") || DSType.Equals("B"))
                {
                    if (APFDueProvider.IsAPFDueAndNotPaid(DistributorID, Locale))
                    {
                        noConsignmentOrdersAllowed = true;
                    }
                }

                //Begin HD Ticket 406707
                if (ShoppingCart.OrderSubType == "A2" || ShoppingCart.OrderSubType == "B2")
                {
                    bool isAPFDue = APFDueProvider.IsAPFDueAndNotPaid(DistributorID, Locale) ||
                                    APFDueProvider.IsAPFDueWithinOneYear(DistributorID, CountryCode) ||
                                    APFDueProvider.IsAPFDueGreaterThanOneYear(DistributorID, CountryCode);
                    if (!isAPFDue)
                    {
                        //delete APF SKU from cart
                        ShoppingCart.DeleteItemsFromCart(APFDueProvider.GetAPFSkuList());
                    }
                }
                //End HD Ticket 406707

                if (noConsignmentOrdersAllowed)
                {
                    lbltext.Text    = GetLocalResourceObject("CannotPlaceConsignmentWhileAPFDue") as string;
                    lbltext.Visible = true;
                }

                ddl_DSSubType.Enabled = false;
                //ddlDelivery.Enabled = false;
                trRemainingVal.Visible = false;

                switch (DSType)
                {
                case "A":
                    ddl_DSSubType.Items.Clear();
                    if (!HideEmptyListItem)
                    {
                        ddl_DSSubType.Items.Add(string.Empty);
                    }
                    if (!noConsignmentOrdersAllowed)
                    {
                        ddl_DSSubType.Items.Add(new ListItem("Vendita a Cliente ", "A1"));     //TODOD: Resx these
                    }
                    ddl_DSSubType.Items.Add(new ListItem("Uso Personale", "A2"));
                    ddl_DSSubType.Enabled = true;
                    if (!String.IsNullOrEmpty(ShoppingCart.SelectedDSSubType))
                    {
                        ddl_DSSubType.ClearSelection();
                        ListItem item = ddl_DSSubType.Items.FindByValue(ShoppingCart.SelectedDSSubType);
                        if (null != item)
                        {
                            item.Selected        = true;
                            lblOrderTypeVal.Text = item.Text;
                        }
                        //lblOrderTypeVal.Text = ddl_DSSubType.Items.FindByValue(ShoppingCart.SelectedDSSubType).Text;
                        DisplayRemainingValues(ShoppingCart.SelectedDSSubType);
                    }
                    break;

                case "B":
                    ddl_DSSubType.Items.Clear();
                    if (!HideEmptyListItem)
                    {
                        ddl_DSSubType.Items.Add(string.Empty);
                    }
                    if (!noConsignmentOrdersAllowed)
                    {
                        ddl_DSSubType.Items.Add(new ListItem("Vendita a Cliente", "B1"));
                        DisplayRemainingValues(ShoppingCart.SelectedDSSubType);
                    }
                    ddl_DSSubType.Items.Add(new ListItem("Uso Personale", "B2"));
                    ddl_DSSubType.Enabled = true;
                    if (!String.IsNullOrEmpty(ShoppingCart.SelectedDSSubType))
                    {
                        ddl_DSSubType.ClearSelection();
                        ListItem item = ddl_DSSubType.Items.FindByValue(ShoppingCart.SelectedDSSubType);
                        if (null != item)
                        {
                            item.Selected        = true;
                            lblOrderTypeVal.Text = item.Text;
                        }
                        DisplayRemainingValues(ShoppingCart.SelectedDSSubType);
                        trRemainingVal.Visible = true;
                    }
                    break;

                case "C":
                case "D":
                case "D2":
                case "E":
                    if (DSType == "D")
                    {
                        DSType = "D2";
                    }
                    lblOrderType.Visible  = false;
                    lblOrderTypeVal.Text  = "Uso Personale";
                    ddl_DSSubType.Visible = false;
                    ddl_DSSubType.Items.Clear();
                    ddl_DSSubType.Items.Add(new ListItem(DSType, DSType));
                    ddl_DSSubType.SelectedIndex = 0;
                    //ddl_DSSubType.Enabled = false;
                    //ddl_DSSubType.Items.Add(DSType);
                    //ddlDelivery.Enabled = true;
                    break;
                }

                if (ddl_DSSubType.SelectedItem != null)
                {
                    ShoppingCart.SelectedDSSubType = ddl_DSSubType.SelectedItem.Value;
                }

                if (DisplayStatic)
                {
                    if (DSType.Equals("A") || DSType.Equals("B"))
                    {
                        ddl_DSSubType.Visible   = false;
                        lblOrderTypeVal.Visible = true;
                    }
                    else if (DSType.Equals("D") || DSType.Equals("D2") || DSType.Equals("E"))
                    {
                        DisplayRemainingValues(DSType);
                    }
                }
                else
                {
                    if (DSType.Equals("A") || DSType.Equals("B"))
                    {
                        ddl_DSSubType.Visible   = true;
                        lblOrderTypeVal.Visible = false;
                    }
                    else if (DSType.Equals("D") || DSType.Equals("D2") || DSType.Equals("E"))
                    {
                        DisplayRemainingValues(DSType);
                    }
                }
                if (this.FOPEnabled)
                {
                    var limits = PurchasingLimitProvider.GetPurchasingLimits(DistributorID, DSType);
                    if (limits != null && limits.LimitsRestrictionType == LimitsRestrictionType.FOP)
                    {
                        DisplayRemainingValues(DSType);
                    }
                }
            }
        }