private void BtnConfirm_Click(object sender, EventArgs e) { RoomDTO room = new RoomDTO(); room.RoomID = this.tbRoomID.Text; room.RoomTypeID = this.cbRoomType.Text; room.RoomNote = this.rtbRoomNote.Text; room.RoomStatusID = ((KeyValuePair<string, string>)this.cbRoomStatus.SelectedItem).Value; switch (this.Tag) { case "AddForm": { if (RoomBUS.InsertRoom(room)) { MessageBox.Show("Thêm phòng " + room.RoomID + " thành công!", "THÊM PHÒNG THÀNH CÔNG", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } else { MessageBox.Show("Phòng đã tồn tại hoặc tên phòng không được để trống", "THÊM PHÒNG THẤT BẠI", MessageBoxButtons.OK, MessageBoxIcon.Warning); } break; } case "EditForm": { if (RoomBUS.UpdateRoom(room)) { MessageBox.Show("Sửa phòng " + room.RoomID + " thành công!", "SỬA PHÒNG THÀNH CÔNG", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } else { MessageBox.Show("Không thể sửa phòng đang thuê", "SỬA PHÒNG THẤT BẠI", MessageBoxButtons.OK, MessageBoxIcon.Warning); } break; } } MainForm mainForm = (MainForm)Owner; mainForm.ReLoadRoomData(); mainForm.ReLoadAvailableRoom(); mainForm.ReLoadFindRoom(); }
public static bool UpdateRoom(Room r) { return(RoomBUS.UpdateRoom(r)); }