public IEnumerable <ListUserLogin> Manage_Partial(Detail data)
        {
            List <ListUserLogin> results = new List <ListUserLogin>();

            try
            {
                ListUserLogin value = new ListUserLogin();

                UserDataContext DropD = new UserDataContext();
                var             dep   = (from xx in DropD.MAS_USER_As
                                         orderby xx.US_ID
                                         select xx).GroupBy(x => x.ANAME).Select(grp => grp.First());

                //value.Dep = new SelectList(dep, "US_ID", "ANAME");

                var sh = data.sh;

                using (UserDataContext Context = new UserDataContext())
                {
                    IQueryable <VW_USER_FOR_LE> DataUser;
                    DataUser = Context.VW_USER_FOR_LEs;

                    if (sh.Length > 0)
                    {
                        DataUser = DataUser.Where(x => x.STCODE.Contains(sh) || x.NAME.Contains(sh) || x.DPCODE.Contains(sh));
                    }

                    List <USER_LOGIN> UserAns = new List <USER_LOGIN>();

                    foreach (var dx in DataUser)
                    {
                        USER_LOGIN ux = new USER_LOGIN();

                        ux.ID       = dx.US_ID;
                        ux.STCODE   = dx.STCODE;
                        ux.FULLNAME = dx.NAME;
                        ux.DEP      = dx.DPCODE;
                        ux.A_NAME   = dx.ANAME;

                        UserAns.Add(ux);
                        //PhoneModels.RowPhone.Add(ipn);
                    }
                    value.Userloginid = UserAns;
                }

                value.sh = sh;

                results.Add(value);
            }
            catch (Exception ex)
            {
                //Detail res = new Detail();
                //res.status = "F";
                //res.message = ex.Message;
                //results.Add(res);
            }

            return(results.ToArray());
        }
Beispiel #2
0
        public ActionResult Manage_Partial(int page = 1, string sh = "")
        {
            UserViewModels Model = new UserViewModels();

            data_userDataContext DropD = new data_userDataContext();
            var dep = (from xx in DropD.MAS_USER_As
                       orderby xx.US_ID
                       select xx).GroupBy(x => x.ANAME).Select(grp => grp.First());

            ViewBag.Dep = new SelectList(dep, "US_ID", "ANAME");

            sh = sh.Trim();

            List <USER_LOGIN> list = new List <USER_LOGIN>();

            using (data_userDataContext Context = new data_userDataContext())
            {
                IQueryable <VW_USER_FOR_LE> DataUser;
                DataUser = Context.VW_USER_FOR_LEs;

                if (sh.Length > 0)
                {
                    DataUser = DataUser.Where(x => x.STCODE.Contains(sh) || x.NAME.Contains(sh) || x.DPCODE.Contains(sh));
                }

                foreach (var dx in DataUser)
                {
                    USER_LOGIN ux = new USER_LOGIN();

                    ux.ID       = dx.US_ID;
                    ux.STCODE   = dx.STCODE;
                    ux.FULLNAME = dx.NAME;
                    ux.DEP      = dx.DPCODE;
                    ux.A_NAME   = dx.ANAME;

                    list.Add(ux);
                    //PhoneModels.RowPhone.Add(ipn);
                }
                //Model.RowUser = list;
            }

            ViewBag.sh = sh;

            return(PartialView(list.ToPagedList(page, 20)));
        }