/// <summary>
/// 显示+分页+模糊查询
/// </summary>
/// <param name="pageindex"></param>
/// <param name="pagesize"></param>
/// <param name="name"></param>
/// <param name="count"></param>
/// <returns></returns>
public List<Model.UserInfo> SelAllpage(int pageindex,int pagesize,string name,out int count)
{
conn.Open();
/// 显示+分页+模糊查询
/// </summary>
/// <param name="pageindex"></param>
/// <param name="pagesize"></param>
/// <param name="name"></param>
/// <param name="count"></param>
/// <returns></returns>
public List<Model.UserInfo> SelAllpage(int pageindex,int pagesize,string name,out int count)
{
conn.Open();
SqlCommand command = new SqlCommand("upage",conn);------"upage"为分页存储过程的名称
command.CommandType = CommandType.StoredProcedure;
SqlParameter[] p =
{
new SqlParameter ("@pageindex",SqlDbType.Int),
new SqlParameter ("@pagesize",SqlDbType.Int),
new SqlParameter ("@count",SqlDbType.Int),
new SqlParameter ("@name",SqlDbType.VarChar,50),
};
{
new SqlParameter ("@pageindex",SqlDbType.Int),
new SqlParameter ("@pagesize",SqlDbType.Int),
new SqlParameter ("@count",SqlDbType.Int),
new SqlParameter ("@name",SqlDbType.VarChar,50),
};
p[0].Value = pageindex;
p[1].Value = pagesize;
p[2].Direction = ParameterDirection.Output;
p[3].Value = name;
p[1].Value = pagesize;
p[2].Direction = ParameterDirection.Output;
p[3].Value = name;
command.Parameters.AddRange(p);
command.ExecuteNonQuery();
command.ExecuteNonQuery();
count = Convert.ToInt32(p[2].Value);
SqlDataAdapter apter = new SqlDataAdapter(command);
DataTable dt = new DataTable();
apter.Fill(dt);
DataTable dt = new DataTable();
apter.Fill(dt);
List<UserInfo> list = new List<UserInfo>();
for (int i = 0; i < dt.Rows.Count;i++ )
{
UserInfo u = new UserInfo();
{
UserInfo u = new UserInfo();
u.ID = Convert.ToInt32(dt.Rows[i]["ID"]);
u.UserName = dt.Rows[i]["UserName"].ToString();
u.UserPwd = dt.Rows[i]["UserPwd"].ToString();
u.RealName = dt.Rows[i]["RealName"].ToString();
u.CreateTime = Convert.ToDateTime(dt.Rows[i]["CreateTime"]);
u.UserName = dt.Rows[i]["UserName"].ToString();
u.UserPwd = dt.Rows[i]["UserPwd"].ToString();
u.RealName = dt.Rows[i]["RealName"].ToString();
u.CreateTime = Convert.ToDateTime(dt.Rows[i]["CreateTime"]);
list.Add(u);
}
return list;
}
return list;
}