namespace WebApp.UiXsOrderSS
{
public partial class List : Pagebase
{
#region 变量定义
string cSql = "";
protected string webmenulistHTML;
private string cDataListSql = "";
protected int iTotalPageCount = 0;
protected int iCurrentPage = 0;
#endregion #region 加载页面
protected void Page_Load(object sender, EventArgs e)
{
this.PageBegin(); if (!Page.IsPostBack)
{
cDataListSql = "select * from vxsOrder where cOrderType = 'SS' and cCreUserName = '" + this.LogName + "'";
iCurrentPage = 1;
InitTableDataList(cDataListSql, iCurrentPage);
}
}
#endregion #region 初始化数据列表
private void InitTableDataList(string cSql, int iCurrentPage)
{
string cOrderBy = "dCreDate desc";
int iTotalCount = 0; SqlConnection conn = new SqlConnection(dbOper.cConns);
SqlCommand cmd = new SqlCommand("aSpSQL2005Paging", conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@Sql", cSql);
cmd.Parameters.AddWithValue("@OrderBy", cOrderBy);
cmd.Parameters.AddWithValue("@CurrentPage", iCurrentPage);
cmd.Parameters.AddWithValue("@PageSize", Global.PageSize);
SqlParameter paramTotalCount = cmd.Parameters.Add("@TotalCount", SqlDbType.Int);
paramTotalCount.Direction = ParameterDirection.Output; conn.Open();
DataTable dt = new DataTable();
dt.Load(cmd.ExecuteReader());
conn.Close(); #region 分页
iTotalCount = Convert.ToInt32(paramTotalCount.Value.ToString());
iTotalPageCount = Convert.ToInt32(Math.Ceiling(Convert.ToDecimal(iTotalCount) / Convert.ToDecimal(Global.PageSize)).ToString()); lblTotalCount.Text = "共" + iTotalCount.ToString() + "条 | 每页" + Global.PageSize.ToString() + "条 | 共" + iTotalPageCount.ToString() + "页 | 第" + iCurrentPage.ToString() + "页"; if (iCurrentPage == 1)
{
btnFirst.Enabled = false;
btnPrev.Enabled = false;
}
else
{
btnFirst.Enabled = true;
btnPrev.Enabled = true;
} if (iCurrentPage == iTotalPageCount)
{
btnNext.Enabled = false;
btnLast.Enabled = false;
}
else
{
btnNext.Enabled = true;
btnLast.Enabled = true;
}
#endregion StringBuilder sb = new StringBuilder();
foreach (DataRow dr in dt.Rows)
{
sb.AppendFormat("<tr runat = \"server\">");
sb.AppendFormat("<td bgcolor=\"#FFFFFF\" align=\"center\"><input type=\"checkbox\" name=\"delid\" value=\"{0}\"/></td>", dr["cID"].ToString());
sb.AppendFormat("<td bgcolor=\"#FFFFFF\">{0}</td>", dr["cOrderCode"].ToString());
sb.AppendFormat("<td bgcolor=\"#FFFFFF\">{0}</td>", dr["cCusName"].ToString());
sb.AppendFormat("<td bgcolor=\"#FFFFFF\" align=\"right\">{0}</td>", dr["iOrderBudJe"].ToString());
sb.AppendFormat("<td bgcolor=\"#FFFFFF\">{0}</td>", dr["cOrderState"].ToString());
sb.AppendFormat("<td bgcolor=\"#FFFFFF\">{0}</td>", dr["cCreUserName"].ToString());
sb.AppendFormat("<td bgcolor=\"#FFFFFF\">{0}</td>", dr["dCreDate"].ToString());
sb.AppendFormat("<td bgcolor=\"#FFFFFF\" align=\"center\"><a href=\"Upd.aspx?cID={0}\">编辑</a></td>", dr["cID"].ToString());
sb.Append("</tr>");
}
webmenulistHTML = sb.ToString(); this.SetParaValue("cDataListSql", cSql);
this.SetParaValue("iTotalPageCount", iTotalPageCount.ToString());
this.SetParaValue("iCurrentPage", iCurrentPage.ToString());
}
#endregion
//导出 这是方法 下面在按钮调用这个方法
public void Export(string FileType, string FileName)
{
Response.Charset = "GB2312";
Response.ContentEncoding = System.Text.Encoding.UTF7;
Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(FileName, Encoding.UTF8).ToString());
Response.ContentType = FileType;
this.EnableViewState = false;
StringWriter tw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(tw);
//GridView1.RenderControl(hw);
Response.Write(tw.ToString());
Response.End();
} // 点击导出按钮
protected void Button1_Click(object sender, EventArgs e)
{
Export("application/ms-excel", "小卖部订单.xls");
} #region 首页
protected void btnFirst_Click(object sender, EventArgs e)
{
iCurrentPage = 1;
cDataListSql = this.GetParaValue("cDataListSql");
InitTableDataList(cDataListSql, iCurrentPage);
}
}
}前台代码
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="List.aspx.cs" Inherits="WebApp.UiXsOrderSS.List" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title></title>
<style type="text/css"></style><link href="../css/css.css" rel="stylesheet" type="text/css" />
<link href="../css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/xiangmu.js"></script>
<script src="../My97DatePicker/WdatePicker.js" type="text/javascript"></script>
</head><SCRIPT language=JavaScript>
function UnSelectAll() {
var obj = document.getElementsByName('delid'); for (var i = 0; i < obj.length; i++) {
if (obj[i].checked == true) obj[i].checked = false;
else obj[i].checked = true;
}
}
</SCRIPT><body >
<form id="fom" runat="server">
<table id="mainpage" width="100%" border="0" cellspacing="0" cellpadding="0"> <tr>
<td height="30"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="62" background="../images/nav04.gif">
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0"
style="height: 35px">
<tr>
<td width="21"><img src="../images/ico07.gif" width="20" height="18" /></td>
<td class="style1">查询条件:订单号:
<asp:TextBox ID="txtOrderCode" runat="server"></asp:TextBox> 日期:<asp:TextBox
ID="txtCreDate1" runat="server" Width="117px" onClick="WdatePicker()"></asp:TextBox>
—
<asp:TextBox ID="txtCreDate2" onClick="WdatePicker()" runat="server" Width="117px"></asp:TextBox>
订货商:<asp:TextBox ID="txtCusName" runat="server" Width="147px"></asp:TextBox>
<asp:Button ID="btnQuery" CssClass = "right-button02" runat="server" Text="查 询"
onclick="btnQuery_Click" />
</td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
<tr>
<td><table id="subtree1" style="DISPLAY: " width="100%" border="0" cellspacing="0" cellpadding="0"> <tr>
<td><table width="95%" border="0" align="center" cellpadding="0" cellspacing="0"> <tr>
<td style="height=20">
<span class="newfont07">选择:<a href="#" class="right-font08" onclick="UnSelectAll();">全选/取消</a></span>
<asp:Button ID="btnDel" runat="server" CssClass="right-button08" Text="删除"
onclick="btnDel_Click" />
<asp:Button ID="btnAdd" runat="server" CssClass="right-button08" Text="添加"
onclick="btnAdd_Click" />
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="导出" />
</td>
</tr>
<tr>
<td height="40" class="font42"> <table id = "tbDataList" width="100%" border="0" cellpadding="4" cellspacing="1" bgcolor="#464646" class="newfont03">
<tr>
<td style="height:20;" colspan = "8" align="center" bgcolor="#EEEEEE" class="tablestyle_title">
小卖部订单列表</td>
</tr>
<tr>
<td width="3%" align="center" bgcolor="#EEEEEE" nowrap="nowrap">选择</td>
<td width="13%" align="center" bgcolor="#EEEEEE">订单号</td>
<td width="13%" align="center" bgcolor="#EEEEEE">订货商</td>
<td width="13%" align="center" bgcolor="#EEEEEE">订单总额</td>
<td width="13%" align="center" bgcolor="#EEEEEE">订单状态</td>
<td width="13%" align="center" bgcolor="#EEEEEE">下单人</td>
<td width="13%" align="center" bgcolor="#EEEEEE">下单日期</td>
<td width="3%" align="center" bgcolor="#EEEEEE" nowrap="nowrap">操作</td>
</tr>
<%=webmenulistHTML%>
</table>
</td>
</tr>
</table></td>
</tr>
</table>
</form>
</body>
</html>data datatableexcelasp.nettablw
解决方案 »
- C#打印问题,好纠结啊!壮士,救我!
- Session超时问题
- 内容页如何触发母板页控件事件
- 怎样编程来控制GridView控件中某字段的可见性
- datagrid格式奇怪的问题
- 关于Session的问题!
- 尝试创建Web项目或打开位于URL"http://localhost/solution1"的Web项目时,Web服务器报告了以下错误"HTTP:/1.1 500 Internal Server Error
- 我也想做个网页了,帮忙介绍一个好的空间,高分******
- 请教大家一个初学者ASP问题,请指教!!!先谢过!!!
- 在sqlCommand里可以通过,在Page_Load()中就通不过?
- 怎么将数据库中的表显示在网页上
- cc域名的cookies跨域问题
{
Response.Charset = "GB2312";
Response.ContentEncoding = System.Text.Encoding.UTF7;
Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(FileName, Encoding.UTF8).ToString());
Response.ContentType = FileType;
this.EnableViewState = false;
StringWriter tw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(tw);
//GridView1.RenderControl(hw);
Response.Write(tw.ToString());
Response.End();
}
红色这句不要注释