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

📄 frmroomquery.cs

📁 酒店管理,主要从事酒店管理都可以.这可是北大青鸟的程序
💻 CS
📖 第 1 页 / 共 2 页
字号:
			this.txtRoomNum.Size = new System.Drawing.Size(39, 21);
			this.txtRoomNum.TabIndex = 15;
			this.txtRoomNum.Text = "";
			// 
			// LabelCancel
			// 
			this.LabelCancel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right)));
			this.LabelCancel.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.LabelCancel.Location = new System.Drawing.Point(9, 69);
			this.LabelCancel.Name = "LabelCancel";
			this.LabelCancel.Size = new System.Drawing.Size(117, 12);
			this.LabelCancel.TabIndex = 13;
			this.LabelCancel.Text = "取消预订提前天数:";
			// 
			// LabelRoomPrice
			// 
			this.LabelRoomPrice.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right)));
			this.LabelRoomPrice.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.LabelRoomPrice.Location = new System.Drawing.Point(146, 28);
			this.LabelRoomPrice.Name = "LabelRoomPrice";
			this.LabelRoomPrice.Size = new System.Drawing.Size(81, 12);
			this.LabelRoomPrice.TabIndex = 11;
			this.LabelRoomPrice.Text = "客房门市价:";
			// 
			// LabelRoomNum
			// 
			this.LabelRoomNum.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right)));
			this.LabelRoomNum.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.LabelRoomNum.Location = new System.Drawing.Point(7, 27);
			this.LabelRoomNum.Name = "LabelRoomNum";
			this.LabelRoomNum.Size = new System.Drawing.Size(68, 12);
			this.LabelRoomNum.TabIndex = 9;
			this.LabelRoomNum.Text = "客房数量:";
			// 
			// btnAddRoom
			// 
			this.btnAddRoom.Location = new System.Drawing.Point(429, 405);
			this.btnAddRoom.Name = "btnAddRoom";
			this.btnAddRoom.TabIndex = 22;
			this.btnAddRoom.Text = "增加客房";
			this.btnAddRoom.Click += new System.EventHandler(this.btnAddRoom_Click);
			// 
			// btnClose
			// 
			this.btnClose.Location = new System.Drawing.Point(534, 405);
			this.btnClose.Name = "btnClose";
			this.btnClose.TabIndex = 24;
			this.btnClose.Text = "关闭";
			this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
			// 
			// btnEditHotel
			// 
			this.btnEditHotel.Location = new System.Drawing.Point(306, 405);
			this.btnEditHotel.Name = "btnEditHotel";
			this.btnEditHotel.Size = new System.Drawing.Size(96, 23);
			this.btnEditHotel.TabIndex = 25;
			this.btnEditHotel.Text = "酒店资料修改";
			this.btnEditHotel.Click += new System.EventHandler(this.btnEditHotel_Click);
			// 
			// btnAddAva
			// 
			this.btnAddAva.Location = new System.Drawing.Point(225, 222);
			this.btnAddAva.Name = "btnAddAva";
			this.btnAddAva.TabIndex = 2;
			this.btnAddAva.Text = "新增";
			this.btnAddAva.Click += new System.EventHandler(this.btnAddAva_Click);
			// 
			// frmRoomQuery
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(684, 444);
			this.Controls.Add(this.btnEditHotel);
			this.Controls.Add(this.btnClose);
			this.Controls.Add(this.groupBox1);
			this.Controls.Add(this.tabControl1);
			this.Controls.Add(this.tvwRoom);
			this.Controls.Add(this.btnAddRoom);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
			this.MaximizeBox = false;
			this.MinimizeBox = false;
			this.Name = "frmRoomQuery";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "客房信息管理";
			this.Load += new System.EventHandler(this.frmRoomQuery_Load);
			this.tabControl1.ResumeLayout(false);
			this.tabPage1.ResumeLayout(false);
			((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
			this.tabPage2.ResumeLayout(false);
			((System.ComponentModel.ISupportInitialize)(this.dataGrid2)).EndInit();
			this.tabPage3.ResumeLayout(false);
			((System.ComponentModel.ISupportInitialize)(this.dataGrid3)).EndInit();
			this.groupBox1.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion
/*
		static void Main() 
		{
			Application.Run(new frm_roomInfo());
		}
*/
		private void tvwRoom_AfterSelect(object sender, TreeViewEventArgs e)
		{
			if(e.Node.Text != "客房类型")
			{

				//显示客房数量,门市价,取消预定提前天数
				string sqlstr_2 = "select  guestroom.roomNum,guestroom.roomPrice,guestroom.cancelDate,guestroom.roomid from guestroom inner join roomtype inner join hotel";
				sqlstr_2 += " on guestroom.roomType = roomtype.typeid and hotel.hotelId = guestroom.hotelID where roomtype.typename = '" + e.Node.Text + "'";
				sqlstr_2 += " and hotel.hotelId = '" + GlobalVars.temp_ID + "'";
				
				dsQuery = dbcon3.executeBySQL(sqlstr_2);

				row = dsQuery.Tables[0].Rows[0];
				txtRoomNum.Text = row["roomNum"].ToString();
				txtRoomPrice.Text = row["roomPrice"].ToString();
				txtCancel.Text = row["cancelDate"].ToString();
				this.rid=Convert.ToInt32(row["roomid"]);
				
				//客房服务项目管理
				string sqlstr_3 = "select roomservice.serviceID as '服务编号',";
				sqlstr_3 += "roomservice.serviceName as '服务名称',roomservice.description as '服务描述'";
				sqlstr_3 += " from roominfo inner join guestroom inner join roomtype inner join roomservice inner join hotel";			
				sqlstr_3 += " on roominfo.roomID = guestroom.roomID and roominfo.serviceID = roomservice.serviceID";
				sqlstr_3 += " and hotel.hotelID = guestroom.hotelID and guestroom.roomType = roomtype.typeid";
				sqlstr_3 += " where roomtype.typename = '" + e.Node.Text + "' and hotel.hotelID = '" + GlobalVars.temp_ID + "'";

				dsQuery = dbcon3.executeBySQL(sqlstr_3);
				dataGrid1.SetDataBinding(dsQuery.Tables[0],"");
				
				//可预订客房信息管理
				string sqlstr_4 = "select roomavailable.id as '号码',roomavailable.roomnum as '客房数量',begindate as '可供预订起始日期',";
				sqlstr_4 += "enddate as '可供预订终止日期',price as '客房单价',roomavailable.lastupdate as '最后更新日期',isPromotion as '是否打折'";
				sqlstr_4 += " from roomavailable inner join guestroom inner join hotel inner join roomtype";
				sqlstr_4 += " on roomavailable.roomid = guestroom.roomID and guestroom.roomType = roomtype.typeid";
				sqlstr_4 += " and hotel.hotelID = guestroom.hotelID";
				sqlstr_4 += " where roomtype.typename = '" + e.Node.Text + "'";
				sqlstr_4 += " and hotel.hotelID = '" + GlobalVars.temp_ID + "'";

				dsQuery = dbcon3.executeBySQL(sqlstr_4);
				dataGrid2.SetDataBinding(dsQuery.Tables[0],"");
				//this.dataGrid2.TableStyles[0].GridColumnStyles[0].Width=0;
				

				//已预订客房信息管理
				string sqlstr_5 = "select resDate as '预订日期',inuseNumber as '预订数量' from inuseroom inner join guestroom inner join hotel";
				sqlstr_5 += " on inuseroom.roomID = guestroom.roomID and guestroom.hotelID = hotel.hotelID";
				sqlstr_5 += " where hotel.User = '" + GlobalVars.temp + "'";

				dsQuery = dbcon3.executeBySQL(sqlstr_5);
				dataGrid3.SetDataBinding(dsQuery.Tables[0],"");

			}
			else
			{
				this.rid = -1;
				txtRoomNum.Text = "";
				txtRoomNum.ReadOnly = true;
				txtRoomPrice.Text = "";
				txtRoomPrice.ReadOnly = true;
				txtCancel.Text = "";
				txtCancel.ReadOnly = true;
				dataGrid1.DataSource = null;
				dataGrid2.DataSource = null;
				dataGrid3.DataSource = null;

				btnEditRoom.Visible = true;
				btnSaveRoom.Visible = false;
				btnCancel.Enabled = false;
			}
		}

		
		
		private void frmRoomQuery_Load(object sender, System.EventArgs e)
		{
			//动态加载TreeView的根节点及其子节点
			TreeNode tvwNode;
			tvwNode = new TreeNode("客房类型");

			dbcon3 = new DBService_2();

			string sqlstr = "select roomtype.typename from roomtype inner join guestroom inner join hotel";
			sqlstr += " on guestroom.roomType = roomtype.typeid and hotel.hotelID = guestroom.hotelID";
			sqlstr += " where hotel.hotelID = '" + GlobalVars.temp_ID + "'";

			dsQuery = dbcon3.executeBySQL(sqlstr);
			
			int cnt = dsQuery.Tables[0].Rows.Count;
			
			TreeNode tvwNode_ch;

			for(int i = 0; i < cnt ; i++)
			{
				row = dsQuery.Tables[0].Rows[i];
	
				tvwNode_ch = new TreeNode(row["typename"].ToString());
				tvwNode.Nodes.Add(tvwNode_ch);
			}
			tvwRoom.Nodes.Add(tvwNode);

//			btnSaveRoom.Enabled = false;
			btnCancel.Enabled = false;

			btnSaveRoom.Visible = false;
		}

		private void btnClose_Click(object sender, System.EventArgs e)
		{
			Application.Exit();
		}

		private void btnAddRoom_Click(object sender, System.EventArgs e)
		{
			new frm_roomInfo(this).Show();
			this.Hide();
		}

		private void btnEditHotel_Click(object sender, System.EventArgs e)
		{
//			frmEditHotel feh = new frmEditHotel();
//			feh.Show();
//			this.Close();
		}

		private void btnEditRoom_Click(object sender, System.EventArgs e)
		{
			if(txtRoomNum.Text != "" && txtRoomPrice.Text != "" && txtCancel.Text != "")
			{
				txtRoomNum.ReadOnly = false;
				txtRoomPrice.ReadOnly = false;
				txtCancel.ReadOnly = false;
				btnSaveRoom.Visible = true;
				btnEditRoom.Visible = false;
				btnCancel.Enabled = true;
			}
		}

		private void btnSaveRoom_Click(object sender, System.EventArgs e)
		{
			/*
			string sqlstr_2 = "select guestroom.roomNum,guestroom.roomPrice,guestroom.cancelDate from guestroom inner join roomtype inner join hotel";
			sqlstr_2 += " on guestroom.roomType = roomtype.typeid and hotel.hotelId = guestroom.hotelID where roomtype.typename = '" + e.Node.Text + "'";
			sqlstr_2 += " and hotel.hotelId = '" + GlobalVars.temp_ID + "'";
				
			dsQuery = dbcon3.executeBySQL(sqlstr_2);

			row = dsQuery.Tables[0].Rows[0];
			txtRoomNum.Text = row["roomNum"].ToString();
			txtRoomPrice.Text = row["roomPrice"].ToString();
			txtCancel.Text = row["cancelDate"].ToString();
			*/

			string sqlstr_6 = "update guestroom inner join roomtype inner join hotel";
			sqlstr_6 += " SET guestroom.roomNum = '" + txtRoomNum.Text.Trim() + "',guestroom.roomPrice = '";
			sqlstr_6 +=	txtRoomPrice.Text.Trim() + "',guestroom.cancelDate = '" + txtCancel.Text.Trim() + "'";
			sqlstr_6 += "where roomtype.typename = '" + tvwRoom.SelectedNode.Text.Trim() + "'";
			sqlstr_6 += " and hotel.hotelId = '" + GlobalVars.temp_ID + "'";
			sqlstr_6 += " and guestroom.roomType = roomtype.typeid and hotel.hotelId = guestroom.hotelID";

			dbcon3.ExecuteNonQuery(sqlstr_6);
			MessageBox.Show("保存成功!");
			
			txtRoomNum.ReadOnly = true;
			txtRoomPrice.ReadOnly = true;
			txtCancel.ReadOnly = true;
			btnEditRoom.Visible = true;
			btnSaveRoom.Visible = false;
			btnCancel.Enabled = false;
		}

		private void btnCancel_Click(object sender, System.EventArgs e)
		{
			txtRoomNum.ReadOnly = true;
			txtRoomPrice.ReadOnly = true;
			txtCancel.ReadOnly = true;
			btnEditRoom.Visible = true;
			btnSaveRoom.Visible = false;
			btnCancel.Enabled = false;
		}

		private void btnEditService_Click(object sender, System.EventArgs e)
		{
		}

		private void btnEditAva_Click(object sender, System.EventArgs e)
		{
			if(this.rid == -1)
			{
				MessageBox.Show("没有选择客房");
				return ;
			}
			else
			{
				int intID=Convert.ToInt32(this.dataGrid2[this.dataGrid2.CurrentRowIndex,0]);
				new frmReserve(this,intID.ToString()).Show();
				this.Hide();
				//MessageBox.Show(intID.ToString());
			}
		}

		private void btnAddAva_Click(object sender, System.EventArgs e)
		{
			if(this.rid == -1)
			{
				MessageBox.Show("没有任何条目");
				return ;
			}
			else
			{
				new frmReserve(this).Show();
				this.Hide();
			}
		}

		public int roomID
		{
			get
			{
				return this.rid;
			}
		}	
	}
}

⌨️ 快捷键说明

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