private void btnXoa_Click(object sender, EventArgs e)
 {
     if (this.dataGridView2.SelectedRows.Count > 0)
     {
         DateTime ngay = DateTime.Parse(this.dataGridView2.Rows[this.dataGridView2.CurrentRow.Index].Cells[0].Value.ToString());
         if (!exedata($"delete from DK_PTN where NgayDK='{ngay}'"))
         {
             MessageBox.Show("Có Lỗi !");
         }
         else
         {
             MessageBox.Show("Thành công !");
         }
         SqlConnection sql = DBUtils.GetDBConnection();
         sql.Open();
         SqlCommand     cm   = new SqlCommand("select * from DK_PTN", sql);
         SqlDataAdapter adap = new SqlDataAdapter(cm);
         DataTable      dt   = new DataTable();
         adap.Fill(dt);
         dataGridView2.DataSource = dt;
         sql.Close();
     }
 }
        private void US_dkPTN_Load(object sender, EventArgs e)
        {
            //-----------load nhom
            SqlConnection sql = DBUtils.GetDBConnection();

            sql.Open();
            SqlCommand     cm   = new SqlCommand("select MaNhom,TenNhom from NhomSV", sql);
            SqlDataAdapter adap = new SqlDataAdapter(cm);
            DataTable      dt   = new DataTable();

            adap.Fill(dt);
            cbTenNhom.DisplayMember = "TenNhom";
            cbTenNhom.ValueMember   = "MaNhom";
            cbTenNhom.DataSource    = dt;
            //-----------load loại TN
            cm   = new SqlCommand("select MaLoaiTN,TenLoai from Loai_TN", sql);
            adap = new SqlDataAdapter(cm);
            dt   = new DataTable();
            adap.Fill(dt);
            cbLoaiTN.DisplayMember = "TenLoai";
            cbLoaiTN.ValueMember   = "MaLoaiTN";
            cbLoaiTN.DataSource    = dt;
            //-----------load loại TN
            cm   = new SqlCommand("select MaPTN,TenPTN from PhongThiNghiem", sql);
            adap = new SqlDataAdapter(cm);
            dt   = new DataTable();
            adap.Fill(dt);
            cbTenPhong.DisplayMember = "MaPTN";
            cbTenPhong.ValueMember   = "MaPTN";
            cbTenPhong.DataSource    = dt;
            //-------------------GVQL
            cm   = new SqlCommand("select MaGVQL,TenGVQL from GV_QLTN", sql);
            adap = new SqlDataAdapter(cm);
            dt   = new DataTable();
            adap.Fill(dt);
            cbTenGV.DisplayMember = "MaGVQL";
            cbTenGV.ValueMember   = "MaGVQL";
            cbTenGV.DataSource    = dt;
            //---------------------Buổi
            cm   = new SqlCommand("select MaBuoi,Tiet from Buoi", sql);
            adap = new SqlDataAdapter(cm);
            dt   = new DataTable();
            adap.Fill(dt);
            cbBuoi.DisplayMember = "MaBuoi";
            cbBuoi.ValueMember   = "MaBuoi";
            cbBuoi.DataSource    = dt;
            //-------------------grid TB
            cm   = new SqlCommand("select MaTB,TenTB from ThietBi", sql);
            adap = new SqlDataAdapter(cm);
            dt   = new DataTable();
            adap.Fill(dt);
            dataGridView_ThietBi.DataSource = dt;

            cm   = new SqlCommand("select * from ThietBi", sql);
            adap = new SqlDataAdapter(cm);
            dt   = new DataTable();
            adap.Fill(dt);
            dataGridView_ThietBi.DataSource = dt;

            cm   = new SqlCommand("select * from DK_PTN", sql);
            adap = new SqlDataAdapter(cm);
            dt   = new DataTable();
            adap.Fill(dt);
            dataGridView2.DataSource = dt;
            sql.Close();

            txtMaTB.Enabled = false;
            btnLuu.Enabled  = false;

            sql.Close();
        }