示例#1
0
        private void DoDuLieu()
        {
            string        IDdean        = txtIDDeAn.Text.Trim();
            string        tendean       = txtTenDeAn.Text.Trim();
            string        loaidean      = cbType.Text;
            string        idnhom        = txtIDNhom.Text.Trim();
            string        gvhd          = txtGVHD.Text.Trim();
            string        idchuyennganh = txtMaChuyenNganh.Text.Trim();
            string        idmonhoc      = txtMaMonHoc.Text.Trim();
            List <string> a             = new List <string>();
            string        type          = "";

            if (loaidean == cbType.Items[0].ToString())
            {
                type = "0";
            }
            else if (loaidean == cbType.Items[1].ToString())
            {
                type = "1";
            }
            else if (loaidean == cbType.Items[2].ToString())
            {
                type = "2";
            }
            using (var _context = new DBLapTrinhWin())
            {
                var x = (from u in _context.DeAns
                         where u.IDDeAn.Contains(IDdean) && u.TenDeAn.Contains(tendean) && u.Type.Contains(type) &&
                         u.IDNhomSV.Contains(idnhom) && u.GiangVien.HoTen.Contains(gvhd) && u.IDDeAn.Contains(idchuyennganh) &&
                         u.IDDeAn.Contains(idmonhoc)
                         select new DeAnViewModel
                {
                    IDDeAn = u.IDDeAn,
                    TenDeAn = u.TenDeAn,
                    TenNhom = u.NhomSinhVien.TenNhom,
                    MoTa = u.MoTa,
                    TenMonHoc = u.MonHoc1.TenMonHoc,
                    LoaiDeAn = u.Type1.LoaiDeAn,
                    StringThanhVien = u.NhomSinhVien.ThanhVien,
                    TenChuyenNganh = u.ChuyenNganh1.TenChuyenNganh,
                    HoTenGV = u.GiangVien.HoTen,
                    DateStart = u.DateStart,
                    DateEnd = u.DateEnd,
                    Diem = u.Diem,
                    TienDo = u.TienDo.HasValue ? (u.TienDo * 100).ToString() + "%" : "0%"
                }).ToList();

                foreach (var deAn in x)
                {
                    deAn.DanhSachThanhVien = NhomController.GetDanhSachThanhVien(deAn.StringThanhVien);
                }

                this.dtgDeAn.DataSource = x;
            }
        }
示例#2
0
        private void btnFind_Click(object sender, EventArgs e)
        {
            string        IDdean        = txtIDDeAn.Text.Trim();
            string        tendean       = txtTenDeAn.Text.Trim();
            string        loaidean      = cbType.Text;
            string        idnhom        = txtIDNhom.Text.Trim();
            string        gvhd          = txtGVHD.Text.Trim();
            string        idchuyennganh = txtMaChuyenNganh.Text.Trim();
            string        idmonhoc      = txtMaMonHoc.Text.Trim();
            List <string> a             = new List <string>();
            string        type          = "";

            if (loaidean == cbType.Items[0].ToString())
            {
                type = "0";
            }
            else if (loaidean == cbType.Items[1].ToString())
            {
                type = "1";
            }
            else if (loaidean == cbType.Items[2].ToString())
            {
                type = "2";
            }
            using (var _context = new DBLapTrinhWin())
            {
                var x = from u in _context.DeAns
                        where u.IDDeAn.Contains(IDdean) && u.TenDeAn.Contains(tendean) && u.Type.Contains(type) &&
                        u.IDNhomSV.Contains(idnhom) && u.GiangVien.HoTen.Contains(gvhd) && u.IDDeAn.Contains(idchuyennganh) &&
                        u.IDDeAn.Contains(idmonhoc)
                        select new
                {
                    u.IDDeAn,
                    u.TenDeAn,
                    u.NhomSinhVien.TenNhom,
                    u.MoTa,
                    u.MonHoc1.TenMonHoc,
                    u.Type1.LoaiDeAn,

                    u.NhomSinhVien.ThanhVien,
                    u.ChuyenNganh1.TenChuyenNganh,
                    u.GiangVien.HoTen,
                    u.DateStart,
                    u.DateEnd,
                    u.TienDo,
                    u.Diem
                };

                List <DeAnViewModel> y = new List <DeAnViewModel>();
                foreach (var i in x)
                {
                    DeAnViewModel k = new DeAnViewModel();
                    k.IDDeAn  = i.IDDeAn;
                    k.TenDeAn = i.TenDeAn;

                    k.TenNhom           = i.TenNhom;
                    k.MoTa              = i.MoTa;
                    k.TenMonHoc         = i.TenMonHoc;
                    k.LoaiDeAn          = i.LoaiDeAn;
                    k.StringThanhVien   = i.ThanhVien;
                    k.TenChuyenNganh    = i.TenChuyenNganh;
                    k.HoTenGV           = i.HoTen;
                    k.DateStart         = i.DateStart;
                    k.DateEnd           = i.DateEnd;
                    k.TienDo            = i.TienDo.HasValue ? (i.TienDo * 100).ToString() + "%" : "0%";
                    k.Diem              = i.Diem;
                    k.DanhSachThanhVien = NhomController.GetDanhSachThanhVien(k.StringThanhVien);

                    y.Add(k);
                }

                this.dtgDeAn.DataSource = y;
            }
        }