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

📄 kfcx.cs

📁 此为本人和同学所开发的酒店管理系统.C#.net.也是软件工程课程的作业.
💻 CS
字号:
using System;using System.Collections;using System.ComponentModel;using System.Drawing;using System.Windows.Forms;using System.Data ;using System.Data .SqlClient ;namespace RoomManage{	public class kfcx : RoomManage.pub	{		private System.ComponentModel.IContainer components = null;		public kfcx(string s)		{			// 该调用是 Windows 窗体设计器所必需的。			InitializeComponent();			this.opername =s;			// TODO: 在 InitializeComponent 调用后添加任何初始化		}		/// <summary>		/// 清理所有正在使用的资源。		/// </summary>		protected override void Dispose( bool disposing )		{			if( disposing )			{				if (components != null) 				{					components.Dispose();				}			}			base.Dispose( disposing );		}		#region 设计器生成的代码		/// <summary>		/// 设计器支持所需的方法 - 不要使用代码编辑器修改		/// 此方法的内容。		/// </summary>		private void InitializeComponent()		{			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(kfcx));
			this.label1 = new System.Windows.Forms.Label();
			this.label2 = new System.Windows.Forms.Label();
			this.groupBox4 = new System.Windows.Forms.GroupBox();
			this.button2 = new System.Windows.Forms.Button();
			this.groupBox6 = new System.Windows.Forms.GroupBox();
			this.dg = new System.Windows.Forms.DataGrid();
			this.label3 = new System.Windows.Forms.Label();
			this.item = new System.Windows.Forms.ComboBox();
			this.fjh = new System.Windows.Forms.ComboBox();
			this.comboBox1 = new System.Windows.Forms.ComboBox();
			this.kflx = new System.Windows.Forms.ComboBox();
			this.ft = new System.Windows.Forms.ComboBox();
			this.groupBox2.SuspendLayout();
			this.groupBox3.SuspendLayout();
			((System.ComponentModel.ISupportInitialize)(this.dg)).BeginInit();
			// 
			// button1
			// 
			this.button1.Location = new System.Drawing.Point(8, 80);
			this.button1.Name = "button1";
			this.button1.TabIndex = 1;
			// 
			// groupBox1
			// 
			this.groupBox1.Name = "groupBox1";
			// 
			// groupBox2
			// 
			this.groupBox2.Controls.Add(this.button2);
			this.groupBox2.Name = "groupBox2";
			this.groupBox2.Controls.SetChildIndex(this.button1, 0);
			this.groupBox2.Controls.SetChildIndex(this.button2, 0);
			// 
			// pictureBox1
			// 
			this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
			this.pictureBox1.Name = "pictureBox1";
			// 
			// groupBox3
			// 
			this.groupBox3.Controls.Add(this.ft);
			this.groupBox3.Controls.Add(this.kflx);
			this.groupBox3.Controls.Add(this.fjh);
			this.groupBox3.Controls.Add(this.label3);
			this.groupBox3.Controls.Add(this.item);
			this.groupBox3.Controls.Add(this.dg);
			this.groupBox3.Controls.Add(this.groupBox6);
			this.groupBox3.Controls.Add(this.groupBox4);
			this.groupBox3.Controls.Add(this.label2);
			this.groupBox3.Controls.Add(this.label1);
			this.groupBox3.Controls.Add(this.comboBox1);
			this.groupBox3.Name = "groupBox3";
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(8, 250);
			this.label1.Name = "label1";
			this.label1.TabIndex = 0;
			this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
			// 
			// label2
			// 
			this.label2.Location = new System.Drawing.Point(200, 250);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(144, 23);
			this.label2.TabIndex = 1;
			this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
			// 
			// groupBox4
			// 
			this.groupBox4.Location = new System.Drawing.Point(0, 240);
			this.groupBox4.Name = "groupBox4";
			this.groupBox4.Size = new System.Drawing.Size(384, 3);
			this.groupBox4.TabIndex = 2;
			this.groupBox4.TabStop = false;
			this.groupBox4.Text = "groupBox4";
			// 
			// button2
			// 
			this.button2.Location = new System.Drawing.Point(8, 32);
			this.button2.Name = "button2";
			this.button2.Size = new System.Drawing.Size(48, 23);
			this.button2.TabIndex = 0;
			this.button2.Text = "查询";
			this.button2.Click += new System.EventHandler(this.button2_Click);
			// 
			// groupBox6
			// 
			this.groupBox6.Location = new System.Drawing.Point(0, 56);
			this.groupBox6.Name = "groupBox6";
			this.groupBox6.Size = new System.Drawing.Size(384, 3);
			this.groupBox6.TabIndex = 20;
			this.groupBox6.TabStop = false;
			// 
			// dg
			// 
			this.dg.AlternatingBackColor = System.Drawing.Color.GhostWhite;
			this.dg.BackColor = System.Drawing.Color.GhostWhite;
			this.dg.BackgroundColor = System.Drawing.Color.Lavender;
			this.dg.BorderStyle = System.Windows.Forms.BorderStyle.None;
			this.dg.CaptionBackColor = System.Drawing.Color.RoyalBlue;
			this.dg.CaptionForeColor = System.Drawing.Color.White;
			this.dg.CaptionText = "查询结果";
			this.dg.DataMember = "";
			this.dg.FlatMode = true;
			this.dg.Font = new System.Drawing.Font("Tahoma", 8F);
			this.dg.ForeColor = System.Drawing.Color.MidnightBlue;
			this.dg.GridLineColor = System.Drawing.Color.RoyalBlue;
			this.dg.HeaderBackColor = System.Drawing.Color.MidnightBlue;
			this.dg.HeaderFont = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Bold);
			this.dg.HeaderForeColor = System.Drawing.Color.Lavender;
			this.dg.LinkColor = System.Drawing.Color.Teal;
			this.dg.Location = new System.Drawing.Point(3, 61);
			this.dg.Name = "dg";
			this.dg.ParentRowsBackColor = System.Drawing.Color.Lavender;
			this.dg.ParentRowsForeColor = System.Drawing.Color.MidnightBlue;
			this.dg.ReadOnly = true;
			this.dg.SelectionBackColor = System.Drawing.Color.Teal;
			this.dg.SelectionForeColor = System.Drawing.Color.PaleGreen;
			this.dg.Size = new System.Drawing.Size(374, 178);
			this.dg.TabIndex = 27;
			// 
			// label3
			// 
			this.label3.Location = new System.Drawing.Point(8, 24);
			this.label3.Name = "label3";
			this.label3.Size = new System.Drawing.Size(72, 23);
			this.label3.TabIndex = 29;
			this.label3.Text = "查 询 项:";
			this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
			// 
			// item
			// 
			this.item.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
			this.item.Items.AddRange(new object[] {
													  "房间类型",
													  "房间号",
													  "房态",
													  "全部"});
			this.item.Location = new System.Drawing.Point(80, 24);
			this.item.Name = "item";
			this.item.Size = new System.Drawing.Size(128, 20);
			this.item.TabIndex = 28;
			this.item.SelectedIndexChanged += new System.EventHandler(this.item_SelectedIndexChanged);
			// 
			// fjh
			// 
			this.fjh.DropDownStyle = System.Windows.Forms.ComboBoxStyle.Simple;
			this.fjh.Location = new System.Drawing.Point(216, 24);
			this.fjh.Name = "fjh";
			this.fjh.Size = new System.Drawing.Size(121, 20);
			this.fjh.TabIndex = 30;
			// 
			// comboBox1
			// 
			this.comboBox1.Location = new System.Drawing.Point(192, 136);
			this.comboBox1.Name = "comboBox1";
			this.comboBox1.Size = new System.Drawing.Size(121, 20);
			this.comboBox1.TabIndex = 30;
			// 
			// kflx
			// 
			this.kflx.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
			this.kflx.Items.AddRange(new object[] {
													  "普房",
													  "标房",
													  "套房",
													  "双人间",
													  "总统套房"});
			this.kflx.Location = new System.Drawing.Point(216, 24);
			this.kflx.Name = "kflx";
			this.kflx.Size = new System.Drawing.Size(121, 20);
			this.kflx.TabIndex = 31;
			// 
			// ft
			// 
			this.ft.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
			this.ft.Items.AddRange(new object[] {
													"空闲",
													"入住",
													"维修"});
			this.ft.Location = new System.Drawing.Point(216, 24);
			this.ft.Name = "ft";
			this.ft.Size = new System.Drawing.Size(121, 20);
			this.ft.TabIndex = 32;
			// 
			// kfcx
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(480, 283);
			this.Name = "kfcx";
			this.Text = "客房查询";
			this.Load += new System.EventHandler(this.kfcx_Load);
			this.groupBox2.ResumeLayout(false);
			this.groupBox3.ResumeLayout(false);
			((System.ComponentModel.ISupportInitialize)(this.dg)).EndInit();

		}		#endregion
		DataConn dc=new DataConn ();
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.GroupBox groupBox4;
		private System.Windows.Forms.Button button2;
		private System.Windows.Forms.GroupBox groupBox6;
		private System.Windows.Forms.DataGrid dg;
		private System.Windows.Forms.Label label3;
		private System.Windows.Forms.ComboBox item;
		private System.Windows.Forms.ComboBox fjh;
		private System.Windows.Forms.ComboBox comboBox1;
		private System.Windows.Forms.ComboBox kflx;
		private System.Windows.Forms.ComboBox ft;
		string opername;//传递操作员姓名

		private void kfcx_Load(object sender, System.EventArgs e)
		{
			this.AcceptButton =this.button2 ;
			this.label1 .Text ="操 作 员:"+this.opername ;
			this.label2 .Text ="查询日期:"+System.DateTime .Today.Date.ToShortDateString();
			
			this.ft.Visible =false;
			this.kflx .Visible =false;
			this.fjh .Visible =false;
		
		}

		private void item_SelectedIndexChanged(object sender, System.EventArgs e)
		{
			if(item.SelectedIndex==0)
			{
				ft.Visible =false;
				this.kflx .Visible =true;
				this.fjh .Visible =false;
			}
			if(item.SelectedIndex==1)
			{
				ft.Visible =false;
				this.kflx .Visible =false;
				this.fjh .Visible =true;
			}
			if(item.SelectedIndex==2)
			{
				ft.Visible =true;
				this.kflx .Visible =false;
				this.fjh .Visible =false;
			}
			if(item.SelectedIndex==3)
			{
				ft.Visible =false;
				this.kflx .Visible =false;
				this.fjh .Visible =false;
			}

		
		}

		private void button2_Click(object sender, System.EventArgs e)
		{
			DataConn dc=new DataConn ();
			string str=dc.connstr ;
			SqlConnection conn=new SqlConnection (str);
			DataSet dataset=new DataSet ();

			if(this.item .SelectedIndex==0)
			{
				string sql1="select * from tabkfinfo where 客房类型='"+this.kflx.Text +"'";
				SqlDataAdapter a1=new SqlDataAdapter (sql1,conn);
				a1.Fill (dataset,"t1");
				dg.DataSource =dataset.Tables ["t1"];
				a1.Dispose ();
			}
			if(this.item .SelectedIndex==1)
			{
				string sql2="select * from tabkfinfo where 房间号='"+this.fjh .Text +"'";
				SqlDataAdapter a2=new SqlDataAdapter (sql2,conn);
				a2.Fill (dataset,"t2");
				dg.DataSource =dataset.Tables ["t2"];
				a2.Dispose ();
			}
			if(this.item .SelectedIndex==2)
			{
				string sql3="select * from tabkfinfo where 房态='"+this.ft.Text +"'";
				SqlDataAdapter a3=new SqlDataAdapter (sql3,conn);
				a3.Fill (dataset,"t3");
				dg.DataSource =dataset.Tables ["t3"];
				a3.Dispose ();
			}
			if(this.item .SelectedIndex==3)
			{
				string sql4="select * from tabkfinfo";
				SqlDataAdapter a4=new SqlDataAdapter (sql4,conn);
				a4.Fill (dataset,"t4");
				dg.DataSource =dataset.Tables ["t4"];
				a4.Dispose ();
			}
			
			dataset.Dispose ();
			conn.Dispose ();

		}	}}

⌨️ 快捷键说明

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