protected void ddlRoomType_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (ddlRoomType.SelectedValue != "NA")
            {
                ddlRoomType.Items[0].Text = "Show All Rooms";
                //This selected index changed event will load rooms selected only from a specific room type
                DateTime startDate = new DateTime();
                DateTime endDate = new DateTime();
                try
                {
                    startDate = (DateTime)Session["StartDate"];
                    endDate = (DateTime)Session["EndDate"];
                }
                catch (NullReferenceException)
                {
                    Response.Redirect("Availability.aspx");
                }

                litHeader.Text = "<h3>Rooms available between " + startDate.Year + "-" + startDate.Month + "-" + startDate.Day + " and " + endDate.Year + "-" + endDate.Month + "-" + endDate.Day + "</h3>";

                int roomID = 0;
                string htmlOutput = "";
                string picture = "";
                int typeID;
                typeID = Convert.ToInt32(ddlRoomType.SelectedValue);
                AvailabilityHandler availabilityHandler = new AvailabilityHandler();
                List<RoomAndType> listRoomAvailability = availabilityHandler.GetListOfSpecificRooms(typeID);

                //Check to make sure there is rooms in the system
                if (listRoomAvailability == null)
                    litHeader.Text = "<h3 style=\"color:red\">There are currently no rooms available in the category you selected</h3>";
                else
                {
                    for (int i = 0; i < listRoomAvailability.Count; i++)
                    {
                        roomID = listRoomAvailability[i].RoomID;
                        if (listRoomAvailability[i].Picture != null && listRoomAvailability[i].Picture != "")
                            picture = "<a href=\"" + "." + listRoomAvailability[i].Picture.Replace('\\', '/') + "\" data-lightbox=\"image" + i.ToString() + "\">View Picture</a>";
                        else
                            picture = "No Picture Available";
                        if (availabilityHandler.CheckAvailability(roomID, startDate, endDate) == true)
                            htmlOutput += "<tr><td>" + listRoomAvailability[i].RoomNo.ToString() + "</td><td>" + listRoomAvailability[i].Name + "</td><td>" + picture + "</td><td>" + listRoomAvailability[i].MaxCapacity.ToString() + "</td><td>R " + listRoomAvailability[i].Rate.ToString() + "</td><td><input type=\"button\" value=\"View\" onclick=\"window.open('RoomDetails.aspx?id=" + listRoomAvailability[i].RoomID + "', 'name', 'height=270,width=270')\" /></td><td><input type=\"checkbox\" onclick=\"AddRoomToBooking(" + listRoomAvailability[i].RoomID + ")\" />" + "</td></tr>\n";
                    }
                    litAvailableRooms.Text = htmlOutput;
                }
            }//End of if statement
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            //Populate room type drop down list
            if (!IsPostBack)
            {
                RoomTypeHandler roomTypeHandler = new RoomTypeHandler();
                List<RoomType> listRoomTypes = roomTypeHandler.GetRoomTypeList();
                ddlRoomType.DataSource = listRoomTypes;
                ddlRoomType.DataValueField = "TypeID";
                ddlRoomType.DataTextField = "Name";
                ddlRoomType.DataBind();
                ddlRoomType.Items.Insert(0, new ListItem("Select Room Type", "NA"));
            }

            DateTime startDate = new DateTime();
            DateTime endDate = new DateTime();
            try
            {
                startDate = (DateTime)Session["StartDate"];
                endDate = (DateTime)Session["EndDate"];
            }
            catch (NullReferenceException)
            {
                Response.Redirect("Availability.aspx");
            }

            litHeader.Text = "<h3>Rooms available between " + startDate.Year + "-" + startDate.Month + "-" + startDate.Day + " and " + endDate.Year + "-" + endDate.Month + "-" + endDate.Day + "</h3>";

            int roomID = 0;
            string htmlOutput = "";
            string picture = "";
            AvailabilityHandler availabilityHandler = new AvailabilityHandler();
            List<RoomAndType> listRoomAvailability = availabilityHandler.GetListOfAllRooms();

            //Check to make sure there is rooms in the system
            if (listRoomAvailability == null)
                litHeader.Text = "<h3>There are currently no rooms added to the system</h3>";
            else
            {
                for (int i = 0; i < listRoomAvailability.Count; i++)
                {
                    roomID = listRoomAvailability[i].RoomID;
                    if (listRoomAvailability[i].Picture != null && listRoomAvailability[i].Picture != "")
                        picture = "<a href=\"" + "." + listRoomAvailability[i].Picture.Replace('\\', '/') + "\" data-lightbox=\"image" + i.ToString() + "\">View Picture</a>";
                    else
                        picture = "No Picture Available";
                    if (availabilityHandler.CheckAvailability(roomID, startDate, endDate) == true)
                        htmlOutput += "<tr><td>" + listRoomAvailability[i].RoomNo.ToString() + "</td><td>" + listRoomAvailability[i].Name + "</td><td>" + picture + "</td><td>" + listRoomAvailability[i].MaxCapacity.ToString() + "</td><td>R " + listRoomAvailability[i].Rate.ToString() + "</td><td><input type=\"button\" value=\"View\" onclick=\"window.open('RoomDetails.aspx?id=" + listRoomAvailability[i].RoomID + "', 'name', 'height=270,width=270')\" /></td><td><input type=\"checkbox\" onclick=\"AddRoomToBooking(" + listRoomAvailability[i].RoomID + ")\" />" + "</td></tr>\n";
                }
                litAvailableRooms.Text = htmlOutput;
            }
        }
Пример #3
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();
        }
Пример #4
0
        public void btnAddRoom_Click(object sender, EventArgs e)
        {
            AvailabilityHandler availabilityHandler = new AvailabilityHandler();
            RoomHandler roomHandler = new RoomHandler();

            string picturePath = @"\RoomPictures\";

            //check if room exists
            if (roomHandler.ValidateRoomNo(txtRoomNo.Text) == false)
            {
                Room room = new Room();

                room.RoomNo = txtRoomNo.Text;
                room.Description = txtDescription.Text;
                room.TypeID = Convert.ToInt32(dlTypeID.SelectedValue);

                if (cbWifi.Checked)
                    room.WifiStatus = "Yes";
                else
                    room.WifiStatus = "No";

                if (cbAircon.Checked)
                    room.AirconStatus = "Yes";
                else
                    room.AirconStatus = "No";

                if (cbRoomservice.Checked)
                    room.RoomserviceStatus = "Yes";
                else
                    room.RoomserviceStatus = "No";

                if (cbTelevision.Checked)
                    room.TelevisionStatus = "Yes";
                else
                    room.TelevisionStatus = "No";

                //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("."));

                                //append room number to the end of the file name
                                filename += "_" + room.RoomNo;

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

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

                                room.Picture = picturePath;

                                int lastRoomID = 0;
                                DateTime currentYear = DateTime.Now;

                                lastRoomID = roomHandler.GetLastRoomID();

                                if (roomHandler.AddNewRoom(room) == false)
                                {
                                    //populate availability table
                                    availabilityHandler.AddAvailabilityRecord(lastRoomID, currentYear.Year);
                                    availabilityHandler.AddAvailabilityRecord(lastRoomID, (currentYear.Year + 1));

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

                                    //delay redirect to alert user of page change
                                    lblRedirect.Text = "Redirecting to room list in 5 seconds.";
                                    Response.Write("<script type=\"text/javascript\">setTimeout(function () { window.location.href = \"RoomList.aspx\"; }, 5000);</script>");
                                }
                            }
                            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";
                    }

                }

                //no picture is selected
                else
                {
                    room.Picture = "";

                    //run SQL insert
                    if (roomHandler.AddNewRoom(room) == false)
                    {
                        //populate availability table
                        int lastRoomID = 0;
                        DateTime currentYear = DateTime.Now;

                        lastRoomID = roomHandler.GetLastRoomID();
                        availabilityHandler.AddAvailabilityRecord(lastRoomID, currentYear.Year);
                        availabilityHandler.AddAvailabilityRecord(lastRoomID, (currentYear.Year + 1));

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

                        //delay redirect to alert user of page change
                        lblRedirect.Text = "Redirecting to room list in 5 seconds.";
                        Response.Write("<script type=\"text/javascript\">setTimeout(function () { window.location.href = \"RoomList.aspx\"; }, 5000);</script>");
                    }
                }
            }
            else
                lblProgress.Text = "This room number already exists!";
        }
Пример #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            double totalPrice = 0;
            string selectedRooms = null;
            DateTime startDate = new DateTime();
            DateTime endDate = new DateTime();
            try
            {
                selectedRooms = (string)Session["SelectedRooms"];
                startDate = (DateTime)Session["StartDate"];
                endDate = (DateTime)Session["EndDate"];
            }
            catch (NullReferenceException)
            {
                Response.Redirect("Availability.aspx");
            }

            double noOfDays = (endDate - startDate).TotalDays;
            string htmlOutput = "";
            string[] rooms = null;
            try
            {
                rooms = selectedRooms.Split(',');
            }
            catch (NullReferenceException)
            {
                Response.Redirect("Availability.aspx");
            }

            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>" + roomAndType.MaxCapacity + "</td><td>R " + roomAndType.Rate + "</td><td>R " + (roomAndType.Rate * noOfDays).ToString() +"</td></tr>";
            }

            litAvailableRooms.Text = htmlOutput;

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

            double depositPercent = business.DepositPercent;
            depositPercent = depositPercent / 100;
            lblDeposit.Text = (totalPrice * depositPercent).ToString();
            lblTotalCost.Text = totalPrice.ToString();

            litDates.Text = startDate.Year + "-" + startDate.Month + "-" + startDate.Day + " to " + endDate.Year + "-" + endDate.Month + "-" + endDate.Day;
        }