Esempio n. 1
0
        /*--------------人员查找-----------*/
        public PageRows <user[]> searchUsers(string name, string department)
        {
            RDDataContext     rd         = new RDDataContext();
            PageRows <user[]> returnData = new PageRows <user[]>();

            if (name != "" && department != "")
            {
                var temp = from a in rd.user
                           where a.name.Contains(name) && a.department.Contains(department)
                           select a;
                returnData.message = "success";
                returnData.success = true;
                returnData.total   = temp.Count();
                returnData.rows    = temp.ToArray();
                rd.Dispose(); return(returnData);
            }
            if (name == "" && department != "")
            {
                var temp = from a in rd.user
                           where a.department.Contains(department)
                           select a;
                returnData.message = "success";
                returnData.success = true;
                returnData.total   = temp.Count();
                returnData.rows    = temp.ToArray();
                rd.Dispose(); return(returnData);
            }
            if (name == "" && department == "")
            {
                var temp = from a in rd.user
                           select a;
                returnData.message = "success";
                returnData.success = true;
                returnData.total   = temp.Count();
                returnData.rows    = temp.ToArray();
                rd.Dispose(); return(returnData);
            }
            if (name != "" && department == "")
            {
                var temp = from a in rd.user
                           where a.name.Contains(name)
                           select a;
                returnData.message = "success";
                returnData.success = true;
                returnData.total   = temp.Count();
                returnData.rows    = temp.ToArray();
                rd.Dispose(); return(returnData);
            }
            else
            {
                returnData.success = false;
                returnData.message = "筛选信息缺失!";
                rd.Dispose(); return(returnData);
            }
        }
Esempio n. 2
0
        /*--------------显示人员列表-----------*/
        public PageRows <user[]> getUserList()
        {
            RDDataContext     rd         = new RDDataContext();
            PageRows <user[]> returnData = new PageRows <user[]>();
            var temp = from a in rd.user
                       select a;

            returnData.message = "success";
            returnData.success = true;
            returnData.total   = temp.Count();
            returnData.rows    = temp.ToArray();
            rd.Dispose(); return(returnData);
        }