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

📄 registerform.h

📁 宾馆酒店管理系统,建议在简体中文版Microsoft Windows Server 2003(SP1)/Microsoft Office 2003(SP2)/Microsoft SQL Server
💻 H
📖 第 1 页 / 共 3 页
字号:
			// 
			this->printDocument1->PrintPage += gcnew System::Drawing::Printing::PrintPageEventHandler(this, &RegisterForm::printDocument1_PrintPage);
			// 
			// groupBox2
			// 
			this->groupBox2->Controls->Add(this->酒店可用房间DataGridView);
			this->groupBox2->Controls->Add(this->酒店房间类别ComboBox);
			this->groupBox2->Controls->Add(this->label1);
			this->groupBox2->Location = System::Drawing::Point(216, 10);
			this->groupBox2->Name = L"groupBox2";
			this->groupBox2->Size = System::Drawing::Size(319, 363);
			this->groupBox2->TabIndex = 6;
			this->groupBox2->TabStop = false;
			this->groupBox2->Text = L"酒店客房信息";
			// 
			// RegisterForm
			// 
			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(540, 414);
			this->Controls->Add(this->保存Button);
			this->Controls->Add(this->打印Button);
			this->Controls->Add(this->新增Button);
			this->Controls->Add(this->groupBox1);
			this->Controls->Add(this->groupBox2);
			this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::Fixed3D;
			this->MaximizeBox = false;
			this->MinimizeBox = false;
			this->Name = L"RegisterForm";
			this->StartPosition = System::Windows::Forms::FormStartPosition::CenterParent;
			this->Text = L"登记旅客入住信息";
			this->Load += gcnew System::EventHandler(this, &RegisterForm::RegisterForm_Load);
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->酒店可用房间DataGridView))->EndInit();
			this->groupBox1->ResumeLayout(false);
			this->groupBox1->PerformLayout();
			this->groupBox2->ResumeLayout(false);
			this->groupBox2->PerformLayout();
			this->ResumeLayout(false);

		}
#pragma endregion
	public: String^ MyOperator;
	public: String^ MyCompany;
	public: static String^ MyHotelConnectionString= L"Data Source=.;Initial Catalog=MyHotel;Integrated Security=True;Pooling=False";			
	private: System::Void RegisterForm_Load(System::Object^  sender, System::EventArgs^  e) {
	   //添加酒店房间类别ComboBox控件的列表项
       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) {
	   //获取未完全入住房间信息
	   this->酒店可用房间DataGridView->GridColor = Color::Blue;
       String^ MySQLConnectionString =MyHotelConnectionString;
       String^ MySQL = "Select 房号,单价,可容纳人数-已入住人数 as 可入住人数,楼层,类别,说明,可容纳人数,已入住人数 From 酒店房间 Where 类别='" + this->酒店房间类别ComboBox->Text + "' AND 可容纳人数>已入住人数";
       if (this->酒店房间类别ComboBox->Text == "所有房间")
       {
          MySQL = "Select 房号,单价,可容纳人数-已入住人数 as 可入住人数,楼层,类别,说明,可容纳人数,已入住人数 From 酒店房间 Where 可容纳人数>已入住人数 ";
       }
       SqlConnection^ MyConnection = gcnew SqlConnection(MySQLConnectionString);
       MyConnection->Open();
       DataTable^ MyTable = gcnew DataTable();
       SqlDataAdapter^ MyAdapter = gcnew SqlDataAdapter(MySQL, MyConnection);
       MyAdapter->Fill(MyTable);
       this->酒店可用房间DataGridView->DataSource = MyTable;
	   if (MyConnection->State == ConnectionState::Open)
       {
          MyConnection->Close();
       }
	}
	private: System::Void 酒店可用房间DataGridView_Click(System::Object^  sender, System::EventArgs^  e) {
      //确定是否设置房号和住宿人数信息
      this->房号TextBox->Text = this->酒店可用房间DataGridView->CurrentRow->Cells[0]->Value->ToString();
      this->折扣价格TextBox->Text = this->酒店可用房间DataGridView->CurrentRow->Cells[1]->Value->ToString();
	  int MyCount = Convert::ToInt16(this->酒店可用房间DataGridView->CurrentRow->Cells[2]->Value->ToString());
      this->住宿人数ComboBox->Items->Clear();
      for (int i = 1; i <= MyCount; i++)
      {
		  this->住宿人数ComboBox->Items->Add(i.ToString());
      }
	  this->住宿人数ComboBox->Text = MyCount.ToString();
	}
	private: System::Void 新增Button_Click(System::Object^  sender, System::EventArgs^  e) {
	   this->房号TextBox->Text="";
       this->折扣价格TextBox->Text="";
       this->预收押金TextBox->Text="";
	   this->入住日期DateTimePicker->Value=DateTime::Now;
	   this->离开日期DateTimePicker->Value=DateTime::Now;
       this->客人姓名TextBox->Text="";
       this->证件名称ComboBox->Text="居民身份证";
       this->证件号码TextBox->Text="";
       this->证件地址TextBox->Text="";
       this->住宿人数ComboBox->Text="0";
       this->客人性别ComboBox->Text="男";
       this->联系电话TextBox->Text="";
       this->操作人员TextBox->Text=this->MyOperator;
       //自动计算入住编号
       String^ MySQLConnectionString =MyHotelConnectionString;
       SqlConnection^ MyConnection = gcnew SqlConnection(MySQLConnectionString);
       MyConnection->Open();
       SqlCommand^ MyCommand = MyConnection->CreateCommand();
       MyCommand->CommandText = "Select max(入住编号) 最大编号 From 客房入住单";
	   System::Object^ MyResult = MyCommand->ExecuteScalar();
	   System::Int64  MyID = 1;
	   if (MyResult != System::DBNull::Value)
       {
           String^ MyMaxID = MyResult->ToString()->Trim();
           MyMaxID = MyMaxID->Substring(2, MyMaxID->Length - 2);
		   MyID = Convert::ToInt64(MyMaxID) + 1;
       }
       int MyLength = MyID.ToString()->Length;
       String^ MyNewID = "";
       switch (MyLength)
       {
          case 1:
             MyNewID = "RZ0000000" + MyID.ToString();
             break;
          case 2:
             MyNewID = "RZ000000" + MyID.ToString();
             break;
          case 3:
             MyNewID = "RZ00000" + MyID.ToString();
             break;
          case 4:
             MyNewID = "RZ0000" + MyID.ToString();
             break;
          case 5:
             MyNewID = "RZ000" + MyID.ToString();
             break;
          case 6:
             MyNewID = "RZ00" + MyID.ToString();
             break;
          case 7:
             MyNewID = "RZ0" + MyID.ToString();
             break;
       }
	   if (MyConnection->State == ConnectionState::Open)
       {
          MyConnection->Close();
       }
       this->入住编号TextBox->Text = MyNewID;         
	}
	private: System::Void 打印Button_Click(System::Object^  sender, System::EventArgs^  e) {
       this->printPreviewDialog1->Document = this->printDocument1;
       this->printPreviewDialog1->ShowDialog();
	}
	private: System::Void printDocument1_PrintPage(System::Object^  sender, System::Drawing::Printing::PrintPageEventArgs^  e) {
		//打印入住单
		e->Graphics->DrawString(this->MyCompany + "旅客入住单", gcnew System::Drawing::Font("宋体", 20), Brushes::Black, 220, 80);
		e->Graphics->DrawString("入住编号:" + this->入住编号TextBox->Text , gcnew System::Drawing::Font("宋体", 12), Brushes::Black, 100, 150);
		DateTime^ MyPrintTime = DateTime::Now;
        e->Graphics->DrawString("打印日期:" + MyPrintTime->ToLongDateString() + MyPrintTime->ToLongTimeString(), gcnew System::Drawing::Font("宋体", 12), Brushes::Black, 450, 150);
        e->Graphics->DrawLine(gcnew Pen(Color::Black), 100, 180, 720, 180);
        e->Graphics->DrawLine(gcnew Pen(Color::Black), 100, 220, 720, 220);
        e->Graphics->DrawLine(gcnew Pen(Color::Black), 100, 260, 720, 260);
        e->Graphics->DrawLine(gcnew Pen(Color::Black), 100, 300, 720, 300);
        e->Graphics->DrawLine(gcnew Pen(Color::Black), 100, 340, 720, 340);
        e->Graphics->DrawLine(gcnew Pen(Color::Black), 100, 180, 100, 340);
        e->Graphics->DrawLine(gcnew Pen(Color::Black), 220, 180, 220, 340);
        e->Graphics->DrawLine(gcnew Pen(Color::Black), 400, 180, 400, 340);
        e->Graphics->DrawLine(gcnew Pen(Color::Black), 720, 180, 720, 340);
        e->Graphics->DrawString("房号:" + this->房号TextBox->Text, gcnew System::Drawing::Font("宋体", 12), Brushes::Black, 105, 190);
        e->Graphics->DrawString("姓名:" + this->客人姓名TextBox->Text, gcnew System::Drawing::Font("宋体", 12), Brushes::Black, 105, 230);
        e->Graphics->DrawString("性别:" + this->客人性别ComboBox->Text, gcnew System::Drawing::Font("宋体", 12), Brushes::Black, 105, 270);
        e->Graphics->DrawString("人数:" + this->住宿人数ComboBox->Text, gcnew System::Drawing::Font("宋体", 12), Brushes::Black, 105, 310);
        e->Graphics->DrawString("折扣价格:" + this->折扣价格TextBox->Text, gcnew System::Drawing::Font("宋体", 12), Brushes::Black, 225, 190);
        e->Graphics->DrawString("预收押金:" + this->预收押金TextBox->Text, gcnew System::Drawing::Font("宋体", 12), Brushes::Black, 225, 230);
        if (this->入住日期DateTimePicker->Value.ToString()->Length > 0)
        {
           e->Graphics->DrawString("入住日期:" + this->入住日期DateTimePicker->Value.ToString()->Remove(10), gcnew System::Drawing::Font("宋体", 12), Brushes::Black, 225, 270);
        }
        if (this->离开日期DateTimePicker->Value.ToString()->Length > 0)
        {
           e->Graphics->DrawString("离开日期:" + this->离开日期DateTimePicker->Value.ToString()->Remove(10), gcnew System::Drawing::Font("宋体", 12), Brushes::Black, 225, 310);
        }
        e->Graphics->DrawString("证件名称:" + this->证件名称ComboBox->Text, gcnew System::Drawing::Font("宋体", 12), Brushes::Black, 405, 190);
        e->Graphics->DrawString("证件编号:" + this->证件号码TextBox->Text, gcnew System::Drawing::Font("宋体", 12), Brushes::Black, 405, 230);
        e->Graphics->DrawString("证件地址:" + this->证件地址TextBox->Text, gcnew System::Drawing::Font("宋体", 12), Brushes::Black, 405, 270);
        e->Graphics->DrawString("联系电话:" + this->联系电话TextBox->Text, gcnew System::Drawing::Font("宋体", 12), Brushes::Black, 405, 310);
        e->Graphics->DrawString("操作员:" + this->操作人员TextBox->Text , gcnew System::Drawing::Font("宋体", 12), Brushes::Black, 600, 350);
        e->Graphics->DrawString("温馨提示:为了维护您及他人的合法权益,请不要带未经登记的人员进出您的房间。", gcnew System::Drawing::Font("宋体", 12), Brushes::Black, 100, 380);
        e->Graphics->DrawString("警察提示:请保管好您的物品,重要物品请寄存于酒店寄存处,免费寄存!", gcnew System::Drawing::Font("宋体", 12), Brushes::Black, 100, 400);
		e->Graphics->DrawString("谢谢合作!", gcnew System::Drawing::Font("宋体", 20), Brushes::Black, 550, 420);
	}
	private: System::Void 保存Button_Click(System::Object^  sender, System::EventArgs^  e) {
		if (MessageBox::Show("请检查旅客信息是否正确,一旦保存就无法修改,是否继续?", "信息提示", MessageBoxButtons::YesNo,MessageBoxIcon::Question) == System::Windows::Forms::DialogResult::No)
        {
          return;
        }
        String^ MySQLConnectionString = MyHotelConnectionString;
        String^ MySQL = "INSERT INTO [客房入住单] ([入住编号], [房号], [折扣价格], [预收押金], [入住日期], [离开日期], [客人姓名], [证件名称], [证件号码], [证件地址], [住宿人数], [客人性别], [联系电话], [操作人员]) VALUES (@入住编号, @房号, @折扣价格, @预收押金, @入住日期, @离开日期, @客人姓名,@证件名称, @证件号码, @证件地址, @住宿人数, @客人性别, @联系电话, @操作人员)";
        SqlConnection^ MyConnection = gcnew SqlConnection(MySQLConnectionString);
        MyConnection->Open();
        SqlCommand^ MyCommand = MyConnection->CreateCommand();
        MyCommand->CommandText =MySQL;
        MyCommand->Parameters->Add(gcnew SqlParameter("@入住编号",SqlDbType::VarChar));
        MyCommand->Parameters->Add(gcnew SqlParameter("@房号",  SqlDbType::VarChar));
        MyCommand->Parameters->Add(gcnew SqlParameter("@折扣价格",  SqlDbType::Float));
        MyCommand->Parameters->Add(gcnew SqlParameter("@预收押金",  SqlDbType::Float));
        MyCommand->Parameters->Add(gcnew SqlParameter("@入住日期",  SqlDbType::DateTime));
        MyCommand->Parameters->Add(gcnew SqlParameter("@离开日期",  SqlDbType::DateTime ));
        MyCommand->Parameters->Add(gcnew SqlParameter("@客人姓名",  SqlDbType::VarChar));
        MyCommand->Parameters->Add(gcnew SqlParameter("@证件名称",  SqlDbType::VarChar));
        MyCommand->Parameters->Add(gcnew SqlParameter("@证件号码",  SqlDbType::VarChar));
        MyCommand->Parameters->Add(gcnew SqlParameter("@证件地址",  SqlDbType::VarChar));
        MyCommand->Parameters->Add(gcnew SqlParameter("@住宿人数",  SqlDbType::Int));
        MyCommand->Parameters->Add(gcnew SqlParameter("@客人性别",  SqlDbType::VarChar));
        MyCommand->Parameters->Add(gcnew SqlParameter("@联系电话",  SqlDbType::VarChar));
        MyCommand->Parameters->Add(gcnew SqlParameter("@操作人员",  SqlDbType::VarChar));         
        MyCommand->Parameters["@入住编号"]->Value = this->入住编号TextBox->Text;
        MyCommand->Parameters["@房号"]->Value = this->房号TextBox->Text;
        MyCommand->Parameters["@折扣价格"]->Value = this->折扣价格TextBox->Text ;
        MyCommand->Parameters["@预收押金"]->Value = this->预收押金TextBox->Text ;
        MyCommand->Parameters["@入住日期"]->Value = this->入住日期DateTimePicker->Value;
        MyCommand->Parameters["@离开日期"]->Value = this->离开日期DateTimePicker->Value;
        MyCommand->Parameters["@客人姓名"]->Value = this->客人姓名TextBox->Text;
        MyCommand->Parameters["@证件名称"]->Value = this->证件名称ComboBox->Text;
        MyCommand->Parameters["@证件号码"]->Value = this->证件号码TextBox->Text;
        MyCommand->Parameters["@证件地址"]->Value = this->证件地址TextBox->Text;
        MyCommand->Parameters["@住宿人数"]->Value = this->住宿人数ComboBox->Text;
        MyCommand->Parameters["@客人性别"]->Value = this->客人性别ComboBox->Text;
        MyCommand->Parameters["@联系电话"]->Value = this->联系电话TextBox->Text ;
        MyCommand->Parameters["@操作人员"]->Value = this->操作人员TextBox->Text;         
        MyCommand->ExecuteNonQuery();
        MySQL = "Update 酒店房间 Set 已入住人数=已入住人数+" + this->住宿人数ComboBox->Text + " WHERE 房号='" + this->房号TextBox->Text + "'";
        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 + -