// fill controls with data
    private void PopulateControls()
    {
        // get the items in the shopping cart
        DataTable dt = ShoppingCartAccess.GetItems();

        // populate the list with the shopping cart contents
        grid.DataSource = dt;
        grid.DataBind();
        // setup controls
        titleLabel.Text =
            "These are the products in your shopping cart:";
        grid.Visible = true;
        // display the total amount
        decimal amount = ShoppingCartAccess.GetTotalAmount();

        totalAmountLabel.Text = String.Format("{0:c}", amount);

        // check customer details
        bool addressOK = true;
        bool cardOK    = true;

        if (Profile.Address1 + Profile.Address2 == "" ||
            Profile.ShippingRegion == "" ||
            Profile.ShippingRegion == "1" ||
            Profile.Country == "")
        {
            addressOK = false;
        }
        if (Profile.CreditCard == "")
        {
            cardOK = false;
        }

        // report / hide place order button / shipping selection
        if (!addressOK)
        {
            if (!cardOK)
            {
                InfoLabel.Text =
                    "You must provide a valid address and credit card "
                    + "before placing your order.";
            }
            else
            {
                InfoLabel.Text =
                    "You must provide a valid address before placing your "
                    + "order.";
            }
        }
        else if (!cardOK)
        {
            InfoLabel.Text = "You must provide a credit card before "
                             + "placing your order.";
        }
        else
        {
            InfoLabel.Text = "Please confirm that the above details are "
                             + "correct before proceeding.";
        }
        placeOrderButton.Visible  = addressOK && cardOK;
        shippingSelection.Visible = addressOK && cardOK;

        // Populate shipping selection
        if (addressOK && cardOK)
        {
            int shippingRegionId = int.Parse(Profile.ShippingRegion);
            List <ShippingInfo> shippingInfoData = CommerceLibAccess.GetShippingInfo(shippingRegionId);
            foreach (ShippingInfo shippingInfo in shippingInfoData)
            {
                shippingSelection.Items.Add(new ListItem(shippingInfo.ShippingType, shippingInfo.ShippingID.ToString()));
            }
            shippingSelection.SelectedIndex = 0;
        }
    }
Ejemplo n.º 2
0
    // fill controls with data
    private void PopulateControls()
    {
        // get the items in the shopping cart
        DataTable dt = ShoppingCartDao.GetItems();

        // populate the list with the shopping cart contents
        grid.DataSource = dt;
        grid.DataBind();
        grid.Visible = true;
        // display the total amount
        decimal amount = ShoppingCartDao.GetTotalAmount();

        totalAmountLabel.Text = String.Format("{0:c}", amount);
        // check customer details
        bool addressOK = true;
        bool cardOK    = true;

        if (Profile.Address1 + Profile.Address2 == "" ||
            Profile.ShippingRegion == "" ||
            Profile.ShippingRegion == "Please Select" ||
            Profile.Country == "")
        {
            addressOK = false;
        }
        if (Profile.CreditCard == "")
        {
            cardOK = false;
        }
        // report/hide place order button
        if (!addressOK)
        {
            if (!cardOK)
            {
                InfoLabel.Text =
                    "You must provide a valid address and credit card "
                    + "before placing your order.";
            }
            else
            {
                InfoLabel.Text =
                    "You must provide a valid address before placing your "
                    + "order.";
            }
        }
        else if (!cardOK)
        {
            InfoLabel.Text = "You must provide a credit card before "
                             + "placing your order.";
        }
        else
        {
            InfoLabel.Text = "Моля, преди да продължите напред, подвърдете, че горепосочените данни са коректни.";
        }
        placeOrderButton.Visible  = addressOK && cardOK;
        shippingSelection.Visible = addressOK && cardOK;
        // Populate shipping selection
        if (addressOK && cardOK)
        {
            int             shippingRegionId = int.Parse(Profile.ShippingRegion);
            List <Shipping> shippingInfoData = CommerceLibAccess.GetShippingInfo(shippingRegionId);
            foreach (Shipping shipping in shippingInfoData)
            {
                ListItem item = new ListItem(shipping.ShippingType, shipping.Id.ToString());
                shippingSelection.Items.Add(item);
            }
            shippingSelection.SelectedIndex = 0;
        }
    }
Ejemplo n.º 3
0
        private void PopulateControls()
        {
            // get the items in the shopping cart
            DataTable dt = ShoppingCartAccess.GetItems();

            // populate the list with the shopping cart contents
            grid.DataSource = dt;
            grid.DataBind();
            grid.Visible = true;
            // display the total amount
            decimal amount = ShoppingCartAccess.GetTotalAmount();

            totalAmountLabel.Text = String.Format("{0:c}", amount);
            // check customer details
            bool addressOK = true;
            bool cardOK    = true;

            ProfileBase Profile = HttpContext.Current.Profile;

            if ((string)Profile["Address1"] + (string)Profile["Address2"] == "" ||
                (string)Profile["ShippingRegion"] == "" ||
                (string)Profile["ShippingRegion"] == "Моля изберете" ||
                (string)Profile["Country"] == "")
            {
                addressOK = false;
            }
            if ((string)Profile["CreditCard"] == "")
            {
                cardOK = false;
            }
            // report/hide place order button
            if (!addressOK)
            {
                if (!cardOK)
                {
                    InfoLabel.Text =
                        "Трябва да въведете валид адрес и дебитна карта.";
                }
                else
                {
                    InfoLabel.Text = "Трябва да въведете валиден адрес";
                }
            }
            else if (!cardOK)
            {
                InfoLabel.Text = "Трябва да въведете номер на дебитна карта.";
            }
            else
            {
                InfoLabel.Text = "Моля потвърдете, че детайлите по-горе са вярни преди извършване на поръчката.";
            }
            placeOrderButton.Visible  = addressOK && cardOK;
            shippingSelection.Visible = addressOK && cardOK;
            // Populate shipping selection
            if (addressOK && cardOK)
            {
                int shippingRegionId = int.Parse((string)Profile["ShippingRegion"]);
                List <ShippingInfo> shippingInfoData =
                    CommerceLibAccess.GetShippingInfo(shippingRegionId);
                foreach (ShippingInfo shippingInfo in shippingInfoData)
                {
                    shippingSelection.Items.Add(
                        new ListItem(shippingInfo.ShippingType,
                                     shippingInfo.ShippingID.ToString()));
                }
                shippingSelection.SelectedIndex = 0;
            }
        }
Ejemplo n.º 4
0
    // fill controls with data
    private void PopulateControls()
    {
        // get the items in the shopping cart
        DataTable dt = ShoppingCartAccess.GetItems();

        // populate the list with the shopping cart contents
        grid.DataSource = dt;
        grid.DataBind();
        grid.Visible = true;
        // display the total amount
        decimal amount = ShoppingCartAccess.GetTotalAmount();

        totalAmountLabel.Text = String.Format("{0:c}", amount);

        // check customer details
        bool addressOK = true;
        bool cardOK    = true;

        if (Profile.Address1 + Profile.Address2 == "" ||
            Profile.ShippingRegion == "" ||
            Profile.ShippingRegion == "Моля изберете" ||
            Profile.Country == "")
        {
            addressOK = false;
        }
        if (Profile.CreditCard == "")
        {
            cardOK = false;
        }

        // report / hide place order button
        if (!addressOK)
        {
            if (!cardOK) // http://localhost:49571/BalloonShop/Default.aspx
            {
                InfoLabel.Text =
                    "Трябва да напишете валиден адрес и кредитна карта "
                    + "преди да пуснете резервацията.";
            }
            else
            {
                InfoLabel.Text =
                    "Трябва да напишете валиден адрес преди да пуснете "
                    + "резервацията.";
            }
        }
        else if (!cardOK)
        {
            InfoLabel.Text = "Трябва да предоставите кредитна карта "
                             + "преди да пуснете резервацията.";
        }
        else
        {
            InfoLabel.Text =
                "Моля потвърдете че данните са "
                + "валидни преди да продължите.";
        }
        placeOrderButton.Visible  = addressOK && cardOK;
        shippingSelection.Visible = addressOK && cardOK;

        // Populate shipping selection
        if (addressOK && cardOK)
        {
            int shippingRegionId = int.Parse(Profile.ShippingRegion);
            List <ShippingInfo> shippingInfoData =
                CommerceLibAccess.GetShippingInfo(shippingRegionId);
            foreach (ShippingInfo shippingInfo in shippingInfoData)
            {
                shippingSelection.Items.Add(
                    new ListItem(shippingInfo.ShippingType,
                                 shippingInfo.ShippingID.ToString()));
            }
            shippingSelection.SelectedIndex = 0;
        }
    }