Exemplo n.º 1
0
        protected void btnAddCC_Click(object sender, EventArgs e)
        {
            if (txtCCNum.Text.Length != 16)
            {
                lblCCNumMsg.Text = "Credit Card Number must be 16 characters long ";
            }

            if (txtCCV.Text.Length != 3)
            {
                lblCCVMsg.Text = "CCV must be 3 characters long";
            }

            if (txtCCExpiry.Text.Length != 4)
            {
                lblCCNumMsg.Text = "Credit Card Expiry must be  4 characters long";
            }

            if (txtCCNum.Text.Length == 16 && txtCCV.Text.Length == 3 && txtCCExpiry.Text.Length == 4)
            {
                CreditCardBLL creditCardBLL = new CreditCardBLL();
                int           checkCCard    = creditCardBLL.DoCheckCreditCardExists(txtCCNum.Text);

                if (checkCCard > 0)
                {
                    alertFailure.Visible = true;
                    lblFailure.Text      = "Credit Card Number exists. Please use another credit card";
                }

                else
                {
                    UserAccount user        = (UserAccount)Session["UserAccountObj"];
                    CustomerBLL customerBLL = new CustomerBLL();
                    Customer    customer    = customerBLL.DoRetrieveCustomerByID(user.UserId);

                    int result = creditCardBLL.DoCreateCreditCard(customer.CId, txtCCNum.Text, txtCCV.Text, txtCCExpiry.Text);

                    if (result > 0)
                    {
                        alertSuccess.Visible = true;

                        if (lblNoCreditCard.Text.Length > 0)
                        {
                            lblNoCreditCard.Text = "";
                        }
                    }

                    else
                    {
                        alertFailure.Visible = true;
                        lblFailure.Text      = "Unable to create credit card record";
                    }

                    //Refresh page
                    DataTable dt = new DataTable();
                    dt = creditCardBLL.DoRetrieveAllCustomerCreditCard(customer.CId);
                    gv_creditCard.DataSource = dt;
                    gv_creditCard.DataBind();
                }
            }
        }
Exemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["isLogin"] == null)
            {
                Response.Redirect("Login.aspx");
            }

            panelCreateCreditCard.Visible = false;
            alertSuccess.Visible          = false;
            alertFailure.Visible          = false;

            UserAccount user = (UserAccount)Session["UserAccountObj"];

            if (!IsPostBack)
            {
                CustomerBLL customerBLL = new CustomerBLL();
                Customer    customer    = customerBLL.DoRetrieveCustomerByID(user.UserId);

                if (customer != null)
                {
                    DataTable     dt            = new DataTable();
                    CreditCardBLL creditCardBLL = new CreditCardBLL();
                    dt = creditCardBLL.DoRetrieveAllCustomerCreditCard(customer.CId);

                    if (dt != null)
                    {
                        if (dt.Rows.Count > 0)
                        {
                            gv_creditCard.DataSource = dt;
                            gv_creditCard.DataBind();
                        }

                        else
                        {
                            lblNoCreditCard.Text = "There is currently no credit card, you can add a credit card";
                        }
                    }

                    else
                    {
                        alertFailure.Visible = true;
                        lblFailure.Text      = "Unable to retrieve credit card records";
                    }
                }

                else
                {
                    alertFailure.Visible = true;
                    lblFailure.Text      = "Unable to retrieve customer account";
                }
            }
        }
Exemplo n.º 3
0
        protected void ddlPaymentMode_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (ddlPaymentMode.SelectedValue == "Card")
            {
                panelCard.Visible = true;

                UserAccount user = (UserAccount)Session["UserAccountObj"];

                DataTable     dt            = new DataTable();
                CreditCardBLL creditCardBLL = new CreditCardBLL();
                dt = creditCardBLL.DoRetrieveAllCustomerCreditCard(user.UserId);

                ddlCardNum.DataSource     = dt;
                ddlCardNum.DataTextField  = "ccNum";
                ddlCardNum.DataValueField = "ccNum";
                ddlCardNum.DataBind();
            }
        }
Exemplo n.º 4
0
        protected void gv_promo_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            int         rowNo   = int.Parse(e.CommandArgument.ToString());
            GridViewRow row     = gv_promo.Rows[rowNo];
            int         promoId = int.Parse(row.Cells[0].Text);

            if (e.CommandName == "Select")
            {
                txtPromoCode.Text = row.Cells[6].Text;
                double totalAmt = double.Parse(lblOrderTotalAmt.Text);

                if (row.Cells[2].Text.Equals("Flat"))
                {
                    totalAmt = totalAmt - double.Parse(row.Cells[3].Text);
                }

                else
                {
                    totalAmt = totalAmt * (100.0 - double.Parse(row.Cells[3].Text)) / 100.0;
                }

                lblOrderTotalAmt.Text = totalAmt.ToString();

                if (ddlPaymentMode.SelectedValue == "Card")
                {
                    panelCard.Visible = true;

                    UserAccount user = (UserAccount)Session["UserAccountObj"];

                    DataTable     dt            = new DataTable();
                    CreditCardBLL creditCardBLL = new CreditCardBLL();
                    dt = creditCardBLL.DoRetrieveAllCustomerCreditCard(user.UserId);

                    ddlCardNum.DataSource     = dt;
                    ddlCardNum.DataTextField  = "ccNum";
                    ddlCardNum.DataValueField = "ccNum";
                    ddlCardNum.DataBind();
                }
            }
        }