📄 roomstatusform.h
字号:
//文件名:RoomStatusForm.h
#pragma once
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
using namespace System::Data::SqlClient;
namespace 宾馆酒店管理系统 {
/// <summary>
/// RoomStatusForm 摘要
///
/// 警告: 如果更改此类的名称,则需要更改
/// 与此类所依赖的所有 .resx 文件关联的托管资源编译器工具的
/// “资源文件名”属性。否则,
/// 设计器将不能与此窗体的关联
/// 本地化资源正确交互。
/// </summary>
public ref class RoomStatusForm : public System::Windows::Forms::Form
{
public:
RoomStatusForm(void)
{
InitializeComponent();
//
//TODO: 在此处添加构造函数代码
//
}
protected:
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
~RoomStatusForm()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::GroupBox^ groupBox2;
protected:
private: System::Windows::Forms::DataGridView^ 酒店客房旅客信息DataGridView;
private: System::Windows::Forms::GroupBox^ groupBox1;
private: System::Windows::Forms::DataGridView^ 酒店客房入住图DataGridView;
private:
/// <summary>
/// 必需的设计器变量。
/// </summary>
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
/// <summary>
/// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。
/// </summary>
void InitializeComponent(void)
{
System::Windows::Forms::DataGridViewCellStyle^ dataGridViewCellStyle1 = (gcnew System::Windows::Forms::DataGridViewCellStyle());
System::Windows::Forms::DataGridViewCellStyle^ dataGridViewCellStyle2 = (gcnew System::Windows::Forms::DataGridViewCellStyle());
this->groupBox2 = (gcnew System::Windows::Forms::GroupBox());
this->酒店客房旅客信息DataGridView = (gcnew System::Windows::Forms::DataGridView());
this->groupBox1 = (gcnew System::Windows::Forms::GroupBox());
this->酒店客房入住图DataGridView = (gcnew System::Windows::Forms::DataGridView());
this->groupBox2->SuspendLayout();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->酒店客房旅客信息DataGridView))->BeginInit();
this->groupBox1->SuspendLayout();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->酒店客房入住图DataGridView))->BeginInit();
this->SuspendLayout();
//
// groupBox2
//
this->groupBox2->Controls->Add(this->酒店客房旅客信息DataGridView);
this->groupBox2->Location = System::Drawing::Point(7, 192);
this->groupBox2->Name = L"groupBox2";
this->groupBox2->Size = System::Drawing::Size(529, 218);
this->groupBox2->TabIndex = 3;
this->groupBox2->TabStop = false;
this->groupBox2->Text = L"酒店客房旅客信息";
//
// 酒店客房旅客信息DataGridView
//
this->酒店客房旅客信息DataGridView->BackgroundColor = System::Drawing::SystemColors::ActiveCaption;
this->酒店客房旅客信息DataGridView->ColumnHeadersHeightSizeMode = System::Windows::Forms::DataGridViewColumnHeadersHeightSizeMode::AutoSize;
this->酒店客房旅客信息DataGridView->Location = System::Drawing::Point(7, 21);
this->酒店客房旅客信息DataGridView->Name = L"酒店客房旅客信息DataGridView";
this->酒店客房旅客信息DataGridView->ReadOnly = true;
this->酒店客房旅客信息DataGridView->RowHeadersVisible = false;
dataGridViewCellStyle1->BackColor = System::Drawing::Color::Green;
dataGridViewCellStyle1->ForeColor = System::Drawing::Color::Yellow;
this->酒店客房旅客信息DataGridView->RowsDefaultCellStyle = dataGridViewCellStyle1;
this->酒店客房旅客信息DataGridView->RowTemplate->Height = 23;
this->酒店客房旅客信息DataGridView->SelectionMode = System::Windows::Forms::DataGridViewSelectionMode::FullRowSelect;
this->酒店客房旅客信息DataGridView->Size = System::Drawing::Size(515, 189);
this->酒店客房旅客信息DataGridView->TabIndex = 0;
//
// groupBox1
//
this->groupBox1->Controls->Add(this->酒店客房入住图DataGridView);
this->groupBox1->Location = System::Drawing::Point(7, 6);
this->groupBox1->Name = L"groupBox1";
this->groupBox1->Size = System::Drawing::Size(529, 180);
this->groupBox1->TabIndex = 2;
this->groupBox1->TabStop = false;
this->groupBox1->Text = L"酒店客房入住图";
//
// 酒店客房入住图DataGridView
//
this->酒店客房入住图DataGridView->BackgroundColor = System::Drawing::SystemColors::ActiveCaption;
this->酒店客房入住图DataGridView->ColumnHeadersHeightSizeMode = System::Windows::Forms::DataGridViewColumnHeadersHeightSizeMode::AutoSize;
this->酒店客房入住图DataGridView->Location = System::Drawing::Point(7, 21);
this->酒店客房入住图DataGridView->Name = L"酒店客房入住图DataGridView";
this->酒店客房入住图DataGridView->ReadOnly = true;
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(516, 150);
this->酒店客房入住图DataGridView->TabIndex = 0;
this->酒店客房入住图DataGridView->CellFormatting += gcnew System::Windows::Forms::DataGridViewCellFormattingEventHandler(this, &RoomStatusForm::酒店客房入住图DataGridView_CellFormatting);
this->酒店客房入住图DataGridView->SelectionChanged += gcnew System::EventHandler(this, &RoomStatusForm::酒店客房入住图DataGridView_SelectionChanged);
//
// RoomStatusForm
//
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->groupBox2);
this->Controls->Add(this->groupBox1);
this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::Fixed3D;
this->MaximizeBox = false;
this->MinimizeBox = false;
this->Name = L"RoomStatusForm";
this->StartPosition = System::Windows::Forms::FormStartPosition::CenterParent;
this->Text = L"酒店房态图";
this->Load += gcnew System::EventHandler(this, &RoomStatusForm::RoomStatusForm_Load);
this->groupBox2->ResumeLayout(false);
(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->酒店客房旅客信息DataGridView))->EndInit();
this->groupBox1->ResumeLayout(false);
(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->酒店客房入住图DataGridView))->EndInit();
this->ResumeLayout(false);
}
#pragma endregion
private: static String^ MyHotelConnectionString= L"Data Source=.;Initial Catalog=MyHotel;Integrated Security=True;Pooling=False";
private: System::Void RoomStatusForm_Load(System::Object^ sender, System::EventArgs^ e) {
//获取酒店客房入住信息
String^ MySQLConnectionString = MyHotelConnectionString;
String^ MySQL = "Select 房号,已入住人数,楼层,单价,类别,可容纳人数,说明 From 酒店房间 ";
SqlConnection^ MyConnection = gcnew SqlConnection(MySQLConnectionString);
MyConnection->Open();
DataTable^ MyRoomTable = gcnew DataTable();
SqlDataAdapter^ MyAdapter = gcnew SqlDataAdapter(MySQL, MyConnection);
MyAdapter->Fill(MyRoomTable);
this->酒店客房入住图DataGridView->DataSource = MyRoomTable;
if (MyConnection->State == ConnectionState::Open)
{
MyConnection->Close();
}
}
private: System::Void 酒店客房入住图DataGridView_SelectionChanged(System::Object^ sender, System::EventArgs^ e) {
String^ My房号 = this->酒店客房入住图DataGridView->CurrentRow->Cells[0]->Value->ToString();
//获取选择的酒店客房入住旅客信息
String^ MySQLConnectionString =MyHotelConnectionString;
String^ MySQL = "Select 入住编号,客人姓名,住宿人数,联系电话,客人性别,房号,折扣价格,预收押金,入住日期,离开日期,证件名称,证件号码,证件地址,操作人员,说明 From 客房入住单 Where 房号='" + My房号 + "' AND 入住编号 NOT IN (Select 入住编号 From 客房结帐单)";
SqlConnection^ MyConnection = gcnew SqlConnection(MySQLConnectionString);
MyConnection->Open();
DataTable^ MyRoomTable = gcnew DataTable();
SqlDataAdapter^ MyAdapter = gcnew SqlDataAdapter(MySQL, MyConnection);
MyAdapter->Fill(MyRoomTable);
this->酒店客房旅客信息DataGridView->DataSource = MyRoomTable;
if (MyConnection->State == ConnectionState::Open)
{
MyConnection->Close();
}
}
private: System::Void 酒店客房入住图DataGridView_CellFormatting(System::Object^ sender, System::Windows::Forms::DataGridViewCellFormattingEventArgs^ e) {
if (e->ColumnIndex == this->酒店客房旅客信息DataGridView->Columns[1]->Index)
{
try
{
if (((int)e->Value) > 0)
{
e->CellStyle->BackColor = Color::Red;
e->CellStyle->SelectionBackColor = Color::Black;
e->CellStyle->SelectionForeColor = Color::Yellow;
e->CellStyle->ForeColor = Color::White;
}
}
catch(Exception^ e)
{
}
}
}
};
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -