📄 queryfrm.aspx.cs
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace WebApplication1
{
/// <summary>
/// QueryFrm 的摘要说明。
/// </summary>
public class QueryFrm : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label Label2;
protected System.Web.UI.WebControls.Label Label3;
protected System.Web.UI.WebControls.Label Label4;
protected System.Web.UI.WebControls.DropDownList RptDList;
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.Label VldDateMsg;
protected System.Web.UI.WebControls.RangeValidator VldStartDate;
protected System.Web.UI.WebControls.TextBox StartDateBox;
protected System.Web.UI.WebControls.TextBox EndDateBox;
protected System.Web.UI.WebControls.RangeValidator VldEndDate;
protected System.Data.DataSet dataSet1;
protected System.Data.Odbc.OdbcConnection odbcConnection1;
protected System.Data.Odbc.OdbcCommand odbcSelectCommand1;
protected System.Data.Odbc.OdbcCommand odbcInsertCommand1;
protected System.Data.Odbc.OdbcCommand odbcUpdateCommand1;
protected System.Data.Odbc.OdbcCommand odbcDeleteCommand1;
protected System.Data.Odbc.OdbcDataAdapter odbcDataAdapter1;
private string strUser ;
private string strUserName;
private string strDept;
private string strDeptName;
protected System.Web.UI.WebControls.Image Image1;
protected System.Web.UI.WebControls.Label Label5;
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.DropDownList PageSizeDList;
protected System.Web.UI.WebControls.Button Button2;
protected int DListIndex;
private void Page_Load(object sender, System.EventArgs e)
{
strUser = (string)Session["strUser"];
strUserName = (string)Session["strUserName"];
strDept = (string)Session["strDept"];
strDeptName = (string)Session["strDeptName"];
// 在此处放置用户代码以初始化页面
if (!Page.IsPostBack)
{
if (!Global.CheckUserValidation((string)Session["strRole"], Global.MENU_STATISTIC))
{
Response.Redirect("err_session.htm", true);
}
RptDList.Items.Clear();
RptDList.Items.Add("部门订餐统计");
RptDList.Items.Add("个人订餐统计");
//2006-05-07
PageSizeDList.Items.Clear();
PageSizeDList.Items.Add("打印机设置的默认大小");
PageSizeDList.Items.Add("A4 纸,210 x 297 毫米");
PageSizeDList.Items.Add("A5 纸,148 x 210 毫米");
PageSizeDList.Items.Add("B4 纸,250 x 354 毫米");
PageSizeDList.Items.Add("B5 纸,182 x 257 毫米");
PageSizeDList.Items.Add("A3 纸,297 x 420 毫米");
PageSizeDList.Items.Add("Letter,215.9x279.4 毫米");
PageSizeDList.Items.Add("纸张为 254 x 355.6 毫米");
PageSizeDList.Items.Add("纸张为 279.4x431.8 毫米");
StartDateBox.Text=DateTime.Today.ToString("yyyy'-'MM'-'dd");
EndDateBox.Text=DateTime.Today.ToString("yyyy'-'MM'-'dd");
//VldDateMsg.Visible=false;
}
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.odbcConnection1 = new System.Data.Odbc.OdbcConnection();
this.odbcSelectCommand1 = new System.Data.Odbc.OdbcCommand();
this.odbcInsertCommand1 = new System.Data.Odbc.OdbcCommand();
this.odbcUpdateCommand1 = new System.Data.Odbc.OdbcCommand();
this.odbcDeleteCommand1 = new System.Data.Odbc.OdbcCommand();
this.odbcDataAdapter1 = new System.Data.Odbc.OdbcDataAdapter();
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.StartDateBox.TextChanged += new System.EventHandler(this.TextBox1_TextChanged);
this.Button2.Click += new System.EventHandler(this.Button2_Click);
//
// odbcDataAdapter1
//
this.odbcDataAdapter1.DeleteCommand = this.odbcDeleteCommand1;
this.odbcDataAdapter1.InsertCommand = this.odbcInsertCommand1;
this.odbcDataAdapter1.SelectCommand = this.odbcSelectCommand1;
this.odbcDataAdapter1.UpdateCommand = this.odbcUpdateCommand1;
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void TextBox1_TextChanged(object sender, System.EventArgs e)
{
}
private void Button1_Click(object sender, System.EventArgs e)
{
//string strConnect = "DRIVER={MySQL ODBC 3.51 Driver};Server=localhost;Database=dinner;PORT=3306;UID=root;Password=abc" ;
string strCommand="";
string strReport="";
string StartDate,EndDate;
string strKind="test";
StartDateBox.DataBind();
EndDateBox.DataBind();
if(!VldStartDate.IsValid||StartDateBox.Text.Trim().CompareTo("")==0)
{
Page.RegisterStartupScript("alert", @"<script language=""javascript"">window.alert(""错误:开始日期输入有误,请重新输入!"")</script>");
//VldDateMsg.Visible=true;
//VldDateMsg.Text="开始日期输入有误,请重新输入!";
return;
}
else if(!VldEndDate.IsValid||EndDateBox.Text.Trim().CompareTo("")==0)
{
Page.RegisterStartupScript("alert", @"<script language=""javascript"">window.alert(""错误:结束日期输入有误,请重新输入!"")</script>");
//VldDateMsg.Visible=true;
//VldDateMsg.Text="结束日期输入有误,请重新输入!";
return;
}
else
{
StartDate=StartDateBox.Text;
EndDate=EndDateBox.Text;
}
//VldDateMsg.Visible=false;
DListIndex = RptDList.SelectedIndex;
if (DListIndex==0)
{
strReport="Batch_Date_rpt";
strCommand ="select date,elt(conv(kind,16,10)-9,'早餐','中餐','午餐','零点餐') kind,department,sum(num) num from t_batch_order "+
"where Effect='1' and date>='"+StartDate+"' and date<='"+EndDate+
"' group by date,kind,department order by date,department,kind";
}
else
{
strReport="Order_Date_rpt";
strCommand ="select Date,elt(Free+1,'非工作餐','工作餐') Free, "+
"elt(conv(kind,16,10)-9,'[A]早餐','[B]中餐','[C]晚餐','[D]零点餐') kind,count(*) Num,"+
"sum(Totel_price/100) Totel_price from t_order "+
"where date>='"+StartDate+"' and date<='"+EndDate+
"' group by date,Free,kind order by date,Free,kind";
/*
strCommand ="select distinct a.Date Date,elt(a.Free+1,'非工作餐','工作餐') Free, "+
"elt(conv(a.kind,16,10)-9,'早餐','中餐','午餐','零点餐') kind,sum(b.Quantity) Num,"+
"sum(a.Totel_price/100) Totel_price from t_order a,T_ORDER_DETAIL b "+
"where a.order_id=b.order_id and date>='"+StartDate+"' and date<='"+EndDate+
"' group by a.date,a.Free,a.kind order by a.date,a.Free,a.kind";
*/
}
//Session["strConnect"]=strConnect;
Session["strCommand"]=strCommand;
Session["strReport"]=strReport;
Session["StartDate"]=StartDate;
Session["EndDate"]=EndDate;
Session["strKind"]=strKind;
//2006-05-07
Session["PageSize"]=PageSizeDList.SelectedIndex;
//Response.Redirect("RptFrm.aspx");
String sUrl = "./RptFrm.aspx";
String sFeatures ="''";
String sScript ="";
sScript += "<script language=javascript>";
sScript += "window.open('" + sUrl + "',''," + sFeatures + ");";
sScript += "</script>";
Response.Write(sScript);
Global.OpenConnection(ref odbcConnection1);
Global.WriteLog(ref odbcConnection1, strUser,Global.MENU_STATISTIC,Global.ACTION_OTHER,"打印"+StartDate+"---"+EndDate+"日,"+RptDList.SelectedItem.Text);
odbcConnection1.Close();
}
private void Button2_Click(object sender, System.EventArgs e)
{
//string strConnect = "DRIVER={MySQL ODBC 3.51 Driver};Server=localhost;Database=dinner;PORT=3306;UID=root;Password=abc" ;
string strCommand="";
string strReport="";
string StartDate,EndDate;
string strKind="test";
StartDateBox.DataBind();
EndDateBox.DataBind();
if(!VldStartDate.IsValid||StartDateBox.Text.Trim().CompareTo("")==0)
{
Page.RegisterStartupScript("alert", @"<script language=""javascript"">window.alert(""错误:开始日期输入有误,请重新输入!"")</script>");
//VldDateMsg.Visible=true;
//VldDateMsg.Text="开始日期输入有误,请重新输入!";
return;
}
else if(!VldEndDate.IsValid||EndDateBox.Text.Trim().CompareTo("")==0)
{
Page.RegisterStartupScript("alert", @"<script language=""javascript"">window.alert(""错误:结束日期输入有误,请重新输入!"")</script>");
//VldDateMsg.Visible=true;
//VldDateMsg.Text="结束日期输入有误,请重新输入!";
return;
}
else
{
StartDate=StartDateBox.Text;
EndDate=EndDateBox.Text;
}
//VldDateMsg.Visible=false;
DListIndex = RptDList.SelectedIndex;
if (DListIndex==0)
{
strReport="Batch_Date_rpt";
strCommand ="select date,elt(conv(kind,16,10)-9,'早餐','中餐','午餐','零点餐') kind,department,sum(num) num from t_batch_order "+
"where Effect='1' and date>='"+StartDate+"' and date<='"+EndDate+
"' group by date,kind,department order by date,department,kind";
}
else
{
strReport="Order_Date_rpt";
strCommand ="select Date,elt(Free+1,'非工作餐','工作餐') Free, "+
"elt(conv(kind,16,10)-9,'[A]早餐','[B]中餐','[C]晚餐','[D]零点餐') kind,count(*) Num,"+
"sum(Totel_price/100) Totel_price from t_order "+
"where date>='"+StartDate+"' and date<='"+EndDate+
"' group by date,Free,kind order by date,Free,kind";
/*
strCommand ="select distinct a.Date Date,elt(a.Free+1,'非工作餐','工作餐') Free, "+
"elt(conv(a.kind,16,10)-9,'早餐','中餐','午餐','零点餐') kind,sum(b.Quantity) Num,"+
"sum(a.Totel_price/100) Totel_price from t_order a,T_ORDER_DETAIL b "+
"where a.order_id=b.order_id and date>='"+StartDate+"' and date<='"+EndDate+
"' group by a.date,a.Free,a.kind order by a.date,a.Free,a.kind";
*/
}
//Session["strConnect"]=strConnect;
Session["strCommand"]=strCommand;
Session["strReport"]=strReport;
Session["StartDate"]=StartDate;
Session["EndDate"]=EndDate;
Session["strKind"]=strKind;
//2006-05-07
Session["PageSize"]=PageSizeDList.SelectedIndex;
String sUrl = "./PdfFrm.aspx";
String sFeatures ="''";
String sScript ="";
sScript += "<script language=javascript>";
sScript += "window.open('" + sUrl + "',''," + sFeatures + ");";
sScript += "</script>";
Response.Write(sScript);
Global.OpenConnection(ref odbcConnection1);
Global.WriteLog(ref odbcConnection1, strUser,Global.MENU_STATISTIC,Global.ACTION_OTHER,"打印"+StartDate+"---"+EndDate+"日,"+RptDList.SelectedItem.Text);
odbcConnection1.Close();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -