public IHttpActionResult PutBOOKING(decimal id, BOOKING bOOKING) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != bOOKING.BOOKING_ID) { return(BadRequest()); } db.Entry(bOOKING).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!BOOKINGExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PostBOOKING(BOOKING bOOKING) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.BOOKINGs.Add(bOOKING); try { db.SaveChanges(); } catch (DbUpdateException) { if (BOOKINGExists(bOOKING.BOOKING_ID)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = bOOKING.BOOKING_ID }, bOOKING)); }
public ActionResult SearchRooms(BOOKING bookingDetails) { Session["fromDate"] = bookingDetails.fromDate; Session["toDate"] = bookingDetails.toDate; Session["adults"] = bookingDetails.adults; Session["children"] = bookingDetails.children; string validationString = IsValid(bookingDetails); if (!validationString.Equals("")) { if (validationString == "validation1") { ViewBag.Message1 = "Check-in date must be greater than or equal to the current date."; } if (validationString == "validation2") { ViewBag.Message2 = "Check-Out date must be greater than the check-in date."; } return(View("BookingHome")); } BookingModel model = new BookingModel(); string query = "SELECT * FROM ROOM WHERE roomId NOT IN (SELECT FK_RID FROM BOOKING WHERE fromDate =@fromDate AND toDate=@toDate)"; IEnumerable <ROOM> roomList = model.Database.SqlQuery <ROOM>(query, new SqlParameter("@fromDate", bookingDetails.fromDate), new SqlParameter("@toDate", bookingDetails.toDate)); ViewBag.RoomList = roomList.ToList(); return(View("BookingHome")); }
// GET: Booking public ActionResult BookingHome() { //BookingModel bookingModel = new BookingModel(); if (Session["userName"] != null) { ViewBag.userName = Session["userName"].ToString(); } BOOKING booking = new BOOKING(); return(View(booking)); }
public IHttpActionResult GetBOOKING(decimal id) { BOOKING bOOKING = db.BOOKINGs.Find(id); if (bOOKING == null) { return(NotFound()); } return(Ok(bOOKING)); }
public ActionResult Edit([Bind(Include = "Booking_id,Check_in_date,Check_out_date,Customer_id,Room_id")] BOOKING bOOKING) { if (ModelState.IsValid) { db.Entry(bOOKING).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Customer_id = new SelectList(db.CUSTOMERs, "Customer_id", "CustomerFirstName", bOOKING.Customer_id); ViewBag.Room_id = new SelectList(db.ROOMs, "Room_id", "RoomType_id", bOOKING.Room_id); return(View(bOOKING)); }
public IHttpActionResult PostBOOKING(BOOKING bOOKING) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.BOOKINGs.Add(bOOKING); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = bOOKING.BookingID }, bOOKING)); }
public IHttpActionResult DeleteBOOKING(decimal id) { BOOKING bOOKING = db.BOOKINGs.Find(id); if (bOOKING == null) { return(NotFound()); } db.BOOKINGs.Remove(bOOKING); db.SaveChanges(); return(Ok(bOOKING)); }
public bool postBooking(BOOKING data) { try { db.BOOKINGs.Add(data); db.SaveChanges(); return(true); } catch (Exception ex) { // we can log the exception here return(false); } }
// GET: BOOKINGs/Details/5 public ActionResult Details(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } BOOKING bOOKING = db.BOOKINGs.Find(id); if (bOOKING == null) { return(HttpNotFound()); } return(View(bOOKING)); }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } BOOKING = await _context.BOOKING.FirstOrDefaultAsync(m => m.Booking_ID == id); if (BOOKING == null) { return(NotFound()); } return(Page()); }
public ActionResult DeleteConfirmed(string id) { BOOKING bOOKING = db.BOOKINGs.Find(id); var s = db.BILLs.Where(u => u.Booking_id == bOOKING.Booking_id).ToList(); if (s != null && s.Count > 0) { db.BILLs.Remove(s[0]); } db.BOOKINGs.Remove(bOOKING); db.SaveChanges(); return(RedirectToAction("Index")); }
public HttpResponseMessage Addbooking(Addbooking sd) { // var httpRequest = HttpContext.Current.Request; BOOKING booking = new BOOKING(); EMPLOYEEDATETIMESLOT bookingUpdate = new EMPLOYEEDATETIMESLOT(); //Save to DB try { booking.CLIENTID = sd.ClientID; booking.PROPERTYID = sd.PropertyID; booking.USERID = 2; // booking.CLIENTID = Convert.ToInt32(httpRequest["CLIENTID"]); } catch (Exception e) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Error With Booking ")); } try { db.BOOKINGs.Add(booking); db.SaveChanges(); bookingUpdate = db.EMPLOYEEDATETIMESLOTs.Find(sd.EmployeeDateTimeSlotID); int value = int.Parse(db.BOOKINGs .OrderByDescending(p => p.BOOKINGID) .Select(r => r.BOOKINGID) .First().ToString()); bookingUpdate.BOOKINGID = value; bookingUpdate.EMPLOYEESLOTSTAUSID = 2; db.SaveChanges(); } catch (Exception) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Error With Booking "));; } //booking.BOOKINGID = getCreatedBookingID(booking.CLIENTID); return(Request.CreateResponse(HttpStatusCode.Created)); }
public IHttpActionResult postBooking(BookingModel data) { BOOKING booking = new BOOKING(); booking.amount = data.amount; booking.capacity_provider_id = data.capacity_provider_id; booking.comment = data.comment; booking.currency = data.currency; booking.date_from = data.date_from; booking.date_to = data.date_to; booking.id = data.id; booking.is_active = data.is_active; booking.object_name = data.object_name; return(Ok(service.postBooking(booking))); }
// GET: BOOKINGs/Edit/5 public ActionResult Edit(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } BOOKING bOOKING = db.BOOKINGs.Find(id); if (bOOKING == null) { return(HttpNotFound()); } ViewBag.Customer_id = new SelectList(db.CUSTOMERs, "Customer_id", "CustomerFirstName", bOOKING.Customer_id); ViewBag.Room_id = new SelectList(db.ROOMs, "Room_id", "RoomType_id", bOOKING.Room_id); return(View(bOOKING)); }
public ActionResult Paynow(FormCollection form) { int roomId = Convert.ToInt32(Session["roomId"].ToString()); Double roomPrice = Convert.ToDouble(Session["roomPrice"].ToString()); DateTime fromDate = Convert.ToDateTime(Session["fromDate"].ToString()); DateTime toDate = Convert.ToDateTime(Session["toDate"].ToString()); UserBankModel userBank = new UserBankModel(); DateTime currentTime = DateTime.UtcNow; int userID = Convert.ToInt32(Session["userId"].ToString()); //string query = "SELECT * FROM USERBANK WHERE FK_UID=@uid"; //IEnumerable<USERBANK> results = userBank.Database.SqlQuery<USERBANK>(query, new SqlParameter("@uid",userID)); double userAmount = 1000; //foreach (USERBANK userAcnt in results ){ // userAmount = Convert.ToDouble(userAcnt.amount); //} if (userAmount >= roomPrice) { BookingModel bookingModel = new BookingModel(); BOOKING bookingDetails = new BOOKING(); bookingDetails.FK_RID = roomId; bookingDetails.FK_UID = userID; bookingDetails.fromDate = fromDate; bookingDetails.toDate = toDate; bookingDetails.bookedTime = currentTime; bookingModel.BOOKINGs.Add(bookingDetails); bookingModel.SaveChanges(); ViewBag.PaymentStatus = "Success"; ViewBag.PaymentInfo = "Thank you for using our services. Enjoy your stay."; ViewBag.userName = Session["userName"].ToString(); Session.Remove("toDate"); Session.Remove("fromDate"); Session.Remove("adults"); Session.Remove("children"); Session.Remove("roomId"); Session.Remove("roomPrice"); } else { ViewBag.PaymentStatus = "Failure"; ViewBag.PaymentInfo = "Insufficient Funds in your Account. PLease try later."; ViewBag.userName = Session["userName"].ToString(); } ViewBag.userName = Session["userName"].ToString(); return(View()); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } BOOKING = await _context.BOOKING.FindAsync(id); if (BOOKING != null) { _context.BOOKING.Remove(BOOKING); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public string IsValid(BOOKING booking) { DateTime checkinDate = (DateTime)booking.fromDate; DateTime checkoutDate = (DateTime)booking.toDate; int result = DateTime.Compare(checkinDate, checkoutDate); if (checkinDate < DateTime.Now.Date) { return("validation1"); } if ((DateTime)checkoutDate <= checkinDate) { return("validation2"); } return(""); }
public ActionResult Confirm(string check_in_date_input, string check_out_date_input, string roomtype_input) { ViewBag.roomtypeData = db.ROOMTYPEs.ToList(); ViewBag.paytypeData = db.PAYTYPEs.ToList(); string customerLastName = Request["customerLastName"]; string customerFirstName = Request["customerFirstName"]; string tel = Request["tel"]; string email = Request["email"]; string paytype = Request["paytype"]; // -------------check user input------------- if (isCorrectFormat(check_in_date_input) == false || isCorrectFormat(check_out_date_input) == false) { return(RedirectToAction("Index")); } else if (NumberOfDays(check_in_date_input, check_out_date_input) < 0) { return(RedirectToAction("Index")); } // -------price and total for booking form---------- int numberOfDays = NumberOfDays(check_in_date_input, check_out_date_input); String queryRent = "SELECT r.Rent_id, r.Price, r.IsActive, r.From_Date, r.To_Date, r.RoomType_id " + "FROM(SELECT * FROM ROOMTYPE rt WHERE(rt.RoomType_id = '" + roomtype_input + "')) rt, RENT r " + "WHERE(r.RoomType_id = rt.RoomType_id) and r.IsActive = 'True' "; var rent = db.Database.SqlQuery <RENT>(queryRent); int price = rent.ToList()[0].Price; int total = numberOfDays * price; // ---------------check room availability-------------- string check_in_date_format = FormatDate(check_in_date_input); string check_out_date_format = FormatDate(check_out_date_input); String query = "DECLARE @S DATE; " + " SET @S = '" + check_in_date_format + "' " + " DECLARE @E DATE; " + " SET @E = '" + check_out_date_format + "' " + " DECLARE @RT varchar(20); " + " SET @RT = '" + roomtype_input + "' " + " SELECT r.Room_id, r.RoomType_id" + " FROM (SELECT * FROM ROOM WHERE ROOM.RoomType_id = @RT) r " + " EXCEPT " + " SELECT Distinct c.Room_id, c.RoomType_id " + " FROM( " + " SELECT a.Room_id, a.RoomType_id, b.Booking_id, b.Check_in_date, b.Check_out_date, b.Customer_id " + " FROM(SELECT * FROM ROOM WHERE ROOM.RoomType_id = @RT) a, BOOKING b " + " WHERE a.Room_id = b.Room_id " + " ) c " + " WHERE( " + " (@S <= c.Check_in_date and(@E >= c.Check_in_date and @E <= c.Check_out_date)) " + " or((@S >= c.Check_in_date and @S <= c.Check_out_date) and @E >= c.Check_out_date ) " + " or(@S >= c.Check_in_date and @E <= c.Check_out_date) " + " or(@S <= c.Check_in_date and @E >= c.Check_out_date) " + ")"; var data = db.Database.SqlQuery <ROOM>(query); List <ROOM> data1 = data.ToList(); // not availability if (data1.Count <= 0) { System.Diagnostics.Debug.WriteLine("Khong co phong"); ViewBag.isExist = false; ViewBag.showAlert = true; return(RedirectToAction("Index")); } else { // flag for create booking form ViewBag.isExist = true; } // create customer CUSTOMER mCustomer = new CUSTOMER(); mCustomer.Customer_id = createCustomerId(); mCustomer.CustomerFirstName = customerFirstName; mCustomer.CustomerLastName = customerLastName; mCustomer.CustomerTel = tel; mCustomer.CustomerEmail = email; db.CUSTOMERs.Add(mCustomer); // create booking BOOKING mBooking = new BOOKING(); mBooking.Booking_id = createBookingId(); mBooking.Check_in_date = Convert.ToDateTime(check_in_date_input); mBooking.Check_out_date = Convert.ToDateTime(check_out_date_input); mBooking.Customer_id = mCustomer.Customer_id; mBooking.Room_id = data1[0].Room_id; db.BOOKINGs.Add(mBooking); // create billpay BILLPAY mBillPay = new BILLPAY(); mBillPay.BillPay_id = createBillPayId(); mBillPay.Date = DateTime.Now; mBillPay.PayType_id = paytype; mBillPay.Customer_id = mCustomer.Customer_id; db.BILLPAYs.Add(mBillPay); // create bill BILL mBill = new BILL(); mBill.Bill_id = createBillId(); mBill.Total = total; mBill.BillPay_id = mBillPay.BillPay_id; mBill.Rent_id = rent.ToList()[0].Rent_id; // ... mBill.Booking_id = mBooking.Booking_id; db.BILLs.Add(mBill); db.SaveChanges(); SendEmail(mCustomer.CustomerLastName + " " + mCustomer.CustomerFirstName, mCustomer.CustomerTel, mCustomer.CustomerEmail, htmlMail(mBill, db.ROOMTYPEs.Find(roomtype_input).RType, price)); return(RedirectToAction("ConfirmBillPay", new { id = mBill.Bill_id })); }
public bool updateBooking(BOOKING bookingUpdate) { return(db.updateBooking(bookingUpdate)); }
public bool BLL_CheckIn(BOOKING booking) { return(db.CheckIn(booking)); }
public dynamic Addbooking(Addbooking sd) { // var httpRequest = HttpContext.Current.Request; BOOKING booking = new BOOKING(); EMPLOYEEDATETIMESLOT bookingUpdate = new EMPLOYEEDATETIMESLOT(); //Save to DB try { var existing = db.BOOKINGs.Where(jj => jj.CLIENTID == sd.ClientID && jj.PROPERTYID == sd.PropertyID).ToList(); if (existing.Count == 0) { booking.CLIENTID = sd.ClientID; booking.PROPERTYID = sd.PropertyID; var USERID = db.CLIENTs.Where(kk => kk.CLIENTID == sd.ClientID).Select(jj => jj.USERID).FirstOrDefault(); booking.USERID = USERID; // booking.CLIENTID = Convert.ToInt32(httpRequest["CLIENTID"]); } else { dynamic setInvalid = new ExpandoObject(); setInvalid = false; return(setInvalid); } } catch (Exception e) { return(false); } try { db.BOOKINGs.Add(booking); db.SaveChanges(); bookingUpdate = db.EMPLOYEEDATETIMESLOTs.Find(sd.EmployeeDateTimeSlotID); int value = int.Parse(db.BOOKINGs .OrderByDescending(p => p.BOOKINGID) .Select(r => r.BOOKINGID) .First().ToString()); bookingUpdate.BOOKINGID = value; bookingUpdate.EMPLOYEESLOTSTAUSID = 2; db.SaveChanges(); var emp = db.EMPLOYEEs.Where(hh => hh.EMPLOYEEID == bookingUpdate.EMPLOYEEID).FirstOrDefault(); var theClient = db.CLIENTs.Where(hh => hh.CLIENTID == sd.ClientID).FirstOrDefault(); var prop = db.PROPERTies.Where(hh => hh.PROPERTYID == sd.PropertyID).FirstOrDefault(); var empslot = bookingUpdate.DATETIMESLOTID; var dateid = db.DATETIMESLOTs.Find(empslot); var date = db.DATEs.Where(kk => kk.DATEID == dateid.DATEID).Select(jj => jj.DATEDESCRIPTION).FirstOrDefault(); var slotS = db.SLOTs.Where(kk => kk.SLOTID == dateid.SLOTID).FirstOrDefault(); //send email with verification MailMessage mail = new MailMessage(); SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com"); mail.From = new MailAddress("*****@*****.**"); mail.To.Add(emp.EMAIL); mail.Subject = "Property Viewing Booking From: " + theClient.NAME + " " + theClient.SURNAME + " " + theClient.PHONENUMBER; mail.Body = "Good day " + emp.NAME + " " + emp.SURNAME + "\n" + theClient.NAME + " " + theClient.SURNAME + " would love to view the property at " + prop.ADDRESS + " with the property reference number " + prop.PROPERTYID + ". \nClient Details \nClient Name : " + theClient.NAME + " " + theClient.SURNAME + "\nClient Email:" + theClient.EMAIL + "\nClient Number:" + theClient.PHONENUMBER + "\nViewing Details \nDate and Time of viewing : " + date + " " + DateTime.Now.Year.ToString() + " \nFrom: " + slotS.STARTTIME + "-" + slotS.ENDTIME + " \n\nThank you "; SmtpServer.Port = 587; SmtpServer.DeliveryMethod = SmtpDeliveryMethod.Network; SmtpServer.UseDefaultCredentials = false; SmtpServer.Credentials = new System.Net.NetworkCredential("*****@*****.**", "test123@123test"); SmtpServer.EnableSsl = true; SmtpServer.Send(mail); } catch (Exception) { return(false); } //booking.BOOKINGID = getCreatedBookingID(booking.CLIENTID); return(true); }
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()); } }
public bool BLL_UpdateCustVisit(CUST_VISIT visit, BOOKING b) { return(db.UpdateCustVisit(visit, b)); }
public bool BLL_AddBooking(BOOKING addBooking) { return(db.AddBooking(addBooking)); }
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()); } }