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

            UserAccount user     = (UserAccount)Session["UserAccountObj"];
            RiderBLL    riderbll = new RiderBLL();
            Rider       rider    = riderbll.DoRetrieveRiderByID(user.UserId);

            if (rider.IsFullTime == true)
            {
                Response.Redirect("RetrieveLatestMWSWWS.aspx");
            }

            if (!IsPostBack)
            {
                PTWWSBLL  ptwwsbll = new PTWWSBLL();
                DataTable ptwwsdt  = new DataTable();
                ptwwsdt = ptwwsbll.DoRetrieveAllPTWWSByRId(user.UserId);

                for (int i = 0; i < ptwwsdt.Rows.Count; i++)
                {
                    string theValue = ptwwsdt.Rows[i].ItemArray[0].ToString();
                    ddlOption.Items.Add(theValue);
                }
            }

            if (ddlOption.SelectedItem.Text == "Remaining Schedule")
            {
                DataTable        dt       = new DataTable();
                PTDayScheduleBLL ptdsbll  = new PTDayScheduleBLL();
                PTWWSBLL         ptwwsbll = new PTWWSBLL();

                PTWWS latestptwws = ptwwsbll.DoRetrieveLatestPTWWSByRId(user.UserId);
                //currently it is based on today's date. If I want to perform testing, I have to manually change the Datetime to some other dates instead
                //DateTime datetest = new DateTime(2020, 4, 26);
                if (latestptwws != null)
                {
                    dt = ptdsbll.DoRetrieveUnfulfilledPTWWSByPTWWSId(latestptwws.PtwwsId, DateTime.Now);
                }

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

                else
                {
                    lblNotWorking.Text = "Unable to retrieve list of schedule";
                }
            }

            else if (ddlOption.SelectedItem.Text != "Select Schedule to View")
            {
                DataTable        dt      = new DataTable();
                PTDayScheduleBLL ptdsbll = new PTDayScheduleBLL();
                //dt = wwsbll.DoRetrieveAllWWSByMWSId(latestmws.MwsId);
                //string value = "4/26/2020";
                //DateTime datetest = DateTime.Parse(value);
                DateTime datetest = new DateTime(2020, 4, 26);
                dt = ptdsbll.DoRetrievePTWWSByPTWWSId(Convert.ToInt32(ddlOption.SelectedValue.ToString()));

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

                else
                {
                    lblNotWorking.Text = "Unable to retrieve list of scheudle";
                }
            }
        }
        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();
                }
            }
        }