Esempio n. 1
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());
            }
        }
Esempio n. 2
0
 public bool BLL_CreateCustVisit(CUST_VISIT cust_visit)
 {
     return(db.CreateCustVisit(cust_visit));
 }
Esempio n. 3
0
        public void getDetailsAndCreateRecord(string bookingID, string customerID)
        {
            try
            {
                bDTL = handler.BLL_GetAllofBookingDTL(bookingID.Replace(" ", string.Empty), customerID);

                //create a variablew to track the row count
                int rCnt = 0;

                TableRow newRow = new TableRow();
                newRow.Height = 50;
                allBookingTable.Rows.Add(newRow);
                TableCell newCell = new TableCell();
                newCell.Font.Bold = true;
                newCell.Text      = "Customer Name:";
                newCell.Width     = 300;
                allBookingTable.Rows[rCnt].Cells.Add(newCell);

                getTimeCustomerServices(bDTL.BookingID, bDTL.BookingID, rCnt, bDTL);

                newRow        = new TableRow();
                newRow.Height = 50;
                tblOther.Rows.Add(newRow);
                newCell           = new TableCell();
                newCell.Font.Bold = true;
                newCell.Text      = "Date:";
                newCell.Width     = 300;
                tblOther.Rows[0].Cells.Add(newCell);
                newCell       = new TableCell();
                newCell.Text  = bDTL.Date.ToString("dd-MM-yyy");
                newCell.Width = 300;
                tblOther.Rows[0].Cells.Add(newCell);

                newRow        = new TableRow();
                newRow.Height = 50;
                tblOther.Rows.Add(newRow);
                newCell           = new TableCell();
                newCell.Font.Bold = true;
                newCell.Text      = "Booking comment:";
                newCell.Width     = 300;
                tblOther.Rows[1].Cells.Add(newCell);
                newCell       = new TableCell();
                newCell.Width = 300;
                TextBox descBox = new TextBox();
                descBox.ID = "bookingComment";
                if (bDTL.Comment != string.Empty)
                {
                    descBox.Text = bDTL.Comment.ToString();
                }
                descBox.CssClass = "form-control";
                //descBox.MaxLength = 50;
                newCell.Controls.Add(descBox);
                tblOther.Rows[1].Cells.Add(newCell);

                newRow = new TableRow();
                tblOther.Rows.Add(newRow);
                TableCell len = new TableCell();
                len.Text      = "*Please keep the comment short and descriptive";
                len.ForeColor = System.Drawing.Color.Red;
                len.Visible   = false;
                tblOther.Rows[2].Cells.Add(len);

                newRow = new TableRow();
                tblOther.Rows.Add(newRow);
                TableCell val = new TableCell();
                val.Text      = "*Please enter comment";
                val.ForeColor = System.Drawing.Color.Red;
                val.Visible   = false;
                tblOther.Rows[3].Cells.Add(val);

                newRow = new TableRow();
                tblOther.Rows.Add(newRow);
                TableCell createVisit = new TableCell();
                createVisit.Width = 300;
                Button btnVisit = new Button();
                btnVisit.Text     = "Update";
                btnVisit.CssClass = "btn btn-primary";
                btnVisit.Click   += (ss, ee) =>
                {
                    try
                    {
                        visit = new CUST_VISIT();

                        visit.CustomerID  = customerID.ToString();
                        visit.BookingID   = bookingID.ToString();
                        visit.Description = Convert.ToString(descBox.Text);

                        b         = new BOOKING();
                        b.Comment = Convert.ToString(descBox.Text);

                        if (b.Comment == string.Empty || b.Comment == null)
                        {
                            val.Visible = true;
                        }
                        if (b.Comment.Length > 50)
                        {
                            len.Visible = true;
                        }
                        else
                        {
                            if (handler.BLL_UpdateCustVisit(visit, b))
                            {
                                Response.Redirect("../Stylist/Stylist.aspx?Action=UpdateVisitRecord&CustomerName="
                                                  + bDTL.CustomerName.ToString().Replace(" ", string.Empty));
                            }
                            else
                            {
                                phVisitErr.Visible = true;
                                lblVisitErr.Text   = "Unable to update visit record.<br/>"
                                                     + "Please report to management or try again later.";
                            }
                        }
                    }
                    catch (Exception err)
                    {
                        phVisitErr.Visible = true;
                        lblVisitErr.Text   = "System is unable to create a visit record.<br/>"
                                             + "Please report to management or try again later.";
                        function.logAnError("Error updating visit [customervisit.aspx btnVisit] err:" + err.ToString());
                    }
                };
                createVisit.Controls.Add(btnVisit);
                tblOther.Rows[4].Cells.Add(createVisit);
            }
            catch (Exception Err)
            {
                phBookingsErr.Visible = true;
                errorHeader.Text      = "Error.Cannot display booking details.";
                errorMessage.Text     = "It seems there is a problem communicating with the database."
                                        + "Please report problem to admin or try again later.";

                function.logAnError("Couldn't display bookingDetails to create visit record"
                                    + " [customerVisit.aspx getDetailsAndCreateRecord method ]"
                                    + " err:" + Err.ToString());
            }
        }
Esempio n. 4
0
 public bool BLL_UpdateCustVisit(CUST_VISIT visit, BOOKING b)
 {
     return(db.UpdateCustVisit(visit, b));
 }