求大神帮小弟给这段代码加个注释,小弟看不懂
publicpartialclassArticle_list:System.Web.UI.Page{protectedvoidPage_Load(objectsender...
public partial class Article_list : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
int typeID = 0;
string sql = "";
String cond = "";
try
{
typeID = int.Parse(Request.QueryString["typeID"].ToString());
}
catch (Exception)
{
if (typeID == null)
{
sql = "select * from article where 1=1";
}
}
sql = "select * from article where 1=1";
if (typeID > 0)
{
cond = " and article_type_id=@typeID ";
}
sql += cond;
SqlParameter[] prass = new SqlParameter[]
{
new SqlParameter("@typeID",typeID)
};
PagedDataSource objPds = new PagedDataSource();
DataTable dt = SqlHelper.ExecuteTable(sql, prass);
objPds.DataSource = dt.DefaultView;
objPds.AllowPaging = true;
objPds.PageSize = 5;
int PageSum = objPds.PageCount;
if (PageSum == 1)
{
PageView.Text = "";
}
else
{
int CurPage;
if (Request.QueryString["Page"] != null)
{
CurPage = Convert.ToInt32(Request.QueryString["Page"]);
}
else
{
CurPage = 1;
}
objPds.CurrentPageIndex = CurPage - 1;
int pagesize = 3;
int totale = (PageSum < pagesize ? PageSum : pagesize);
if (CurPage < PageSum + 1)
{
totale = PageSum % pagesize;
PageView.Text = "当前第 <font color=\"Red\">" + CurPage + "</font> 页 共 " + PageSum + " 页<br/>";
PageView.Text += "<a class='page' href='?id=" + 1 + "&typeID=" + typeID + "'> 首页 </a>";
if (!objPds.IsFirstPage)
{
PageView.Text += "<a class='page' href='?Page=" + (CurPage - 1) + "&id=" + 1 + "&typeID=" + typeID + "'> 上一页 </a>";
}
else
{
PageView.Text += " 上一页 ";
}
}
if (!objPds.IsLastPage)
{
PageView.Text += "<a class='page' href='?Page=" + (CurPage + 1) + "&id=" + 1 + "&typeID=" + typeID + "'> 下一页 </a>";
}
else
{
PageView.Text += " 下一页 ";
}
PageView.Text += "<a class='page' href='?Page=" + PageSum + "&id=" + 1 + "&typeID=" + typeID + "'> 尾页 </a>";
}
}
}
大神帮忙给这段代码加下注释,解释下这都什么意思~谢谢~
这是一个网站的二级页面的代码。 展开
{
protected void Page_Load(object sender, EventArgs e)
{
int typeID = 0;
string sql = "";
String cond = "";
try
{
typeID = int.Parse(Request.QueryString["typeID"].ToString());
}
catch (Exception)
{
if (typeID == null)
{
sql = "select * from article where 1=1";
}
}
sql = "select * from article where 1=1";
if (typeID > 0)
{
cond = " and article_type_id=@typeID ";
}
sql += cond;
SqlParameter[] prass = new SqlParameter[]
{
new SqlParameter("@typeID",typeID)
};
PagedDataSource objPds = new PagedDataSource();
DataTable dt = SqlHelper.ExecuteTable(sql, prass);
objPds.DataSource = dt.DefaultView;
objPds.AllowPaging = true;
objPds.PageSize = 5;
int PageSum = objPds.PageCount;
if (PageSum == 1)
{
PageView.Text = "";
}
else
{
int CurPage;
if (Request.QueryString["Page"] != null)
{
CurPage = Convert.ToInt32(Request.QueryString["Page"]);
}
else
{
CurPage = 1;
}
objPds.CurrentPageIndex = CurPage - 1;
int pagesize = 3;
int totale = (PageSum < pagesize ? PageSum : pagesize);
if (CurPage < PageSum + 1)
{
totale = PageSum % pagesize;
PageView.Text = "当前第 <font color=\"Red\">" + CurPage + "</font> 页 共 " + PageSum + " 页<br/>";
PageView.Text += "<a class='page' href='?id=" + 1 + "&typeID=" + typeID + "'> 首页 </a>";
if (!objPds.IsFirstPage)
{
PageView.Text += "<a class='page' href='?Page=" + (CurPage - 1) + "&id=" + 1 + "&typeID=" + typeID + "'> 上一页 </a>";
}
else
{
PageView.Text += " 上一页 ";
}
}
if (!objPds.IsLastPage)
{
PageView.Text += "<a class='page' href='?Page=" + (CurPage + 1) + "&id=" + 1 + "&typeID=" + typeID + "'> 下一页 </a>";
}
else
{
PageView.Text += " 下一页 ";
}
PageView.Text += "<a class='page' href='?Page=" + PageSum + "&id=" + 1 + "&typeID=" + typeID + "'> 尾页 </a>";
}
}
}
大神帮忙给这段代码加下注释,解释下这都什么意思~谢谢~
这是一个网站的二级页面的代码。 展开
1个回答
展开全部
public partial class Article_list : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
int typeID = 0;
string sql = "";
String cond = "";
try
{
//获取类型ID(Get提交)
typeID = int.Parse(Request.QueryString["typeID"].ToString());
}
catch (Exception)
{
if (typeID == null)
{
//在article里查询数据(见意不要直接用*,选取你用到的数据字段)
sql = "select * from article where 1=1";
}
}
sql = "select * from article where 1=1";
if (typeID > 0)
{
//拼接SQL 查询条件为article_type_id=你提交过来的ID
cond = " and article_type_id=@typeID ";
}
sql += cond;
//参数化查询SQL 为了防止SQL注入
SqlParameter[] prass = new SqlParameter[]
{
new SqlParameter("@typeID",typeID)
};
//这里是绑定DataTable数据
PagedDataSource objPds = new PagedDataSource();
DataTable dt = SqlHelper.ExecuteTable(sql, prass);
objPds.DataSource = dt.DefaultView;
objPds.AllowPaging = true;
objPds.PageSize = 5;
int PageSum = objPds.PageCount;
if (PageSum == 1)
{
PageView.Text = "";
}
else
{
//下面这一大段代码是分页的处理逻辑
int CurPage;
if (Request.QueryString["Page"] != null)
{
CurPage = Convert.ToInt32(Request.QueryString["Page"]);
}
else
{
CurPage = 1;
}
objPds.CurrentPageIndex = CurPage - 1;
int pagesize = 3;
int totale = (PageSum < pagesize ? PageSum : pagesize);
if (CurPage < PageSum + 1)
{
totale = PageSum % pagesize;
PageView.Text = "当前第 <font color=\"Red\">" + CurPage + "</font> 页 共 " + PageSum + " 页<br/>";
PageView.Text += "<a class='page' href='?id=" + 1 + "&typeID=" + typeID + "'> 首页 </a>";
if (!objPds.IsFirstPage)
{
PageView.Text += "<a class='page' href='?Page=" + (CurPage - 1) + "&id=" + 1 + "&typeID=" + typeID + "'> 上一页 </a>";
}
else
{
PageView.Text += " 上一页 ";
}
}
if (!objPds.IsLastPage)
{
PageView.Text += "<a class='page' href='?Page=" + (CurPage + 1) + "&id=" + 1 + "&typeID=" + typeID + "'> 下一页 </a>";
}
else
{
PageView.Text += " 下一页 ";
}
PageView.Text += "<a class='page' href='?Page=" + PageSum + "&id=" + 1 + "&typeID=" + typeID + "'> 尾页 </a>";
}
}
}
杭州一知智能科技有限公司
2022-03-17 广告
2022-03-17 广告
电话机器人主要就是用来模拟人工通话的一组程序,一般由,CRM系统,语义识别,转换文字,话术体系,这是软的部分,再加上底层软交换和通信模块一起,合并起来就是一套完整的电话机器人系统。电话机器人可以代替真人进行电话工作的,像是电话营销、售后回访...
点击进入详情页
本回答由杭州一知智能科技有限公司提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询