Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            #region Error
            errorHeader.Font.Bold      = true;
            errorHeader.Font.Underline = true;
            errorHeader.Font.Size      = 21;
            errorMessage.Font.Size     = 14;
            #endregion

            #region Access Control
            cookie = Request.Cookies["CheveuxUserID"];
            if (cookie == null)
            {
                LoggedOut.Visible         = true;
                viewStylistHeader.Visible = false;
                drpEmpNames.Visible       = false;
                LoggedIn.Visible          = false;
            }
            else if (cookie["UT"] != "R")
            {
                Response.Redirect("../Default.aspx");
            }
            else if (cookie["UT"] == "R")
            {
                LoggedOut.Visible         = false;
                viewStylistHeader.Visible = true;
                drpEmpNames.Visible       = true;
                LoggedIn.Visible          = true;
                sidebar.Visible           = true;
                #endregion

                #region Alerts
                //Check For Low Stock
                checkForLowStock();

                if (alertCount == 0)
                {
                    alertsContainer.Visible = false;
                }
                #endregion

                #region Header
                //date
                lblDate.Text = dayDate;

                //welcom back
                string wB = Request.QueryString["WB"];
                if (wB == "True")
                {
                    Welcome.Text = "Welcome Back " + handler.GetUserDetails(cookie["ID"]).FirstName;
                }
                #endregion

                #region Agenda
                list = handler.BLL_GetEmpNames();
                if (!Page.IsPostBack)
                {
                    try
                    {
                        list = handler.BLL_GetEmpNames();
                        foreach (SP_GetEmpNames emps in list)
                        {
                            //Load employee names into dropdownlist
                            drpEmpNames.DataSource = list;
                            //set the coloumn that will be displayed to the user
                            drpEmpNames.DataTextField = "Name";
                            //set the coloumn that will be used for the valuefield
                            drpEmpNames.DataValueField = "EmployeeID";
                            //bind the data
                            drpEmpNames.DataBind();
                        }
                    }
                    catch (Exception Err)
                    {
                        drpEmpNames.Items.Add("Stylist names unavailable");
                        function.logAnError(Err.ToString());
                    }
                }

                try
                {
                    getAgenda(drpEmpNames.SelectedValue, DateTime.Parse(bookingDate), null, null);

                    if (AgendaTable.Rows.Count == 1)
                    {
                        if (drpEmpNames.Text == "Stylist names unavailable")
                        {
                            AgendaTable.Visible  = false;
                            noBookingsPH.Visible = false;
                        }
                        else
                        {
                            AgendaTable.Visible  = false;
                            noBookingsPH.Visible = true;
                            lblNoBookings.Text   = drpEmpNames.SelectedItem.Text +
                                                   " has not been appointed to any bookings today."
                                                   + "<br/>Refresh for updated stylists appointments.";
                        }
                    }
                    else if (AgendaTable.Rows.Count > 1)
                    {
                        noBookingsPH.Visible = false;
                        AgendaTable.Visible  = true;
                    }
                }
                catch (Exception Err)
                {
                    AgendaTable.Visible   = false;
                    phBookingsErr.Visible = true;
                    errorHeader.Text      = "Error";
                    errorMessage.Text     = "It seems there is a problem retrieving employees bookings.<br/>"
                                            + "Please report problem or try again later.";
                    function.logAnError(Err.ToString());
                }

                string action      = Request.QueryString["Action"];
                string custName    = Request.QueryString["CustomerName"];
                string stylistName = Request.QueryString["StylistName"];

                if (action == "CheckedIn" && custName != null && stylistName != null)
                {
                    phCheckInSuccess.Visible = true;
                    lblSuccess.Text          = custName.ToString() + " has been checked in for their booking with "
                                               + stylistName.ToString();
                }
                #endregion

                loadOutOrders();
            }
        }