private void DatPhong_Click(object sender, EventArgs e) { Button btn = new Button(); panelDP.Controls.Add(btn); panelDV.Hide(); panelNP.Hide(); panelHD.Hide(); panelDP.Show(); DP_CBMaDP.Hide(); DP_CBMaKH.Hide(); DP_CBNgay.Hide(); DP_CBPhong.Hide(); DP_CBTenKH.Hide(); connectDatabase(); SqlDataAdapter sqlDa = new SqlDataAdapter("SELECT * FROM LOAIPHONG", sqlCon); dtTable = new DataTable(); sqlDa.Fill(dtTable); String ItemRowName = ""; foreach (DataRow dr in dtTable.Rows) { if (dr["TENLOAI"].ToString() != ItemRowName) { DP_LoaiPhong.Items.Add(dr["TENLOAI"]); } ItemRowName = dr["TENLOAI"].ToString(); } sqlDa = new SqlDataAdapter("SELECT * FROM PHONG", sqlCon); dtTable = new DataTable(); sqlDa.Fill(dtTable); ItemRowName = ""; foreach (DataRow dr in dtTable.Rows) { if (dr["MAPHONG"].ToString() != ItemRowName) { DP_MaPhong.Items.Add(dr["MAPHONG"]); } ItemRowName = dr["MAPHONG"].ToString(); } sqlCon.Close(); }
/// <summary> /// /// </summary> /// <param Đặt phong ="sender"></param> /// <param name="e"></param> private bool DP_KiemTraThongTin() { if (DP_MaKH.Text == "") { DP_CBMaKH.Show(); return(false); } else { DP_CBMaKH.Hide(); } if (DP_TenKH.Text == "") { DP_CBTenKH.Show(); return(false); } else { DP_CBTenKH.Hide(); } if (DP_MaDP.Text == "") { DP_CBMaDP.Show(); return(false); } else { DP_CBMaDP.Hide(); } if (DP_MaPhong.Text == "") { DP_CBPhong.Show(); return(false); } else { DP_CBPhong.Hide(); } if (DP_NgayDen.Value < DateTime.Now || DP_NgayDen.Value >= DP_NgayDi.Value) { DP_CBNgay.Show(); return(false); } else { DP_CBNgay.Hide(); } return(true); }