📄 queryconsumeprint.aspx.cs
字号:
//文件名:QueryConsumePrint.aspx.cs
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class QueryManage_QueryConsumePrint : System.Web.UI.Page
{
private QueryManage_QueryConsumeForm MyQueryConsumeForm;
protected void Page_Load(object sender, EventArgs e)
{//将查询结果输出到Excel文件中
MyQueryConsumeForm = (QueryManage_QueryConsumeForm)Context.Handler;
string MySQL = MyQueryConsumeForm.MyPrintSQL;
string My商品名称 = MyQueryConsumeForm.MyPrint商品名称;
string My开始日期 = MyQueryConsumeForm.MyPrint开始日期;
string My结束日期 = MyQueryConsumeForm.MyPrint结束日期;
this.Label1.Text = Session["MyCompanyName"].ToString() + "消费商品分类统计表";
this.Label2.Text="开始日期:"+My开始日期+" 结束日期:"+My结束日期+" 商品名称:"+My商品名称;
string MyConnectionString = ConfigurationManager.ConnectionStrings["MyHotelDBConnectionString"].ConnectionString; ;
SqlDataAdapter MyAdapter = new SqlDataAdapter(MySQL, MyConnectionString);
DataSet MySet = new DataSet();
MyAdapter.Fill(MySet);
this.DataGrid1.DataSource = MySet;
this.DataGrid1.DataBind();
this.Response.ContentType = "application/vnd.ms-excel";
this.Response.Charset = "";
//关闭 ViewState
this.EnableViewState = false;
System.IO.StringWriter MyWriter;
System.Web.UI.HtmlTextWriter MyWeb;
//将信息写入字符串
MyWriter = new System.IO.StringWriter();
//在Web窗体页上写出一系列连续的HTML特定字符和文本
MyWeb = new System.Web.UI.HtmlTextWriter(MyWriter);
//将DataGrid中的内容输出到HtmlTextWriter对象中
this.DataGrid1.RenderControl(MyWeb);
//把HTML写回浏览器
Response.Write(MyWriter.ToString());
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -