public CapNhatThongTinLop(ChuyenDeDuocMo n)
        {
            InitializeComponent();


            //ChuyenDeDuocMo m = new ChuyenDeDuocMo();
            var ds = Dao_GiaoVu.DSCacLopChuyenDeDuocMo();

            foreach (var tt in ds)
            {
                if (tt.MaLop == n.MaLop)
                {
                    SLNTD.Text  = tt.SoNToiDa1Lop.ToString();
                    SLSV1L.Text = tt.slsv1lop.ToString();
                    break;
                }
            }
            tbTenLop.Text = n.MaLop;
            var dsnhom = Dao_GiaoVu.DSNhom();

            foreach (var tt in dsnhom)
            {
                if (tt.malop == n.MaLop)
                {
                    SLSVTD1N.Text = tt.sosvtoida1nhom.ToString();
                }
            }
            //SLSV1L.Text = n.slsv1lop.ToString();
            //SLNTD.Text = m.SoNToiDa1Lop.ToString();
            cddm.slsv1lop     = Int32.Parse(SLSV1L.Text);
            cddm.SoNToiDa1Lop = Int32.Parse(SLNTD.Text);
        }
        private void LoadLopTheoChuyenDe(object sender, System.EventArgs e)
        {
            tb_TTDK_MaLop.Text = "";
            //load tên lớp
            var dscd = Dao_GiaoVu.DSTatCaChuyenDe();

            foreach (var tt in dscd)
            {
                if (tt.MaCD == tb_TTDK_MaCD.Text)
                {
                    tb_TTDK_TenCD.Text    = tt.TenCD;
                    tb_TTDK_TenCD.Enabled = false;
                    break;
                }
            }

            //load lớp
            tb_TTDK_MaLop.Items.Clear();
            var    dscd1 = Dao_GiaoVu.DSCacLopChuyenDeDuocMo();
            string temp  = tb_TTDK_MaCD.Text;

            foreach (var tt in dscd1)
            {
                if (tt.MaCD == temp)
                {
                    tb_TTDK_MaLop.Items.Add(tt.MaLop);
                }
            }
        }
Пример #3
0
        public CapNhatChuyenDeDangDuocMo(ChuyenDeDuocMo n)
        {
            InitializeComponent();
            x = n;
            //Mã cd
            tbMaCD.Text = n.MaCD.ToString();
            //Tên cd
            var dscd         = Dao_GiaoVu.DSTatCaChuyenDe();
            var dsBaogom     = Dao_GiaoVu.DSBaoGom();
            var dsThuocNganh = Dao_GiaoVu.DSNganh();
            var dsNH         = Dao_GiaoVu.DSNamHoc();
            var dsHK         = Dao_GiaoVu.DSHocKy();
            var ds           = Dao_GiaoVu.DSCacLopChuyenDeDuocMo();

            foreach (var tt in dscd)
            {
                if (tt.MaCD == n.MaCD)
                {
                    tbTenCD.Text = tt.TenCD;
                    break;
                }
            }

            //Thuộc ngành
            string manganh = "";

            foreach (var tt in dsBaogom)
            {
                if (tt.MaCD == n.MaCD)
                {
                    manganh = tt.MaNganh;
                    break;
                }
            }
            foreach (var tt in dsThuocNganh)
            {
                if (tt.manganh == manganh)
                {
                    manganh = tt.tennganh;
                }
            }
            tbThuocNganh.Text = manganh;

            //Năm học
            foreach (var tt in dsNH)
            {
                cbbNamHoc.Items.Add(tt.namhoc);
            }
            cbbNamHoc.Text = n.NamHoc;

            //Học kỳ
            foreach (var tt in dsHK)
            {
                cbbHocKi.Items.Add(tt.hocky);
            }
            cbbHocKi.Text = n.HocKy.ToString();

            //SL lớp
            List <string> dslophoc = new List <string>();
            int           demlop   = 0;

            foreach (var tt in ds)
            {
                if (tt.MaCD == tbMaCD.Text && tt.NamHoc == cbbNamHoc.Text && tt.HocKy.ToString() == cbbHocKi.Text)
                {
                    dslophoc.Add(tt.MaLop);
                    demlop++;
                }
            }
            SLL.Text = demlop.ToString();

            //Tên bắt đầu
            string tenlop = "";

            foreach (var tt in ds)
            {
                if (tt.MaCD == tbMaCD.Text && tt.NamHoc == cbbNamHoc.Text && tt.HocKy.ToString() == cbbHocKi.Text)
                {
                    tenlop = tt.MaLop;
                }
            }
            int VT = 0;

            for (int i = tenlop.Length - 1; i >= 0; i--)
            {
                if (Char.IsNumber(tenlop[i]))
                {
                    VT = i;
                    break;
                }
            }
            string abc = tenlop.Substring(0, VT);

            cbbTenBatDau.Text = abc;

            //SLSV1Lop
            foreach (var tt in ds)
            {
                if (tt.MaCD == tbMaCD.Text)
                {
                    SLSV1L.Text = tt.slsv1lop.ToString();
                    break;
                }
            }

            //SLSV 1lop
            foreach (var tt in ds)
            {
                if (tt.MaCD == tbMaCD.Text && tt.NamHoc == cbbNamHoc.Text && tt.HocKy.ToString() == cbbHocKi.Text)
                {
                    //SLSV1L.Text = tt.slsv1lop.ToString();
                }
            }
            SLL.Text = demlop.ToString();

            //SL Nhóm 1 lớp
            foreach (var tt in ds)
            {
                if (tt.MaCD == tbMaCD.Text && tt.NamHoc == cbbNamHoc.Text && tt.HocKy.ToString() == cbbHocKi.Text)
                {
                    SLNTD.Text = tt.SoNToiDa1Lop.ToString();
                    break;
                }
            }

            //SLSV TD 1 nhóm
            var dsn     = Dao_GiaoVu.DSNhom();
            int maxnhom = 0;

            foreach (var tt in dslophoc)
            {
                int maxnhomtemp = 0;
                foreach (var tt1 in dsn)
                {
                    if (tt1.malop == tt)
                    {
                        maxnhomtemp = tt1.sosvtoida1nhom;
                        break;
                    }
                }
                if (maxnhomtemp > maxnhom)
                {
                    maxnhom = maxnhomtemp;
                }
            }
            SLSVTD1N.Text = maxnhom.ToString();

            x.SoNToiDa1Lop = Int32.Parse(SLNTD.Text);

            sll = Int32.Parse(SLL.Text);
            sln = Int32.Parse(SLNTD.Text);
        }
        void LoadDGV1(VIEW_DTO.GiaoVu.TraCuuTTDK tc)
        {
            dataGridViewTraCuuTTDK.Rows.Clear();
            var ds     = Dao_GiaoVu.DSTTDKMaCD(tc);
            var dssv   = Dao_GiaoVu.DSSinhVien();
            var dscd   = Dao_GiaoVu.DSTatCaChuyenDe();
            var dscddm = Dao_GiaoVu.DSCacLopChuyenDeDuocMo();

            if (ds.Count == 0)
            {
                MessageBox.Show("Không tìm thấy dữ liệu phù hợp", "Thông báo");
                dataGridViewTraCuuTTDK.Columns.Clear();
                return;
            }
            DataGridViewRow  row  = null;
            DataGridViewCell cell = null;

            foreach (var tt in ds)
            {
                row     = new DataGridViewRow();
                row.Tag = tt;

                cell       = new DataGridViewTextBoxCell();
                cell.Value = tt.masv;
                row.Cells.Add(cell);

                cell = new DataGridViewTextBoxCell();
                foreach (var tt1 in dssv)
                {
                    if (tt1.mand == tt.masv)
                    {
                        cell.Value = tt1.hoten;
                    }
                }
                row.Cells.Add(cell);

                cell       = new DataGridViewTextBoxCell();
                cell.Value = tt.malop;
                row.Cells.Add(cell);

                cell = new DataGridViewTextBoxCell();
                foreach (var tt2 in dscddm)
                {
                    if (tt2.MaLop == tt.malop)
                    {
                        foreach (var tt3 in dscd)
                        {
                            if (tt3.MaCD == tt2.MaCD)
                            {
                                cell.Value = tt3.TenCD;
                                break;
                            }
                        }
                        break;
                    }
                }
                row.Cells.Add(cell);

                cell       = new DataGridViewTextBoxCell();
                cell.Value = tt.manhom;
                row.Cells.Add(cell);

                dataGridViewTraCuuTTDK.Rows.Add(row);
            }
        }
        void LoadDGVCacLopChuyenDeDuocMo()
        {
            dataGridViewCacLopChuyenDeDangMo.Rows.Clear();
            var              ds   = Dao_GiaoVu.DSCacLopChuyenDeDuocMo();
            DataGridViewRow  row  = null;
            DataGridViewCell cell = null;

            foreach (var cd in ds)
            {
                row     = new DataGridViewRow();
                row.Tag = cd;

                cell       = new DataGridViewTextBoxCell();
                cell.Value = cd.MaLop;
                row.Cells.Add(cell);

                cell = new DataGridViewTextBoxCell();
                string tencd = "";
                var    lqq   = Dao_GiaoVu.DSTatCaChuyenDe();
                foreach (var tt in lqq)
                {
                    if (cd.MaCD == tt.MaCD)
                    {
                        tencd = tt.TenCD;
                        break;
                    }
                }
                cell.Value = tencd;
                row.Cells.Add(cell);

                cell       = new DataGridViewTextBoxCell();
                cell.Value = cd.NamHoc;
                row.Cells.Add(cell);

                cell       = new DataGridViewTextBoxCell();
                cell.Value = cd.HocKy;
                row.Cells.Add(cell);

                cell       = new DataGridViewTextBoxCell();
                cell.Value = cd.SoSVToiDa;
                row.Cells.Add(cell);

                //cell = new DataGridViewTextBoxCell();
                //cell.Value = cd.SoSVDaDK;
                //row.Cells.Add(cell);

                cell = new DataGridViewTextBoxCell();
                string tengv = "";
                var    dsgv  = Dao_GiaoVu.DSGiaoVien();
                foreach (var tt in dsgv)
                {
                    if (cd.GVPhuTrach == tt.MaND)
                    {
                        tengv = tt.TenGV;
                        break;
                    }
                }
                cell.Value = tengv;
                row.Cells.Add(cell);

                dataGridViewCacLopChuyenDeDangMo.Rows.Add(row);
            }
        }
        void LoadDGV(VIEW_DTO.GiaoVu.TraCuuDiem n)
        {
            dataGridViewTraCuuDiem.Rows.Clear();
            var ds     = Dao_GiaoVu.DSDangKy(n);
            var dssv   = Dao_GiaoVu.DSSinhVien();
            var dscd   = Dao_GiaoVu.DSTatCaChuyenDe();
            var dscddm = Dao_GiaoVu.DSCacLopChuyenDeDuocMo();

            if (ds.Count == 0)
            {
                MessageBox.Show("Không tìm thấy dữ liệu phù hợp", "Thông báo");
                dataGridViewTraCuuDiem.Columns.Clear();
                return;
            }
            DataGridViewRow  row  = null;
            DataGridViewCell cell = null;

            foreach (var tc in ds)
            {
                row     = new DataGridViewRow();
                row.Tag = tc;

                cell       = new DataGridViewTextBoxCell();
                cell.Value = tc.mand;
                row.Cells.Add(cell);

                cell = new DataGridViewTextBoxCell();
                foreach (var tt in dssv)
                {
                    if (tt.mand == tc.mand)
                    {
                        cell.Value = tt.hoten;
                    }
                }
                row.Cells.Add(cell);

                cell       = new DataGridViewTextBoxCell();
                cell.Value = tc.malop;
                row.Cells.Add(cell);

                cell = new DataGridViewTextBoxCell();
                foreach (var tt in dscd)
                {
                    if (tt.MaCD == n.macd)
                    {
                        cell.Value = tt.TenCD;
                        break;
                    }
                }
                row.Cells.Add(cell);

                cell       = new DataGridViewTextBoxCell();
                cell.Value = tc.manhom;
                row.Cells.Add(cell);

                cell       = new DataGridViewTextBoxCell();
                cell.Value = tc.diem;
                row.Cells.Add(cell);

                dataGridViewTraCuuDiem.Rows.Add(row);
            }
        }
        void LoadDGVCacLopChuyenDeDuocMo()
        {
            dataGridViewCacLopChuyenDeDangMo.Rows.Clear();
            var              ds   = Dao_GiaoVu.DSCacLopChuyenDeDuocMo();
            DataGridViewRow  row  = null;
            DataGridViewCell cell = null;

            foreach (var cd in ds)
            {
                row     = new DataGridViewRow();
                row.Tag = cd;

                cell       = new DataGridViewTextBoxCell();
                cell.Value = cd.MaLop;
                row.Cells.Add(cell);

                cell = new DataGridViewTextBoxCell();
                string tencd = "";
                var    lqq   = Dao_GiaoVu.DSTatCaChuyenDe();
                foreach (var tt in lqq)
                {
                    if (cd.MaCD == tt.MaCD)
                    {
                        tencd = tt.TenCD;
                        break;
                    }
                }
                cell.Value = tencd;
                row.Cells.Add(cell);

                cell       = new DataGridViewTextBoxCell();
                cell.Value = cd.NamHoc;
                row.Cells.Add(cell);

                cell       = new DataGridViewTextBoxCell();
                cell.Value = cd.HocKy;
                row.Cells.Add(cell);

                //
                var dsndk         = Dao_GiaoVu.DSNhom();
                int sosvtoida1lop = 0;
                foreach (var tt in dsndk)
                {
                    if (tt.malop == cd.MaLop)
                    {
                        sosvtoida1lop = tt.sosvtoida1nhom;
                    }
                }
                cell       = new DataGridViewTextBoxCell();
                cell.Value = sosvtoida1lop;
                row.Cells.Add(cell);

                //
                var dsdk       = Dao_GiaoVu.DSDangKy();
                int svdadk1lop = 0;
                foreach (var tt in dsdk)
                {
                    if (tt.malop == cd.MaLop)
                    {
                        svdadk1lop++;
                    }
                }
                cell       = new DataGridViewTextBoxCell();
                cell.Value = svdadk1lop;
                row.Cells.Add(cell);

                //
                cell = new DataGridViewTextBoxCell();
                string tengv = "";
                var    dsgv  = Dao_GiaoVu.DSGiaoVien();
                foreach (var tt in dsgv)
                {
                    if (cd.GVPhuTrach == tt.MaND)
                    {
                        tengv = tt.TenGV;
                        break;
                    }
                }
                if (tengv == "" || tengv == "no")
                {
                    cell.Value = "Chưa có";
                }
                else
                {
                    cell.Value = tengv;
                }
                row.Cells.Add(cell);

                dataGridViewCacLopChuyenDeDangMo.Rows.Add(row);
            }
        }
        void LoadDGVChuyenDeDuocMo()
        {
            dataGridViewChuyenDeDuocMo.Rows.Clear();
            var              ds   = Dao_GiaoVu.DSChuyenDeDuocMo();
            DataGridViewRow  row  = null;
            DataGridViewCell cell = null;

            foreach (var cd in ds)
            {
                row     = new DataGridViewRow();
                row.Tag = cd;

                //cell = new DataGridViewTextBoxCell();
                //cell.Value = cd.MaLop;
                //row.Cells.Add(cell);

                cell = new DataGridViewTextBoxCell();
                string tencd = "";
                var    lqq   = Dao_GiaoVu.DSTatCaChuyenDe();
                foreach (var tt in lqq)
                {
                    if (cd.MaCD == tt.MaCD)
                    {
                        tencd = tt.TenCD;
                        break;
                    }
                }
                cell.Value = tencd;
                row.Cells.Add(cell);

                cell       = new DataGridViewTextBoxCell();
                cell.Value = cd.NamHoc;
                row.Cells.Add(cell);

                cell       = new DataGridViewTextBoxCell();
                cell.Value = cd.HocKy;
                row.Cells.Add(cell);

                //SL SV Toi da cua chuyen de + namhoc + hocki
                var dsslsv       = Dao_GiaoVu.DSSLSVTheoChuyenDe();
                int slsvtoida1cd = 0;
                foreach (var tt in dsslsv)
                {
                    if (tt.macd == cd.MaCD && tt.namhoc == cd.NamHoc && tt.hocki == cd.HocKy)
                    {
                        slsvtoida1cd = tt.sosvtoida1cd;
                    }
                }
                cell       = new DataGridViewTextBoxCell();
                cell.Value = slsvtoida1cd;
                row.Cells.Add(cell);


                //so sv da dangky
                cell = new DataGridViewTextBoxCell();
                var           dslopcuacd = Dao_GiaoVu.DSCacLopChuyenDeDuocMo();
                List <string> arrlop     = new List <string>();
                foreach (var tt in dslopcuacd)
                {
                    if (tt.MaCD == cd.MaCD)
                    {
                        arrlop.Add(tt.MaLop);
                    }
                }
                int svdadk = 0;
                var dsdk   = Dao_GiaoVu.DSDangKy();
                foreach (var tt in dsdk)
                {
                    foreach (var tt1 in arrlop)
                    {
                        if (tt1 == tt.malop)
                        {
                            svdadk++;
                        }
                    }
                }
                cell.Value = svdadk.ToString();
                row.Cells.Add(cell);

                //GV phu trach
                //cell = new DataGridViewTextBoxCell();
                //string tengv = "";
                //var dsgv = Dao_GiaoVu.DSGiaoVien();
                //foreach (var tt in dsgv)
                //{
                //    if (cd.GVPhuTrach == tt.MaND)
                //    {
                //        tengv = tt.TenGV;
                //        break;
                //    }
                //}
                //cell.Value = tengv;
                //row.Cells.Add(cell);

                dataGridViewChuyenDeDuocMo.Rows.Add(row);
            }
        }