zoukankan      html  css  js  c++  java
  • 通用存储过程定义

    using System;

    using System.Collections.Generic;

    using System.Data.SqlClient;

    using System.Linq;

    using System.Text;

    using System.Threading.Tasks;

    using Model;

    using Model.DTO;

    using System.Data;

    using DB;

    using Newtonsoft.Json;

    namespace DAL

    {

        public class PageCommon

        {

            public static PageList<T> StoredList<T>(ParaModel model)

            {

                string sql = "up_CommodityFy";

                SqlParameter[] pars = new SqlParameter[7];

                pars[0] = new SqlParameter("@tableName", model.TableName);

                pars[1] = new SqlParameter("@indexCol", model.IndexCOl);

                pars[2] = new SqlParameter("@pageSize", model.PageSize);

                pars[3] = new SqlParameter("@pageIndex", model.PageIndex);

                pars[4] = new SqlParameter("@orderCol", model.OrderCol);

                pars[5] = new SqlParameter("@where", model.StrWhere);

                pars[6] = new SqlParameter("@columns", model.Columns);

                DataSet ds = DbHelperSQL.ExecuteDataset(DbHelperSQL.ConnB2c, CommandType.StoredProcedure, sql, pars);

                var list = JsonConvert.DeserializeObject<List<T>>(JsonConvert.SerializeObject(ds.Tables[0]));

                PageList<T> pagelist = new PageList<T>();

                pagelist.listData = list;

                //总条数

                int totalNum=    pagelist.TotalNum = Convert.ToInt32(ds.Tables[1].Rows[0][0]);

                //总页数

                int totalPage = (totalNum % model.PageSize) > 0 ? (totalNum / model.PageSize) + 1 : totalNum / model.PageSize;

             

                pagelist.TotalNum = totalNum;

                pagelist.TotalPage = totalPage;

                return pagelist;

            }

        }

    }

  • 相关阅读:
    stm32启动代码分析
    STM32固件库详解
    ARM GCC CodeSourcery EABI下载地址
    Linux/redhat 基本网络配置
    侧边栏导航
    div滚动,页面不滚动
    自定义滚动条样式
    placeholder自定义CSS
    浏览器判断
    初始化页面垂直居中
  • 原文地址:https://www.cnblogs.com/lockzy/p/9520343.html
Copyright © 2011-2022 走看看