protected void rdoAll_CheckedChanged(object sender, EventArgs e)
        {
            int bookingID = 0;
            string htmlOutput = "";
            string arriveDate = null;
            string departDate = null;

            InvoiceHandler invoiceHandler = new InvoiceHandler();

            BookingHandler bookingHandler = new BookingHandler();
            List<ProvisionalBooking> listProvisionalBookings = bookingHandler.GetAllProvisionalBookings();
            if (listProvisionalBookings == null)
            {
                if (listProvisionalBookings == null)
                    litProvisionalBookings.Text = "<tr><td colspan=\"6\" style=\"color:red;text-align:center;\">There are currently no provisional bookings</td></tr>";
            }
            else
            {
                for (int i = 0; i < listProvisionalBookings.Count; i++)
                {
                    arriveDate = listProvisionalBookings[i].ArriveDate.Day + "-" + listProvisionalBookings[i].ArriveDate.Month + "-" + listProvisionalBookings[i].ArriveDate.Year;
                    departDate = listProvisionalBookings[i].DepartDate.Day + "-" + listProvisionalBookings[i].DepartDate.Month + "-" + listProvisionalBookings[i].DepartDate.Year;
                    bookingID = listProvisionalBookings[i].BookingID;
                    htmlOutput += "<tr><td>" + bookingID.ToString() + "</td><td>" + listProvisionalBookings[i].Name + "</td><td>R " + invoiceHandler.GetDepositAmount(bookingID) + "</td><td>" + arriveDate + "</td><td>" + departDate + "</td><td>" + "<a class=\"btn btn-info viewBooking\" href=\"ViewProvisionalBooking.aspx?id=" + bookingID + "\">View Booking</a>" + "</td></tr>\n";
                }
                litProvisionalBookings.Text = htmlOutput;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            int bookingID = 0;
            string htmlOutput = "";
            string arriveDate = null;
            string departDate = null;

            InvoiceHandler invoiceHandler = new InvoiceHandler();

            BookingHandler bookingHandler = new BookingHandler();
            List<ProvisionalBooking> listAllConfirmedBookings = bookingHandler.GetAllConfirmedBookings();
            if (listAllConfirmedBookings == null)
            {
                if (listAllConfirmedBookings == null)
                    litHeader.Text = "<h3 style=\"color:red\">There are currently no confirmed bookings</h3><br />";
            }
            else
            {
                for (int i = 0; i < listAllConfirmedBookings.Count; i++)
                {
                    arriveDate = listAllConfirmedBookings[i].ArriveDate.Day + "-" + listAllConfirmedBookings[i].ArriveDate.Month + "-" + listAllConfirmedBookings[i].ArriveDate.Year;
                    departDate = listAllConfirmedBookings[i].DepartDate.Day + "-" + listAllConfirmedBookings[i].DepartDate.Month + "-" + listAllConfirmedBookings[i].DepartDate.Year;
                    bookingID = listAllConfirmedBookings[i].BookingID;
                    htmlOutput += "<tr><td>" + bookingID.ToString() + "</td><td>" + listAllConfirmedBookings[i].Name + "</td><td>" + arriveDate + "</td><td>" + departDate + "</td><td>" + "<a class=\"btn btn-info viewBooking\" href=\"Checkin.aspx?id=" + bookingID + "\">Check-in</a>" + "</td></tr>\n";
                }
                if (!IsPostBack)
                {
                    litConfirmedBookings.Text = htmlOutput;
                }
            }
        }
        protected void btnFinishBooking_Click(object sender, EventArgs e)
        {
            int bookingID = 0;
            string selectedRooms = null;
            DateTime startDate = new DateTime();
            DateTime endDate = new DateTime();
            int memberID = 0;
            try
            {
                selectedRooms = (string)Session["SelectedRooms"];
                startDate = (DateTime)Session["StartDate"];
                endDate = (DateTime)Session["EndDate"];
                memberID = (int)Session["MemberID"];
            }
            catch (NullReferenceException)
            {
                Response.Redirect("Availability.aspx");
            }

            BookingHandler bookingHandler = new BookingHandler();
            bookingHandler.CreateBooking(startDate, endDate, memberID, selectedRooms);

            try
            {
                bookingID = bookingHandler.GetLastBookingID();
            }
            catch (Exception)
            {
            }
            Session["BookingID"] = bookingID;
            Response.Redirect("SuccessfullBooking.aspx");
        }
        protected void btnYes_Click(object sender, EventArgs e)
        {
            string action = "";
            try
            {
                action = (string)Session["Action"];
            }
            catch (NullReferenceException)
            {
                Response.Redirect("ProvisionalBookings.aspx");
            }

            int bookingID = 0;
            try
            {
                bookingID = (int)Session["BookingID"];
            }
            catch (NullReferenceException)
            {
                Response.Redirect("ProvisionalBookings.aspx");
            }

            BookingHandler bookingHandler = new BookingHandler();

            if (action == "Confirm")
            {
                //Confirm booking
                /*try
                {
                    SendMail(bookingID, true);*/
                    bookingHandler.ConfirmBooking(bookingID);
                /*}
                catch (Exception)
                {
                }*/
            }
            else if (action == "Decline")
            {
                //Decline booking
                /*try
                {
                    SendMail(bookingID, false);*/
                    bookingHandler.DeclineBooking(bookingID);
                /*}
                catch (Exception ex)
                {

                }*/

            }
            else
            {
                Response.Redirect("ProvisionalBookings.aspx");
            }
        }
Esempio n. 5
0
        protected void btnYes_Click(object sender, EventArgs e)
        {
            int checkinID = 0;
            bool intTest = false;
            intTest = int.TryParse(Request.QueryString["id"], out checkinID);

            if (checkinID == 0)
                Response.Redirect("CheckinList.aspx");

            BookingHandler bookingHandler = new BookingHandler();
            bookingHandler.Checkin(checkinID);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            int bookingID = 0;
            bool intTest = false;
            intTest = int.TryParse(Request.QueryString["id"], out bookingID);
            Session["BookingID"] = bookingID;

            BookingHandler bookingHandler = new BookingHandler();
            InvoiceHandler invoiceHandler = new InvoiceHandler();
            ProvisionalBooking provisionalBooking = bookingHandler.GetProvisionalBookingDetails(bookingID);
            try
            {
                Page.Title = "EASiBOOK :: Booking Number" + bookingID.ToString();
                litBookingNo.Text = bookingID.ToString();
                lblName.Text = provisionalBooking.Name;
                lblEmail.Text = provisionalBooking.Email;
                lblPhoneNo.Text = provisionalBooking.PhoneNo;
                lblDeposit.Text = "R " + invoiceHandler.GetDepositAmount(bookingID).ToString();
                lblArriveDate.Text = provisionalBooking.ArriveDate.Year + "-" + provisionalBooking.ArriveDate.Month + "-" + provisionalBooking.ArriveDate.Day;
                lblDepartDate.Text = provisionalBooking.DepartDate.Year + "-" + provisionalBooking.DepartDate.Month + "-" + provisionalBooking.DepartDate.Day;
                if (provisionalBooking.ProofOfPayment != "")
                    imgProofOfPayment.ImageUrl = "." + provisionalBooking.ProofOfPayment;
                else
                {
                    imgProofOfPayment.Visible = false;
                    lblLargeImage.Visible = false;
                    lblNoPOP.Visible = true;
                }

                if (provisionalBooking.ProofOfPayment.EndsWith(".pdf"))
                {
                    litProofOfPayment.Text = "." + provisionalBooking.ProofOfPayment + "\" target=\"_blank\"";
                    imgProofOfPayment.ImageUrl = "/resources/pdflogo.png";
                }
                else
                    litProofOfPayment.Text = "." + provisionalBooking.ProofOfPayment + "\" data-lightbox=\"image\"";
            }
            catch (NullReferenceException)
            {
                Response.Redirect("ProvisionalBookings.aspx");
            }
        }
        protected void btnYes_Click(object sender, EventArgs e)
        {
            int myRole = 1;
            int bookingID = 0;
            bool intTest = false;
            intTest = int.TryParse(Request.QueryString["id"], out bookingID);
            int returnID = 0;
            intTest = false;
            intTest = int.TryParse(Request.QueryString["return"], out returnID);

            if (bookingID == 0)
                Response.Redirect("Default.aspx");

            bool loggedIn = false;
            //Checks for a login
            if (Session["MemberID"] != null)
                loggedIn = true;
            if (loggedIn == false)
            {
                Session["LoginRedirect"] = "CancelBooking.aspx?id=" + bookingID.ToString() + "&return=" + returnID.ToString();
                Response.Redirect("Login.aspx");
            }
            //End of login check

            BookingHandler bookingHandler = new BookingHandler();
            bookingHandler.CancelBooking(bookingID);

            int memberID = bookingHandler.GetBookingOwner(bookingID);

            //Checks if role is high enough
            MemberHandler memberHandler = new MemberHandler();
            myRole = memberHandler.GetRole((int)Session["MemberID"]);
            if (myRole != 3 && (int)Session["MemberID"] != memberID)
            {
                Response.Redirect("Default.aspx");
            }
            //End check for role
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            BookingHandler bookingHandler = new BookingHandler();
            Booking booking = new Booking();

            int bookingID = 0;
            string picturePath = @"\ProofOfPayment\";

            try
            {
                //bookingID = Convert.ToInt32(Request.QueryString["id"]);
                bookingID = 1;
            }
            catch (NullReferenceException)
            {
                Response.Redirect("Default.aspx");
            }

            //check if picture is selected
            if (fileUploadControl.HasFile)
            {
                try
                {
                    //only accept .png and .jpg image files
                    if (fileUploadControl.PostedFile.ContentType == "image/jpeg" || fileUploadControl.PostedFile.ContentType == "image/png")
                    {
                        //check file is within maximum size limit
                        if (fileUploadControl.PostedFile.ContentLength < 3072000)
                        {
                            //get file name from the upload control
                            string filename = Path.GetFileName(fileUploadControl.FileName);

                            //get the extension name of the file
                            string extension = filename.Substring(filename.LastIndexOf("."));
                            //remove the extension from the file name
                            filename = filename.Substring(0, filename.LastIndexOf("."));

                            //give file a unique name using bookingID
                            filename = "booking_" + bookingID.ToString();

                            //combine path, file name and extension. phew
                            picturePath += filename + extension;

                            //all checks successfull, upload image and run SQL command
                            fileUploadControl.SaveAs(Server.MapPath(@"~" + picturePath));

                            booking.BookingID = bookingID;
                            booking.ProofOfPayment = picturePath;

                            if (bookingHandler.UpdateProofOfPayment(booking) == false)
                            {

                                //alert of success
                                lblProgress.CssClass = "label label-success";
                                lblProgress.Text = "Room added successfully";

                            }
                        }
                        else
                            lblProgress.Text = "The picture has to be less than 3 megabytes!";

                    }
                    else
                        lblProgress.Text = "Only JPEG or PNG files are accepted!";

                }
                catch (Exception)
                {
                    lblProgress.Text = "The picture failed to upload";
                }
            }
        }
        public void btnSave_Click(object sender, EventArgs e)
        {
            BookingHandler bookingHandler = new BookingHandler();
            Booking booking = new Booking();

            int bookingID = 0;
            string picturePath = @"/ProofOfPayment/";

            try
            {
                bookingID = Convert.ToInt32(Request.QueryString["id"]);
            }
            catch (NullReferenceException)
            {
                Response.Redirect("Default.aspx");
            }

            //check if picture is selected
            if (fileUploadControl.HasFile)
            {
                try
                {
                    //only accept .png and .jpg image files
                    if (fileUploadControl.PostedFile.ContentType == "image/jpeg" || fileUploadControl.PostedFile.ContentType == "image/png" || fileUploadControl.PostedFile.ContentType == "application/pdf")
                    {
                            //get file name from the upload control
                            string filename = Path.GetFileName(fileUploadControl.FileName);

                            //get the extension name of the file
                            string extension = filename.Substring(filename.LastIndexOf("."));
                            //remove the extension from the file name
                            filename = filename.Substring(0, filename.LastIndexOf("."));

                            //give file a unique name using bookingID
                            filename = "booking_" + bookingID.ToString();

                            //combine path, file name and extension. phew
                            picturePath += filename + extension;

                            //all checks successfull, upload image and run SQL command
                            fileUploadControl.SaveAs(Server.MapPath(@"~" + picturePath));

                            booking.BookingID = bookingID;
                            booking.ProofOfPayment = picturePath;

                            int memberID = (int)Session["MemberID"];
                            if (bookingHandler.UpdateProofOfPayment(booking) == false)
                            {

                                //alert of success
                                lblProgress.CssClass = "label label-success";
                                lblProgress.Text = "Proof of Payment added successfully";

                                //delay redirect to alert user of page change
                                lblRedirect.Text = "Redirecting to booking history in 5 seconds.";
                                Response.Write("<script type=\"text/javascript\">setTimeout(function () { window.location.href = \"BookingHistory.aspx?id=" + memberID.ToString() +"\"; }, 5000);</script>");
                            }

                        else
                            lblProgress.Text = "The file has to be less than 3 megabytes!";

                    }
                    else
                        lblProgress.Text = "Only JPEG, PNG or PDF files are accepted!";

                }
                catch (Exception)
                {
                    lblProgress.Text = "The file failed to upload.";
                }
            }
        }
        protected void SendMail(int bookingID, bool confirmed)
        {
            //get member who created the booking
            BookingHandler bookingHandler = new BookingHandler();
            int memberID = bookingHandler.GetBookingOwner(bookingID);

            //the get members email
            MemberHandler memberHandler = new MemberHandler();
            Member member = new Member();
            member = memberHandler.GetMemberDetails(memberID);

            BusinessHandler businessHandler = null;
            Business business = null;

            //get business email and password
            string businessName, businessEmail, businessPassword, emailServer;
            int port;

            businessHandler = new BusinessHandler();
            business = new Business();
            business = businessHandler.GetBusinessDetails();

            businessName = business.Name;
            businessEmail = business.Email;
            businessPassword = business.EmailPassword;
            emailServer = business.EmailServer;
            port = business.EmailPort;

            //send email
            MailMessage mail = new MailMessage();
            SmtpClient smtpClient = new SmtpClient(emailServer);
            mail.From = new MailAddress(businessEmail);
            mail.To.Add(member.Email);

            if (confirmed)
            {
                mail.Subject = businessName + " Booking Confirmed";
                mail.Body = "We are pleased to inform you, your booking at " + businessName + " has been confirmed. Please supply the following booking referance number when checking in: " + bookingID.ToString();
            }
            else
            {
                mail.Subject = businessName + " Booking Declined";
                mail.Body = "We are sad to inform you, your booking at " + businessName + " has been declined. If you have any queries please contact us for assistance.";
            }

            smtpClient.Port = port;
            smtpClient.Credentials = new NetworkCredential(businessEmail, businessPassword);
            smtpClient.EnableSsl = true;

            smtpClient.Send(mail);
            memberHandler.UpdateMemberPassword(member);

                /*
                lblProgress.CssClass = "label label-success";
                lblProgress.Text = "An email was sent, check you email for your new password.";

                //delay redirect to alert user of page change
                lblRedirect.Text = "Redirecting to log in, in 5 seconds.";
                Response.Write("<script type=\"text/javascript\">setTimeout(function () { window.location.href = \"Login.aspx\"; }, 5000);</script>");
            */
        }
Esempio n. 11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int invoiceID = 0;
            bool intTest = false;
            intTest = int.TryParse(Request.QueryString["id"], out invoiceID);

            if (invoiceID == 0)
                Response.Redirect("Default.aspx");

            litInvoiceNo.Text = invoiceID.ToString();

            BusinessHandler businessHandler = new BusinessHandler();
            Business business = businessHandler.GetBusinessDetails();

            lblCompanyName.Text = business.Name;
            lblAddressLine1.Text = business.AddressLine1;
            lblAddressLine2.Text = business.AddressLine2;
            lblPhoneNo.Text = business.PhoneNo;
            lblEmail.Text = business.Email;
            lblBankName.Text = business.BankName;
            lblBankAccountNo.Text = business.AccountNo;
            lblBranchCode.Text = business.BranchCode;

            InvoiceHandler invoiceHandler = new InvoiceHandler();
            DAL.Invoice invoice = invoiceHandler.GetInvoiceDetails(invoiceID);
            int bookingID = 0;
            try
            {
                bookingID = invoice.BookingID;
            }
            catch (NullReferenceException)
            {
                Response.Redirect("Default.aspx");
            }

            BookingHandler bookingHandler = new BookingHandler();
            ProvisionalBooking provisionalBooking = bookingHandler.GetProvisionalBookingDetails(bookingID);
            lblArriveDate.Text = provisionalBooking.ArriveDate.Year + "-" + provisionalBooking.ArriveDate.Month + "-" + provisionalBooking.ArriveDate.Day;
            lblDepartDate.Text = provisionalBooking.DepartDate.Year + "-" + provisionalBooking.DepartDate.Month + "-" + provisionalBooking.DepartDate.Day;

            //Get all rooms in booking
            double totalPrice = 0;
            DateTime startDate = new DateTime();
            DateTime endDate = new DateTime();
            startDate = provisionalBooking.ArriveDate;
            endDate = provisionalBooking.DepartDate;
            double noOfDays = (endDate - startDate).TotalDays;
            string htmlOutput = "";
            string[] rooms = invoice.Rooms.Split(',');
            int roomCount = rooms.Count();
            RoomAndType roomAndType = null;
            AvailabilityHandler availabilityHandler = new AvailabilityHandler();
            for (int i = 0; i < roomCount - 1; i++)
            {
                roomAndType = availabilityHandler.GetAvailableRoomDetails(Convert.ToInt32(rooms[i]));
                totalPrice = totalPrice + (roomAndType.Rate * noOfDays);
                htmlOutput += "<tr><td>" + roomAndType.RoomNo + "</td><td>" + roomAndType.Name + "</td><td>R " + roomAndType.Rate + "</td><td>R " + (roomAndType.Rate * noOfDays).ToString() + "</td></tr>";
            }
            //end get all rooms in booking

            litSelectedRooms.Text = htmlOutput;
            double depositAmount = invoiceHandler.GetDepositAmount(bookingID);
            double totalAmount = invoiceHandler.GetTotalAmount(bookingID);
            lblDeposit.Text = depositAmount.ToString();
            lblTotalAmount.Text = totalAmount.ToString();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            int myRole = 1;
            int bookingID = 0;
            bool intTest = false;
            intTest = int.TryParse(Request.QueryString["id"], out bookingID);
            int returnID = 0;
            intTest = false;
            intTest = int.TryParse(Request.QueryString["return"], out returnID);

            if (bookingID == 0)
                Response.Redirect("Default.aspx");

            if (IsPostBack)
            {
                litHeader.Text = "The booking has been cancelled sucessfully!";
                btnYes.Visible = false;
                btnNo.Visible = false;
                btnBack.Visible = true;
            }
            else
            {
                litHeader.Text = "You are about to cancel booking number " + bookingID.ToString() + "<br /><br />Once this booking has been cancelled, this process can't be undone. Are you sure you want to continue?";
            }

            bool loggedIn = false;
            //Checks for a login
            if (Session["MemberID"] != null)
                loggedIn = true;
            if (loggedIn == false)
            {
                Session["LoginRedirect"] = "CancelBooking.aspx?id=" + bookingID.ToString() + "&return=" + returnID.ToString();
                Response.Redirect("Login.aspx");
            }
            //End of login check

            BookingHandler bookingHandler = new BookingHandler();

            int memberID = bookingHandler.GetBookingOwner(bookingID);

            //Checks if role is high enough
            MemberHandler memberHandler = new MemberHandler();
            myRole = memberHandler.GetRole((int)Session["MemberID"]);
            if (myRole != 3 && (int)Session["MemberID"] != memberID)
            {
                Response.Redirect("Default.aspx");
            }
            //End check for role
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            int myRole = 1;
            bool loggedIn = false;
            int memberID = 0;
            bool intTest = false;
            intTest = int.TryParse(Request.QueryString["id"], out memberID);
            if (memberID == 0)
                Response.Redirect("Default.aspx");
            //Checks for a login
            if (Session["MemberID"] != null)
                loggedIn = true;
            if (loggedIn == false)
            {
                Session["LoginRedirect"] = "BookingHistory.aspx?id=";
                Response.Redirect("Login.aspx");
            }
            //End of login check
            MemberHandler memberHandler = new MemberHandler();
            Member member = memberHandler.GetMemberDetails(memberID);
            try
            {
                litMemberName.Text = member.FirstName + ' ' + member.Surname;
            }
            catch (NullReferenceException)
            {
                Response.Redirect("Default.aspx");
            }
            //Checks if role is high enough
            myRole = memberHandler.GetRole((int)Session["MemberID"]);
            if (myRole != 3 && (int)Session["MemberID"] != memberID)
            {
                Response.Redirect("Default.aspx");
            }
            //End check for role

            BookingHandler bookingHandler = new BookingHandler();
            List<Booking> bookingHistory = bookingHandler.GetBookingHistory(memberID);
            if (bookingHistory == null)
                litError.Text = "<h3 style=\"color:red\">There are no previous or current bookings</h3><br />";
            else
            {
                int bookingID = 0;
                string htmlOutput = "";
                string proofOfPayment = "No";
                string arriveDate = "";
                string departDate = "";
                string uploadProofText = "Upload";
                string colour = "blue";
                string status = "";
                string cancelButton = "";
                for (int i = 0; i < bookingHistory.Count; i++)
                {
                    bookingID = bookingHistory[i].BookingID;
                    arriveDate = bookingHistory[i].ArriveDate.Year.ToString() + '-' + bookingHistory[i].ArriveDate.Month.ToString() + '-' + bookingHistory[i].ArriveDate.Day.ToString();
                    departDate = bookingHistory[i].DepartDate.Year.ToString() + '-' + bookingHistory[i].DepartDate.Month.ToString() + '-' + bookingHistory[i].DepartDate.Day.ToString();
                    if (bookingHistory[i].ProofOfPayment == null || bookingHistory[i].ProofOfPayment == "")
                    {
                        proofOfPayment = "No";
                        uploadProofText = "Upload";
                    }
                    else
                    {
                        proofOfPayment = "Yes";
                        uploadProofText = "Re-Upload";
                    }
                    switch (bookingHistory[i].Status)
                    {
                        case "P": colour = "#FF6600";
                            status = "Provisional";
                            break;
                        case "C": colour = "#00C0FF";
                            status = "Cancelled";
                            break;
                        case "D": colour = "#FF3300";
                            status = "Declined";
                            break;
                        case "A": colour = "#66FF66";
                            status = "Confirmed";
                            break;
                        default: colour = "#66CCFF";
                            break;
                    }
                    if (bookingHistory[i].Status != "C" && bookingHistory[i].Status != "D" && bookingHistory[i].ArriveDate > DateTime.Now.AddDays(-1))
                        cancelButton = "<a class=\"btn btn-danger\" style=\"width:130px;height:30px;\" href=\"CancelBooking.aspx?id=" + bookingID.ToString() + "&return=" + memberID.ToString() + "\">Cancel Booking</a>";
                    else
                        cancelButton = "<strong>Unavailable</strong>";

                    htmlOutput += "<tr style=\"background-color:" + colour + "\"><td>" + bookingID.ToString() + "</td><td>" + arriveDate + "</td><td>" + departDate + "</td><td>" + status + "</td><td>" + proofOfPayment + "</td><td>" + "<a class=\"btn btn-success\" style=\"width:100px;height:30px;\" href=\"UploadProof.aspx?id=" + bookingID.ToString() + "\">" + uploadProofText + "</a>" + "</td><td><a class=\"btn btn-warning\" style=\"width:100px;height:30px;\" href=\"Invoice.aspx?id=" + bookingID.ToString() + "\">Invoice</a></td><td>" + cancelButton + "</td></tr>\n";
                }
                litBookingHistory.Text = htmlOutput;
            }
        }