private void listDeTai_Click(object sender, EventArgs e)
        {
            try
            {
                this.txtMaDT.Text      = this.listDeTai.SelectedItems[0].SubItems[0].Text.Trim();
                this.txtTenDT.Text     = this.listDeTai.SelectedItems[0].SubItems[1].Text.Trim();
                this.rtMoTa.Text       = this.listDeTai.SelectedItems[0].SubItems[2].Text.Trim();
                this.NgayBatDau.Value  = DateTime.Parse(this.listDeTai.SelectedItems[0].SubItems[3].Text.Trim());
                this.NgayKetThuc.Value = DateTime.Parse(this.listDeTai.SelectedItems[0].SubItems[4].Text.Trim());
                this.txtTienDo.Text    = this.listDeTai.SelectedItems[0].SubItems[5].Text.Trim();
                //hiển thị lại trên listsinhvien
                lstSV.Items.Clear();
                if (DeTaiController.checkExistDeTai(listDeTai.SelectedItems[0].SubItems[0].Text))
                {
                    int dem = DeTaiController.demsinhvien(listDeTai.SelectedItems[0].SubItems[0].Text.Trim());
                    for (int i = 0; i < dem; i++)
                    {
                        lstSV.Items.Add(DeTaiController.danhsach(listDeTai.SelectedItems[0].SubItems[0].Text.Trim())[i]);
                    }
                }

                this.cbGV.Text       = this.listDeTai.SelectedItems[0].SubItems[7].Text.Trim();
                this.rtNhanXet.Text  = this.listDeTai.SelectedItems[0].SubItems[9].Text.Trim();
                checkTienDo1.Checked = false;
                checkTienDo2.Checked = false;
                checkTienDo3.Checked = false;
                checkTienDo4.Checked = false;
                if (int.Parse(txtTienDo.Text) == 25)
                {
                    checkTienDo1.Checked = true;
                }
                else if (int.Parse(txtTienDo.Text) == 50)
                {
                    checkTienDo1.Checked = true;
                    checkTienDo2.Checked = true;
                }
                else if (int.Parse(txtTienDo.Text) == 75)
                {
                    checkTienDo1.Checked = true;
                    checkTienDo2.Checked = true;
                    checkTienDo3.Checked = true;
                }
                else if (int.Parse(txtTienDo.Text) == 100)
                {
                    checkTienDo1.Checked = true;
                    checkTienDo2.Checked = true;
                    checkTienDo3.Checked = true;
                    checkTienDo4.Checked = true;
                }
            }
            catch { }
        }
        private void btnSua_Click(object sender, EventArgs e)
        {
            try
            {
                if (this.txtMaDT.Text.Trim().Length <= 0)
                {
                    this.errorProvider1.SetError(this.txtMaDT, "Phai nhap Ma De Tai");
                    return;
                }
                else
                {
                    this.errorProvider1.Clear();
                }
                if (this.txtTenDT.Text.Trim().Length <= 0)
                {
                    this.errorProvider1.SetError(this.txtTenDT, "Phai nhap Ten De Tai");
                    return;
                }
                else
                {
                    this.errorProvider1.Clear();
                }
                if (rtMoTa.Text == "")
                {
                    this.errorProvider1.SetError(this.rtMoTa, "Phai co mo ta");
                    return;
                }
                else
                {
                    this.errorProvider1.Clear();
                }

                if (NgayKetThuc.Value <= NgayBatDau.Value)
                {
                    this.errorProvider1.SetError(this.NgayKetThuc, "Phai nhap ngay ket thuc lon hon ngay bat dau");
                    return;
                }
                else
                {
                    this.errorProvider1.Clear();
                }

                if (rtNhanXet.Text == "")
                {
                    this.errorProvider1.SetError(this.rtNhanXet, "Phai co nhan xet");
                    return;
                }
                else
                {
                    this.errorProvider1.Clear();
                }
                if (cbGV.Text == "")
                {
                    this.errorProvider1.SetError(this.rtNhanXet, "Phai co Giao Vien");
                    return;
                }
                else
                {
                    this.errorProvider1.Clear();
                }

                DeTai  detai    = new DeTai();
                double soTienDo = 0;
                detai.MaDT        = txtMaDT.Text;
                detai.TenDT       = txtTenDT.Text;
                detai.MoTaDT      = rtMoTa.Text;
                detai.NgayBatDau  = NgayBatDau.Value;
                detai.NgayKetThuc = NgayKetThuc.Value;
                detai.MaGV        = cbGV.Text;
                string displaySV = "";
                for (int i = 0; i < lstSV.Items.Count; i++)
                {
                    displaySV = displaySV + this.lstSV.Items[i] + " ";
                    detai.SinhViens.Add(this.lstSV.Items[i] as SinhVien);
                }
                if (checkTienDo1.Checked == true)
                {
                    soTienDo = soTienDo + 25;
                }
                if (checkTienDo2.Checked == true && checkTienDo1.Checked == true)
                {
                    soTienDo = 50;
                }
                if (checkTienDo3.Checked == true && checkTienDo2.Checked == true && checkTienDo1.Checked == true)
                {
                    soTienDo = 75;
                }
                if (checkTienDo4.Checked == true && checkTienDo2.Checked == true && checkTienDo1.Checked == true)
                {
                    soTienDo = 100;
                }

                detai.TienDoDT = soTienDo;
                txtTienDo.Text = soTienDo.ToString();
                detai.NhanXet  = rtNhanXet.Text;
                if (DeTaiController.checkExistDeTai(detai.MaDT))
                {
                    DeTaiController.UpdateDeTai(detai);
                }
                else
                {
                    MessageBox.Show("Vui lòng không sửa Mã đề tài", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                listDeTai.Items.Clear();
                displayDeTai();
            }

            catch
            {
            }
        }