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

📄 telephoneform.h

📁 宾馆酒店管理系统,建议在简体中文版Microsoft Windows Server 2003(SP1)/Microsoft Office 2003(SP2)/Microsoft SQL Server
💻 H
📖 第 1 页 / 共 2 页
字号:
			this->label3->AutoSize = true;
			this->label3->Location = System::Drawing::Point(9, 62);
			this->label3->Name = L"label3";
			this->label3->Size = System::Drawing::Size(41, 12);
			this->label3->TabIndex = 80;
			this->label3->Text = L"金额:";
			// 
			// 酒店房号ComboBox
			// 
			this->酒店房号ComboBox->DropDownStyle = System::Windows::Forms::ComboBoxStyle::DropDownList;
			this->酒店房号ComboBox->FormattingEnabled = true;
			this->酒店房号ComboBox->Location = System::Drawing::Point(84, 5);
			this->酒店房号ComboBox->Name = L"酒店房号ComboBox";
			this->酒店房号ComboBox->Size = System::Drawing::Size(168, 20);
			this->酒店房号ComboBox->TabIndex = 78;
			this->酒店房号ComboBox->SelectedIndexChanged += gcnew System::EventHandler(this, &TelephoneForm::酒店房号ComboBox_SelectedIndexChanged);
			// 
			// TelephoneForm
			// 
			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->类别ComboBox);
			this->Controls->Add(this->label5);
			this->Controls->Add(this->通话时间TextBox);
			this->Controls->Add(this->新增Button);
			this->Controls->Add(this->旅客话费表DataGridView);
			this->Controls->Add(this->保存Button);
			this->Controls->Add(this->打印Button);
			this->Controls->Add(this->说明TextBox);
			this->Controls->Add(入住日期Label);
			this->Controls->Add(this->旅客姓名ComboBox);
			this->Controls->Add(this->label2);
			this->Controls->Add(this->label1);
			this->Controls->Add(this->label4);
			this->Controls->Add(this->金额TextBox);
			this->Controls->Add(this->label3);
			this->Controls->Add(this->酒店房号ComboBox);
			this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::Fixed3D;
			this->MaximizeBox = false;
			this->MinimizeBox = false;
			this->Name = L"TelephoneForm";
			this->StartPosition = System::Windows::Forms::FormStartPosition::CenterParent;
			this->Text = L"登记旅客话费信息";
			this->Load += gcnew System::EventHandler(this, &TelephoneForm::TelephoneForm_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^ MyTelephoneTable = gcnew DataTable();
		private: 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 = "HF0000000" + MyID.ToString();
                    break;
                case 2:
                    MyNewID = "HF000000" + MyID.ToString();
                    break;
                case 3:
                    MyNewID = "HF00000" + MyID.ToString();
                    break;
                case 4:
                    MyNewID = "HF0000" + MyID.ToString();
                    break;
                case 5:
                    MyNewID = "HF000" + MyID.ToString();
                    break;
                case 6:
                    MyNewID = "HF00" + MyID.ToString();
                    break;
                case 7:
                    MyNewID = "HF0" + MyID.ToString();
                    break;
            }
			if (MyConnection->State == ConnectionState::Open)
            {
                MyConnection->Close();
            }
            return MyNewID;
        }
		private: System::Void TelephoneForm_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);
            MyTelephoneTable = gcnew DataTable("旅客话费表");
            DataColumn^ MyColumn = gcnew DataColumn();
			MyColumn->DataType = System::Type::GetType("System.Int32");
            MyColumn->ColumnName = "序号";
            MyTelephoneTable->Columns->Add(MyColumn);
            MyKey[0] = MyColumn;
            MyTelephoneTable->PrimaryKey = MyKey;
            MyTelephoneTable->Columns->Add("通话时间", System::Type::GetType("System.String"));
            MyTelephoneTable->Columns->Add("类别", System::Type::GetType("System.String"));
            MyTelephoneTable->Columns->Add("金额", System::Type::GetType("System.Double"));
            MyTelephoneTable->Columns->Add("说明", System::Type::GetType("System.String"));
            this->旅客话费表DataGridView->DataSource = MyTelephoneTable;
			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;
            MyTelephoneTable->Rows->Clear();
            MyID = 0;
		}
		private: System::Void 新增Button_Click(System::Object^  sender, System::EventArgs^  e) {
			MyID = MyID + 1;
            DataRow^ MyRow = MyTelephoneTable->NewRow();
            MyRow[0] = MyID;
            MyRow["通话时间"] = this->通话时间TextBox->Text;
            MyRow["类别"] = this->类别ComboBox->Text;
			MyRow["金额"] = Convert::ToDouble(this->金额TextBox->Text);
            MyRow["说明"] = this->说明TextBox->Text;
            MyTelephoneTable->Rows->Add(MyRow);
		}
		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 < MyTelephoneTable->Rows->Count; i++)
            {
                e->Graphics->DrawLine(gcnew Pen(Color::Black), 100, MyPosY, 720, MyPosY);
                e->Graphics->DrawString(MyTelephoneTable->Rows[i][0]->ToString(), gcnew System::Drawing::Font("宋体", 12), Brushes::Black, 110, MyPosY + 5);
                e->Graphics->DrawString(MyTelephoneTable->Rows[i][1]->ToString(), gcnew System::Drawing::Font("宋体", 12), Brushes::Black, 160, MyPosY + 5);
                e->Graphics->DrawString(MyTelephoneTable->Rows[i][2]->ToString(), gcnew System::Drawing::Font("宋体", 12), Brushes::Black, 350, MyPosY + 5);
                e->Graphics->DrawString(MyTelephoneTable->Rows[i][3]->ToString(), gcnew System::Drawing::Font("宋体", 12), Brushes::Black, 450, MyPosY + 5);
                e->Graphics->DrawString(MyTelephoneTable->Rows[i][4]->ToString(), gcnew System::Drawing::Font("宋体", 12), Brushes::Black, 550, MyPosY + 5);
				MyAmount = MyAmount + Convert::ToDouble(MyTelephoneTable->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) {
			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 < MyTelephoneTable->Rows->Count; i++)
            {
                MyCommand->Parameters["@自编号"]->Value = GetNewID();
                MyCommand->Parameters["@入住编号"]->Value = this->My入住编号;
                MyCommand->Parameters["@话费编号"]->Value = this->My话费编号->ToUpper();
                MyCommand->Parameters["@通话时间"]->Value = MyTelephoneTable->Rows[i][1]->ToString();
                MyCommand->Parameters["@类别"]->Value = MyTelephoneTable->Rows[i][2]->ToString();
				MyCommand->Parameters["@金额"]->Value = Convert::ToDouble(MyTelephoneTable->Rows[i][3]->ToString());
                MyCommand->Parameters["@说明"]->Value = MyTelephoneTable->Rows[i][4]->ToString();
                MyCommand->Parameters["@操作人员"]->Value = this->MyOperator;
                MyCommand->Parameters["@记帐时间"]->Value = this->MyDate;
                MyCommand->ExecuteNonQuery();
            }
            if (MyConnection->State == ConnectionState::Open)
            {
                MyConnection->Close();
            }
            MyTelephoneTable->Rows->Clear();
		}
	};
}

⌨️ 快捷键说明

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