コード例 #1
0
        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
        }
コード例 #2
0
        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>");
            */
        }
コード例 #3
0
        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
        }