📄 st_turnoverstatmodule.ascx.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;
using SQLExe;
public partial class Context_ST_TurnoverStatModule : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
Show_Category();///设置类型下拉列表内容
}
}
public void Show_Category()
{
SqlConnection ST_myCon = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
SqlCommand ST_mycommand = new SqlCommand();
ST_mycommand.Connection = ST_myCon;
ST_myCon.Open();
ST_mycommand.CommandText = "select ST_RCategoryId,ST_Name from ST_RoomCategory";
SqlDataReader dl = ST_mycommand.ExecuteReader();
while (dl.Read())
{
ListItem li = new ListItem(dl["ST_Name"].ToString(), dl["ST_RCategoryId"].ToString());
this.ddlRoomType.Items.Add(li);
}
dl.Close();
ST_myCon.Close();
}
protected void Button1_Click(object sender, EventArgs e)///设置日历控件的显示
{
this.calfrom.Visible = true;
}
protected void Button2_Click(object sender, EventArgs e)
{
this.calto.Visible = true;
}
protected void calfrom_SelectionChanged(object sender, EventArgs e)
{
this.txtDateFrom.Text = this.calfrom.SelectedDate.ToString();
this.calfrom.Visible = false;
}
protected void calto_SelectionChanged(object sender, EventArgs e)
{
this.txtDateTo.Text = this.calto.SelectedDate.ToString();
this.calto.Visible = false;
}
protected void Button3_Click(object sender, EventArgs e)
{
if (this.txtDateFrom.Text == "")
{
this.lblInfo.Text = "起始日期不能为空";
return;
}
DateTime DateBegin=System.Convert.ToDateTime(this.txtDateFrom.Text);
DateTime DateEnd;
int type;
string str = "select * from HistoryView where ST_BeginTime>='" + DateBegin + "'";//初始化SQL语句
string Search = "";///保存判断条件
SQLExe.SQLExe myExe = new SQLExe.SQLExe();
DataSet ds = new DataSet();
if (this.txtDateTo.Text.ToString()!= "")
{
DateEnd = System.Convert.ToDateTime(this.txtDateTo.Text);
Search = Search + " and ST_BeginTime<='" + DateEnd + "'";
}
if (this.ddlRoomType.SelectedValue.ToString()!= "--请选择--")
{
type=System.Convert.ToInt32(this.ddlRoomType.SelectedValue);
Search = Search + " and ST_RCategoryId=" + type + "";
}
str = str + Search;
ds=myExe.GetDataSet(str);
this.DataGrid1.DataSource = ds.Tables[0].DefaultView;
this.DataGrid1.DataBind();
int count = 0;////统计 总营业额
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
DataRow dr = ds.Tables[0].Rows[i];
count = count + System.Convert.ToInt32(dr["ST_TotalPrice"]);
}
this.lblPrice.Text = count.ToString();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -