protected void Page_Load(object sender, EventArgs e) { userDAL Users = new userDAL(); houseDAL Houses = new houseDAL(); bookingDAL Bookings = new bookingDAL(); lblHouses.Text = Houses.TotalHouses().ToString(); lblUsers.Text = Users.TotalUsers().ToString(); lblBookings.Text = Bookings.TotalBookings().ToString(); }
protected void btnAddHouse_Click(object sender, EventArgs e) { house.house_name = txtHouseName.Text; house.house_price = decimal.Parse(txtHousePrice.Text); house.house_location = txtHouseLocation.Text; house.house_description = txtHouseDescription.Text; house.added_date = DateTime.Now; house.is_active = ddlIsActive.SelectedValue.ToString(); house.image_name = "no-image.jpg"; //File Upload Starts HEre try { if (ImageUplad.HasFile) { //Generating Random Number Random rand = new Random(); int guid = rand.Next(); string fileName = guid + Path.GetFileName(ImageUplad.FileName); ImageUplad.PostedFile.SaveAs(Server.MapPath("~/images/house/") + fileName); lblImage.Text = "Image " + fileName + " Successfully Uploaded"; house.image_name = fileName; } else { lblImage.Text = "No Image Selected"; } } catch (Exception ex) { lblImage.Text = "Failed to upload Image."; } finally { } //Image Upload Ends Here //Object for DAL houseDAL DAL = new houseDAL(); bool success = DAL.AddHouse(house); if (success == true) { lblResult.Text = "House Successfully Added."; Clear(); } else { lblResult.Text = "Failed to Add New House."; } }
protected void btnBook_Click(object sender, EventArgs e) { //Get VAlues from UI book.house_id = id; book.first_name = txtFirstName.Text; book.last_name = txtLastName.Text; book.email = txtEmail.Text; book.contact = txtContact.Text; book.address = txtAddress.Text; book.booked_date = DateTime.Now; //Object for DAL bookingDAL dal = new bookingDAL(); bool success = dal.AddBooking(book); if (success == true) { //Update Booking Table and set is_active to no houseDAL housedal = new houseDAL(); bool change = housedal.ActivityChange(id); if (change == true) { lblUpdate.Text = "Updated."; } else { lblUpdate.Text = "Update Failed."; } lblBook.Text = "Your House Successfully Booked."; Clear(); } else { lblBook.Text = "Failed to book your house."; } }