Ejemplo n.º 1
0
        public PagerResultSet <Department> GetList(PagerParameter pageParameter, Action <IDepartmentDataLeave> option = null)
        {
            string sql            = "select * from Department";
            var    departmentList = _dbHelper.GetModelList <Department>(sql, null, pageParameter);

            DepartmentDataLeval dataLeval = new DepartmentDataLeval();

            if (option != null)
            {
                option(dataLeval);
                if (dataLeval.HasUser)
                {
                    var users = new List <UserInfo>(userInfoDataService.GetListAtCache());
                    foreach (var department in departmentList.Rows)
                    {
                        department.CreateUser  = users.Where(x => x.ID.Equals(department.CreateBy)).FirstOrDefault();
                        department.ManagerUser = users.Where(x => x.ID.Equals(department.Manager)).FirstOrDefault();
                    }
                }
                if (dataLeval.HasRotes)
                {
                    var roles = roleDataService.GetListByCatch();
                    foreach (var department in departmentList.Rows)
                    {
                        department.Roles = roles.Where(x => x.DepartmentID.Equals(department.ID)).ToList();
                    }
                }
            }
            return(departmentList);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取分页数据集
        /// </summary>
        /// <param name="helper"></param>
        /// <param name="parameter"></param>
        /// <returns></returns>
        public static PagedSet GetPagerSet(this SqlHelper helper, PagerParameter parameter)
        {
            if (parameter == null)
            {
                throw new ArgumentNullException("分页参数不能为空");
            }

            List <SqlParameter> sqlParam = new List <SqlParameter>
            {
                new SqlParameter("@TableName", parameter.TableName),
                new SqlParameter("@ReturnFields", GetFields(parameter.Fileds, parameter.FiledAlias)),
                new SqlParameter("@PageSize", parameter.PageSize),
                new SqlParameter("@PageIndex", parameter.PageIndex),
                new SqlParameter("@Where", parameter.Condition),
                new SqlParameter("@Orderby", parameter.OrderBy),
                new SqlParameter {
                    ParameterName = "PageCount", DbType = DbType.Int32, Direction = ParameterDirection.Output
                },
                new SqlParameter {
                    ParameterName = "RecordCount", DbType = DbType.Int32, Direction = ParameterDirection.Output
                }
            };

            sqlParam.BuildReturnParameter();

            DataSet dataSet = helper.ExecuteFillDataSet(CommandType.StoredProcedure, _procName, sqlParam.ToArray <SqlParameter>());

            int pageCount   = Convert.ToInt32(sqlParam[sqlParam.Count - 3].Value);
            int recordCount = Convert.ToInt32(sqlParam[sqlParam.Count - 2].Value);

            return(new PagedSet(parameter.PageIndex, parameter.PageSize, pageCount, recordCount, dataSet));
        }
Ejemplo n.º 3
0
        public IActionResult Index(int?ID, PagerParameter pagerParameter)
        {
            var departmentList = departmentDataService.GetList().MapperList <ExternalDepartmentViewModel, Department>();

            PageParameterDefault ppd = new PageParameterDefault();

            ppd.SetDefaultValue(pagerParameter);
            Department department = new Department();

            if (!ID.HasValue)
            {
                department = departmentList.First();
            }
            else
            {
                department = departmentDataService.Get(ID.Value);
            }
            if (department.ID != 0)
            {
                var pager = roleDataService.GetList(department.ID, pagerParameter);
                ViewBag.Department     = department;
                ViewBag.DepartmentList = departmentList;
                return(View(pager));
            }
            else
            {
                return(View());
            }
        }
Ejemplo n.º 4
0
        public IActionResult Index(PagerParameter pageParameter)
        {
            PageParameterDefault ppd = new PageParameterDefault();

            ppd.SetDefaultValue(pageParameter);
            var pagers = dataService.GetList(pageParameter, x => x.HasUser = true);

            return(View(pagers));
        }
Ejemplo n.º 5
0
        public IActionResult Index(PagerParameter pageParameter)
        {
            PageParameterDefault ppd = new PageParameterDefault();

            ppd.SetDefaultValue(pageParameter);
            var pager = userInfoDataService.GetPager(pageParameter);

            return(View(pager));
        }
Ejemplo n.º 6
0
        public IActionResult SetAuth(int ID, PagerParameter pager)
        {
            PageParameterDefault pageParameterDefault = new PageParameterDefault();

            pageParameterDefault.SetDefaultValue(pager);
            var user = authorizationDataService.GetList(ID, pager);

            ViewBag.UserID = ID;
            return(View(user));
        }
Ejemplo n.º 7
0
        protected void xsPage_PageChanged(object sender, xsFramework.UserControl.Pager.PageChangedEventArgs e)
        {
            PagerParameter pagepara = new PagerParameter();

            pagepara.DbConn  = GlabalString.DBString;
            pagepara.XsPager = xsPage;
            pagepara.Sql     = pageLogic.QueryGroup();
            pagepara.OrderBy = "group_id";

            gvGroup.DataSource = xsPageHelper.BindPager(pagepara, e);
            gvGroup.DataBind();
        }
Ejemplo n.º 8
0
        // GET: Admin/Book
        public ActionResult List(int?categoryId, int pageIndex = 1)
        {
            var categories = base.Facade.Category.GetAllCategories();

            //将取到的数据存入viewData 中 Categories 是键 显示name 取得id
            ViewData["Categories"] = new SelectList(categories, Category._Id, Category._Name);

            PagerParameter param = new PagerParameter(Book.Tablename, Book._Id, categoryId.HasValue ? "CategoryId=" + categoryId.Value : "1=1", pageIndex);
            var            model = base.Facade.Book.GetPageBooks(param);

            return(View(model));
        }
Ejemplo n.º 9
0
        protected void xsPage_PageChanged(object sender, PageChangedEventArgs e)
        {
            PagerParameter pagepara = new PagerParameter();

            pagepara.DbConn  = GlabalString.DBString;
            pagepara.XsPager = xsPage;
            pagepara.Sql     = pageLogic.QueryUser(ddlGroup.SelectedValue);
            pagepara.OrderBy = "group_id";

            if (!"G001".Equals(LoginUser.LoginUserGroup))
            {
                gvUser.Columns[2].Visible = false;
            }
            gvUser.DataSource = xsPageHelper.BindPager(pagepara, e);
            gvUser.DataBind();
        }
Ejemplo n.º 10
0
        /// <summary>
        /// 获取分页数据集合
        /// </summary>
        /// <param name="helper"></param>
        /// <param name="parameter"></param>
        /// <returns></returns>
        public static PagedList <T> GetPagerList <T>(this SqlHelper helper, PagerParameter parameter)
        {
            if (parameter == null)
            {
                throw new ArgumentNullException("分页参数不能为空");
            }

            List <SqlParameter> sqlParam = new List <SqlParameter>
            {
                new SqlParameter("@TableName", parameter.TableName),
                new SqlParameter("@ReturnFields", GetFields(parameter.Fileds, parameter.FiledAlias)),
                new SqlParameter("@Where", parameter.Condition),
                new SqlParameter("@Orderby", parameter.OrderBy)
            };

            return(GetPagerList <T>(helper, _procName, parameter, sqlParam.ToArray()));
        }
Ejemplo n.º 11
0
        protected void xsPage_PageChanged(object sender, xsFramework.UserControl.Pager.PageChangedEventArgs e)
        {
            PagerParameter pagepara = new PagerParameter();

            pagepara.DbConn  = GlabalString.DBString;
            pagepara.XsPager = xsPage;
            pagepara.Sql     = pageLogic.QueryProducts(ddlType.SelectedValue, txtName.Text);
            pagepara.OrderBy = "product_id";

            DataTable dt = xsPageHelper.BindPager(pagepara, e);

            Nodata.Visible = false;
            if (dt.Rows.Count == 0)
            {
                Nodata.Visible = true;
            }

            rptProduct.DataSource = dt;
            rptProduct.DataBind();
        }
Ejemplo n.º 12
0
        protected void xsPage_PageChanged(object sender, xsFramework.UserControl.Pager.PageChangedEventArgs e)
        {
            PagerParameter pagepara = new PagerParameter();

            pagepara.DbConn  = GlabalString.DBString;
            pagepara.XsPager = xsPage;
            pagepara.Sql     = pageLogic.QueryLeave();
            pagepara.OrderBy = "leave_time";
            DataTable dt = xsPageHelper.BindPager(pagepara, e);

            NoData.Visible = false;
            if (dt.Rows.Count == 0)
            {
                NoData.Visible = true;
            }
            else
            {
                rptLeave.DataSource = dt;
                rptLeave.DataBind();
            }
        }
Ejemplo n.º 13
0
 public PagerResultSet <UserInfo> GetPager(PagerParameter pager)
 {
     return(_dbHelper.GetModelList <UserInfo>("select * from UserInfo", null, pager));
 }
Ejemplo n.º 14
0
 /// <summary>
 /// 获取分页图书列表
 /// </summary>
 /// <param name="param">分页参数类型</param>
 /// <returns></returns>
 public PagedList <Book> GetPageBooks(PagerParameter param)
 {
     return(base.BookRepository.GetPageBooks(param));
 }
Ejemplo n.º 15
0
        public PagerResultSet <UserAuthorization> GetList(int userID, PagerParameter pager)
        {
            string sql = @" SELECT 
	                                UserAuthorization.*,
	                                UserInfo.ID as UID,
	                                UserInfo.[Name] as UName,
	                                UserInfo.Phone as UPhone,
	                                UserInfo.Cornet as UCornet,
	                                UserInfo.EMail  as UEmail,
	                                UserInfo.QQ as UQQ,
	                                UserInfo.Address as UAddress,
	                                UserInfo.Domicile as UDomicile,
	                                UserInfo.PhotoUrl as UPhotoUrl,
	                                AppInfo.ID as AID,
	                                AppInfo.Name as AName,
	                                AppInfo.Code as ACode,
	                                Department.ID as DID,
	                                Department.CreateBy as DCreateBy,
	                                Department.CreateDate as DCreateDate,
	                                Department.Deleted as DDeleted,
	                                Department.Manager as DManager,
	                                Department.Name as DName
	
                                FROM UserAuthorization
                                join UserInfo on UserInfo.ID = UserAuthorization.UserID
                                join AppInfo on AppInfo.ID = UserAuthorization.AppInfoID
                                join Department on Department.ID = UserAuthorization.DepartmentID ";

            if (userID != 0)
            {
                sql += " where UserInfo.ID=" + userID;
            }
            return(_dbHelper.GetModelList <UserAuthorization>(sql, null, pager, dr => {
                UserAuthorization userAuthorization = new UserAuthorization();
                userAuthorization.ID = int.Parse(dr["ID"].ToString());
                userAuthorization.AppInfo = new AppInfo();
                userAuthorization.AppInfoID = int.Parse(dr["AppInfoID"].ToString());
                userAuthorization.AppInfo.Code = dr["ACode"].ToString();
                userAuthorization.AppInfo.Name = dr["AName"].ToString();
                userAuthorization.AppInfo.ID = userAuthorization.AppInfoID;
                userAuthorization.Department = new Department();
                userAuthorization.DepartmentID = (int)dr["DepartmentID"];
                userAuthorization.Department.ID = userAuthorization.DepartmentID;
                userAuthorization.Department.Name = dr["DName"].ToString();
                userAuthorization.Department.Manager = (int)dr["DManager"];
                userAuthorization.Department.Deleted = (bool)dr["DDeleted"];
                userAuthorization.Department.CreateBy = (int)dr["DCreateBy"];
                userAuthorization.Department.CreateDate = (DateTime)dr["DCreateDate"];
                userAuthorization.User = new UserInfo();
                userAuthorization.UserID = (int)dr["UserID"];
                userAuthorization.User.ID = userAuthorization.UserID;
                userAuthorization.User.Name = (string)dr["UName"];
                userAuthorization.User.Phone = (string)dr["UPhone"];
                userAuthorization.User.Cornet = (string)dr["UCornet"];
                userAuthorization.User.Email = (string)dr["UEmail"];
                userAuthorization.User.QQ = (string)dr["UQQ"];
                userAuthorization.User.Address = (string)dr["UAddress"];
                userAuthorization.User.Domicile = (string)dr["UDomicile"];
                userAuthorization.User.PhotoUrl = (string)dr["UPhotoUrl"];
                userAuthorization.LoginID = (string)dr["LoginID"];
                userAuthorization.Password = (string)dr["Password"];
                return userAuthorization;
            }));
        }
Ejemplo n.º 16
0
        /// <summary>
        /// 获取分页数据集合
        /// </summary>
        /// <param name="helper"></param>
        /// <param name="parameter"></param>
        /// <returns></returns>
        public static PagedList <T> GetPagerList <T>(this SqlHelper helper, string procName, PagerParameter parameter, params SqlParameter[] param)
        {
            if (parameter == null)
            {
                throw new ArgumentNullException("分页参数不能为空");
            }

            List <SqlParameter> sqlParam = new List <SqlParameter>
            {
                new SqlParameter("@PageSize", parameter.PageSize),
                new SqlParameter("@PageIndex", parameter.PageIndex),
            };

            sqlParam = sqlParam.Concat(param).ToList();

            sqlParam.Add(ParameterHelper.NewOutParameter("PageCount", SqlDbType.Int));
            sqlParam.Add(ParameterHelper.NewOutParameter("RecordCount", SqlDbType.Int));
            sqlParam.BuildReturnParameter();

            IList <T> result = null;
            //去数据库
            DataSet dataSet = helper.ExecuteFillDataSet(CommandType.StoredProcedure, procName, sqlParam.ToArray <SqlParameter>());

            if (ValidationHelper.IsNotEmptyDataSet(dataSet))
            {
                result = DataConvertHelper.ToList <T>(dataSet.Tables[0], "PageView_RowNo");
            }

            int pageCount   = Convert.ToInt32(sqlParam[sqlParam.Count - 3].Value);
            int recordCount = Convert.ToInt32(sqlParam[sqlParam.Count - 2].Value);

            return(new PagedList <T>(parameter.PageIndex, parameter.PageSize, pageCount, recordCount, result));
        }
        public static PagerResult <TDto> GetPagerResult <TDto, TEntity>(this IQueryable <TEntity> source, PagerParameter parameter)
        {
            if (string.IsNullOrEmpty(parameter.OrderBy))
            {
                parameter.OrderBy = "Id";
            }
            int total = source.Count();
            var list  = source.OrderBy(parameter.OrderBy, parameter.IsAsc).Skip((parameter.PageIndex - 1) * parameter.PageSize).Take(parameter.PageSize).ToList();
            var dtos  = list.MapTo <List <TDto> >();

            return(new PagerResult <TDto>(parameter.PageSize, parameter.PageIndex, total, dtos.ToList()));
        }
Ejemplo n.º 18
0
        public static PagerResult <TEntity> Page <TEntity>(this IQueryable <TEntity> source, PagerParameter parameter)
        {
            int total = source.Count();
            var list  = source.Skip((parameter.PageIndex - 1) * parameter.PageSize).Take(parameter.PageSize).ToList();

            return(new PagerResult <TEntity>(parameter.PageSize, parameter.PageIndex, total, list));
        }
Ejemplo n.º 19
0
        public static PagerResult <TResult> Page <TSource, TResult>(this IQueryable <TSource> source, PagerParameter parameter, Func <TSource, TResult> selector)
        {
            int total = source.Count();
            var list  = source.Skip((parameter.PageIndex - 1) * parameter.PageSize).Take(parameter.PageSize).ToList().Select(selector);

            return(new PagerResult <TResult>(parameter.PageSize, parameter.PageIndex, total, list.ToList()));
        }
Ejemplo n.º 20
0
 public PagedList <Book> GetPageBooks(PagerParameter param)
 {
     return(base.Database.GetPagerList <Book>(param));
 }
Ejemplo n.º 21
0
        public PagerResultSet <Role> GetList(int departmentID, PagerParameter pageParameter)
        {
            string sql = " select * from Role where departmentID=@departmentID ";

            return(dbHelper.GetModelList <Role>(sql, new { departmentID = departmentID }, pageParameter));
        }