private void add_room_btn_Click(object sender, EventArgs e) { var room_number = Convert.ToInt32(add_room_number.Text); var room_type_id = Convert.ToInt32(add_room_type.SelectedValue); var bed_count = Convert.ToInt32(add_room_bed_count.Text); var room_price = Convert.ToInt32(add_room_price.Text); var reservation_status = add_room_reservation_status.SelectedItem.ToString(); var cleaning_status = add_room_cleaning_status.SelectedItem.ToString(); var room_status = add_room_room_status.SelectedItem.ToString(); try { HotelDatabaseEntities db = new HotelDatabaseEntities(); var new_room = new Rooms(); new_room.room_number = room_number; new_room.room_type_id = room_type_id; new_room.bed_count = bed_count; new_room.room_price = room_price; new_room.room_reservation_status = Convert.ToBoolean(reservation_status); new_room.room_cleaning_status = Convert.ToBoolean(cleaning_status); new_room.room_status = Convert.ToBoolean(room_status); db.Rooms.Add(new_room); db.SaveChanges(); MessageBox.Show("New room has created!"); } catch { MessageBox.Show("Please try again!"); } }
private void add_photo_btn_Click(object sender, EventArgs e) { if (imgSelected) { try { File.Copy(imgPathAndName, "../../images/" + imgName); HotelDatabaseEntities db = new HotelDatabaseEntities(); Photos photo = new Photos(); photo.image_name = Path.GetFileNameWithoutExtension(imgName); photo.image_src = "images/" + imgName; db.Photos.Add(photo); db.SaveChanges(); selected_photo_picturebox.ImageLocation = ""; MessageBox.Show("Image added!"); } catch { MessageBox.Show("Please try again!"); } } else { MessageBox.Show("Please select an image!"); } }
private void bind_btn_Click(object sender, EventArgs e) { int room_id = Convert.ToInt32(bind_room_to_photo_room_number.SelectedValue); int photo_id = Convert.ToInt32(bind_room_to_photo_photo_name.SelectedValue); HotelDatabaseEntities db = new HotelDatabaseEntities(); Rooms_Photos room_photo = new Rooms_Photos(); room_photo.room_id = room_id; room_photo.photo_id = photo_id; db.Rooms_Photos.Add(room_photo); db.SaveChanges(); }
private void add_type_btn_Click(object sender, EventArgs e) { try { string type_name = add_type_name.Text; HotelDatabaseEntities db = new HotelDatabaseEntities(); Room_Types type = new Room_Types(); type.room_type_name = type_name; db.Room_Types.Add(type); db.SaveChanges(); add_type_name.Text = ""; MessageBox.Show("Room Type Added!"); } catch { MessageBox.Show("Please try again"); } }
private void add_detail_btn_Click(object sender, EventArgs e) { try { string detail_name = add_detail_name.Text; HotelDatabaseEntities db = new HotelDatabaseEntities(); Room_Details detail = new Room_Details(); detail.detail_name = detail_name; db.Room_Details.Add(detail); db.SaveChanges(); add_detail_name.Text = ""; MessageBox.Show("Room Detail Added!"); } catch { MessageBox.Show("Please try again!"); } }
private void bind_btn_Click(object sender, EventArgs e) { try { int room_id = Convert.ToInt32(bind_room_to_detail_room_number.SelectedValue); int detail_id = Convert.ToInt32(bind_room_to_detail_detail.SelectedValue); HotelDatabaseEntities db = new HotelDatabaseEntities(); Rooms_Details detail = new Rooms_Details(); detail.room_id = room_id; detail.detail_id = detail_id; db.Rooms_Details.Add(detail); db.SaveChanges(); MessageBox.Show("Room and Detail succesfully binded!"); } catch { MessageBox.Show("Please try again!"); } }