Example #1
0
        private void btnCapNhatLH_Click(object sender, EventArgs e)
        {
            BUSGiaoVien a = new BUSGiaoVien();

            int    solopcu = a.SoLuongLopDayDu(IDChuyenDe);
            string tenlop  = a.LayTenLop(IDChuyenDe, solopcu);
            int    temp    = solopcu;

            int    solop = Convert.ToInt32(txtSLSVCNLop.Text) + solopcu - a.SoLuongLop(IDChuyenDe, IDNguoiDung);
            string lopid;

            if (solop > 20)
            {
                MessageBox.Show("Số lượng lớp phải nhỏ hơn 20!");
                return;
            }
            if (solop <= 0)
            {
                MessageBox.Show("Số lượng lớp lớn hơn 0!");
                return;
            }
            if (solop > solopcu)
            {
                while (solop != temp)
                {
                    temp++;
                    lopid = tenlop.Replace(IDChuyenDe + solopcu.ToString(), "");
                    lopid = lopid.Replace(" ", "") + IDChuyenDe + temp;
                    a.InsertLop(IDChuyenDe, lopid, IDNguoiDung);
                }
            }
            if (solop < solopcu)
            {
                while (solop != temp)
                {
                    lopid = tenlop.Replace(IDChuyenDe + solopcu.ToString(), "");
                    lopid = lopid.Replace(" ", "") + IDChuyenDe + temp;

                    a.DeleteLop(IDChuyenDe, lopid);
                    temp--;
                }
            }


            MessageBox.Show("Số Lượng Lớp Đã Được Cập Nhật!");

            GDChinhGiaoVien_Load(sender, e);
            btnVeTrangChu_Click(sender, e);
        }