示例#1
0
        private void btnThemMoi_Click(object sender, EventArgs e)
        {
            try {
                string tenPhong  = txtTenPhong.Text;
                string loaiPhong = txtLoaiPhong.Text;
                float  giaPhong  = float.Parse(txtGia.Text);
                bool   trangthai = true;
                string ghichu    = txtGhiChu.Text;
                Room   room      = new Room(tenPhong, loaiPhong, giaPhong, trangthai, ghichu);

                if (txtTenPhong.Text.Length == 0 || txtGia.Text.Length == 0 || txtLoaiPhong.Text.Length == 0)
                {
                    MessageBox.Show("Vui Lòng Nhập Đầy Đủ Thông Tin Phòng!");
                }
                try {
                    if (dataRoom.AddNewRoom(room))
                    {
                        MessageBox.Show("Thêm Phòng Mới Thành Công!");
                    }
                    else
                    {
                        MessageBox.Show("Thêm Phòng Mới Không Thành Công!");
                    }
                } catch (Exception) {
                    MessageBox.Show("Phòng đã tồn tại");
                }
            } catch (Exception) {
                MessageBox.Show("Vui Lòng Nhập Đầy Đủ Thông Tin!");
            }
            Server sv = new Server();

            sv.loadAllRoom();
        }