// fill the controls with data
 private void PopulateControls()
 {
     // get the items in the shopping cart
     System.Data.DataTable dt = ShoppingCartDao.GetItems();
     // if the shopping cart is empty...
     if (dt.Rows.Count == 0)
     {
         cartSummaryLabel.Text = "Вашата количка е празна.";
         totalAmountLabel.Text = String.Format("{0:c}", 0);
         viewCartLink.Visible  = false;
         list.Visible          = false;
     }
     else
     // if the shopping cart is not empty...
     {
         // populate the list with the shopping cart contents
         list.Visible    = true;
         list.DataSource = dt;
         list.DataBind();
         // set up controls
         cartSummaryLabel.Text = "Вашата количка ";
         viewCartLink.Visible  = true;
         // display the total amount
         decimal amount = ShoppingCartDao.GetTotalAmount();
         totalAmountLabel.Text = String.Format("{0:c}", amount);
     }
 }
    // fill shopping cart controls with data
    private void PopulateControls()
    {
        // Display product recommendations
        recommendations.LoadCartRecommendations();

        // get the items in the shopping cart
        DataTable dt = ShoppingCartDao.GetItems();

        // if the shopping cart is empty...
        if (dt.Rows.Count == 0)
        {
            titleLabel.Text        = "Вашата количка е празна!";
            grid.Visible           = false;
            updateButton.Enabled   = false;
            checkoutButton.Enabled = false;
            totalAmountLabel.Text  = String.Format("{0:c}", 0);
        }
        else
        // if the shopping cart is not empty...
        {
            // populate the list with the shopping cart contents
            grid.DataSource = dt;
            grid.DataBind();
            // setup controls
            titleLabel.Text        = "Това са продуктите във вашата кошница:";
            grid.Visible           = true;
            updateButton.Enabled   = true;
            checkoutButton.Enabled = true;
            // display the total amount
            decimal amount = ShoppingCartDao.GetTotalAmount();
            totalAmountLabel.Text = String.Format("{0:c}", amount);
        }
    }
Beispiel #3
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;
        }
    }