⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 st_turnoverstatmodule.ascx.cs

📁 酒店管理系统,适合做毕业设计的人
💻 CS
字号:
namespace ST_GROUP.Modules
{
	using System;
	using System.Data;
	using System.Data.SqlClient;
	using System.Drawing;
	using System.Web;
	using System.Web.UI.WebControls;
	using System.Web.UI.HtmlControls;
	using System.Configuration;

	/// <summary>
	///		ST_TurnOverStatModule 的摘要说明。
	/// </summary>
	public partial class ST_TurnOverStatModule : ST_ModuleBase
	{

		private void Page_Load(object sender, System.EventArgs e)
		{
			if(!IsPostBack) 
			{   
				//
				//绑定房间类型信息下拉列表框
				//
				//从文件Web.config中读取连接字符串
				string ST_sqldb= ConfigurationSettings.AppSettings["ConnectionString"];
				//连接ST_GinShopManage数据库
				SqlConnection ST_Conn= new SqlConnection (ST_sqldb);
				ST_Conn.Open ();
				//定义sql语句
				string ST_mysql="select ST_RCategoryId,ST_Name from ST_RoomCategory ";
				SqlCommand ST_cm=new SqlCommand  (ST_mysql,ST_Conn);
				SqlDataReader dr=ST_cm.ExecuteReader ();
				while(dr.Read ())
				{
					ListItem li=new ListItem(dr["ST_Name"].ToString(),dr["ST_RCategoryId"].ToString());
					RCategoryNameList.Items.Add (li);
				}
				ST_Conn.Close ();
                
				Show_TurnOverList();
			}
		}

		protected void  Show_TurnOverList()
		{
			//从文件Web.config中读取连接字符串
			string ST_sqldb = ConfigurationSettings.AppSettings["ConnectionString"];
			//连接ST_GinShopManage数据库
			SqlConnection ST_Conn = new SqlConnection (ST_sqldb);
			//定义sql
			string ST_selsql="select h.ST_BeginTime,h.ST_EndTime,h.ST_RoomId,c.ST_Name,h.ST_CName,h.ST_CIdentityId,h.ST_CPhone,h.ST_TotalPrice"+
                " from ST_History h,ST_RoomsInfo r,ST_RoomCategory c where r.ST_RoomId=h.ST_RoomId and r.ST_RCategoryId=c.ST_RCategoryId";
			//创建SqlDataAdapter对象,调用存储过程ST_ShowRoomsInfo
			SqlDataAdapter ST_myadapter=new SqlDataAdapter (ST_selsql,ST_Conn);
			//创建并填充DataSet
			DataSet ds = new DataSet ();
			ST_myadapter.Fill (ds);
        
			dg_TurnOverList.DataSource =ds;
			dg_TurnOverList.DataBind ();

			ST_Conn.Close ();
		}

		protected void DataGrid_Page(Object sender,DataGridPageChangedEventArgs E)
		{
			dg_TurnOverList.CurrentPageIndex =E.NewPageIndex ;
			Show_TurnOverList();
		}
		#region Web 窗体设计器生成的代码
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		///		设计器支持所需的方法 - 不要使用代码编辑器
		///		修改此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{
			this.Calculate.Click += new System.EventHandler(this.Calculate_Click);
			this.ShowAll.Click += new System.EventHandler(this.ShowAll_Click);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

		private void Calculate_Click(object sender, System.EventArgs e)
		{
			dg_TurnOverList.CurrentPageIndex=0;

			//从文件Web.config中读取连接字符串
			string ST_sqldb = ConfigurationSettings.AppSettings["ConnectionString"];
			//连接ST_GinShopManage数据库
			SqlConnection ST_Conn = new SqlConnection (ST_sqldb);
			//定义sql语句
			String ST_selsql="select h.ST_BeginTime,h.ST_EndTime,h.ST_RoomId,c.ST_Name,h.ST_CName,h.ST_CIdentityId,h.ST_CPhone,h.ST_TotalPrice"+
				" from ST_History h,ST_RoomsInfo r,ST_RoomCategory c where r.ST_RoomId=h.ST_RoomId and r.ST_RCategoryId=c.ST_RCategoryId";
			//读取时间纪录
			string datefrom=YearFromList.SelectedItem.Value.ToString()+"-"+MouthFromList.SelectedItem.Value.ToString()+"-"+DayFromList.SelectedItem.Value.ToString();
			string dateto=YearToList.SelectedItem.Value.ToString()+"-"+MouthToList.SelectedItem.Value.ToString()+"-"+DayToList.SelectedItem.Value.ToString();
			ST_selsql=ST_selsql+" and h.ST_BeginTime between '"+datefrom+"'and'"+dateto+"'";
			//读取方式记录
			if(RCategoryNameList.SelectedIndex!=0)
			{
				ST_selsql=ST_selsql+" and c.ST_RCategoryId='"+RCategoryNameList.SelectedIndex+"'";
			}
			//创建SqlDataAdapter对象,调用ST_selsql
			SqlDataAdapter ST_myadapter = new SqlDataAdapter (ST_selsql,ST_Conn);
			//创建并填充DataSet
			DataSet ds = new DataSet ();
			ST_myadapter.Fill (ds);

			dg_TurnOverList.DataSource =ds;
			dg_TurnOverList.DataBind ();
			
			//计算营业额
			double SumPrice=0;
			for(int i=0;i<dg_TurnOverList.Items.Count;i++){
			    
                DataRow dr=ds.Tables[0].Rows[i];
				SumPrice=SumPrice+Convert.ToDouble(dr["ST_TotalPrice"].ToString());
			}
            TurnOverLabel.Text=SumPrice.ToString();
			//关闭ST_Conn
			ST_Conn.Close ();
		}

		private void ShowAll_Click(object sender, System.EventArgs e)
		{
		    Show_TurnOverList();
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -