sql语句用行计数器
解决方案 »
- 请问高手一个问题,如何把一片文章完整的存储在数据库中。再显示出来,文章中有图片存在。(asp.net)
- WInFORM ShowDialog()后父窗口还可以获取焦点
- 广播ARP包,用.net怎么实现?急!!
- 有谁知道怎么编写接收温度传感器的数据的程序?
- 你们几岁开始学编程的啊?
- 正则表达式!?
- vs2005 中对datagridview 添加样式问题!怎么没有tablestyle呢?
- 在C#中使用javascript的问题.!!!????
- 谁能帮我解释一下下面的语句
- c#怎么写dll控件啊,通过编译器怎么编译.
- .net的连接池会造成内存泄露
- while(buffter=="")""指的是什么??
前台代码你应该会了吧,直接调用 [Ajax.AjaxMethod(Ajax.HttpSessionStateRequirement.Read)]
public string getGrid(int pageIndex, string keyword)
{
int userID = 0;
string shopnum = "";
if (HttpContext.Current.Session["Puserid"] != "" && HttpContext.Current.Session["Puserid"] != null)
{ userID = Convert.ToInt32(HttpContext.Current.Session["Puserid"]);
}
if (HttpContext.Current.Session["usershop"] != "" && HttpContext.Current.Session["usershop"] != null)
{ shopnum = HttpContext.Current.Session["usershop"].ToString().Trim();
} string StrConn = System.Web.Configuration.WebConfigurationManager.AppSettings["DSN_YT"];
SqlConnection Sqlconn = new SqlConnection(StrConn);
string sql1 = ""; if (keyword.Replace(" ", "").Replace("'", "") != "" && keyword != null)
{
keyword = keyword.Replace(" ", "").Replace("'", "").Trim();
sql1 = " and userZh like '%" + keyword + "%'";
}
string shopUserArr = "";//先算出所有用户
int shopuser = 0;
string sqluser = "select shopUserArr,userID from YT_shop where shopNum='" + shopnum + "'";
try
{
Sqlconn.Open();
SqlCommand ma = new SqlCommand(sqluser, Sqlconn);
SqlDataReader dr = ma.ExecuteReader();
if (dr.Read())
{
shopUserArr = dr["shopUserArr"].ToString();
shopuser = Convert.ToInt32(dr["userID"]);
}
Sqlconn.Close();
}
catch { }
shopUserArr = shopUserArr.Replace("|", ",");
shopUserArr = shopUserArr.Substring(1);
shopUserArr = shopUserArr.Substring(0, shopUserArr.Length - 1); string sqlStr = "SELECT id FROM YT_user WHERE id in (" + shopUserArr + ") " + sql1 + "";
int j = 0;
try
{
Sqlconn.Open();
SqlCommand ma = new SqlCommand(sqlStr, Sqlconn);
SqlDataReader dr = ma.ExecuteReader();
while (dr.Read())
{
j++;
}
Sqlconn.Close();
}
catch { } int pagecount = 0; //页数
if (j <= 20)
{
pagecount = 1;
}
else
{
pagecount = j / 20;
}
if (pageIndex > pagecount)
{
if (pageIndex == 30000)
{
pageIndex = pagecount;
}
else
{
pageIndex = 1;
}
}
else if (pageIndex < 1)
{
pageIndex = 1;
}
int tiaoshu = 20 * (pageIndex - 1);
string listtxt = "";
string ItemTitle = "";
string ItemGQF = "";
string useradmin = "";
sqlStr = "SELECT TOP 20 id,userZh,SaleZcj,SaleZcj_cg,userLogin1,BuyZcj,BuyZcj_cg,shname FROM YT_user WHERE id in (" + shopUserArr + ") " + sql1 + " and (id NOT IN (SELECT TOP " + tiaoshu + " id FROM YT_user where id in (" + shopUserArr + ") " + sql1 + " ORDER BY ID DESC)) ORDER BY ID DESC";
string ItemStypea = "";
string ItemStypetxt = "";
int ItemYJ = 0;
int i = 0;
int zongtiaoshu = 0;
string strError = "";
string shname = "";
try
{
Sqlconn.Open();
SqlCommand ma = new SqlCommand(sqlStr, Sqlconn);
SqlDataReader dr = ma.ExecuteReader();
while (dr.Read())
{
if (dr["shname"] != "" && dr["shname"] != null)
{
shname = dr["shname"].ToString();
}
else
{
shname = dr["userZH"].ToString();
}
if (Convert.ToInt32(dr["id"]) == shopuser)
{
useradmin = "<font color=red>会长</font><img src=../SysImage/ftp.gif border=0 alt='商会会长'>";
}
else
{
useradmin = "<font color=green>会员</font>";
}
listtxt += "<div class=\"show_word_worre\" onmouseover=\"this.style.background='#ffffff'\" onmouseout=\"this.style.background='#F7F7F7'\">";
listtxt += "<ul>";
listtxt += "<li class=\"ligamm1\">" + useradmin + "</li>";
listtxt += "<li class=\"ligamm11\">" + shname + "</li>";
listtxt += "<li class=\"ligamm2\"><div align=left>总卖<font color=red>" + dr["SaleZcj"].ToString() + "</font>次 / 卖成功<font color=red>" + dr["SaleZcj_cg"].ToString() + "</font>次 / 总买<font color=red>" + dr["BuyZcj"].ToString() + "</font>次 / 买成功<font color=red>" + dr["BuyZcj_cg"].ToString() + "</font>次</div></li>";
listtxt += "<li class=\"ligamm3\">" + getusercard(dr["id"].ToString()) + "张</li>";
listtxt += "<li class=\"ligamm5\">" + dr["userLogin1"].ToString() + "</li>";
listtxt += "<li class=\"ligamm7\">" + getuserpro(dr["id"].ToString()) + "件</li>";
listtxt += "<li class=\"ligamm8\"><a href='javascript:' onclick=\"delusers(" + dr["id"].ToString() + ");\">[剔除]</a></li>";
listtxt += "</ul>";
listtxt += "</div>";
i++;
}
Sqlconn.Close();
}
catch { } string xiala = "<input type=image src=\"../images/newlist/useradmn_z2_18x15.gif\"" +
" value='<' onclick='this.disabled=goToshouPage()'>";
xiala += "<input type=image src=\"../images/newlist/useradmn_z1_18x15.gif\"" +
" value='<' onclick='this.disabled=goToPrevPage()'>"; xiala += "<select id=\"\" name=\"\" style=\"background-color:#efefef;\" onchange=\"goToPage(this.value);\">";
for (int k = 1; k <= pagecount; k++)
{
if (pageIndex == k)
{
xiala += "<option value=\"" + k.ToString() + "\" selected>第" + k.ToString() + "页</option>";
}
else
{
xiala += "<option value=\"" + k.ToString() + "\" >第" + k.ToString() + "页</option>";
}
}
xiala += "</select>";
xiala += "<input type=image src=\"../images/newlist/useradmn_y1_18x15.gif\"" +
" onclick='this.disabled=goToNextPage()'>";
xiala += "<input type=image src=\"../images/newlist/useradmn_y2_18x15.gif\"" +
" value='<' onclick='this.disabled=goTolastPage()'>"; return xiala + " 共有记录:" + j.ToString() + "<br>" + listtxt;
}