コード例 #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();

            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;
            }
        }
コード例 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["isLogin"] == null)
            {
                Response.Redirect("Login.aspx");
            }

            UserAccount user = (UserAccount)Session["UserAccountObj"];
            OrdersBLL   obll = new OrdersBLL();
            String      riderCurrentTrans;

            riderCurrentTrans = obll.DoRetrieveRiderCurrentOrderTransactionId(user.UserId);
            RiderBLL riderbll = new RiderBLL();
            Rider    rider    = riderbll.DoRetrieveRiderByID(user.UserId);

            if (riderCurrentTrans != null)
            {
                lblNotWorking.Text   = "You have a current delivery ongoing!";
                gv_orderlist.Visible = false;
            }

            else if (rider.IsFullTime == true)
            {
                WWSBLL   wwsbll    = new WWSBLL();
                MWSBLL   mwsbll    = new MWSBLL();
                MWS      mws       = mwsbll.DoRetrieveLatestMWSByRId(user.UserId);
                DateTime timetest  = new DateTime(2020, 4, 13, 16, 30, 00);
                int      isWorking = 0;

                if (mws != null)
                {
                    //replace with timetest to test. Modify timetest according to the schedule time.
                    isWorking = wwsbll.doIsRiderCurrentlyWorking(mws.MwsId, DateTime.Now);
                    //isWorking = wwsbll.doIsRiderCurrentlyWorking(mws.MwsId, timetest);
                }

                if (isWorking == 0)
                {
                    lblNotWorking.Text   = "Please refer to your schedule again!";
                    gv_orderlist.Visible = false;
                }
            }

            else if (rider.IsFullTime == false)
            {
                PTWWSBLL         ptwwsbll = new PTWWSBLL();
                PTDayScheduleBLL ptdsbll  = new PTDayScheduleBLL();

                DateTime timetest  = new DateTime(2020, 4, 13, 11, 00, 00);
                int      isWorking = 0;

                //replace with timetest to test. Modify timetest according to the schedule time.
                isWorking = ptdsbll.doIsPartTimeRiderCurrentlyWorking(user.UserId, DateTime.Now);

                if (isWorking == 0)
                {
                    lblNotWorking.Text   = "Please refer to your schedule again!";
                    gv_orderlist.Visible = false;
                }
            }

            if (!IsPostBack)
            {
                DataTable dt = new DataTable();
                dt = obll.DoRetrieveNoRiderAllCustomerOrder();

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