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

📄 statistic.aspx.cs

📁 房屋管理系统 房屋管理系统 房屋管理系统 房屋管理系统
💻 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;
using System.Configuration;
using System.Data.Odbc;


namespace RoomMngSystem.Manager
{
	/// <summary>
	/// Statistic 的摘要说明。
	/// </summary>
	public class Statistic : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.Button Btn_QuaryForm;
		protected System.Web.UI.WebControls.Button Btn_StatForm;
		protected System.Web.UI.WebControls.Panel Pn_Tree;
		protected System.Web.UI.WebControls.DataGrid DG_BuildingTree;
		protected System.Data.Odbc.OdbcConnection oCn_Statistic;
		protected System.Data.DataSet dS_BuildingTree;
		protected System.Data.Odbc.OdbcCommand oCmd_CreateTree;
		protected System.Data.Odbc.OdbcDataAdapter oDA_Rpt;
		protected System.Web.UI.WebControls.Panel Pn_BuildingInfo;
		protected System.Web.UI.WebControls.Label Lb_Bld_Bno;
		protected System.Web.UI.WebControls.Label Lb_Bld_TotalArea;
		protected System.Web.UI.WebControls.Label Lb_Bld_RoomNum;
		protected System.Web.UI.WebControls.Label Lb_Bld_BldArea;
		protected System.Web.UI.WebControls.Label Lb_Bld_TchRate;
		protected System.Web.UI.WebControls.Label Lb_Bld_TchRoom;
		protected System.Web.UI.WebControls.Label Lb_Bld_OfficeRoom;
		protected System.Web.UI.WebControls.Label Lb_Bld_OfficeRate;
		protected System.Web.UI.WebControls.Label Lb_Bld_LabRate;
		protected System.Web.UI.WebControls.Label Lb_Bld_LabRoom;
		protected System.Web.UI.WebControls.Label Lb_Bld_FloorNum;
		protected System.Data.DataSet dS_Rpt;
		protected System.Web.UI.WebControls.Label Lb_Floor_BNo;
		protected System.Web.UI.WebControls.Label Lb_Floor_BldArea;
		protected System.Web.UI.WebControls.Label Lb_Floor_RoomNum;
		protected System.Web.UI.WebControls.Label Lb_Floor_TchRoom;
		protected System.Web.UI.WebControls.Label Lb_Floor_TchRate;
		protected System.Web.UI.WebControls.Label Lb_Floor_OfficeRoom;
		protected System.Web.UI.WebControls.Label Lb_Floor_OfficeRate;
		protected System.Web.UI.WebControls.Label Lb_Floor_LabRoom;
		protected System.Web.UI.WebControls.Label Lb_Floor_LabRate;
		protected System.Web.UI.WebControls.Panel Pn_FloorInfo;
		protected System.Web.UI.WebControls.Label Lb_Floor_FloorNo;
		protected System.Data.Odbc.OdbcCommand oCmd_Quary;
		protected System.Web.UI.WebControls.Image Im_Floor;
		protected System.Web.UI.WebControls.Image Image1;
		protected System.Web.UI.WebControls.Button Btn_PWDAlter;
	
		private void Page_Load(object sender, System.EventArgs e)
		{
			// 在此处放置用户代码以初始化页面
			oCn_Statistic.ConnectionString=ConfigurationSettings.AppSettings["oCn_Str"];
			CreateRoomTree();
		}

		#region Web 窗体设计器生成的代码
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{    
			this.oCn_Statistic = new System.Data.Odbc.OdbcConnection();
			this.dS_BuildingTree = new System.Data.DataSet();
			this.oCmd_CreateTree = new System.Data.Odbc.OdbcCommand();
			this.oDA_Rpt = new System.Data.Odbc.OdbcDataAdapter();
			this.dS_Rpt = new System.Data.DataSet();
			this.oCmd_Quary = new System.Data.Odbc.OdbcCommand();
			((System.ComponentModel.ISupportInitialize)(this.dS_BuildingTree)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.dS_Rpt)).BeginInit();
			// 
			// dS_BuildingTree
			// 
			this.dS_BuildingTree.DataSetName = "NewDataSet";
			this.dS_BuildingTree.Locale = new System.Globalization.CultureInfo("zh-CN");
			// 
			// oCmd_CreateTree
			// 
			this.oCmd_CreateTree.Connection = this.oCn_Statistic;
			// 
			// oDA_Rpt
			// 
			this.oDA_Rpt.SelectCommand = this.oCmd_CreateTree;
			// 
			// dS_Rpt
			// 
			this.dS_Rpt.DataSetName = "NewDataSet";
			this.dS_Rpt.Locale = new System.Globalization.CultureInfo("zh-CN");
			// 
			// oCmd_Quary
			// 
			this.oCmd_Quary.Connection = this.oCn_Statistic;
			this.Btn_QuaryForm.Click += new System.EventHandler(this.Btn_QuaryForm_Click);
			this.Btn_StatForm.Click += new System.EventHandler(this.Btn_StatForm_Click);
			this.Btn_PWDAlter.Click += new System.EventHandler(this.Btn_PWDAlter_Click);
			this.DG_BuildingTree.ItemCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.DG_BuildingTree_ItemCommand);
			this.Load += new System.EventHandler(this.Page_Load);
			((System.ComponentModel.ISupportInitialize)(this.dS_BuildingTree)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.dS_Rpt)).EndInit();

		}
		#endregion

		private void CreateRoomTree()
		{
			//OdbcDataAdapter oDA_Rpt=new OdbcDataAdapter();
            oCmd_CreateTree.CommandText="select * from TreeView";
            //oDA_Rpt.SelectCommand=oCmd_CreateTree;
			//DataSet dS_Rpt=new DataSet();
            oCn_Statistic.Open();
			oDA_Rpt.Fill(dS_Rpt,"BuildingTree");
            oCn_Statistic.Close();
			DG_BuildingTree.DataSource=dS_Rpt;
			DG_BuildingTree.DataBind();

		}

		private void Btn_QuaryForm_Click(object sender, System.EventArgs e)
		{
		    Response.Redirect("QuaryForm.aspx");
		}

		private void Btn_StatForm_Click(object sender, System.EventArgs e)
		{
		    Response.Redirect("Statistic.aspx");
		}

		private void Btn_PWDAlter_Click(object sender, System.EventArgs e)
		{
			Response.Redirect("PWDMng.aspx");
		}

		public void DG_BuildingTree_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
		{
			if(e.CommandName == "Quary") 
			{	
				if(Convert.ToBoolean(dS_Rpt.Tables["BuildingTree"].Rows[e.Item.ItemIndex].ItemArray[2])==true)
				{
					Pn_BuildingInfo.Visible=true;
					Pn_FloorInfo.Visible=false;
					oCmd_Quary.CommandText="select * from BuildingInfo where bno='"+dS_Rpt.Tables["BuildingTree"].Rows[e.Item.ItemIndex].ItemArray[1]+"'";
					oCn_Statistic.Open();
					OdbcDataReader DR_RoomInfo=oCmd_Quary.ExecuteReader();
					while(DR_RoomInfo.Read())
					{
						Lb_Bld_Bno.Text=DR_RoomInfo.GetString(0);
						if(!DR_RoomInfo.IsDBNull(1)&&!DR_RoomInfo.IsDBNull(2))
						{
							Lb_Bld_TotalArea.Text=DR_RoomInfo.GetFloat(1).ToString();
							Lb_Bld_BldArea.Text=DR_RoomInfo.GetFloat(2).ToString();
						}
						Lb_Bld_RoomNum.Text=DR_RoomInfo.GetString(3);
						Lb_Bld_TchRoom.Text=DR_RoomInfo.GetString(4);
						Lb_Bld_TchRate.Text=DR_RoomInfo.GetString(5);
						Lb_Bld_OfficeRoom.Text=DR_RoomInfo.GetString(6);
						Lb_Bld_OfficeRate.Text=DR_RoomInfo.GetString(7);
						Lb_Bld_LabRoom.Text=DR_RoomInfo.GetString(8);
						Lb_Bld_LabRate.Text=DR_RoomInfo.GetString(9);
						Lb_Bld_FloorNum.Text=DR_RoomInfo.GetString(10);
					}
					DR_RoomInfo.Close();
					oCn_Statistic.Close();
				}
				else
				{
					Pn_BuildingInfo.Visible=false;
					Pn_FloorInfo.Visible=true;
					string NodeName=dS_Rpt.Tables["BuildingTree"].Rows[e.Item.ItemIndex].ItemArray[0].ToString();
					string floor=dS_Rpt.Tables["BuildingTree"].Rows[e.Item.ItemIndex].ItemArray[1].ToString();
					oCmd_Quary.CommandText="select * from FloorInfo where bno='"+NodeName.Substring(0,NodeName.Length-floor.Length)+"'and Floor='"+floor+"'";
					oCn_Statistic.Open();
					OdbcDataReader DR_RoomInfo=oCmd_Quary.ExecuteReader();
					while(DR_RoomInfo.Read())
					{
						Lb_Floor_BNo.Text=DR_RoomInfo.GetString(0);
						Lb_Floor_FloorNo.Text=DR_RoomInfo.GetString(1);
					    Lb_Floor_BldArea.Text=DR_RoomInfo.GetString(2);
						Lb_Floor_RoomNum.Text=DR_RoomInfo.GetString(3);
						Lb_Floor_TchRoom.Text=DR_RoomInfo.GetString(4);
						Lb_Floor_TchRate.Text=DR_RoomInfo.GetString(5);
						Lb_Floor_OfficeRoom.Text=DR_RoomInfo.GetString(6);
						Lb_Floor_OfficeRate.Text=DR_RoomInfo.GetString(7);
						Lb_Floor_LabRoom.Text=DR_RoomInfo.GetString(8);
						Lb_Floor_LabRate.Text=DR_RoomInfo.GetString(9);
						Im_Floor.ImageUrl="\\RoomMngSystem\\Picture\\"+NodeName+".jpg";
					}
					DR_RoomInfo.Close();
					oCn_Statistic.Close();
				}

			}
		}
	}
}

⌨️ 快捷键说明

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