/// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btRemoveAll_Click(object sender, EventArgs e)
        {
            this.cmbNamHoc.Enabled  = false;
            this.cmbKhoiLop.Enabled = false;
            this.cmbLop.Enabled     = false;

            IEnumerator ie = this.lvDSMonHocDuocChon.Items.GetEnumerator();

            while (ie.MoveNext())
            {
                ListViewItem item = (ListViewItem)ie.Current;
                this.lvDSMonHocDuocChon.Items.Remove(item);
                this.lvDMMonHoc.Items.Add(item);
            }

            //Tao mot doi tuong PhanCongController dung de xoa mon hoc duoc phan cong khi mon hoc do bi xoa khoi danh sach mon hoc cua lop
            PhanCongController phanCongCtrl = new PhanCongController();

            foreach (DataRow row in this.LopMonHocController.Data.DataService.Rows)
            {
                if (row["MaLopMonHoc"].ToString() != "")
                {
                    LopMonHocInfo lopMonHoc = new LopMonHocInfo();
                    lopMonHoc.MaLopMonHoc = int.Parse(row["MaLopMonHoc"].ToString());
                    phanCongCtrl.Xoa(lopMonHoc);
                }
                this.LopMonHocController.Data.DataService.Rows[this.LopMonHocController.Data.DataService.Rows.IndexOf(row)].Delete();
            }

            this.LopMonHocController.Update();
        }
 /// <summary>
 /// Khoi tao form cap nhat
 /// </summary>
 /// <param name="maLop"></param>
 /// <param name="phanCongCtrl"></param>
 /// <param name="index"></param>
 public frmThemPhanCong(String maLop, PhanCongController phanCongCtrl, int index)
 {
     InitializeComponent();
     this.MaLop = maLop;
     this.PhanCongController  = phanCongCtrl;
     this.LopMonHocController = new LopMonHocController();
     this.GiaoVienController  = new GiaoVienController();
     this.IsAdd = false;
 }
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btChinhSua_Click(object sender, EventArgs e)
        {
            PhanCongInfo phanCong = new PhanCongInfo();
            DataRowView  r        = (DataRowView)this.bnDS.BindingSource.Current;

            phanCong = new PhanCongController().LayTuMa(int.Parse(r["MaPhanCong"].ToString()));

            frmCapNhatPhanCong frm = new frmCapNhatPhanCong(phanCong);

            if (frm.ShowDialog() == DialogResult.OK)
            {
                phanCong = frm.PhanCong;
                DataRow row = this.PhanCongController.Data.DataService.Rows[this.bnDS.BindingSource.Position];
                row["MaGiaoVien"] = phanCong.GiaoVien.MaGiaoVien;
                this.PhanCongController.Update();
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btLuu_Click(object sender, EventArgs e)
        {
            this.cmbNamHoc.Enabled  = true;
            this.cmbKhoiLop.Enabled = true;
            this.cmbLop.Enabled     = true;

            foreach (ListViewItem item in this.lvDSMonHocDuocChon.Items)
            {
                DataRow r = (DataRow)((object[])item.Tag)[1];
                if (this.LopMonHocController.Data.DataService.Rows.IndexOf(r) == -1)
                {
                    this.LopMonHocController.Data.DataService.Rows.Add(r);
                }
            }

            //Tao mot doi tuong PhanCongController dung de xoa mon hoc duoc phan cong khi mon hoc do bi xoa khoi danh sach mon hoc cua lop
            PhanCongController phanCongCtrl = new PhanCongController();
            bool daXoa = false;

            foreach (DataRow row in this.LopMonHocController.Data.DataService.Rows)
            {
                foreach (ListViewItem item in this.lvDSMonHocDuocChon.Items)
                {
                    DataRow r = (DataRow)((object[])item.Tag)[1];
                    if (row.Equals(r))
                    {
                        daXoa = false;
                        break;
                    }
                    daXoa = true;
                }
                if (daXoa)
                {
                    if (row["MaLopMonHoc"].ToString() != "")
                    {
                        LopMonHocInfo lopMonHoc = new LopMonHocInfo();
                        lopMonHoc.MaLopMonHoc = int.Parse(row["MaLopMonHoc"].ToString());
                        phanCongCtrl.Xoa(lopMonHoc);
                    }
                    this.LopMonHocController.Data.DataService.Rows[this.LopMonHocController.Data.DataService.Rows.IndexOf(row)].Delete();
                    daXoa = false;
                }
            }

            this.LopMonHocController.Update();
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dgvDS_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
        {
            if (MessageBox.Show("Bạn có chắc xóa không?", "Xóa Giáo viên", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
            {
                //Neu chon No, cancel thao tac xoa
                e.Cancel = true;
            }
            else
            {
                /*
                 * Vi thao tac xoa chi co tac dung tren DataGridView nen ta cancel di
                 * Sau co xoa theo cach cua ta
                 * */
                e.Cancel = true;
                IEnumerator ie = this.dgvDS.SelectedRows.GetEnumerator();
                if (ie.MoveNext())
                {
                    DataGridViewRow row = (DataGridViewRow)ie.Current;
                    this.dgvDS.Rows.Remove(row);
                    while (ie.MoveNext())
                    {
                        row = (DataGridViewRow)ie.Current;
                        this.dgvDS.Rows.Remove(row);
                    }
                }
                else
                {
                    this.bnDS.BindingSource.RemoveCurrent();
                }

                if (this.PhanCongController.Update())
                {
                    MessageBox.Show("Đã xóa!", "Xóa Giáo viên", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("Không thể xóa!", "Xóa giáo viên", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    this.PhanCongController = new PhanCongController();
                    this.PhanCongController.Data.LayDS();
                    //this.Controller.DisplayList(this.dgvList, this.bn);
                }
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void frmPhanCong_Load(object sender, EventArgs e)
        {
            if (this.NamHocController == null)
            {
                this.NamHocController = new NamHocController();
            }
            if (this.KhoiLopController == null)
            {
                this.KhoiLopController = new KhoiLopController();
            }
            if (this.LopController == null)
            {
                this.LopController = new LopController();
            }
            if (this.LopMonHocController == null)
            {
                this.LopMonHocController = new LopMonHocController();
            }
            if (this.GiaoVienController == null)
            {
                this.GiaoVienController = new GiaoVienController();
            }
            if (this.PhanCongController == null)
            {
                this.PhanCongController = new PhanCongController();
            }

            this.lbNamHoc.Font = new Font(this.lbNamHoc.Font, FontStyle.Bold);
            this.lbNamHoc.Tag  = this.NamHocController.LayTuMa(this.NamHocController.LayMaCuoi());
            this.lbNamHoc.Text = "Năm Học " + ((NamHocInfo)this.lbNamHoc.Tag).TenNamHoc;

            this.LopMonHocController.HienThiComboBox(this.cmbMonHoc);
            new LopMonHocController().HienThiDataGridViewComboBoxColumn(this.colMonHoc);
            this.GiaoVienController.HienThiComboBox(this.cmbGiaoVien);
            new GiaoVienController().HienThiDataGridComboBoxColumn(this.colGiaoVien);

            this.PhanCongController.HienThiDS(this.dgvDS, this.bnDS, this.cmbMonHoc, this.cmbGiaoVien);

            this.KhoiLopController.HienThiCombobox(this.cmbKhoiLop);
        }