예제 #1
0
        protected void RefreshData(object sender, StoreReadDataEventArgs e)
        {
            int start    = e.Start;
            int pageSize = e.Limit;
            int total    = 0;

            //查询条件
            string Where = " 1=1 ";
            string Name  = Request["UserQuery"] + "";

            Name = Name.Replace("输入姓名简拼", "");
            if (!string.IsNullOrEmpty(Name))
            {
                Where += " and UserName like '%" + Name + "%' or (" + GetPinyinWhereString("UserName", Name) + ")  ";
            }

            if (e.Parameters.GetParameter("PID") != null)
            {
                var PID = e.Parameters.GetParameter("PID").Value;
                if (PID == "root")
                {
                    SysUser[] UserEnts = DataHelper.GetPageList <SysUser>(start, pageSize, new Order[] { new Order("CreateTime", false) }, out total, Expression.Sql(Where));
                    e.Total        = total;
                    UserStore.Data = UserEnts;
                    UserStore.DataBind();
                }
                else
                {
                    Where += " and OrgID='" + PID + "' ";
                    SysOrgUser[] SysOUserEnt = DataHelper.GetPageList <SysOrgUser>(start, pageSize, new Order[] { new Order("CreateTime", false) }, out total, Expression.Sql(Where));
                    e.Total = total;
                    IList <SysUser> UserList = SysOrgUser.GetUsersByEnts(SysOUserEnt);
                    foreach (var item in SysOUserEnt)
                    {
                        var ent = UserList.Where(ten => ten.ID == item.UserID).First();
                        if (ent != null)
                        {
                            UserList.Add(ent);
                        }
                    }
                    UserStore.Data = UserList;
                    UserStore.DataBind();
                    return;
                }
            }
            //默认情况
            SysUser[] Arr = DataHelper.GetPageList <SysUser>(start, pageSize, new Order[] { new Order("CreateTime", false) }, out total, Expression.Sql(Where));
            e.Total        = total;
            UserStore.Data = Arr;
            UserStore.DataBind();
        }