public Rooms(RoomNo roomNo, RoomType type, double roomPrice, List <Booking_Date> bd) // This is the overloaded constractor of the bill with the values below. { this.roomNo = roomNo; this.type = type; this.roomPrice = roomPrice; this.bd = bd; }
public List <RoomNo> GetAllRoom() { SqlConnection connection = new SqlConnection(connectionString); string query = "SELECT * FROM RoomNo"; SqlCommand command = new SqlCommand(query, connection); connection.Open(); SqlDataReader reader = command.ExecuteReader(); List <RoomNo> rooms = new List <RoomNo>(); while (reader.Read()) { RoomNo aRoom = new RoomNo { RoomId = (int)reader["RoomId"], RoomName = reader["RoomName"].ToString() }; rooms.Add(aRoom); } reader.Close(); connection.Close(); return(rooms); }
public override void IsValid() { if (DateTime.Parse(ClassDate) < DateTime.Today) { throw new Exception("Class date cannot be set in the past"); } if (!(ClassType == ClassTypes.Lab || ClassType == ClassTypes.Theory)) { throw new Exception("Invaild class type"); } if (StartTimeId > EndTimeId) { throw new Exception("Starting time cannot be after ending time"); } if (EndTimeId - StartTimeId < 2) { throw new Exception("Class length cannot be shorter than an hour"); } if (String.IsNullOrWhiteSpace(RoomNo)) { throw new Exception("Please Enter Room No."); } if (!RoomNo.Any(char.IsDigit)) { throw new Exception("Invaid Room No. Plaease check again.Make sure room no has at least one digit in it"); } }
public IHttpActionResult PutRoomNo(int id, RoomNo roomNo) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != roomNo.RoomID) { return(BadRequest()); } db.Entry(roomNo).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!RoomNoExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
private void btnCountinue_Click(object sender, EventArgs e) { //Declaring the Variables int mobileNumber; string email = txtEmail.Text; string name = txtName.Text; string surname = txtSurname.Text; string address = txtAddress.Text; string idNumber = txtId.Text; string bdId = txtBdId.Text; int telephone; double bookingDays; double roomPrice; double bookingPrice; Email userEmail = new Email(); // intializing a new email if (ValidateControls() && int.TryParse(txtMobile.Text, out mobileNumber) && int.TryParse(txtMobile.Text, out telephone)) // the form is validated and the inputs taken { DateTime dateFrom = new DateTime(); // intilizing a new date (From) DateTime dateTo = new DateTime(); // intilizing a new date (to) dateFrom = dateFromPick.Value.Date; // Getting the value from dateTo = dateToPick.Value.Date; // Getting the value to TimeSpan t = dateTo.Date - dateFrom.Date; //setting the time span to get the days bookingDays = t.TotalDays; // getting total days RoomNo roomNo = (RoomNo)Enum.Parse(typeof(RoomNo), cbxRoomNo.SelectedItem.ToString()); // Get roomNo from enums of the cbx RoomType type = (RoomType)Enum.Parse(typeof(RoomType), cbxTyp.SelectedItem.ToString()); // Get type from enums of the cbx cust = new Customer(mobileNumber, email, name, surname, address, idNumber, telephone); // Intilizing a new customer with all the details roomPrice = room.GetRoomPrice(type); // getting the room price and inputing the type bookingPrice = bookingDays * roomPrice; // Getting the price of the booking room = new Rooms(roomNo, type, roomPrice, bdlst); // Creating a room and settinf it's properties bd = new Booking_Date(emp, cust, dateFrom, dateTo, room, bookingPrice, bdId); // creating a booking date and giving it its properties bill = new Bill(cust, emp, bd); // crearing a new bill tblCustomerTableAdapter.InsertQuery(mobileNumber, email, name, surname, address, idNumber, telephone); //inserting the date to the database tblBookingDateTableAdapter1.Insert(bd.Emp.ToString(), emp.ToString(), dateFrom, dateTo, room.ToString(), bookingPrice.ToString(), bdId);; //inserting the date to the database this.tblCustomerTableAdapter.Fill(this.customerDS.tblCustomer); // filling the tables this.tblBookingDateTableAdapter1.Fill(this.customerDS.tblBookingDate); MessageBox.Show("Booking" + "\nInfo:" + cust.GetInfo() + "\n" + bd.GetInfo() + "\n" + "Type: " + type); // messages box al the booking info userEmail.SendEmail(txtEmail.Text, "*****@*****.**", "DETAILS OF YOUR BOOKING", "\nEnjoy Your Stay" + bd.GetInfo()); // sending the email Menu m1 = new Menu(emp); // Sets the user back to the menu this.Hide(); m1.ShowDialog(); } }
public IHttpActionResult GetRoomNo(int id) { RoomNo roomNo = db.RoomNoes.Find(id); if (roomNo == null) { return(NotFound()); } return(Ok(roomNo)); }
public IHttpActionResult PostRoomNo(RoomNo roomNo) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.RoomNoes.Add(roomNo); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = roomNo.RoomID }, roomNo)); }
public IHttpActionResult DeleteRoomNo(int id) { RoomNo roomNo = db.RoomNoes.Find(id); if (roomNo == null) { return(NotFound()); } db.RoomNoes.Remove(roomNo); db.SaveChanges(); return(Ok(roomNo)); }
protected void Page_Load(object sender, EventArgs e) { if (Session["account"] == null) { Session["active"] = true; Response.Redirect("HotelLogin.aspx"); } else { acc = (Account)Session["account"]; } if (Page.IsPostBack) { roomList = new List <String>(); } else if (!IsPostBack) { Session["booked"] = false; roomList = new List <String>(); DataTable dt = db.DisplayAllRooms(); foreach (DataRow row in dt.Rows) { Room r = new Room(); r.Id = Convert.ToInt32(row["Id"]); r.RoomNo = row["RoomNo"].ToString(); r.RoomType = row["title"].ToString(); r.Price = Convert.ToDecimal(row["Price"].ToString()); r.Formatted = r.Price.ToString("c"); if (r.RoomType.Equals("Deluxe")) { roomList.Add(r.RoomNo); } } RoomNo.DataSource = roomList; RoomNo.DataBind(); } }
private void switchcase() { switch (Convert.ToInt32(roomtype.SelectedValue)) { case 1: DataTable dt = db.DisplayAllRooms(); foreach (DataRow row in dt.Rows) { Room r = new Room(); r.Id = Convert.ToInt32(row["Id"]); r.RoomNo = row["RoomNo"].ToString(); r.RoomType = row["title"].ToString(); r.Price = Convert.ToDecimal(row["Price"].ToString()); r.Formatted = r.Price.ToString("c"); if (r.RoomType.Equals("Deluxe")) { roomList.Add(r.RoomNo); } } RoomNo.DataSource = roomList; RoomNo.DataBind(); break; case 2: DataTable dt2 = db.DisplayAllRooms(); foreach (DataRow row in dt2.Rows) { Room r = new Room(); r.Id = Convert.ToInt32(row["Id"]); r.RoomNo = row["RoomNo"].ToString(); r.RoomType = row["title"].ToString(); r.Price = Convert.ToDecimal(row["Price"].ToString()); r.Formatted = r.Price.ToString("c"); if (r.RoomType.Equals("Suite")) { roomList.Add(r.RoomNo); } } RoomNo.DataSource = roomList; RoomNo.DataBind(); break; case 3: DataTable dt3 = db.DisplayAllRooms(); foreach (DataRow row in dt3.Rows) { Room r = new Room(); r.Id = Convert.ToInt32(row["Id"]); r.RoomNo = row["RoomNo"].ToString(); r.RoomType = row["title"].ToString(); r.Price = Convert.ToDecimal(row["Price"].ToString()); r.Formatted = r.Price.ToString("c"); if (r.RoomType.Equals("Regular")) { roomList.Add(r.RoomNo); } } RoomNo.DataSource = roomList; RoomNo.DataBind(); break; } }
/// <summary> /// Returns back all information about a room /// </summary> /// <returns>All information as a neatly padded out string</returns> public override string ToString() { return(RoomNo.ToString().PadRight(5) + RoomType.ToString().PadRight(10) + Capacity.ToString().PadRight(5) + GetCost().ToString("c")); }