Пример #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["isLogin"] == null)
            {
                Response.Redirect("Login.aspx");
            }

            gv_listofRestaurant.Visible = false;
            gv_listOfFood.Visible       = false;
            btnBack.Visible             = false;
            alertFailure.Visible        = false;
            alertSuccess.Visible        = false;

            OrderItemListBLL orderItemListBLL = new OrderItemListBLL();

            if (Session["generatedId"] == null)
            {
                string transactionId = GenerateRandomString();
                int    result        = orderItemListBLL.DoCheckIfTransactionIDExists(transactionId);

                while (result > 0)
                {
                    transactionId = GenerateRandomString();
                    result        = orderItemListBLL.DoCheckIfTransactionIDExists(transactionId);
                }

                Session["generatedId"] = transactionId;
            }

            else
            {
                Restaurant restaurant = orderItemListBLL.DoCheckOrderLineItemForExistingRestaurant((Session["generatedId"].ToString()));
                if (restaurant != null)
                {
                    btnSearch.Enabled = false;
                    btnBack.Enabled   = false;

                    FoodItemBLL foodItemBLL = new FoodItemBLL();
                    DataTable   dt          = new DataTable();
                    dt = foodItemBLL.DoRetrieveAllFoodItemByRestId(restaurant.RestId);

                    if (dt != null)
                    {
                        lblRestName.Text         = restaurant.RestName;
                        lblRestAddress.Text      = restaurant.RestAddress;
                        gv_listOfFood.DataSource = dt;
                        gv_listOfFood.DataBind();
                        gv_listOfFood.Visible = true;
                    }

                    else
                    {
                        alertFailure.Visible  = true;
                        lblErrorRetrieve.Text = "Error in retrieving food item list";
                    }
                }
            }
        }
        protected void btnCheckout_Click(object sender, EventArgs e)
        {
            OrderItemListBLL orderItemListBLL = new OrderItemListBLL();
            Restaurant       restaurant       = orderItemListBLL.DoCheckOrderLineItemForExistingRestaurant(Session["generatedId"].ToString());

            double totalAmt = double.Parse(lblTotalAmt.Text);

            if (totalAmt >= restaurant.MinAmnt)
            {
                Response.Redirect("UserCheckout.aspx");
            }

            else
            {
                alertFailure.Visible = true;
                lblFailure.Text      = "Your order does not exceed the minimum amount";
            }
        }