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

📄 eatingform.h

📁 宾馆酒店管理系统,建议在简体中文版Microsoft Windows Server 2003(SP1)/Microsoft Office 2003(SP2)/Microsoft SQL Server
💻 H
📖 第 1 页 / 共 2 页
字号:
			// 
			this->label2->AutoSize = true;
			this->label2->Location = System::Drawing::Point(210, 11);
			this->label2->Name = L"label2";
			this->label2->Size = System::Drawing::Size(65, 12);
			this->label2->TabIndex = 58;
			this->label2->Text = L"旅客姓名:";
			// 
			// label1
			// 
			this->label1->AutoSize = true;
			this->label1->Location = System::Drawing::Point(5, 11);
			this->label1->Name = L"label1";
			this->label1->Size = System::Drawing::Size(65, 12);
			this->label1->TabIndex = 57;
			this->label1->Text = L"酒店房号:";
			// 
			// EatingForm
			// 
			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->用餐时间TextBox);
			this->Controls->Add(this->新增Button);
			this->Controls->Add(this->旅客餐费表DataGridView);
			this->Controls->Add(this->类别ComboBox);
			this->Controls->Add(this->label5);
			this->Controls->Add(this->保存Button);
			this->Controls->Add(this->打印Button);
			this->Controls->Add(this->说明TextBox);
			this->Controls->Add(this->label4);
			this->Controls->Add(this->金额TextBox);
			this->Controls->Add(this->label3);
			this->Controls->Add(入住日期Label);
			this->Controls->Add(this->酒店房号ComboBox);
			this->Controls->Add(this->旅客姓名ComboBox);
			this->Controls->Add(this->label2);
			this->Controls->Add(this->label1);
			this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::Fixed3D;
			this->MaximizeBox = false;
			this->MinimizeBox = false;
			this->Name = L"EatingForm";
			this->StartPosition = System::Windows::Forms::FormStartPosition::CenterParent;
			this->Text = L"登记旅客用餐信息";
			this->Load += gcnew System::EventHandler(this, &EatingForm::EatingForm_Load);
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->旅客餐费表DataGridView))->EndInit();
			this->ResumeLayout(false);
			this->PerformLayout();

		}
#pragma endregion
	private: String^ My餐费编号;
	private: String^ My入住编号;
	public: String^ MyOperator;
	public: String^ MyCompany;
	private: DateTime^ MyDate;
	private: int MyID;
	private: static DataTable^ MyEatingTable = gcnew DataTable();
	public: static String^ MyHotelConnectionString= L"Data Source=.;Initial Catalog=MyHotel;Integrated Security=True;Pooling=False";			
	private: String^ GetNewID()
    {
       //自动计算餐费编号
       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 = "CF0000000" + MyID.ToString();
             break;
          case 2:
             MyNewID = "CF000000" + MyID.ToString();
             break;
          case 3:
             MyNewID = "CF00000" + MyID.ToString();
             break;
          case 4:
             MyNewID = "CF0000" + MyID.ToString();
             break;
          case 5:
             MyNewID = "CF000" + MyID.ToString();
             break;
          case 6:
             MyNewID = "CF00" + MyID.ToString();
             break;
          case 7:
             MyNewID = "CF0" + MyID.ToString();
             break;
       }
	   if (MyConnection->State == ConnectionState::Open)
       {
          MyConnection->Close();
       }
       return MyNewID;
    }
	private: System::Void EatingForm_Load(System::Object^  sender, System::EventArgs^  e) {
	   this->酒店房号ComboBox->Items->Clear();
       String^ MySQLConnectionString =MyHotelConnectionString;
       SqlConnection^ MyConnection = gcnew SqlConnection(MySQLConnectionString);
       MyConnection->Open();        
       DataTable^ MyRoomTable = gcnew DataTable();
       //获取酒店已入住房间信息
       String^ MySQL = "Select * From 酒店房间 Where 已入住人数<>0 ";
       SqlDataAdapter^ MyAdapter = gcnew SqlDataAdapter(MySQL, MyConnection);
       MyAdapter->Fill(MyRoomTable);
       this->酒店房号ComboBox->DataSource = MyRoomTable;
       this->酒店房号ComboBox->DisplayMember = "房号";
       this->酒店房号ComboBox->ValueMember = "房号";
	   if (MyConnection->State == ConnectionState::Open)
       {
          MyConnection->Close();
       }
       //创建无连接的数据表
	   array<DataColumn^>^ MyKey=gcnew array<DataColumn^>(1);       
       MyEatingTable = gcnew DataTable("旅客餐费表");
       DataColumn^ MyColumn = gcnew DataColumn();
	   MyColumn->DataType = System::Type::GetType("System.Int32");
       MyColumn->ColumnName = "序号";
       MyEatingTable->Columns->Add(MyColumn);
       MyKey[0] = MyColumn;
       MyEatingTable->PrimaryKey = MyKey;
       MyEatingTable->Columns->Add("用餐时间",System::Type::GetType("System.String"));
       MyEatingTable->Columns->Add("类别", System::Type::GetType("System.String"));
       MyEatingTable->Columns->Add("金额", System::Type::GetType("System.Double"));
       MyEatingTable->Columns->Add("说明", System::Type::GetType("System.String"));
       this->旅客餐费表DataGridView->DataSource = MyEatingTable;
	   this->用餐时间TextBox->Text = DateTime::Now.ToLongDateString();
	}
	private: System::Void 酒店房号ComboBox_SelectedIndexChanged(System::Object^  sender, System::EventArgs^  e) {
	   //获取入住客人信息
       String^ MySQLConnectionString = MyHotelConnectionString;
       String^ MySQL = "Select 客人姓名,入住编号 From 客房入住单 Where 房号='" + this->酒店房号ComboBox->Text + "' AND 入住编号 NOT IN(Select 入住编号 FROM 客房结帐单)";            
       SqlConnection^ MyConnection = gcnew SqlConnection(MySQLConnectionString);
       MyConnection->Open();
       DataTable^ MyGuestTable = gcnew DataTable();
       SqlDataAdapter^ MyAdapter = gcnew SqlDataAdapter(MySQL, MyConnection);
       MyAdapter->Fill(MyGuestTable);
       this->旅客姓名ComboBox->DataSource = MyGuestTable;
       this->旅客姓名ComboBox->DisplayMember = "客人姓名";
       this->旅客姓名ComboBox->ValueMember = "入住编号";
	   if (MyConnection->State == ConnectionState::Open)
       {
         MyConnection->Close();
       }    
	}
	private: System::Void 旅客姓名ComboBox_SelectedIndexChanged(System::Object^  sender, System::EventArgs^  e) {
	    My入住编号 = this->旅客姓名ComboBox->SelectedValue->ToString();
		My餐费编号 = System::Guid::NewGuid().ToString();
		MyDate = DateTime::Now;
        MyEatingTable->Rows->Clear();
        MyID = 0;
	}
	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->My餐费编号->ToUpper(), gcnew System::Drawing::Font("宋体", 12), Brushes::Black, 100, 150);
        e->Graphics->DrawString("操作员:" + this->MyOperator, gcnew System::Drawing::Font("宋体", 12), Brushes::Black, 600, 150);
        e->Graphics->DrawLine(gcnew Pen(Color::Black, (float)3.00), 100, 185, 720, 185);
        e->Graphics->DrawString("房号:" + this->酒店房号ComboBox->Text, gcnew System::Drawing::Font("宋体", 12), Brushes::Black, 110, 195);
        e->Graphics->DrawString("姓名:" + this->旅客姓名ComboBox->Text, gcnew System::Drawing::Font("宋体", 12), Brushes::Black, 300, 195);
        e->Graphics->DrawString("入住编号:" + this->My入住编号, gcnew System::Drawing::Font("宋体", 12), Brushes::Black, 530, 195);
        e->Graphics->DrawLine(gcnew Pen(Color::Black), 100, 215, 720, 215);
        e->Graphics->DrawString("序号", gcnew System::Drawing::Font("宋体", 12), Brushes::Black, 110, 220);
        e->Graphics->DrawString("用餐时间", gcnew System::Drawing::Font("宋体", 12), Brushes::Black, 200, 220);
        e->Graphics->DrawString("类别", gcnew System::Drawing::Font("宋体", 12), Brushes::Black, 350, 220);
        e->Graphics->DrawString("金额", gcnew System::Drawing::Font("宋体", 12), Brushes::Black, 450, 220);
        e->Graphics->DrawString("说明", gcnew System::Drawing::Font("宋体", 12), Brushes::Black, 550, 220);
        int MyPosY = 240;
        float MyAmount = 0;
        for (int i = 0; i < MyEatingTable->Rows->Count; i++)
        {
           e->Graphics->DrawLine(gcnew Pen(Color::Black), 100, MyPosY, 720, MyPosY);
           e->Graphics->DrawString(MyEatingTable->Rows[i][0]->ToString(), gcnew System::Drawing::Font("宋体", 12), Brushes::Black, 110, MyPosY + 5);
           e->Graphics->DrawString(MyEatingTable->Rows[i][1]->ToString(), gcnew System::Drawing::Font("宋体", 12), Brushes::Black, 160, MyPosY + 5);
           e->Graphics->DrawString(MyEatingTable->Rows[i][2]->ToString(), gcnew System::Drawing::Font("宋体", 12), Brushes::Black, 350, MyPosY + 5);
           e->Graphics->DrawString(MyEatingTable->Rows[i][3]->ToString(), gcnew System::Drawing::Font("宋体", 12), Brushes::Black, 450, MyPosY + 5);
           e->Graphics->DrawString(MyEatingTable->Rows[i][4]->ToString(), gcnew System::Drawing::Font("宋体", 12), Brushes::Black, 550, MyPosY + 5);
		   MyAmount = MyAmount + Convert::ToDouble(MyEatingTable->Rows[i][3]->ToString());
           MyPosY = MyPosY + 25;
        }
        e->Graphics->DrawLine(gcnew Pen(Color::Black), 100, MyPosY, 720, MyPosY);
        e->Graphics->DrawString("合计金额:" + MyAmount.ToString(), gcnew System::Drawing::Font("宋体", 12), Brushes::Black, 360, MyPosY + 5);
        e->Graphics->DrawLine(gcnew Pen(Color::Black, (float)3.00), 100, MyPosY + 25, 720, MyPosY + 25);
        e->Graphics->DrawString("打印日期:" + this->MyDate->ToLongDateString() + this->MyDate->ToLongTimeString(), gcnew System::Drawing::Font("宋体", 12), Brushes::Black, 450, MyPosY + 30);
        e->Graphics->DrawString("温馨提示:为了维护您及他人的合法权益,请不要带未经登记的人员进出您的房间。", gcnew System::Drawing::Font("宋体", 12), Brushes::Black, 100, MyPosY + 50);
        e->Graphics->DrawString("警察提示:请保管好您的物品,重要物品请寄存于酒店寄存处,免费寄存!", gcnew System::Drawing::Font("宋体", 12), Brushes::Black, 100, MyPosY + 70);
        e->Graphics->DrawString("谢谢合作!", gcnew System::Drawing::Font("宋体", 20), Brushes::Black, 550, MyPosY + 90);
	}
	private: System::Void 新增Button_Click(System::Object^  sender, System::EventArgs^  e) {
	    MyID = MyID + 1;
        DataRow^ MyRow = MyEatingTable->NewRow();
        MyRow[0] = MyID;
        MyRow["用餐时间"] = this->用餐时间TextBox->Text;
        MyRow["类别"] = this->类别ComboBox->Text;
		MyRow["金额"] = Convert::ToDouble(this->金额TextBox->Text);
        MyRow["说明"] = this->说明TextBox->Text;
        MyEatingTable->Rows->Add(MyRow);
	}
	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::VarChar));
        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::VarChar));
        MyCommand->Parameters->Add(gcnew SqlParameter("@操作人员", SqlDbType::VarChar));
        MyCommand->Parameters->Add(gcnew SqlParameter("@记帐时间", SqlDbType::DateTime));
        for (int i = 0; i < MyEatingTable->Rows->Count; i++)
        {
          MyCommand->Parameters["@自编号"]->Value = GetNewID();
          MyCommand->Parameters["@入住编号"]->Value = this->My入住编号;
          MyCommand->Parameters["@餐费编号"]->Value = this->My餐费编号->ToUpper();
          MyCommand->Parameters["@用餐时间"]->Value = MyEatingTable->Rows[i][1]->ToString();
          MyCommand->Parameters["@类别"]->Value = MyEatingTable->Rows[i][2]->ToString();
		  MyCommand->Parameters["@金额"]->Value = Convert::ToDouble(MyEatingTable->Rows[i][3]->ToString());
          MyCommand->Parameters["@说明"]->Value = MyEatingTable->Rows[i][4]->ToString();
          MyCommand->Parameters["@操作人员"]->Value = this->MyOperator;
          MyCommand->Parameters["@记帐时间"]->Value = this->MyDate;
          MyCommand->ExecuteNonQuery();
        }
		if (MyConnection->State == ConnectionState::Open)
        {
          MyConnection->Close();
        }
        MyEatingTable->Rows->Clear();
	}
};
}

⌨️ 快捷键说明

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