示例#1
0
        public void getAgenda(string id, DateTime bookingDate, string sortBy, string sortDir)
        {
            Button btnCheckin;

            try
            {
                agenda = handler.BLL_GetEmpAgenda(id, bookingDate, sortBy, sortDir);

                AgendaTable.CssClass = "table table-light table-hover";

                //create row for the table
                TableRow row = new TableRow();
                row.Height = 50;

                //add row to the table
                AgendaTable.Rows.Add(row);

                /*
                 * create the cells for the row
                 * and their names
                 * the cells being created are for the first row of the table
                 * and their names are the column names
                 * Each cell is added to the table row
                 * .Rows[0] => refers to the first row of the table
                 * */
                TableCell startTime = new TableCell();
                startTime.Text      = "Start Time";
                startTime.Width     = 200;
                startTime.Font.Bold = true;
                AgendaTable.Rows[0].Cells.Add(startTime);

                TableCell endTime = new TableCell();
                endTime.Text      = "End Time";
                endTime.Width     = 200;
                endTime.Font.Bold = true;
                AgendaTable.Rows[0].Cells.Add(endTime);

                TableCell cust = new TableCell();
                cust.Text      = "Customer";
                cust.Width     = 300;
                cust.Font.Bold = true;
                AgendaTable.Rows[0].Cells.Add(cust);

                TableCell service = new TableCell();
                service.Text      = "Service";
                service.Width     = 300;
                service.Font.Bold = true;
                AgendaTable.Rows[0].Cells.Add(service);

                TableCell arrived = new TableCell();
                arrived.Text      = "Arrived";
                arrived.Width     = 100;
                arrived.Font.Bold = true;
                AgendaTable.Rows[0].Cells.Add(arrived);

                TableCell edit = new TableCell();
                edit.Width = 200;
                AgendaTable.Rows[0].Cells.Add(edit);

                TableCell checkin = new TableCell();
                checkin.Width = 200;
                AgendaTable.Rows[0].Cells.Add(checkin);

                //integer that will be incremented in the foreach loop to access the new row for every iteration of the foreach
                int i = 1;
                foreach (SP_GetEmpAgenda a in agenda)
                {
                    TableRow r = new TableRow();
                    AgendaTable.Rows.Add(r);

                    getTimeCustomerServices(a.BookingID, a.PrimaryID, i, a);

                    TableCell present = new TableCell();
                    present.Width = 100;
                    present.Text  = function.GetFullArrivedStatus(a.Arrived.ToString()[0]);
                    AgendaTable.Rows[i].Cells.Add(present);

                    //check in BTN
                    if (function.GetFullArrivedStatus(a.Arrived.ToString()[0]) == "No")
                    {
                        TableCell buttonCell = new TableCell();
                        if ((a.StartTime.TimeOfDay >= DateTime.Now.TimeOfDay))
                        {
                            //edit
                            buttonCell.Text =
                                "<button type = 'button' class='btn btn-default'>" +
                                "<a href = '../ViewBooking.aspx?BookingID=" + a.BookingID.ToString().Replace(" ", string.Empty) +
                                "&Action=Edit'>Edit Booking</a></button>";
                            AgendaTable.Rows[i].Cells.Add(buttonCell);
                        }

                        //create cell that will be populated by the button and add to row.. cell index: 6
                        buttonCell        = new TableCell();
                        buttonCell.Width  = 200;
                        buttonCell.Height = 50;

                        //create button
                        btnCheckin          = new Button();
                        btnCheckin.Text     = "Check-in";
                        btnCheckin.CssClass = "btn btn-primary";
                        btnCheckin.Click   += (ss, ee) => {
                            /*
                             * Check-in code here
                             * After clicking the button arrived should change to Y
                             * and the button text should change to Check-out
                             * and code should cater for the change as the stored procedure to check out and generate invoice
                             * needs to be called
                             */
                            try
                            {
                                checkIn = new BOOKING();

                                checkIn.BookingID = a.BookingID.ToString();

                                if (handler.BLL_CheckIn(checkIn))
                                {
                                    //if BLL_CheckIn successful and arrival status changed show user and refresh the page
                                    //Response.Write("<script>alert('Customer has been checked-in.');location.reload();</script>");
                                    Response.Redirect("../Receptionist/Receptionist.aspx?Action=CheckedIn&CustomerName=" +
                                                      a.CustomerFName.ToString().Replace(" ", string.Empty)
                                                      + "&StylistName=" + drpEmpNames.SelectedItem.Text);
                                }
                                else
                                {
                                    //if BLL_CheckIn unsuccessful and arrival status was not changed tell the user to try again or report to admin
                                    phCheckInErr.Visible = true;
                                    lblCheckinErr.Text   = "We are unable to check-in customer.<br/>"
                                                           + "Please report to management. Sorry for the inconvenience.";
                                }
                            }
                            catch (Exception err)
                            {
                                //Error handling
                                //Response.Write("<script>alert('Our apologies. An error has occured. Please report to the administrator or try again later.')</script>");
                                phCheckInErr.Visible = true;
                                lblCheckinErr.Text   = "An error has occured during the check-in process.<br/>"
                                                       + "Please report to management or try again later. Sorry for the inconvenience.";
                                //add error to the error log and then display response tab to say that an error has occured
                                function.logAnError(err.ToString());
                            }
                        };
                        //add button to cell
                        buttonCell.Controls.Add(btnCheckin);
                        //add cell to row
                        AgendaTable.Rows[i].Cells.Add(buttonCell);
                    }
                    //check Out BTN
                    else if (function.GetFullArrivedStatus(a.Arrived.ToString()[0]) == "Yes")
                    {
                        //edit
                        TableCell emptybuttonCell = new TableCell();
                        emptybuttonCell.Text = "";
                        AgendaTable.Rows[i].Cells.Add(emptybuttonCell);

                        //create button
                        TableCell newCell = new TableCell();
                        newCell.Text = "<button type = 'button' class='btn btn-primary'>" +
                                       "<a href = '../ViewBooking.aspx?BookingID=" + a.BookingID.ToString().Replace(" ", string.Empty) +
                                       "&BookingType=CheckOut" +
                                       "&PreviousPage=Receptionist.aspx' style='color:White'>Check-out</a></button>";
                        AgendaTable.Rows[i].Cells.Add(newCell);
                    }
                    //increment control variable
                    i++;
                }
            }
            catch (Exception E)
            {
                //Response.Write("<script>alert('Trouble communicating with the database.Report to admin and try again later.');location.reload();</script>");
                phBookingsErr.Visible = true;
                errorHeader.Text      = "Error getting employee agenda.";
                errorMessage.Text     = "It seems there is a problem communicating with the database."
                                        + "Please report problem to admin or try again later.";
                function.logAnError(E.ToString());
            }
        }
示例#2
0
        public void getAgenda(string id, DateTime bookingDate, string sortBy, string sortDir)
        {
            Button btn;

            try
            {
                agenda = handler.BLL_GetEmpAgenda(id, bookingDate, sortBy, sortDir);

                AgendaTable.CssClass = "table table-light table-hover";

                //create row for the table
                TableRow row = new TableRow();
                row.Height = 50;

                //add row to the table
                AgendaTable.Rows.Add(row);

                /*
                 * create the cells for the row
                 * and their names
                 * the cells being created are for the first row of the table
                 * and their names are the column names
                 * Each cell is added to the table row
                 * .Rows[0] => refers to the first row of the table
                 * */
                TableCell startTime = new TableCell();
                startTime.Text      = "Start Time";
                startTime.Font.Bold = true;
                startTime.Width     = 250;
                AgendaTable.Rows[0].Cells.Add(startTime);

                TableCell endTime = new TableCell();
                endTime.Text      = "End Time";
                endTime.Font.Bold = true;
                endTime.Width     = 250;
                AgendaTable.Rows[0].Cells.Add(endTime);

                TableCell cust = new TableCell();
                cust.Text      = "Customer";
                cust.Font.Bold = true;
                cust.Width     = 350;
                AgendaTable.Rows[0].Cells.Add(cust);

                TableCell service = new TableCell();
                service.Text      = "Service";
                service.Font.Bold = true;
                service.Width     = 350;
                AgendaTable.Rows[0].Cells.Add(service);

                TableCell comment = new TableCell();
                comment.Text      = "Comment";
                comment.Font.Bold = true;
                comment.Width     = 350;
                AgendaTable.Rows[0].Cells.Add(comment);

                TableCell arrived = new TableCell();
                arrived.Text      = "Arrived";
                arrived.Font.Bold = true;
                arrived.Width     = 100;
                AgendaTable.Rows[0].Cells.Add(arrived);

                TableCell visitRecord = new TableCell();
                visitRecord.Width = 400;
                AgendaTable.Rows[0].Cells.Add(visitRecord);

                //integer that will be appended in the foreach loop to access the new row for every iteration of the foreach
                int i = 1;
                foreach (SP_GetEmpAgenda a in agenda)
                {
                    try
                    {
                        cv = handler.BLL_ViewCustVisit(a.UserID, a.BookingID);
                    }
                    catch (Exception err)
                    {
                        function.logAnError("Unable to check if visit record exists[stylist.aspx] err:" + err.ToString());
                    }
                    //create row
                    TableRow r = new TableRow();
                    AgendaTable.Rows.Add(r);

                    getTimeCustomerServices(a.BookingID, a.PrimaryID, i, a);

                    TableCell c = new TableCell();
                    c.Text = a.Comment.ToString();
                    AgendaTable.Rows[i].Cells.Add(c);

                    TableCell present = new TableCell();
                    present.Text = function.GetFullArrivedStatus(a.Arrived.ToString()[0]);
                    AgendaTable.Rows[i].Cells.Add(present);

                    if (function.GetFullArrivedStatus(a.Arrived.ToString()[0]) == "Yes")
                    {
                        TableCell buttonCell = new TableCell();
                        buttonCell.Width  = 100;
                        buttonCell.Height = 50;

                        if (cv == null)
                        {   //if visit record doesn't exist show button
                            //create button
                            btn          = new Button();
                            btn.Text     = "Create Visit Record";
                            btn.CssClass = "btn btn-primary";
                            //button's click event
                            btn.Click += (ss, ee) =>
                            {
                                try
                                {
                                    /* What does the button do:
                                     * =======================
                                     * button creates customer visit record in the CUST_VISIT table
                                     * and redirects user to the customer visit page of the booking
                                     *
                                     */
                                    cust_visit = new CUST_VISIT();

                                    cust_visit.CustomerID  = a.UserID.ToString();
                                    cust_visit.Date        = Convert.ToDateTime(a.Date);
                                    cust_visit.BookingID   = a.PrimaryID.ToString();
                                    cust_visit.Description = "Pending";
                                    if (handler.BLL_CreateCustVisit(cust_visit))
                                    {
                                        Response.Redirect("../Stylist/CustomerVisit.aspx?Action=CreateRecord&bookingID=" + cust_visit.BookingID.ToString()
                                                          + "&customerID=" + cust_visit.CustomerID.ToString());
                                    }
                                    else
                                    {
                                        phVisitSuccess.Visible = false;
                                        //if the insert fails, display failed message
                                        phRecordErr.Visible = true;
                                        lblRecordErr.Text   = "Error creating record<br/>Please try again later or report to admin.";
                                    }
                                }
                                catch (Exception err)
                                {
                                    phVisitSuccess.Visible = false;
                                    phVisitErr.Visible     = true;
                                    lblVisitErr.Text       = "Error:System is unable to create a visit record.br/>"
                                                             + "Please report to management. Sorry for the inconvenience.";
                                    //add error to the error log and then display response tab to say that an error has occured
                                    function.logAnError("Error creating visit record [stylist.aspx {btn}] err: " + err.ToString());
                                }
                            };
                            //add button control to the cell
                            buttonCell.Controls.Add(btn);
                        }
                        else if (cv != null)
                        {
                            //if visit record already exists stylist should be able to update the visit
                            buttonCell.Text = "<button type='button' class='btn btn-primary'>"
                                              + "<a href='../Stylist/CustomerVisit.aspx?Action=CreateRecord&bookingID="
                                              + a.PrimaryID.ToString().Replace(" ", string.Empty)
                                              + "&customerID=" + a.UserID.ToString().Replace(" ", string.Empty)
                                              + "' style='color:White; text-decoration:none;' >Update</a>"
                                              + "</button>";
                        }


                        //add the cell to the row
                        AgendaTable.Rows[i].Cells.Add(buttonCell);
                    }
                    //increment i
                    i++;
                }
            }
            catch (Exception E)
            {
                phVisitSuccess.Visible = false;
                phBookingsErr.Visible  = true;
                errorHeader.Text       = "Error getting employee agenda.";
                errorMessage.Text      = "It seems there is a problem communicating with the database."
                                         + "Please report problem to admin or try again later.";
                //log error, display error message,redirect to the error which then takes user to the home page if they would like to
                function.logAnError("Error with getEmpAgenda [stylist.aspx {getAgenda}]. err: " + E.ToString());
            }
        }