Пример #1
0
        private void themHocPhan()
        {
            if (this.cbbMaHP.Text == "")
            {
                MessageBox.Show("Mã HỌC PHẦN không được để trống.", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.cbbMaHP.Focus();
            }
            else
            {
                var hp = hpBUS.getHPTheoMaHP(this.cbbMaHP.Text);
                if (hp.Count != 0)
                {
                    MessageBox.Show("Mã HỌC PHẦN đã tồn tại.", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    this.cbbMaHP.Focus();
                    this.cbbMaHP.SelectAll();
                }
                else
                {
                    var gv = gvBUS.getGVTheoMaGV(this.txtGiangVien.Text);

                    if (this.txtGiangVien.Text != "" && gv.Count == 0)
                    {
                        MessageBox.Show("GIẢNG VIÊN không tồn tại.", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        this.txtGiangVien.Focus();
                        this.txtGiangVien.SelectAll();
                    }
                    else
                    {
                        if (hpBUS.themHocPhan(this.cbbMaHP.Text, this.cbbMaMH_HP.SelectedValue.ToString(),
                                              this.txtHocKy.Text == "" ? 0 : Convert.ToInt32(this.txtHocKy.Text), this.txtNamHoc.Text,
                                              this.txtGiangVien.Text == "" ? null : this.txtGiangVien.Text,
                                              this.txtSoTC.Text == "" ? 0 : Convert.ToInt32(this.txtSoTC.Text),
                                              this.txtHocPhi.Text == "" ? 0 : Convert.ToInt32(this.txtHocPhi.Text)))
                        {
                            MessageBox.Show("Đã thêm xong");
                            LoadData();
                        }
                        else
                        {
                            MessageBox.Show("Khong them duoc. Loi !!!", "THONG BAO", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
            }
        }
        private void cbbHocPhan_SelectedValueChanged(object sender, EventArgs e)
        {
            if (this.cbbHocPhan.Text != "")
            {
                var hocPhan = hpBUS.getHPTheoMaHP(this.cbbHocPhan.SelectedValue.ToString());

                this.txtNamHoc.Text     = hocPhan[0].NamHoc;
                this.txtHocKy.Text      = hocPhan[0].HocKy.ToString();
                this.txtSoTC.Text       = hocPhan[0].SoTC.ToString();
                this.txtMaGiaoVien.Text = hocPhan[0].MaGV.ToString();

                this.dgcDiemThi.DataSource = svBUS.getSVTheoMaHP(this.cbbHocPhan.SelectedValue.ToString());
            }
        }