Example #1
0
        protected void btnCheckout_Click(object sender, EventArgs e)
        {
            string paymentMode;
            string cardNum;
            string hasPaid;

            DateTime orderCreated = DateTime.Now;

            if (txtDeliverAddress.Text.Length <= 0)
            {
                lblDeliverAddressMsg.Text = "Delivery Address cannot be blank";
            }

            if (txtContactNo.Text.Length <= 0)
            {
                lblContactNoMsg.Text = "Contact Number cannot be blank";
            }

            if (ddlPaymentMode.SelectedValue == "Cash")
            {
                paymentMode = ddlPaymentMode.SelectedValue;
                cardNum     = "0";
                hasPaid     = "NP";
            }

            else
            {
                paymentMode = ddlPaymentMode.SelectedValue;
                cardNum     = ddlCardNum.SelectedValue;
                hasPaid     = "P";
            }

            if (txtDeliverAddress.Text.Length > 0 && txtContactNo.Text.Length > 0)
            {
                DoCheckOutOperation();         //Change OrderItemList checkout status
                DoUpdateOrderCountOperation(); //Increase the ordercounter in FoodItem

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

                OrdersBLL ordersBLL = new OrdersBLL();
                int       result    = ordersBLL.DoCreateOrder(user.UserId, Session["generatedId"].ToString(), paymentMode, cardNum, txtDeliverAddress.Text,
                                                              txtContactNo.Text, double.Parse(lblDeliveryFee.Text), double.Parse(lblOrderTotalAmt.Text), orderCreated, hasPaid, "Pending Rider");

                if (result > 0)
                {
                    alertSuccess.Visible = true;
                    btnCheckout.Enabled  = false;
                    btnBack.Enabled      = false;
                    UpdateRewardPointRecentLocation(user);
                }

                else
                {
                    alertFailure.Visible  = true;
                    lblErrorRetrieve.Text = "Unable to create new order record";
                }
            }
        }