コード例 #1
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());
            }
        }