コード例 #1
0
        /// <summary>
        /// 根据分页获得数据列表
        /// </summary>
        /// <param name="TbFields">返回字段</param>
        /// <param name="strWhere">查询条件</param>
        /// <param name="OrderField">排序字段</param>
        /// <param name="PageIndex">页码</param>
        /// <param name="PageSize">页尺寸</param>
        /// <param name="TotalCount">返回总记录数</param>
        /// <returns>IList<AdminRoleInfo></returns>
        public IList <AdminRoleInfo> Find(string tbFields, string strWhere, string orderField, int pageIndex, int pageSize, out int totalCount)
        {
            IList <AdminRoleInfo> list = new List <AdminRoleInfo>();

            using (DbCommand cmd = db.GetStoredProcCommand("SP_SqlPagenation"))
            {
                db.AddInParameter(cmd, "@TbName", DbType.String, "AdminRole");
                db.AddInParameter(cmd, "@TbFields", DbType.String, tbFields);
                db.AddInParameter(cmd, "@StrWhere", DbType.String, strWhere);
                db.AddInParameter(cmd, "@OrderField", DbType.String, orderField);
                db.AddInParameter(cmd, "@PageIndex", DbType.Int32, pageIndex);
                db.AddInParameter(cmd, "@PageSize", DbType.Int32, pageSize);
                db.AddOutParameter(cmd, "@Total", DbType.Int32, int.MaxValue);
                using (DataTable dt = db.ExecuteDataSet(cmd).Tables[0])
                {
                    if (dt.Rows.Count > 0)
                    {
                        foreach (DataRow dr in dt.Rows)
                        {
                            AdminRoleInfo model = new AdminRoleInfo();
                            model.LoadFromDataRow(dr);
                            list.Add(model);
                        }
                    }
                }

                totalCount = (int)db.GetParameterValue(cmd, "@Total");
                return(list);
            }
        }
コード例 #2
0
        /// <summary>
        /// 获得实体
        /// </summary>
        /// <param name="keyValue">编号</param>
        /// <returns>AdminRoleInfo</returns>
        public AdminRoleInfo Get(int keyValue)
        {
            AdminRoleInfo model = null;

            using (DbCommand cmd = db.GetStoredProcCommand("SP_GetRecord"))
            {
                db.AddInParameter(cmd, "@TableName", DbType.String, "AdminRole");
                db.AddInParameter(cmd, "@KeyName", DbType.String, "AdminID");
                db.AddInParameter(cmd, "@KeyValue", DbType.Int32, keyValue);
                using (DataTable dt = db.ExecuteDataSet(cmd).Tables[0])
                {
                    if (dt.Rows.Count > 0)
                    {
                        model = new AdminRoleInfo();
                        model.LoadFromDataRow(dt.Rows[0]);
                    }
                }
                return(model);
            }
        }
コード例 #3
0
ファイル: AdminRoleDAL.cs プロジェクト: aNd1coder/Wojoz
        /// <summary>
        /// 根据分页获得数据列表
        /// </summary>
        /// <param name="TbFields">返回字段</param>
        /// <param name="strWhere">查询条件</param>
        /// <param name="OrderField">排序字段</param>
        /// <param name="PageIndex">页码</param>
        /// <param name="PageSize">页尺寸</param> 
        /// <param name="TotalCount">返回总记录数</param>
        /// <returns>IList<AdminRoleInfo></returns>
        public IList<AdminRoleInfo> Find(string tbFields, string strWhere, string orderField, int pageIndex, int pageSize, out int totalCount)
        {
			IList<AdminRoleInfo> list = new List<AdminRoleInfo>();
			using (DbCommand cmd = db.GetStoredProcCommand("SP_SqlPagenation"))
			{
				db.AddInParameter(cmd, "@TbName", DbType.String, "AdminRole");
				db.AddInParameter(cmd, "@TbFields", DbType.String, tbFields);
				db.AddInParameter(cmd, "@StrWhere", DbType.String, strWhere);
				db.AddInParameter(cmd, "@OrderField", DbType.String, orderField);
				db.AddInParameter(cmd, "@PageIndex", DbType.Int32, pageIndex);
				db.AddInParameter(cmd, "@PageSize", DbType.Int32, pageSize);
				db.AddOutParameter(cmd, "@Total", DbType.Int32, int.MaxValue);
				using (DataTable dt = db.ExecuteDataSet(cmd).Tables[0])
				{
					if (dt.Rows.Count > 0)
					{
						foreach (DataRow dr in dt.Rows)
						{
							AdminRoleInfo model = new AdminRoleInfo();
							model.LoadFromDataRow(dr);
							list.Add(model);
						}
					}
				}

				totalCount = (int)db.GetParameterValue(cmd, "@Total");
				return list;
			}
		} 
コード例 #4
0
ファイル: AdminRoleDAL.cs プロジェクト: aNd1coder/Wojoz
        /// <summary>
        /// 获得实体
        /// </summary>
        /// <param name="keyValue">编号</param>
        /// <returns>AdminRoleInfo</returns>
        public AdminRoleInfo Get(int keyValue)
        {
            AdminRoleInfo model = null;
			using (DbCommand cmd = db.GetStoredProcCommand("SP_GetRecord"))
			{
				db.AddInParameter(cmd, "@TableName", DbType.String, "AdminRole");
				db.AddInParameter(cmd, "@KeyName", DbType.String, "AdminID");
				db.AddInParameter(cmd, "@KeyValue", DbType.Int32, keyValue);
				using (DataTable dt = db.ExecuteDataSet(cmd).Tables[0])
				{
					if (dt.Rows.Count > 0)
					{
						model = new AdminRoleInfo();
						model.LoadFromDataRow(dt.Rows[0]);
					}
				}
				return model;
			}
        }