コード例 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["isLogin"] == null)
            {
                Response.Redirect("Login.aspx");
            }

            UserAccount user  = (UserAccount)Session["UserAccountObj"];
            OrdersBLL   odbll = new OrdersBLL();

            txtTransactionID.Text = Request.QueryString["transactionid"].ToString();

            Orders od = new Orders();

            od = odbll.DoRetrieveOrderByTransactionId(txtTransactionID.Text);
            CustomerBLL cbll = new CustomerBLL();
            Customer    cust = cbll.DoRetrieveCustomerByID(od.CId);

            txtCustName.Text       = cust.CName;
            txtDeliverAddress.Text = od.DeliverAddress;
            txtOrderStatus.Text    = od.Status;
            txtCustContact.Text    = od.ContactNo;
            txtTotalPayment.Text   = (od.TotalCost + od.DeliveryFee).ToString();

            DataTable        dt   = new DataTable();
            OrderItemListBLL obll = new OrderItemListBLL();

            dt = obll.DoRetrieveCustomerOrderItemByTransactionId(txtTransactionID.Text);

            if (dt != null)
            {
                gv_orderlist.DataSource = dt;
                gv_orderlist.DataBind();
            }
        }
コード例 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            UserAccount user = (UserAccount)Session["UserAccountObj"];

            if (Session["isLogin"] == null)
            {
                Response.Redirect("Login.aspx");
            }

            alertFailure.Visible = false;

            string transactionId = "";

            if (Session["generatedId"] == null)
            {
                lblNoList.Text             = "There is no order list currently. Add items into the order list";
                btnClear.Visible           = false;
                btnCheckout.Visible        = false;
                panelTotalAmt.Visible      = false;
                panelTransactionId.Visible = false;
            }

            else
            {
                transactionId         = Session["generatedId"].ToString();
                lbltransactionId.Text = transactionId.ToString();

                DataTable        dt = new DataTable();
                OrderItemListBLL orderItemListBLL = new OrderItemListBLL();
                dt = orderItemListBLL.DoRetrieveCustomerOrderItem(transactionId, user.UserId);

                loadOrderItemList(dt);
            }
        }
コード例 #3
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";
                    }
                }
            }
        }
コード例 #4
0
        public void DoCheckOutOperation()
        {
            OrderItemListBLL orderItemListBLL = new OrderItemListBLL();
            int result = orderItemListBLL.DoUpdateFoodItemListCheckOut(Session["generatedId"].ToString());

            if (result < 0)
            {
                alertFailure.Visible  = true;
                lblErrorRetrieve.Text = "Unable to update checkout status";
            }
        }
コード例 #5
0
        public void LoadPromoList()
        {
            OrderItemListBLL orderItemListBLL = new OrderItemListBLL();
            int restId = orderItemListBLL.DoRetrieveRestaurantID(lblTransactionId.Text);

            DataTable dt       = new DataTable();
            PromoBLL  promoBLL = new PromoBLL();

            dt = promoBLL.DoRetrieveValidPromoByRestId(restId, DateTime.Now);

            gv_promo.DataSource = dt;
            gv_promo.DataBind();
            gv_promo.Visible = false;
        }
コード例 #6
0
        protected void gv_listOfFood_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            int         rowNo  = int.Parse(e.CommandArgument.ToString());
            GridViewRow row    = gv_listOfFood.Rows[rowNo];
            int         foodId = int.Parse(row.Cells[0].Text);

            if (e.CommandName == "SelectItem")
            {
                UserAccount      user             = (UserAccount)Session["UserAccountObj"];
                OrderItemListBLL orderItemListBLL = new OrderItemListBLL();
                int checkExist = orderItemListBLL.DoCheckIfFoodIDExists(Session["generatedId"].ToString(), foodId);

                if (checkExist > 0)
                {
                    alertFailure.Visible  = true;
                    lblErrorRetrieve.Text = "Food item record has already exist in order list";
                }

                else
                {
                    int orderCount = int.Parse(row.Cells[5].Text);
                    int dailyLimit = int.Parse(row.Cells[6].Text);

                    if (orderCount > dailyLimit)
                    {
                        alertFailure.Visible  = true;
                        lblErrorRetrieve.Text = "This food item is curretly no longer available";
                    }

                    else
                    {
                        int result = orderItemListBLL.DoCreateFoodItemRecord(Session["generatedId"].ToString(), user.UserId, foodId, 1);

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

                        else
                        {
                            alertFailure.Visible  = true;
                            lblErrorRetrieve.Text = "Unable to add new food item record";
                        }
                    }
                }

                gv_listOfFood.Visible = true;
                btnBack.Enabled       = false;
            }
        }
コード例 #7
0
        public void LoadFoodOrderList()
        {
            UserAccount user = (UserAccount)Session["UserAccountObj"];

            DataTable        dt = new DataTable();
            OrderItemListBLL orderItemListBLL = new OrderItemListBLL();

            dt = orderItemListBLL.DoRetrieveCustomerOrderItem(Session["generatedId"].ToString(), user.UserId);

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

                    double currTotal = 0.0;
                    for (int i = 0; i < gv_currFoodItemList.Rows.Count; i++)
                    {
                        currTotal += double.Parse(gv_currFoodItemList.Rows[i].Cells[5].Text.ToString()) *
                                     int.Parse(gv_currFoodItemList.Rows[i].Cells[6].Text.ToString());
                    }

                    lblOrderTotalAmt.Text = currTotal.ToString();

                    if (gv_currFoodItemList.Rows.Count > 5)
                    {
                        lblDeliveryFee.Text = "10.00";
                    }

                    else
                    {
                        lblDeliveryFee.Text = "5.00";
                    }
                }

                else
                {
                    btnCheckout.Visible = false;
                }
            }

            else
            {
                btnCheckout.Visible   = false;
                alertFailure.Visible  = true;
                lblErrorRetrieve.Text = "Unable to retrieve list";
            }
        }
コード例 #8
0
        protected void btnClear_Click(object sender, EventArgs e)
        {
            OrderItemListBLL orderItemListBLL = new OrderItemListBLL();
            int result = orderItemListBLL.DoClearExistingOrderItemList(Session["generatedId"].ToString());

            if (result > 0)
            {
                Response.Redirect("UserViewCurrentOrderItemList.aspx");
            }

            else
            {
                alertFailure.Visible = true;
                lblFailure.Text      = "Unable to clear list";
            }
        }
コード例 #9
0
        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";
            }
        }
コード例 #10
0
ファイル: UserIndex.aspx.cs プロジェクト: jakq/FDSApplication
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["isLogin"] == null)
            {
                Response.Redirect("Login.aspx");
            }

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

            lblUserName.Text = user.Username.ToUpper();

            if (Session["generatedId"] == null)
            {
                OrderItemListBLL orderItemListBLL = new OrderItemListBLL();
                OrderItemList    orderItemList    = orderItemListBLL.DoRetrieveExisitngCustomerFoodItemListByCustId(user.UserId);

                if (orderItemList != null)
                {
                    Session["generatedId"] = orderItemList.TransactionId;
                }
            }

            StatsBLL statsBLL       = new StatsBLL();
            string   recentLocation = statsBLL.DoRetrieveRecentLocation(user.UserId);

            if (recentLocation == "")
            {
                lblRecentLocation.Text  = "You have no recent location";
                btnClearHistory.Enabled = false;
            }

            else
            {
                lblRecentLocation.Text = recentLocation;
            }

            int ordersMade = statsBLL.DoCountCustomersOrder(user.UserId);

            lblOrdersMade.Text = ordersMade.ToString();

            int reviewMade = statsBLL.DoCountCustomersReviews(user.UserId);

            lblReviewsMade.Text = reviewMade.ToString();
        }
コード例 #11
0
        protected void gv_currFoodItemList_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            int         rowNo         = int.Parse(e.CommandArgument.ToString());
            GridViewRow row           = gv_currFoodItemList.Rows[rowNo];
            int         foodId        = int.Parse(row.Cells[2].Text);
            int         orderQuantity = int.Parse(row.Cells[6].Text);

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

            if (e.CommandName == "AddQuantity")
            {
                OrderItemListBLL orderItemListBLL = new OrderItemListBLL();
                int result = orderItemListBLL.DoUpdateFoodItemQuantityByIncreaseCount(Session["generatedId"].ToString(), user.UserId, foodId, orderQuantity);
                if (result > 0)
                {
                    Response.Redirect("UserViewCurrentOrderItemList.aspx");
                }

                else
                {
                    alertFailure.Visible = true;
                    lblFailure.Text      = "Unable to increase count";
                }
            }

            if (e.CommandName == "MinusQuantity")
            {
                OrderItemListBLL orderItemListBLL = new OrderItemListBLL();
                int result = orderItemListBLL.DoUpdateFoodItemQuantityByDecreaseCount(Session["generatedId"].ToString(), user.UserId, foodId, orderQuantity);
                if (result > 0)
                {
                    Response.Redirect("UserViewCurrentOrderItemList.aspx");
                }

                else
                {
                    alertFailure.Visible = true;
                    lblFailure.Text      = "Unable to decrease count";
                }
            }
        }
コード例 #12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["isLogin"] == null)
            {
                Response.Redirect("Login.aspx");
            }

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

            txtOrderId.Text = Request.QueryString["orderid"].ToString();

            Orders    od    = new Orders();
            OrdersBLL odbll = new OrdersBLL();

            od = odbll.DoRetrieveUserOrderDetails(int.Parse(txtOrderId.Text));

            btn_Review.Enabled = false;

            txtTransactionID.Text  = od.TransactionId;
            txtOrderStatus.Text    = od.Status;
            txtOrderCreate.Text    = od.OrderCreated.ToString("dd/MM/yyyy HH:mm");
            txtCustContact.Text    = od.ContactNo;
            txtDeliverAddress.Text = od.DeliverAddress;
            txtTotalPayment.Text   = od.TotalCost.ToString();
            txtDeliverFee.Text     = od.DeliveryFee.ToString();
            txtPaymentType.Text    = od.PaymentType;

            if (od.Status == "Completed")
            {
                btn_Review.Enabled = true;
            }

            if (od.RId == 0)
            {
                panelRiderDetails.Visible = false;
            }

            else
            {
                panelRiderDetails.Visible = true;
                Rider    rider    = new Rider();
                RiderBLL riderBLL = new RiderBLL();
                rider = riderBLL.DoRetrieveRiderByID(od.RId);

                txtRiderID.Text   = od.RId.ToString();
                txtRiderName.Text = rider.RName;

                if (od.ArriveTime == null)
                {
                    txtTimeArrive.Text = "-";
                }

                else
                {
                    txtTimeArrive.Text = od.ArriveTime.ToString("dd/MM/yyyy HH:mm");
                }

                if (od.DepartTime == null)
                {
                    txtTimeDepart.Text = "-";
                }

                else
                {
                    txtTimeDepart.Text = od.DepartTime.ToString("dd/MM/yyyy HH:mm");
                }

                if (od.DeliverTime == null)
                {
                    txtTimeDeliver.Text = "-";
                }

                else
                {
                    txtTimeDeliver.Text = od.DeliverTime.ToString("dd/MM/yyyy HH:mm");
                }
            }

            DataTable        dt   = new DataTable();
            OrderItemListBLL obll = new OrderItemListBLL();

            dt = obll.DoRetrieveCustomerOrderItemByTransactionId(txtTransactionID.Text);

            if (dt != null)
            {
                gv_orderlist.DataSource = dt;
                gv_orderlist.DataBind();
            }

            else
            {
                lblRetrieveError.Text = "Unable to retrive food item list";
            }
        }
コード例 #13
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["isLogin"] == null)
            {
                Response.Redirect("Login.aspx");
            }

            UserAccount user  = (UserAccount)Session["UserAccountObj"];
            OrdersBLL   odbll = new OrdersBLL();

            if (Request.QueryString["transactionid"] != null)
            {
                txtTransactionID.Text = Request.QueryString["transactionid"].ToString();
            }

            else
            {
                //get transactionId that is accepted by riders that is not "Completed"
                if (odbll.DoRetrieveRiderCurrentOrderTransactionId(user.UserId) == null)
                {
                    Response.Redirect("RiderReceiveOrder.aspx");
                }

                else
                {
                    txtTransactionID.Text = odbll.DoRetrieveRiderCurrentOrderTransactionId(user.UserId);
                }
            }

            Orders od = new Orders();

            od = odbll.DoRetrieveOrderByTransactionId(txtTransactionID.Text);
            CustomerBLL cbll = new CustomerBLL();
            Customer    cust = cbll.DoRetrieveCustomerByID(od.CId);

            txtCustName.Text       = cust.CName;
            txtDeliverAddress.Text = od.DeliverAddress;
            txtOrderStatus.Text    = od.Status;
            txtCustContact.Text    = od.ContactNo;
            txtTotalPayment.Text   = (od.TotalCost + od.DeliveryFee).ToString();

            if (od.Status == "Pending Rider")
            {
                btn_function.Text = "Accept";
            }

            else if (od.Status == "Accept")
            {
                btn_function.Text = "Arrived";
            }

            else if (od.Status == "Arrived")
            {
                btn_function.Text = "Delivering";
            }

            else if (od.Status == "Delivering")
            {
                btn_function.Text = "Completed";
            }

            else if (od.Status == "Completed")
            {
                btn_function.Text = "Back";
            }

            DataTable        dt   = new DataTable();
            OrderItemListBLL obll = new OrderItemListBLL();

            dt = obll.DoRetrieveCustomerOrderItemByTransactionId(txtTransactionID.Text);

            string restName;
            string restArea;
            string restAddress;

            if (dt != null)
            {
                gv_orderlist.DataSource = dt;
                gv_orderlist.DataBind();

                restArea    = dt.Rows[0]["restarea"].ToString();
                restName    = dt.Rows[0]["restname"].ToString();
                restAddress = dt.Rows[0]["restaddress"].ToString();

                txtRestArea.Text    = restArea;
                txtRestName.Text    = restName;
                txtRestAddress.Text = restAddress;
            }
        }