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

📄 changeform.h

📁 宾馆酒店管理系统,建议在简体中文版Microsoft Windows Server 2003(SP1)/Microsoft Office 2003(SP2)/Microsoft SQL Server
💻 H
📖 第 1 页 / 共 2 页
字号:
			this->label1->Location = System::Drawing::Point(3, 10);
			this->label1->Name = L"label1";
			this->label1->Size = System::Drawing::Size(89, 12);
			this->label1->TabIndex = 13;
			this->label1->Text = L"旅客入住编号:";
			// 
			// groupBox2
			// 
			this->groupBox2->Controls->Add(this->酒店客房信息DataGridView);
			this->groupBox2->Location = System::Drawing::Point(5, 230);
			this->groupBox2->Name = L"groupBox2";
			this->groupBox2->Size = System::Drawing::Size(533, 179);
			this->groupBox2->TabIndex = 12;
			this->groupBox2->TabStop = false;
			this->groupBox2->Text = L"酒店客房信息";
			// 
			// 酒店客房信息DataGridView
			// 
			this->酒店客房信息DataGridView->BackgroundColor = System::Drawing::SystemColors::MenuHighlight;
			this->酒店客房信息DataGridView->ColumnHeadersHeightSizeMode = System::Windows::Forms::DataGridViewColumnHeadersHeightSizeMode::AutoSize;
			this->酒店客房信息DataGridView->Location = System::Drawing::Point(5, 17);
			this->酒店客房信息DataGridView->Name = L"酒店客房信息DataGridView";
			this->酒店客房信息DataGridView->RowHeadersVisible = false;
			dataGridViewCellStyle2->BackColor = System::Drawing::Color::Green;
			dataGridViewCellStyle2->ForeColor = System::Drawing::Color::Yellow;
			this->酒店客房信息DataGridView->RowsDefaultCellStyle = dataGridViewCellStyle2;
			this->酒店客房信息DataGridView->RowTemplate->Height = 23;
			this->酒店客房信息DataGridView->SelectionMode = System::Windows::Forms::DataGridViewSelectionMode::FullRowSelect;
			this->酒店客房信息DataGridView->Size = System::Drawing::Size(525, 155);
			this->酒店客房信息DataGridView->TabIndex = 0;
			// 
			// groupBox1
			// 
			this->groupBox1->Controls->Add(this->客房入住单DataGridView);
			this->groupBox1->Location = System::Drawing::Point(5, 30);
			this->groupBox1->Name = L"groupBox1";
			this->groupBox1->Size = System::Drawing::Size(533, 194);
			this->groupBox1->TabIndex = 11;
			this->groupBox1->TabStop = false;
			this->groupBox1->Text = L"客房入住单信息";
			// 
			// ChangeForm
			// 
			this->AutoScaleDimensions = System::Drawing::SizeF(6, 12);
			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
			this->BackColor = System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(0)), static_cast<System::Int32>(static_cast<System::Byte>(192)), 
				static_cast<System::Int32>(static_cast<System::Byte>(192)));
			this->ClientSize = System::Drawing::Size(542, 416);
			this->Controls->Add(this->根据当前选择换房Button);
			this->Controls->Add(this->酒店房间类别ComboBox);
			this->Controls->Add(this->label2);
			this->Controls->Add(this->旅客登记信息Button);
			this->Controls->Add(this->入住编号TextBox);
			this->Controls->Add(this->label1);
			this->Controls->Add(this->groupBox2);
			this->Controls->Add(this->groupBox1);
			this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::Fixed3D;
			this->MaximizeBox = false;
			this->MinimizeBox = false;
			this->Name = L"ChangeForm";
			this->StartPosition = System::Windows::Forms::FormStartPosition::CenterParent;
			this->Text = L"旅客换房登记";
			this->Load += gcnew System::EventHandler(this, &ChangeForm::ChangeForm_Load);
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->客房入住单DataGridView))->EndInit();
			this->groupBox2->ResumeLayout(false);
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->酒店客房信息DataGridView))->EndInit();
			this->groupBox1->ResumeLayout(false);
			this->ResumeLayout(false);
			this->PerformLayout();

		}
#pragma endregion
		private: static String^ MyHotelConnectionString= L"Data Source=.;Initial Catalog=MyHotel;Integrated Security=True;Pooling=False";
		private: System::Void ChangeForm_Load(System::Object^  sender, System::EventArgs^  e) {
		    SqlConnection^ MyConnection = gcnew SqlConnection();
            MyConnection->ConnectionString = MyHotelConnectionString;
            MyConnection->Open();
            SqlCommand^ MyCommand = gcnew SqlCommand("Select DISTINCT 类别  From 酒店房间", MyConnection);
            SqlDataReader^ MyReader = MyCommand->ExecuteReader();
            while (MyReader->Read())
            {
                this->酒店房间类别ComboBox->Items->Add(MyReader->GetString(0));
            }
            this->酒店房间类别ComboBox->Items->Add("所有房间");
            this->酒店房间类别ComboBox->Text = "所有房间";
            if (MyConnection->State == ConnectionState::Open)
            {
                MyConnection->Close();
            }            
		}
		private: System::Void 酒店房间类别ComboBox_SelectedIndexChanged(System::Object^  sender, System::EventArgs^  e) {
			//获取未完全入住房间信息
            String^ MySQLConnectionString = MyHotelConnectionString;
            String^ MySQL = "Select 房号,单价,可容纳人数-已入住人数 as 可入住人数,楼层,类别,说明,可容纳人数,已入住人数 From 酒店房间 Where 类别='" + this->酒店房间类别ComboBox->Text + "'";
            if (this->酒店房间类别ComboBox->Text == "所有房间")
            {
                MySQL = "Select 房号,单价,可容纳人数-已入住人数 as 可入住人数,楼层,类别,说明,可容纳人数,已入住人数 From 酒店房间 ";
            }
            SqlConnection^ MyConnection = gcnew SqlConnection(MySQLConnectionString);
            MyConnection->Open();
			System::Data::DataTable^ MyTable = gcnew System::Data::DataTable();
            SqlDataAdapter^ MyAdapter = gcnew SqlDataAdapter(MySQL, MyConnection);
            MyAdapter->Fill(MyTable);
            this->酒店客房信息DataGridView->DataSource = MyTable;
            if (MyConnection->State == ConnectionState::Open)
            {
                MyConnection->Close();
            } 
		}
		private: System::Void 旅客登记信息Button_Click(System::Object^  sender, System::EventArgs^  e) {
			String^ MySQLConnectionString = MyHotelConnectionString;
            String^ MySQL = "Select * From 客房入住单 Where 入住编号 LIKE '" + this->入住编号TextBox->Text + "' AND 入住编号 NOT IN (Select 入住编号 FROM 客房结帐单)";
            SqlConnection^ MyConnection = gcnew SqlConnection(MySQLConnectionString);
            MyConnection->Open();
			System::Data::DataTable^ MyTable = gcnew System::Data::DataTable();
            SqlDataAdapter^ MyAdapter = gcnew SqlDataAdapter(MySQL, MyConnection);
            MyAdapter->Fill(MyTable);
            this->客房入住单DataGridView->DataSource = MyTable;
            if (MyConnection->State == ConnectionState::Open)
            {
                MyConnection->Close();
            } 
		}
		private: System::Void 根据当前选择换房Button_Click(System::Object^  sender, System::EventArgs^  e) {
			int My住宿人数 = Convert::ToInt16(this->客房入住单DataGridView->CurrentRow->Cells[10]->Value->ToString());
            int My可入住人数 = Convert::ToInt16(this->酒店客房信息DataGridView->CurrentRow->Cells[2]->Value->ToString());
            if (My住宿人数 > My可入住人数)
            {
				MessageBox::Show("没有足够的床位进行换房操作!", "信息提示", MessageBoxButtons::OK, MessageBoxIcon::Information);
                return;
            }
            String^ My入住编号 = this->客房入住单DataGridView->CurrentRow->Cells[0]->Value->ToString();
            String^ My原房号 = this->客房入住单DataGridView->CurrentRow->Cells[1]->Value->ToString();
            String^ My新房号 = this->酒店客房信息DataGridView->CurrentRow->Cells[0]->Value->ToString();
            String^ MyInfo = "是否确定将" + My入住编号 + "中的客人从" + My原房号 + "号房换到" + My新房号 + "号房?";
			if (MessageBox::Show(MyInfo, "信息提示", MessageBoxButtons::YesNo, MessageBoxIcon::Question) ==System::Windows::Forms::DialogResult::No)
            {
                return;
            }
            String^ MySQLConnectionString =MyHotelConnectionString;
            SqlConnection^ MyConnection = gcnew SqlConnection(MySQLConnectionString);
            MyConnection->Open();
            SqlCommand^ MyCommand = MyConnection->CreateCommand();
            String^ MySQL = "Update 酒店房间 Set 已入住人数=已入住人数+" + My住宿人数 + " WHERE 房号='" + My新房号 + "';";
            MySQL += "Update 酒店房间 Set 已入住人数=已入住人数-" + My住宿人数 + " WHERE 房号='" + My原房号 + "';";
            MySQL += "Update 客房入住单 Set 房号='" + My新房号 + "' WHERE 入住编号='" + My入住编号 + "';";
            MyCommand->CommandText = MySQL;
            MyCommand->ExecuteNonQuery();
            if (MyConnection->State == ConnectionState::Open)
            {
                MyConnection->Close();
            }
            酒店房间类别ComboBox_SelectedIndexChanged(nullptr, nullptr);
            旅客登记信息Button_Click(nullptr, nullptr);
		}
	};
}

⌨️ 快捷键说明

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