コード例 #1
0
    protected void btnHRegister_Click(object sender, EventArgs e)
    {
        string imagefile = "notavailable.jpg";

        if (FileUpload3.HasFile) //checking whether the file upload has the file
        {
            imagefile = FileUpload3.FileName;
            FileUpload3.SaveAs(Server.MapPath("~/images/" + imagefile));//store the file in the images folder
        }
        //hotel
        Random rndRandom = new Random();
        int    newLicNo  = rndRandom.Next(1, 1000);
        Hotel  h         = new Hotel()
        {
            OrgEmail     = tbxHEmail.Text,
            Name         = tbxHName.Text,
            RegID        = tbxHRegID.Text,
            Address      = tbxHAddress.Text,
            PostalCode   = tbxHPostalCode.Text,
            City         = tbxHCity.Text,
            Country      = tbxHCountry.Text,
            Password     = tbxHPassword.Text,
            ContactNo    = tbxHPhone.Text,
            Description  = "Not Applicable",
            License      = "SH" + newLicNo,
            StarRating   = Convert.ToInt32(5),
            Photo        = imagefile,
            Verification = false
        };
        int id = HotelDB.insertHotel(h);

        lblOutput.Text = id + "Registered Successfully!";
    }
コード例 #2
0
        private void btn_addHotel_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                byte[]       img = null;
                FileStream   fs  = new FileStream(imgLocation, FileMode.Open, FileAccess.Read);
                BinaryReader br  = new BinaryReader(fs);
                img = br.ReadBytes((int)fs.Length);

                using (HotelDB db = new HotelDB())
                {
                    Hotels hotel = new Hotels();
                    hotel.Name        = txt_Name.Text;
                    hotel.Address     = txt_Address.Text;
                    hotel.Description = txt_Description.Text;
                    hotel.Stars       = Convert.ToInt32(txt_Stars.Text);
                    hotel.RoomsCount  = Convert.ToInt32(txt_RoomsCount.Text);
                    hotel.Photo       = img;
                    db.Hotels.Add(hotel);

                    db.SaveChanges();
                }
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
コード例 #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["HotelID"] != null)
        {
            List <Hotel> hotels = new List <Hotel>();
            //get the hotel from the database using hotel id
            Hotel h = HotelDB.getHotelByID(Session["HotelID"].ToString());
            hotels.Add(h);                       //add the account to the hotel list
            lvAccommodation.DataSource = hotels; //add the hotel list to list view data source
            lvAccommodation.DataBind();          //bind the list view data

            //retrieve all the feedback available for an hotel from the database and store them in a list
            List <Review> rvList = ReviewDB.getAllHotelReviewByID(Convert.ToInt32(Session["HotelID"]));
            AcmReviews.DataSource = rvList; //add the datasource to the grid view
            AcmReviews.DataBind();          // bind the grid view data
            if (rvList.Count == 0)          //checking whether there is a feedback availble for that hotel
            {
                lblOutput.Text = "No feedback available for this hotel";
            }
        }
        else
        {
            Response.Redirect("HomePage.aspx"); //transfer the page to view hotel
        }
    }
コード例 #4
0
    //to accept the attraction information details (update verification from false to true) -- user can show the attraction information into public website
    protected void btnAccept_Click(object sender, EventArgs e)
    {
        Hotel a = (Hotel)Session["emailH"];

        a.Verification    = true;
        Session["emailH"] = a;
        int row = HotelDB.updateHotelVerify(a); //to update the row into database
    }
コード例 #5
0
    private void getAllHotel()
    {
        //list the gridview from database
        List <Hotel> hotels = HotelDB.getAllHotel();

        gvHotel.DataSource = hotels;
        gvHotel.DataBind();
    }
コード例 #6
0
    protected void btnDelete_Click(object sender, EventArgs e)
    {
        Hotel  a   = (Hotel)Session["emailH"];
        string id  = a.OrgEmail;
        int    row = HotelDB.deleteHotel(id); //to delete the row from database

        Response.Redirect("Homepage.aspx");   //to redirect to the homepage
    }
コード例 #7
0
    protected void gvHotel_SelectedIndexChanged(object sender, EventArgs e)
    {
        List <Hotel> hotels = HotelDB.getAllHotel();
        Hotel        h      = hotels[gvHotel.SelectedIndex];

        Session["emailH"]      = h;
        Session["hotel"]       = h.Name;
        Session["countryName"] = h.Country;
        Response.Redirect("AHdetails.aspx");
    }
コード例 #8
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            //to get data from database
            List <Hotel> hotels = HotelDB.getHotelByCountry(Session["countryName"].ToString(), verification);
            //check the data is not null
            if (hotels.Count != 0)
            {
                Session["hotel"] = hotels; //create hotel session

                lblNoAcm.Visible   = false;
                lvHotel.DataSource = hotels;
                lvHotel.DataBind();
            }
            else
            {
                lblNoAcm.Visible = true; //show the error message
            }
        }
        lblCountry.Text = Session["countryName"].ToString(); //show the country name
    }
コード例 #9
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();
        }
    }
コード例 #10
0
ファイル: DbManager.cs プロジェクト: Flamious/HotelManagement
 public DbManager()
 {
     db = new HotelDB();
 }
コード例 #11
0
 public CustomerRepository()
 {
     _context = new HotelDB();
 }
コード例 #12
0
 public AccountRepository(HotelDB dbcontext)
 {
     this.db = dbcontext;
 }
コード例 #13
0
ファイル: HotelManager.cs プロジェクト: llooiicc9/Agricathon
 //Récupère un hotel selon son id
 public static Hotel GetHotelById(int idHotelDesired)
 {
     return(HotelDB.GetHotelById(idHotelDesired));
 }
コード例 #14
0
 public static List <Hotel> GetHotelsByDateLocationAndNbPerson(DateTime beginDate, DateTime endDate, string location, int nbPerson, int minCategory, int maxCategory, bool?hasWifi = null, bool?hasParking = null)
 {
     return(HotelDB.GetHotelsByDateLocationAndNbPerson(beginDate, endDate, location, nbPerson, minCategory, maxCategory, hasWifi, hasParking));
 }
 public static double GetHotelOccupationAtDateFromId(int IdHotel, DateTime Date)
 {
     return(HotelDB.GetHotelOccupationAtDateFromId(IdHotel, Date));
 }
コード例 #16
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
    }
コード例 #17
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
            }
        }
    }
コード例 #18
0
 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();
     }
 }
コード例 #19
0
 // Appelle la requête qui récupère un hôtel en fonction d'un identifiant en paramètre
 public static Hotel GetHotel(int idHotel)
 {
     return(HotelDB.GetHotel(idHotel));
 }
コード例 #20
0
 public ServiceRepository(HotelDB dbcontext)
 {
     this.db = dbcontext;
 }
コード例 #21
0
 public ModifierRepository(HotelDB dbcontext)
 {
     this.db = dbcontext;
 }
コード例 #22
0
 public CheckInRepository(HotelDB dbcontext)
 {
     this.db = dbcontext;
 }
コード例 #23
0
ファイル: HotelManager.cs プロジェクト: llooiicc9/Agricathon
 //Récupère tous les hotels dans une liste
 public static List <Hotel> GetAllHotel()
 {
     return(HotelDB.GetAllHotel());//djeéajfékadsfj
 }
 public static List <Hotel> GetAllHotel()
 {
     return(HotelDB.GetAllHotel());
 }
コード例 #25
0
 public BookingController()
 {
     //***instantiate the HotelDB object to communicate with the database
     hotelDB  = new HotelDB();
     bookings = hotelDB.Bookings;
 }
 public static Hotel GetHotelFromId(int IdHotel)
 {
     return(HotelDB.GetHotelFromId(IdHotel));
 }
コード例 #27
0
 public ReservationRepository()
 {
     _context = new HotelDB();
 }
コード例 #28
0
 public static Hotel GetHotelById(int id)
 {
     return(HotelDB.GetHotelfromId(id));
 }
コード例 #29
0
ファイル: GuestController.cs プロジェクト: huntingphi/REHOMAS
 public GuestController()
 {
     //***instantiate the HotelDB object to communicate with the database
     hotelDB = new HotelDB();
     guests  = hotelDB.Guests;
 }
コード例 #30
0
 public RoomTypeRepository(HotelDB dbcontext)
 {
     this.db = dbcontext;
 }