示例#1
0
        private void buttonInit_Click(object sender, EventArgs e)
        {
            //using (WE_LinqToSQLDataContext context = new WE_LinqToSQLDataContext())
            //{
            //	relationDeptBindingSource.DataSource = context.RelationDepts;
            //}
            //gridLookUpEdit1.Properties.DataSource = context.a();

/*
 *                      var kq = from user in context.UserInfos
 *                                              join phong in context.RelationDepts.DefaultIfEmpty() on user.UserIDD equals phong.ID
 *                              select user;
 *                      gridControl1.DataSource = kq;
 */
            GV.cs = (@"Data Source=.\sqlexpress;Initial Catalog=WiseEyeV5Express;Integrated Security=True;");
            test();
            return;

            var kq = from user in db.UserInfos
                     join phong in db.RelationDepts on user.UserIDD equals phong.ID into JG_Phong
                     join lichtrinh in db.Schedules on user.SchID equals lichtrinh.SchID into JG_LichTrinh
                     from listDeptOfEachUser in JG_Phong.DefaultIfEmpty()
                     from listScheOfEachUser in JG_LichTrinh.DefaultIfEmpty()
                     where   user.UserIDD != null &&
                     (from phanQuyen in db.DeptPrivileges
                      where   phanQuyen.IsYes && phanQuyen.UserID == 21
                      select phanQuyen.IDD).Contains((int)user.UserIDD) &&
                     listDeptOfEachUser != null
                     select new {
                user.UserFullCode, user.UserFullName, UserEnrollNumber = user.UserEnrollNumber, user.UserLastName,
                UserIDDepartment = user.UserIDD, DepartmentDescription = listDeptOfEachUser.Description,
                ScheduleID       = user.SchID, ScheduleName = listScheOfEachUser.SchName
            };

            //popupContainerEdit1.DataBindings.Add("EditValue", kq.ToList(), "UserFullName");
            //popupContainerEdit1.DataBindings.Add("EditValue", kq.ToList(), "User");
            gridControl1.DataSource = kq;
        }
        private void simpleButtonInitData_Click(object sender, EventArgs e)
        {
            var kq5 =             //from phanQuyen in db.DeptPrivileges
                                  //from phong in db.RelationDepts
                                  //from user in db.UserInfos
                                  //	 join phong in db.RelationDepts on user.UserIDD equals phong.ID into JG_Phong
                                  //	 join lichtrinh in db.Schedules on user.SchID equals lichtrinh.SchID into JG_LichTrinh
                                  //	 from item1 in JG_Phong.DefaultIfEmpty()
                                  //	 from item2 in JG_LichTrinh.DefaultIfEmpty()
                                  //where	item1 != null && item2 != null &&
                                  //		(from phong in db.RelationDepts
                                  //			   where
                                  //			   select phong.ID).Contains((int) user.UserIDD)


                      from user in db.UserInfos
                      join phong in db.RelationDepts on user.UserIDD equals phong.ID into JG_Phong
                      join lichtrinh in db.Schedules on user.SchID equals lichtrinh.SchID into JG_LichTrinh
                      from listDeptOfEachUser in JG_Phong.DefaultIfEmpty()
                      from listScheOfEachUser in JG_LichTrinh.DefaultIfEmpty()
                      where
                      user.UserIDD != null &&
                      (from phanQuyen in db.DeptPrivileges
                       where phanQuyen.IsYes && phanQuyen.UserID == 21
                       select phanQuyen.IDD).Contains((int)user.UserIDD) &&
                      listDeptOfEachUser != null
                      select new {
                user.UserLastName, user.UserFullCode, user.UserFullName, user.UserEnrollNumber,
                UserIDDepartment = user.UserIDD, DepartmentDescription = listDeptOfEachUser.Description,
                ScheduleID       = user.SchID, ScheduleName = listScheOfEachUser.SchName
            };

            //var kq6 = from user in

            gridControl1.DataSource = kq5;
        }