protected void btn_Confirm_WWS_Click(object sender, EventArgs e)
        {
            //create a MWS
            //perform a check such that the MWS cannot be created if there is
            //an existing wws that is within the mws
            //create individual wws

            UserAccount user   = (UserAccount)Session["UserAccountObj"];
            MWSBLL      mwsbll = new MWSBLL();
            WWSBLL      wwsbll = new WWSBLL();

            MWS mws = mwsbll.DoRetrieveLatestMWSByRId(user.UserId);

            if (mws != null && ddlWorkDay.SelectedIndex != 0)
            {
                WWS wws = wwsbll.DoRetrieveLatestWWSByMwsId(mws.MwsId);
                if (DateTime.Parse(txtStartDate.Text) <= wws.WwsDate)
                {
                    lblNoSelection.Text = "You have a current Monthly work schedule in the system. Please retry once the monthly work schedule have been completed!";
                }
                else if (ddlShift.SelectedItem.Value == "Select" || ddlWorkDay.SelectedItem.Value == "Select")
                {
                    lblNoSelection.Text = "Please select a shift slot and work day!";
                }
                else
                {
                    createWWSBasedOnDateRange(DateTime.Parse(txtStartDate.Text), DateTime.Parse(txtEndDate.Text), Convert.ToInt32(ddlShift.SelectedValue), Convert.ToInt32(ddlWorkDay.SelectedValue));
                    lblSuccess.Text = "Successfully created a schedule.";
                }
            }
            else
            {
                if (ddlShift.SelectedItem.Value == "Select" || ddlWorkDay.SelectedItem.Value == "Select")
                {
                    lblNoSelection.Text = "Please select a shift slot and work day!";
                }
                else
                {
                    createWWSBasedOnDateRange(DateTime.Parse(txtStartDate.Text), DateTime.Parse(txtEndDate.Text), Convert.ToInt32(ddlShift.SelectedValue), Convert.ToInt32(ddlWorkDay.SelectedValue));
                    lblSuccess.Text = "Successfully created a schedule.";
                }
            }
        }
        protected void createWWSBasedOnDateRange(DateTime startDate, DateTime endDate, int shiftType, int shiftDay)
        {
            UserAccount user     = (UserAccount)Session["UserAccountObj"];
            MWSBLL      mwsbll   = new MWSBLL();
            int         result   = mwsbll.DoCreateMWS(user.UserId);
            WWSBLL      wwsbll   = new WWSBLL();
            MWS         mws      = mwsbll.DoRetrieveLatestMWSByRId(user.UserId);
            DateTime    workDate = DateTime.Parse(txtStartDate.Text);

            while (startDate != endDate)
            {
                if (shiftType == 1)
                {
                    wwsbll.DoCreateWWS(mws.MwsId, startDate, startDate.AddHours(10), startDate.AddHours(14), startDate.AddHours(15), startDate.AddHours(19));
                }

                else if (shiftType == 2)
                {
                    wwsbll.DoCreateWWS(mws.MwsId, startDate, startDate.AddHours(11), startDate.AddHours(15), startDate.AddHours(16), startDate.AddHours(20));
                }

                else if (shiftType == 3)
                {
                    wwsbll.DoCreateWWS(mws.MwsId, startDate, startDate.AddHours(12), startDate.AddHours(16), startDate.AddHours(17), startDate.AddHours(21));
                }

                else if (shiftType == 4)
                {
                    wwsbll.DoCreateWWS(mws.MwsId, startDate, startDate.AddHours(13), startDate.AddHours(17), startDate.AddHours(18), startDate.AddHours(22));
                }

                startDate = startDate.AddDays(1);

                if (shiftDay == 1)
                {
                    if (startDate.DayOfWeek == DayOfWeek.Saturday)
                    {
                        startDate = startDate.AddDays(2);
                    }

                    else if (startDate.DayOfWeek == DayOfWeek.Sunday)
                    {
                        startDate = startDate.AddDays(1);
                    }
                }

                else if (shiftDay == 2)
                {
                    if (startDate.DayOfWeek == DayOfWeek.Sunday)
                    {
                        startDate = startDate.AddDays(2);
                    }

                    else if (startDate.DayOfWeek == DayOfWeek.Monday)
                    {
                        startDate = startDate.AddDays(1);
                    }
                }

                else if (shiftDay == 3)
                {
                    if (startDate.DayOfWeek == DayOfWeek.Monday)
                    {
                        startDate = startDate.AddDays(2);
                    }

                    else if (startDate.DayOfWeek == DayOfWeek.Tuesday)
                    {
                        startDate = startDate.AddDays(1);
                    }
                }

                else if (shiftDay == 4)
                {
                    if (startDate.DayOfWeek == DayOfWeek.Tuesday)
                    {
                        startDate = startDate.AddDays(2);
                    }

                    else if (startDate.DayOfWeek == DayOfWeek.Wednesday)
                    {
                        startDate = startDate.AddDays(1);
                    }
                }

                else if (shiftDay == 5)
                {
                    if (startDate.DayOfWeek == DayOfWeek.Wednesday)
                    {
                        startDate = startDate.AddDays(2);
                    }

                    else if (startDate.DayOfWeek == DayOfWeek.Thursday)
                    {
                        startDate = startDate.AddDays(1);
                    }
                }

                else if (shiftDay == 6)
                {
                    if (startDate.DayOfWeek == DayOfWeek.Thursday)
                    {
                        startDate = startDate.AddDays(2);
                    }

                    else if (startDate.DayOfWeek == DayOfWeek.Friday)
                    {
                        startDate = startDate.AddDays(1);
                    }
                }

                else if (shiftDay == 7)
                {
                    if (startDate.DayOfWeek == DayOfWeek.Friday)
                    {
                        startDate = startDate.AddDays(2);
                    }

                    else if (startDate.DayOfWeek == DayOfWeek.Saturday)
                    {
                        startDate = startDate.AddDays(1);
                    }
                }
            }
        }
        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);

            alertFailure.Visible = false;
            gv_schedule.Visible  = false;

            if (rider.IsFullTime == false)
            {
                Response.Redirect("RetrieveLatestPTWWS.aspx");
            }

            if (!IsPostBack)
            {
                MWSBLL    mwsbll2 = new MWSBLL();
                DataTable mwsdt   = new DataTable();
                mwsdt = mwsbll2.DoRetrieveAllMWSByRId(user.UserId);
                for (int i = 0; i < mwsdt.Rows.Count; i++)
                {
                    string theValue = mwsdt.Rows[i].ItemArray[0].ToString();
                    ddlOption.Items.Add(theValue);
                }
            }

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

                WWSBLL wwsbll    = new WWSBLL();
                MWSBLL mwsbll    = new MWSBLL();
                MWS    latestmws = mwsbll.DoRetrieveLatestMWSByRId(user.UserId);
                //dt = wwsbll.DoRetrieveAllWWSByMWSId(latestmws.MwsId);
                //string value = "4/26/2020";
                //DateTime datetest = DateTime.Parse(value);
                //DateTime datetest = new DateTime(2020, 4, 26);

                //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
                if (latestmws != null)
                {
                    dt = wwsbll.DoRetrieveUnfulfilledWWSByMWSId(latestmws.MwsId, DateTime.Now);

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


                    else
                    {
                        alertFailure.Visible = true;
                        lblAlertMsg.Text     = "Error in retrieving current schedule list";
                    }
                }

                else
                {
                    alertFailure.Visible = true;
                    lblAlertMsg.Text     = "Error in retrieving schedule list";
                }
            }

            else if (ddlOption.SelectedItem.Text != "Select Schedule to View")
            {
                DataTable dt     = new DataTable();
                WWSBLL    wwsbll = new WWSBLL();
                //dt = wwsbll.DoRetrieveAllWWSByMWSId(latestmws.MwsId);
                //string value = "4/26/2020";
                //DateTime datetest = DateTime.Parse(value);

                DateTime datetest = new DateTime(2020, 4, 26);
                dt = wwsbll.DoRetrieveAllWWSByMWSId(Convert.ToInt32(ddlOption.SelectedValue));
                if (dt != null)
                {
                    gv_schedule.DataSource = dt;
                    gv_schedule.DataBind();
                    gv_schedule.Visible = true;
                }

                else
                {
                    alertFailure.Visible = true;
                    lblAlertMsg.Text     = "Error in retrieving list";
                }
            }
        }
        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();
                }
            }
        }