コード例 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="lvDS"></param>
        public void HienThiDS(ListView lvDS)
        {
            if (this.Data == null)
            {
                this.Data = new LopMonHocData();
            }
            DataTable table = this.Data.LayDS(false);

            lvDS.Items.Clear();
            foreach (DataRow row in table.Rows)
            {
                LopMonHocInfo info = new LopMonHocInfo();
                info.MaLopMonHoc = int.Parse(row["MaLopMonHoc"].ToString());
                LopController lopCtrl = new LopController();
                info.Lop = lopCtrl.LayTuMa(row["MaLop"].ToString());
                MonHocController monHocCtrl = new MonHocController();
                info.MonHoc = monHocCtrl.LayTuMa(row["MaMonHoc"].ToString());

                ListViewItem item = new ListViewItem();
                item.Text = info.Lop.TenLop;
                item.SubItems.Add(info.MonHoc.TenMonHoc);

                object[] tag = new object[2];
                tag[0] = info;
                tag[1] = row;

                item.Tag = tag;
                lvDS.Items.Add(item);
            }
        }
コード例 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="maLopMonHoc"></param>
        /// <returns></returns>
        public LopMonHocInfo LayTuMa(int maLopMonHoc)
        {
            if (this.Data == null)
            {
                this.Data = new LopMonHocData();
            }
            DataTable table = this.Data.LayTuMa(maLopMonHoc);

            if (table.Rows.Count > 0)
            {
                LopMonHocInfo info = new LopMonHocInfo();
                info.MaLopMonHoc = int.Parse(table.Rows[0]["MaLopMonHoc"].ToString());
                LopController lopCtrl = new LopController();
                info.Lop = lopCtrl.LayTuMa(table.Rows[0]["MaLop"].ToString());
                MonHocController monHocCtrl = new MonHocController();
                info.MonHoc = monHocCtrl.LayTuMa(table.Rows[0]["MaMonHoc"].ToString());
                return(info);
            }
            return(null);
        }