Beispiel #1
0
        public void load(string MACV, string MAKHOA, string MAHV)
        {
            using (var db = new QLHOCVUEntities())
            {
                //load listBox
                if (lbdsCV.DataSource == null)
                {
                    var cvdf = new CHUC_VU()
                    {
                        MACV  = "",
                        TENCV = "Tất cả"
                    };

                    var chuc_vu = db.CHUC_VU.ToList();
                    chuc_vu.Insert(0, cvdf);
                    lbdsCV.DataSource = chuc_vu;
                }
                lbdsCV.DisplayMember = "TENCV";
                lbdsCV.ValueMember   = "MACV";


                if (lbdsK.DataSource == null)
                {
                    var kdf = new KHOA()
                    {
                        MAKHOA  = "",
                        TENKHOA = "Tất cả"
                    };

                    var khoas = db.KHOAs.ToList();
                    khoas.Insert(0, kdf);
                    lbdsK.DataSource = khoas;
                }
                lbdsK.DisplayMember = "TENKHOA";
                lbdsK.ValueMember   = "MAKHOA";


                if (lbdsHV.DataSource == null)
                {
                    var hvdf = new HOC_VI()
                    {
                        MAHV  = "",
                        TENHV = "Tất cả"
                    };

                    var hoc_vi = db.HOC_VI.ToList();
                    hoc_vi.Insert(0, hvdf);
                    lbdsHV.DataSource = hoc_vi;
                }
                lbdsHV.DisplayMember = "TENHV";
                lbdsHV.ValueMember   = "MAHV";



                dgvGV.AutoSize            = true;
                dgvGV.AutoGenerateColumns = false;
                var GV = db.GIANG_VIEN.AsQueryable();
                if (!string.IsNullOrEmpty(MACV))
                {
                    GV = GV.Where(x => x.MACV == MACV);
                }
                if (!string.IsNullOrEmpty(MAKHOA))
                {
                    GV = GV.Where(x => x.MAKHOA == MAKHOA);
                }
                if (!string.IsNullOrEmpty(MAHV))
                {
                    GV = GV.Where(x => x.MAHV == MAHV);
                }

                dgvGV.DataSource = GV.Select(x => new
                {
                    MAGV         = x.MAGV,
                    MACV         = x.MACV,
                    TENCV        = x.CHUC_VU.TENCV,
                    TENGV        = x.TENGV,
                    MAHV         = x.MAHV,
                    TENHV        = x.HOC_VI.TENHV,
                    Email        = x.EMAIL,
                    QueQuan      = x.QUEQUAN,
                    DiaChiTamChu = x.DIACHITAMCHU,
                    MAKHOA       = x.MAKHOA,
                    TenKhoa      = x.KHOA.TENKHOA,
                    TrangThaiGV  = x.TRANGTHAIGV == "1" ? "Rảnh" : "Không Rảnh",
                }).ToList();

                btnThem.Enabled = false;
                btnSua.Enabled  = false;
            }
        }
Beispiel #2
0
        public void loadList()
        {
            string        connecStr = "workstation id = QLGIAOVU.mssql.somee.com; packet size = 4096; user id = nhoxliaryeuem1_SQLLogin_1; pwd=8l5ab41xg8;data source = QLGIAOVU.mssql.somee.com; persist security info=False;initial catalog = QLGIAOVU";
            SqlConnection conn      = new SqlConnection(connecStr);

            using (var db = new QLHOCVUEntities())
            {
                //load listBox
                if (lbdsCV.DataSource == null)
                {
                    var cvdf = new CHUC_VU()
                    {
                        MACV  = "",
                        TENCV = "Tất cả"
                    };

                    var chuc_vu = db.CHUC_VU.ToList();
                    chuc_vu.Insert(0, cvdf);
                    lbdsCV.DataSource = chuc_vu;
                }
                lbdsCV.DisplayMember = "TENCV";
                lbdsCV.ValueMember   = "MACV";


                if (lbdsK.DataSource == null)
                {
                    var kdf = new KHOA()
                    {
                        MAKHOA  = "",
                        TENKHOA = "Tất cả"
                    };

                    var khoas = db.KHOAs.ToList();
                    khoas.Insert(0, kdf);
                    lbdsK.DataSource = khoas;
                }
                lbdsK.DisplayMember = "TENKHOA";
                lbdsK.ValueMember   = "MAKHOA";


                if (lbdsHV.DataSource == null)
                {
                    var hvdf = new HOC_VI()
                    {
                        MAHV  = "",
                        TENHV = "Tất cả"
                    };

                    var hoc_vi = db.HOC_VI.ToList();
                    hoc_vi.Insert(0, hvdf);
                    lbdsHV.DataSource = hoc_vi;
                }
                lbdsHV.DisplayMember = "TENHV";
                lbdsHV.ValueMember   = "MAHV";
            }

            //try
            //{
            //    string cautruyvan = "select * from CHUC_VU";
            //    SqlDataAdapter adt = new SqlDataAdapter(cautruyvan, conn);
            //    DataTable dt = new DataTable();
            //    adt.Fill(dt);

            //    ///////////////////////////////////////////////////////
            //    if (lbdsCV.DataSource == null)
            //    {
            //        var cvdf = new CHUC_VU()
            //        {
            //            MACV = "",
            //            TENCV = "Tất cả"
            //        };



            //        var chuc_vu = db.CHUC_VU.ToList();
            //        chuc_vu.Insert(0, cvdf);
            //        lbdsCV.DataSource = chuc_vu;
            //    }


            //    lbdsCV.DataSource = dt;
            //    lbdsCV.DisplayMember = "TENCV";
            //    lbdsCV.ValueMember = "MACV";
            //}
            //catch (SqlException)
            //{
            //    MessageBox.Show("Error CHUC_VU");
            //    //hien loi
            //}
            //try
            //{
            //    string cautruyvan = "select * from KHOA";
            //    SqlDataAdapter adt = new SqlDataAdapter(cautruyvan, conn);
            //    DataTable dt = new DataTable();
            //    adt.Fill(dt);
            //    lbdsK.DataSource = dt;
            //    lbdsK.DisplayMember = "TENKHOA";
            //    lbdsK.ValueMember = "MAKHOA";
            //}
            //catch (SqlException)
            //{
            //    MessageBox.Show("Error KHOA");
            //    //hien loi
            //}
            //try
            //{
            //    string cautruyvan = "select * from HOC_VI";
            //    SqlDataAdapter adt = new SqlDataAdapter(cautruyvan, conn);
            //    DataTable dt = new DataTable();
            //    adt.Fill(dt);
            //    lbdsHV.DataSource = dt;
            //    lbdsHV.DisplayMember = "TENHV";
            //    lbdsHV.ValueMember = "MAHV";
            //}
            //catch (SqlException)
            //{
            //    MessageBox.Show("Error HOC_VI");
            //    //hien loi
            //}
        }