Exemple #1
0
        public frmBoSungDiem(string IDStudent, string IDKhoa)
        {
            InitializeComponent();
            this.IDStudent = IDStudent;
            var lsMonHoc = MonHocService.GetListMonHocByIDKhoa(IDKhoa);

            foreach (MonHoc mon in lsMonHoc)
            {
                Label label = new Label();
                label.Text = mon.TenMonHoc;
                TextBox text = new TextBox();
                text.Text = "0";
                text.Name = mon.IDMonHoc;
                lsTextBox.Add(text);
                flpBoSungDiem.Controls.Add(label);
                flpBoSungDiem.Controls.Add(text);
            }
            var lsDiem = DiemService.GetListDiemByIDStudent(IDStudent);

            foreach (TextBox tb in lsTextBox)
            {
                foreach (Diem diem in lsDiem)
                {
                    if (tb.Name == diem.IDMonHoc)
                    {
                        tb.Text = diem.DiemMonHoc.ToString();
                    }
                }
            }
        }
        private void loadCheckedListbox()
        {
            clbSinhVien.Items.Clear();

            List <Student> lsstudent = StudentService.GetAllStudentDB(null);

            clbSinhVien.DisplayMember = "FullName";
            foreach (Student std in lsstudent)
            {
                clbSinhVien.Items.Add(std);
            }
            clbSinhVien.SelectedIndex = 0;
            var lsVan    = MonHocService.GetListMonHocByIDKhoa("1");
            var lsMonHoc = MonHocService.GetListMonHoc();

            foreach (MonHoc mon in lsMonHoc)
            {
                Label label = new Label();
                label.Text = mon.TenMonHoc;
                TextBox text = new TextBox();
                text.Text = "0";
                text.Name = mon.IDMonHoc;
                lsTextBox.Add(text);
                if (mon.IDKhoa == Van)
                {
                    flpVan.Controls.Add(label);
                    flpVan.Controls.Add(text);
                }
                else if (mon.IDKhoa == VatLy)
                {
                    flpVatLy.Controls.Add(label);
                    flpVatLy.Controls.Add(text);
                }
                else if (mon.IDKhoa == CNTT)
                {
                    flpCNTT.Controls.Add(label);
                    flpCNTT.Controls.Add(text);
                }
            }
            Student stdent = clbSinhVien.Items[0] as Student;

            var lsDiem = DiemService.GetListDiemByIDStudent(stdent.IDStudent);

            foreach (TextBox tb in lsTextBox)
            {
                foreach (Diem diem in lsDiem)
                {
                    if (tb.Name == diem.IDMonHoc)
                    {
                        tb.Text = diem.DiemMonHoc.ToString();
                    }
                }
            }
        }