Ejemplo n.º 1
0
 bool verification = true; //declare the bool verification, to check if the item is true
 protected void Page_Load(object sender, EventArgs e)
 {
     //check the session country name is null
     if (Session["countryName"] == null)
     {
         Response.Redirect("AHRPage.aspx"); //brings back to the AHR page
     }
     else
     {
         if (!IsPostBack)
         {
             lblNoAttraction.Visible = false;
             List <Attraction> attractions = AttractionDB.getAttractionByCountry(Session["countryName"].ToString(), verification); //get the attraction list and the item must be approved by an admin -- the verification must be true to show into public website
             if (attractions.Count != 0)                                                                                           //check whether the attraction is not null
             {
                 //show the attraction list
                 lvAttraction.DataSource = attractions;
                 lvAttraction.DataBind();
                 lblCountry.Text       = Session["countryName"].ToString(); //show country name in the label
                 Session["attraction"] = attractions;                       //brings the session for attraction
             }
             else
             {
                 lblNoAttraction.Visible = true; //when there is no attraction, show the error message
             }
         }
     }
 }
Ejemplo n.º 2
0
    protected void btnARegister_Click(object sender, EventArgs e)
    {
        string imagefile = "notavailable.jpg";

        if (FileUpload2.HasFile) //checking whether the file upload has the file
        {
            imagefile = FileUpload2.FileName;
            FileUpload2.SaveAs(Server.MapPath("~/images/" + imagefile));//store the file in the images folder
        }
        //attraction
        Attraction a = new Attraction()
        {
            OrgEmail     = tbxAEmail.Text,
            Name         = tbxAName.Text,
            RegID        = tbxARegID.Text,
            Address      = tbxAddressA.Text,
            PostalCode   = tbxAPostalCode.Text,
            City         = tbxACity.Text,
            Country      = tbxACountry.Text,
            Password     = tbxAPassword.Text,
            ContactNo    = tbxAPhone.Text,
            Description  = "Not Applicable",
            StarRating   = Convert.ToInt32(5),
            OpeningHours = tbxAHour.Text,
            Photo        = imagefile,
            Verification = false
        };
        int id = AttractionDB.insertAttraction(a);

        lblOutput.Text = id + "Registered Successfully!";
    }
Ejemplo n.º 3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        //if the sessiom is null
        if (Session["attraction"] == null)
        {
            Response.Redirect("AttractionPage.aspx"); //brings back to the attraction page
        }
        else
        {
            //create a new list for attraction
            List <Attraction> attList = new List <Attraction>();
            //retrieve the attraction id from the session and use it to get a attraction from the database
            Attraction att = AttractionDB.getAttractionByID(Session["attraction"].ToString());
            attList.Add(att);                  //add a vehicle to attraction list
            lvAttraction.DataSource = attList; //add the attraction list to a list view data source
            lvAttraction.DataBind();           //bind the data into listview

            //get all feedbacks of a vehicle
            List <Review> rvList = ReviewDB.getAllAttractionReviewByID(Convert.ToInt32(Session["attraction"]));
            attReviews.DataSource = rvList;
            attReviews.DataBind();
            if (rvList.Count == 0)                                            //checking whether there is no feedback available for attraction
            {
                lblOutput.Text = "No feedback available for this attraction"; //show the message
            }
        }
    }
    private void getAllAttraction()
    {
        //list the gridview from database
        List <Attraction> attractions = AttractionDB.getAllAttraction();

        gvAttraction.DataSource = attractions;
        gvAttraction.DataBind();
    }
    protected void gvAttraction_SelectedIndexChanged(object sender, EventArgs e)
    {
        List <Attraction> attractions = AttractionDB.getAllAttraction();
        Attraction        a           = attractions[gvAttraction.SelectedIndex];

        Session["emailA"]      = a;
        Session["attraction"]  = a.Name;
        Session["countryName"] = a.Country;
        Response.Redirect("AAdetails.aspx");
    }
Ejemplo n.º 6
0
    protected void btnSearch_Click(object sender, EventArgs e)
    {
        string userinput = tbxInput.Text;

        using (WebClient wc = new WebClient())
        {
            var json = wc.DownloadString("https://maps.googleapis.com/maps/api/place/textsearch/json?query=" + tbxInput.Text + "&key=AIzaSyA-Brzltyb6U-xbPlQyCUM2n4F_c130xl0");
            //tbxOutput.Text = json;
            JObject jt     = JObject.Parse(json);
            JToken  c      = jt.GetValue("results");
            String  output = "";
            foreach (var result in c)
            {
                output += result.Value <string>("formatted_address").ToString() + Environment.NewLine;
                output += result.Value <string>("name").ToString() + Environment.NewLine;
                output += result.Value <int>("rating") + Environment.NewLine;

                Attraction a = new Attraction()
                {
                    OrgEmail     = "",
                    Name         = result.Value <string>("name").ToString(),
                    RegID        = "",
                    Address      = result.Value <string>("formatted_address").ToString(),
                    PostalCode   = "",
                    City         = "",
                    Country      = "",
                    Password     = "******",
                    ContactNo    = "",
                    Description  = "Not Applicable",
                    StarRating   = Convert.ToInt32(5),
                    OpeningHours = "",
                    Photo        = "",
                    Verification = true
                };

                int id = AttractionDB.insertAttraction(a);
                lblOutput.Text = id + "Registered Successfully!";
            }
            tbxOutput.Text = output;
        }
    }
Ejemplo n.º 7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            GetWeatherInfo();               //get the weather informatio
        }
        bool verification = true;           //initialize the verification is true

        if (Session["countryName"] != null) //if the session for countryName is not null
        {
            //show the top 4 of attraction into gridview
            List <Attraction> attractions = AttractionDB.getTOP4AttractionByCountry(Session["countryName"].ToString(), verification);
            dlAttraction.DataSource = attractions;
            dlAttraction.DataBind();
        }
        else
        {
            Response.Redirect("AHRPage.aspx");
        }

        //show the top 4 of hotel into gridview
        List <Hotel> hotels = HotelDB.getTOP4HotelByCountry(Session["countryName"].ToString(), verification);

        dlHotel.DataSource = hotels;
        dlHotel.DataBind();
        //show the top 4 of restaurant into gridview
        List <Restaurant> restaurants = RestaurantDB.getTOP4RestaurantByCountry(Session["countryName"].ToString(), verification);

        dlRestaurant.DataSource = restaurants;
        dlRestaurant.DataBind();

        //if the session of countryName is not null
        if (Session["countryName"] != null)
        {
            //show the country name in label
            lblCountry.Text = Session["countryName"].ToString();
        }
    }
Ejemplo n.º 8
0
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        //get admin from database
        Admin d = AdminDB.getAdminbyID(tbxEmail.Text, tbxPassword.Text);

        if (d != null)                              //if admin is not null
        {
            if (d.AdminID == tbxEmail.Text)         //check the admin id from database, matched or not
            {
                if (d.Password == tbxPassword.Text) //check the admin password from database, matched or not
                {
                    //create a session for admin
                    Session["admin"] = d;
                    //redirect to AdminView page
                    Server.Transfer("AdminView.aspx");
                }
            }
        }
        else
        {
            lblOutput.Text = "sorry admin cannot login!"; //to show error message
        }

        if (ddlCustOrg.SelectedItem.Text == "Customer")                                  //user selected on customer
        {
            Customer c = CustomerDB.getCustomerByEmail(tbxEmail.Text, tbxPassword.Text); //get the customer details from database
            if (c != null)                                                               //if customer is not null
            {
                //customer email and password must matched from the databse
                if (c.CustEmail == tbxEmail.Text)
                {
                    if (c.Password == tbxPassword.Text)
                    {
                        //create session for user
                        Session["user"]      = c;
                        Session["emailUser"] = c.CustEmail;
                        //redirect to the default page
                        Server.Transfer("Default.aspx");
                    }
                    else
                    {
                        lblOutput.Text = "Incorrect password"; //show error message
                    }
                }
            }
            else
            {
                lblOutput.Text = "Incorrect email/password"; //show error message
            }
        }


        else if (ddlCustOrg.SelectedItem.Text == "Hotel Owner")                 //user selected on hotel owner
        {
            Hotel h = HotelDB.getHotelByEmail(tbxEmail.Text, tbxPassword.Text); //get the data from database
            //check the data is not null
            if (h != null)
            {
                //email and password must matched into the database
                if (h.OrgEmail == tbxEmail.Text)
                {
                    if (h.Password == tbxPassword.Text)
                    {
                        //create session for user
                        Session["userHotel"]  = h;
                        Session["hotelEmail"] = h.OrgEmail;
                        Session["hotelID"]    = h.HotelID;

                        //redirect to the default page
                        Server.Transfer("Default.aspx");
                    }
                    else
                    {
                        lblOutput.Text = "Incorrect password"; //show error message
                    }
                }
            }
            else
            {
                lblOutput.Text = "Incorrect email/password"; //show error message
            }
        }
        else if (ddlCustOrg.SelectedItem.Text == "Restaurant Owner") //user selected on the restaurant owner
        {
            //get the data from database
            Restaurant r = RestaurantDB.getRestaurantByEmail(tbxEmail.Text, tbxPassword.Text);
            //check the data is not null
            if (r != null)
            {
                //email and password must matched into database
                if (r.OrgEmail == tbxEmail.Text)
                {
                    if (r.Password == tbxPassword.Text)
                    {
                        //create session for user
                        Session["userRestaurant"]  = r;
                        Session["restaurantEmail"] = r.OrgEmail;
                        Session["restaurantID"]    = r.RestaurantID;

                        //redirect to the default page
                        Server.Transfer("Default.aspx");
                    }
                    else
                    {
                        lblOutput.Text = "Incorrect password"; //show error message
                    }
                }
            }
            else
            {
                lblOutput.Text = "Incorrect email/password"; //show error message
            }
        }
        else if (ddlCustOrg.SelectedItem.Text == "Attraction Owner") //user selected on the attraction owner
        {
            //get the data from database
            Attraction a = AttractionDB.getAttractionByEmail(tbxEmail.Text, tbxPassword.Text);
            //check the data if not null
            if (a != null)
            {
                //email and password must matched into our database
                if (a.OrgEmail == tbxEmail.Text)
                {
                    if (a.Password == tbxPassword.Text)
                    {
                        //create session for user
                        Session["userAttraction"]  = a;
                        Session["attractionEmail"] = a.OrgEmail;
                        Session["attractionID"]    = a.AttractionID;

                        //redirect to the default page
                        Server.Transfer("Default.aspx");
                    }
                    else
                    {
                        lblOutput.Text = "Incorrect password";  //show error message
                    }
                }
            }
            else
            {
                lblOutput.Text = "Incorrect email/password"; //show error message
            }
        }
    }
Ejemplo n.º 9
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        //initialize the random number generator
        Random r = new Random();
        //set the new password from random number generator
        int newPw = r.Next(1, 100000);

        int  result = 0;                                //initialze the result
        bool found  = true;                             //initialize the boolean is true

        if (ddlCustOrg.SelectedItem.Text == "Customer") //when user choose to reset password for customer
        {
            //get the customer from database
            Customer c = CustomerDB.getACustomerByEmail(tbxEmail.Text);
            if (c != null)                                 //if the customer is not null
            {
                c.Password = newPw.ToString();             //set the new password
                result     = CustomerDB.updateCustomer(c); //update into customer database
            }
            else
            {
                found = false; //cannot find the customer from the database
            }
        }
        else if (ddlCustOrg.SelectedItem.Text == "Hotel Owner") //when user choose to reset password for hotel owner
        {
            Hotel h = HotelDB.getAHotelByEmail(tbxEmail.Text);  //get the hotel owner from database
            if (h != null)                                      //if the hotel is not null
            {
                h.Password = newPw.ToString();                  //set the new password
                result     = HotelDB.updateHotel(h);            //update into hotel database
            }
            else
            {
                found = false; //cannot find the hotel owner from the database
            }
        }
        else if (ddlCustOrg.SelectedItem.Text == "Attraction Owner")          //when user choose to reset password for attraction
        {
            Attraction a = AttractionDB.getAAttractionByEmail(tbxEmail.Text); //get the attraction owner from database
            if (a != null)                                                    //if the attraction is not null
            {
                //set the new password
                a.Password = newPw.ToString();
                //update into attraction database
                result = AttractionDB.updateAttraction(a);
            }
            else
            {
                found = false; //canoot find the attraction from the database
            }
        }
        else if (ddlCustOrg.SelectedItem.Text == "Restaurant Owner")           //when user choose to reset password for restaurant owner
        {
            Restaurant ra = RestaurantDB.getARestaurantByEmail(tbxEmail.Text); //get the restaurant owner from database
            if (ra != null)                                                    //if the restaurant is not null
            {
                //set the new password
                ra.Password = newPw.ToString();
                //update into restaurant database
                result = RestaurantDB.updateRestaurant(ra);
            }
            else
            {
                found = false; //cannot find the restaurant from the database
            }
        }
        if (found)          //if found
        {
            if (result > 0) //result cannot be zero
            {
                try         //use try and catch to send an email to the organization and customer
                {
                    SmtpClient client = new SmtpClient("smtp.gmail.com");
                    client.EnableSsl   = true;
                    client.Credentials = new NetworkCredential("*****@*****.**", "smart-travel1005");

                    MailMessage msg = new MailMessage("*****@*****.**", tbxEmail.Text);
                    msg.Subject = "New Password";
                    msg.Body    = "Your new password is: " + newPw.ToString() + "\r\n Please change your password again";
                    client.Send(msg); //send an email
                    lblOutput.Text = "New Password has been sent to your email";
                    return;
                }
                catch (Exception ex)
                {
                    lblOutput.Text = "Active internet connection needed!"; //show error message when user do not have internet connection
                    return;
                }
            }
            else
            {
                lblOutput.Text = "Fails to update the password"; //show error message when user cannot update the password
                return;
            }
        }
        lblOutput.Text = "Account with this email address does not exist. Sign up for the account"; //if the account is not exist with our website
    }
 protected void btnUpdate_Click(object sender, EventArgs e)
 {
     if (Session["user"] != null)
     {
         //calling member class to the session of user
         Customer c = (Customer)Session["user"];
         c.Name          = tbxName.Text;
         c.Gender        = tbxGender.Text;
         c.DateOfBirth   = Convert.ToDateTime(tbxDOB.Text);
         c.Address       = tbxAddress.Text;
         c.PostalCode    = tbxPostalCode.Text;
         c.PersonalID    = tbxPID.Text;
         c.Nationality   = tbxNationality.Text;
         c.PhoneNumber   = Convert.ToInt32(tbxPhone.Text);
         c.CustEmail     = tbxEmail.Text;
         c.Password      = tbxPassword.Text;
         Session["user"] = c;
         int row = CustomerDB.updateCustomer(c);
         //display an output
         lblOutput.Text = "Update successfully!";
         databindedCust();
     }
     else if (Session["userAttraction"] != null)
     {
         Attraction a = (Attraction)Session["userAttraction"];
         a.Name         = tbxCName.Text;
         a.RegID        = tbxRID.Text;
         a.Address      = tbxCAddress.Text;
         a.PostalCode   = tbxCPostalCode.Text;
         a.City         = tbxCCity.Text;
         a.Country      = tbxCCountry.Text;
         a.Password     = tbxCpass.Text;
         a.ContactNo    = tbxCPhone.Text;
         a.OrgEmail     = tbxCEmail.Text;
         a.Password     = tbxCPassword.Text;
         a.Description  = tbxDesc.Text;
         a.OpeningHours = tbxOHour.Text;
         string imagefile = "notavailable";
         if (FileUpload1.HasFile)
         {
             imagefile = FileUpload1.FileName;
             FileUpload1.SaveAs(Server.MapPath("../images/" + imagefile));
             a.Photo             = FileUpload1.FileName;
             imgProfile.ImageUrl = "../images/" + a.Photo;
         }
         Session["userAttraction"] = a;
         lblOutput.Text            = "Update successfully!";
         int row = AttractionDB.updateAttraction(a);
         databindedOrg();
     }
     else if (Session["userRestaurant"] != null)
     {
         Restaurant r = (Restaurant)Session["userRestaurant"];
         r.Name         = tbxCName.Text;
         r.RegID        = tbxRID.Text;
         r.Address      = tbxCAddress.Text;
         r.PostalCode   = tbxCPostalCode.Text;
         r.City         = tbxCCity.Text;
         r.Country      = tbxCCountry.Text;
         r.Password     = tbxCpass.Text;
         r.ContactNo    = tbxCPhone.Text;
         r.OrgEmail     = tbxCEmail.Text;
         r.Password     = tbxCPassword.Text;
         r.Description  = tbxDesc.Text;
         r.OpeningHours = tbxOHour.Text;
         string imagefile = "notavailable";
         if (FileUpload1.HasFile)
         {
             imagefile = FileUpload1.FileName;
             FileUpload1.SaveAs(Server.MapPath("../images/" + imagefile));
             r.Photo             = FileUpload1.FileName;
             imgProfile.ImageUrl = "../images/" + r.Photo;
         }
         r.License = tbxLicenseNo.Text;
         Session["userRestaurant"] = r;
         lblOutput.Text            = "Update successfully!";
         int row = RestaurantDB.updateRestaurant(r);
         databindedROrg();
     }
     else if (Session["userHotel"] != null)
     {
         Hotel h = (Hotel)Session["userHotel"];
         h.Name        = tbxCName.Text;
         h.RegID       = tbxRID.Text;
         h.Address     = tbxCAddress.Text;
         h.PostalCode  = tbxCPostalCode.Text;
         h.City        = tbxCCity.Text;
         h.Country     = tbxCCountry.Text;
         h.Password    = tbxCpass.Text;
         h.ContactNo   = tbxCPhone.Text;
         h.OrgEmail    = tbxCEmail.Text;
         h.Password    = tbxCPassword.Text;
         h.Description = tbxDesc.Text;
         string imagefile = "notavailable";
         if (FileUpload1.HasFile)
         {
             imagefile = FileUpload1.FileName;
             FileUpload1.SaveAs(Server.MapPath("../images/" + imagefile));
             h.Photo             = FileUpload1.FileName;
             imgProfile.ImageUrl = "../images/" + h.Photo;
         }
         h.License            = tbxOHour.Text;
         Session["userHotel"] = h;
         lblOutput.Text       = "Update successfully!";
         int row = HotelDB.updateHotel(h);
         databindedHOrg();
     }
 }