Exemple #1
0
        // GET: Admin/Lop
        public ActionResult Index()
        {
            LopData ld    = new LopData();
            var     model = ld.ListLop();

            return(View(model));
        }
        public static IList <LopInfo> LayDsLop(String namHoc)
        {
            LopData   m_LData = new LopData();
            DataTable m_DT    = m_LData.LayDsLopForReport(namHoc);

            IList <LopInfo> dS = new List <LopInfo>();

            foreach (DataRow Row in m_DT.Rows)
            {
                LopInfo lop = new LopInfo();

                GiaoVienInfo gv = new GiaoVienInfo();
                gv.MaGiaoVien  = Convert.ToString(Row["MaGiaoVien"]);
                gv.TenGiaoVien = Convert.ToString(Row["TenGiaoVien"]);

                KhoiLopInfo kl = new KhoiLopInfo();
                kl.MaKhoiLop  = Convert.ToString(Row["MaKhoiLop"]);
                kl.TenKhoiLop = Convert.ToString(Row["TenKhoiLop"]);

                NamHocInfo nh = new NamHocInfo();
                nh.MaNamHoc  = Convert.ToString(Row["MaNamHoc"]);
                nh.TenNamHoc = Convert.ToString(Row["TenNamHoc"]);

                lop.MaLop    = Convert.ToString(Row["MaLop"]);
                lop.TenLop   = Convert.ToString(Row["TenLop"]);
                lop.KhoiLop  = kl;
                lop.NamHoc   = nh;
                lop.SiSo     = Convert.ToInt32(Row["SiSo"]);
                lop.GiaoVien = gv;

                dS.Add(lop);
            }
            return(dS);
        }
        public void HienThiComboBox(String khoiLop, String namHoc, ComboBox comboBox)
        {
            LopData m_LData = new LopData();

            comboBox.DataSource    = m_LData.LayDsLop(khoiLop, namHoc);
            comboBox.DisplayMember = "TenLop";
            comboBox.ValueMember   = "MaLop";
        }
Exemple #4
0
        //Mới
        public void HienThiComboBox_new(String namHoc, String hocKy, ComboBox comboBox)
        {
            LopData m_LData = new LopData();

            comboBox.DataSource    = m_LData.LayDs_Lop(namHoc, hocKy);
            comboBox.DisplayMember = "TenLop";
            comboBox.ValueMember   = "MaLop";
        }
 /// <summary>
 ///
 /// </summary>
 /// <returns></returns>
 public string LayMaCuoi()
 {
     if (this.Data == null)
     {
         this.Data = new LopData();
     }
     return(Convert.ToString(this.Data.LayMaCuoi()));
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="cmb"></param>
 public void HienThiCombobox(ComboBox cmb)
 {
     if (this.Data == null)
     {
         this.Data = new LopData();
     }
     cmb.DataSource    = this.Data.LayDS();
     cmb.DisplayMember = "TenLop";
     cmb.ValueMember   = "MaLop";
     cmb.SelectedValue = "MaLop";
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="col"></param>
 /// <param name="khoiLop"></param>
 /// <param name="maNamHoc"></param>
 public void HienThiDataGridComboBoxColumn(DataGridViewComboBoxColumn col, string maKhoi, string maNamHoc)
 {
     if (this.Data == null)
     {
         this.Data = new LopData();
     }
     col.DataSource       = this.Data.LayDS(maKhoi, maNamHoc);
     col.DisplayMember    = "TenLop";
     col.ValueMember      = "MaLop";
     col.DataPropertyName = "MaLop";
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="cmb"></param>
 /// <param name="maKhoi"></param>
 /// <param name="maNamHoc"></param>
 /// <param name="maGiaoVien"></param>
 public void HienThiCombobox(ComboBox cmb, string maKhoi, string maNamHoc, string maGiaoVien)
 {
     if (this.Data == null)
     {
         this.Data = new LopData();
     }
     cmb.DataSource    = this.Data.LayDS(maKhoi, maNamHoc, maGiaoVien);
     cmb.DisplayMember = "TenLop";
     cmb.ValueMember   = "MaLop";
     cmb.SelectedValue = "MaLop";
 }
        /// <summary>
        ///
        /// </summary>
        /// <param name="txtMaLop"></param>
        /// <param name="txtTenLop"></param>
        /// <param name="txtSiSo"></param>
        /// <param name="cmbKhoiLop"></param>
        /// <param name="cmbNamHoc"></param>
        /// <param name="cmbMaGiaoVien"></param>
        /// <param name="dgvDS"></param>
        /// <param name="bnDS"></param>
        public void HienThiDS(TextBox txtMaLop, TextBox txtTenLop, TextBox txtSiSo, ComboBox cmbKhoiLop, ComboBox cmbNamHoc, ComboBox cmbMaGiaoVien, DataGridView dgvDS, BindingNavigator bnDS)
        {
            if (this.Data == null)
            {
                this.Data = new LopData();
            }
            BindingSource bs = new BindingSource();

            bs.DataSource      = this.Data.LayDS();
            bnDS.BindingSource = bs;
            dgvDS.DataSource   = bs;
            txtMaLop.DataBindings.Add("Text", bs, "MaLop");
            txtTenLop.DataBindings.Add("Text", bs, "TenLop");
            txtSiSo.DataBindings.Add("Text", bs, "SiSo");
            cmbKhoiLop.DataBindings.Add("SelectedValue", bs, "MaKhoiLop");
            cmbNamHoc.DataBindings.Add("SelectedValue", bs, "MaNamHoc");
            cmbMaGiaoVien.DataBindings.Add("SelectedValue", bs, "MaGiaoVien");
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="maLop"></param>
        /// <returns></returns>
        public LopInfo LayTuMa(string maLop)
        {
            if (this.Data == null)
            {
                this.Data = new LopData();
            }
            DataTable table = this.Data.LayTuMa(maLop);

            if (table.Rows.Count > 0)
            {
                LopInfo info = new LopInfo();
                info.MaLop    = table.Rows[0]["MaLop"].ToString();
                info.TenLop   = table.Rows[0]["TenLop"].ToString();
                info.KhoiLop  = new KhoiLopController().LayTuMa(table.Rows[0]["MaKhoiLop"].ToString());
                info.NamHoc   = new NamHocController().LayTuMa(table.Rows[0]["MaNamHoc"].ToString());
                info.SiSo     = int.Parse(table.Rows[0]["SiSo"].ToString());
                info.GiaoVien = new GiaoVienController().LayTuMa(table.Rows[0]["MaGiaoVien"].ToString());
                return(info);
            }
            return(null);
        }
        public void SetViewBagDD(int?selectedID = null)
        {
            var mt = new LopData();

            ViewBag.MaLop = new SelectList(mt.ListLop(), "MaLop", "TenLop", selectedID);
        }
 public LopController()
 {
     this.Data = new LopData();
 }