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

📄 checkoutform.h

📁 宾馆酒店管理系统,建议在简体中文版Microsoft Windows Server 2003(SP1)/Microsoft Office 2003(SP2)/Microsoft SQL Server
💻 H
📖 第 1 页 / 共 3 页
字号:
            this->酒店房号ComboBox->DataSource = MyRoomTable;
            this->酒店房号ComboBox->DisplayMember = "房号";
            this->酒店房号ComboBox->ValueMember = "房号";
            if (MyConnection->State == ConnectionState::Open)
            {
                MyConnection->Close();
            }
		 }
		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();
            System::Data::DataTable^ MyGuestTable = gcnew System::Data::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店内消费 = 0;
            My电话费 = 0;
            My用餐费 = 0;
            My住宿费 = 0;
            My费用总额 = 0;
            My预收押金 = 0;
            My结帐金额 = 0;
            this->预收押金TextBox->Text = "0";
            this->电话费TextBox->Text = "";
            this->用餐费TextBox->Text = "";
            this->店内消费TextBox->Text = "";
            this->住宿费TextBox->Text = "";
            this->结帐金额TextBox->Text = "";
            this->费用总额TextBox->Text = "0";
            this->My入住编号 = this->旅客姓名ComboBox->SelectedValue->ToString();
            String^ MySQLConnectionString = MyHotelConnectionString;
            SqlConnection^ MyConnection = gcnew SqlConnection(MySQLConnectionString);
            MyConnection->Open();
            String^ MySQL = "Select Count(*) From 客房结帐单 Where 入住编号='" + this->My入住编号 + "'";
            SqlCommand^ MyCommand = gcnew SqlCommand(MySQL, MyConnection);
			int MyCount = Convert::ToInt16(MyCommand->ExecuteScalar()->ToString());
            if (MyCount > 0)
            {
                if (MyConnection->State == ConnectionState::Open)
                {
                    MyConnection->Close();
                } 
                return;
            }
            MySQL = "Select SUM(预收押金) From 客房入住单 Where 入住编号='" + this->My入住编号 + "'";
            MyCommand = gcnew SqlCommand(MySQL, MyConnection);
            this->预收押金TextBox->Text = MyCommand->ExecuteScalar()->ToString();
            MySQL = "Select SUM(金额) From 话费入帐 Where 入住编号='" + this->My入住编号 + "'";
            MyCommand = gcnew SqlCommand(MySQL, MyConnection);
            this->电话费TextBox->Text = MyCommand->ExecuteScalar()->ToString();
            MySQL = "Select SUM(金额) From 餐费入帐 Where 入住编号='" + this->My入住编号 + "'";
            MyCommand = gcnew SqlCommand(MySQL, MyConnection);
            this->用餐费TextBox->Text = MyCommand->ExecuteScalar()->ToString();
            MySQL = "Select SUM(数量*折扣价格) From 消费入帐 Where 入住编号='" + this->My入住编号 + "'";
            MyCommand = gcnew SqlCommand(MySQL, MyConnection);
            this->店内消费TextBox->Text = MyCommand->ExecuteScalar()->ToString();
            this->My结帐日期 = this->结帐日期DateTimePicker->Value;
            MySQL = "Select 折扣价格,入住日期,住宿人数 From 客房入住单 Where 入住编号='" + this->My入住编号 + "'";
            System::Data::DataTable^ MyNewTable = gcnew System::Data::DataTable();
            SqlDataAdapter^ MyAdapter = gcnew SqlDataAdapter(MySQL, MyConnection);
            MyAdapter->Fill(MyNewTable);
            String^ My折扣价格 = MyNewTable->Rows[0][0]->ToString();
            this->折扣价格TextBox->Text = My折扣价格->ToString();
            this->My入住日期 = (DateTime)MyNewTable->Rows[0][1];
            this->入住日期TextBox->Text = this->My入住日期.ToLongDateString();
            this->My住宿人数 = (int)MyNewTable->Rows[0][2]; 
            TimeSpan MySpan = this->My结帐日期.Subtract(My入住日期);
			My住宿费 = Convert::ToDouble(My折扣价格) * Math::Round(MySpan.TotalDays, 0) * My住宿人数;
            this->住宿费TextBox->Text = My住宿费.ToString();
            if (this->店内消费TextBox->Text->Length > 1)
                My店内消费 = Convert::ToDouble(this->店内消费TextBox->Text);
            if (this->电话费TextBox->Text->Length > 1)
                My电话费 = Convert::ToDouble(this->电话费TextBox->Text);
            if (this->用餐费TextBox->Text->Length > 1)
                My用餐费 = Convert::ToDouble(this->用餐费TextBox->Text);
            My费用总额 = My住宿费 + My电话费 + My用餐费 + My店内消费;
            this->费用总额TextBox->Text = My费用总额.ToString();
            this->My预收押金=Convert::ToDouble(this->预收押金TextBox->Text);
            this->My结帐金额 = My费用总额 - this->My预收押金;
            this->结帐金额TextBox->Text = My结帐金额.ToString();
            MySQL = "Select * From 客房入住单 Where 入住编号='" + this->My入住编号 + "'";
            System::Data::DataTable^ MyGuestTable = gcnew System::Data::DataTable();
            SqlDataAdapter^ MyDataAdapter = gcnew SqlDataAdapter(MySQL, MyConnection);
            MyDataAdapter->Fill(MyGuestTable);
            this->客房入住单DataGridView->DataSource = MyGuestTable;
            if (MyConnection->State == ConnectionState::Open)
            {
                MyConnection->Close();
            }
			My结帐编号 = System::Guid::NewGuid().ToString()->ToUpper();
		 }
		private: System::Void 结帐日期DateTimePicker_ValueChanged(System::Object^  sender, System::EventArgs^  e) {
			旅客姓名ComboBox_SelectedIndexChanged(nullptr, nullptr);
		 }
		private: System::Void 打印Button_Click(System::Object^  sender, System::EventArgs^  e) {
			if (this->旅客姓名ComboBox->Text->Length < 1||this->费用总额TextBox->Text=="0" )
            {
                return;
            }
			if (MessageBox::Show("当您为旅客打印结帐单后,您必须保存该项操作,是否继续?", "信息提示", MessageBoxButtons::YesNo, MessageBoxIcon::Question) == System::Windows::Forms::DialogResult::No)
            {
                return;
            }
            this->printPreviewDialog1->Document = this->printDocument1;
            this->printPreviewDialog1->ShowDialog();
            this->结帐金额TextBox->Enabled = false;
		 }
		private: System::Void printDocument1_PrintPage(System::Object^  sender, System::Drawing::Printing::PrintPageEventArgs^  e) {
		    double MyAmount = this->My费用总额 - Convert::ToDouble(this->预收押金TextBox->Text);
            String^ MyAmountInfo="实收金额:"+MyAmount.ToString();
            if (MyAmount < 0)
            {
                MyAmountInfo = "实补金额:" + MyAmount.ToString()->Remove(0,1);
            }
            //打印旅客结帐单
            e->Graphics->DrawString(this->MyCompany + "旅客结帐单", gcnew System::Drawing::Font("宋体", 20), Brushes::Black, 220, 80);
            e->Graphics->DrawString("结帐编号:" + this->My结帐编号, 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, 500, 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->DrawLine(gcnew Pen(Color::Black), 100, 240, 720, 240);
            e->Graphics->DrawString("           1     店内消费               " + this->My店内消费.ToString(), gcnew System::Drawing::Font("宋体", 12), Brushes::Black, 110, 245);
            e->Graphics->DrawString("           2     住宿费                " + this->My住宿费.ToString(), gcnew System::Drawing::Font("宋体", 12), Brushes::Black, 110, 265);
            e->Graphics->DrawString("           3     电话费                " + this->My电话费.ToString(), gcnew System::Drawing::Font("宋体", 12), Brushes::Black, 110, 285);
            e->Graphics->DrawString("           4     用餐费                " + this->My用餐费.ToString(), gcnew System::Drawing::Font("宋体", 12), Brushes::Black, 110, 305);
            e->Graphics->DrawLine(gcnew Pen(Color::Black), 100, 325, 720, 325);
            e->Graphics->DrawString("                                     费用金额合计:" + this->My费用总额.ToString(), gcnew System::Drawing::Font("宋体", 12), Brushes::Black, 110, 330);            
            e->Graphics->DrawLine(gcnew Pen(Color::Black), 100, 350, 720, 350);
            e->Graphics->DrawString("入住日期:" + this->My入住日期.ToLongDateString()+"                 结帐日期:"+this->My结帐日期.ToLongDateString(), gcnew System::Drawing::Font("宋体", 12), Brushes::Black, 110, 355);
            e->Graphics->DrawLine(gcnew Pen(Color::Black), 100, 375, 720, 375);
            e->Graphics->DrawString("预收押金:" + this->预收押金TextBox->Text + "                           " + MyAmountInfo, gcnew System::Drawing::Font("宋体", 12), Brushes::Black, 110, 380);         
            e->Graphics->DrawLine(gcnew Pen(Color::Black, (float)3.00), 100, 400, 720, 400);
			DateTime MyDate = DateTime::Now;
            e->Graphics->DrawString("打印日期:" + MyDate.ToLongDateString() + MyDate.ToLongTimeString(), gcnew System::Drawing::Font("宋体", 12), Brushes::Black, 450, 405);
            e->Graphics->DrawString("温馨提示:为了维护您及他人的合法权益,请不要带未经登记的人员进出您的房间。", gcnew System::Drawing::Font("宋体", 12), Brushes::Black, 100, 425);
            e->Graphics->DrawString("警察提示:请保管好您的物品,重要物品请寄存于酒店寄存处,免费寄存!", gcnew System::Drawing::Font("宋体", 12), Brushes::Black, 100, 445);
            e->Graphics->DrawString("谢谢合作!", gcnew System::Drawing::Font("宋体", 20), Brushes::Black, 550, 465);
		 }
		private: System::Void 保存Button_Click(System::Object^  sender, System::EventArgs^  e) {
		    String^ MySQLConnectionString = MyHotelConnectionString;
            SqlConnection^ MyConnection = gcnew SqlConnection(MySQLConnectionString);
            MyConnection->Open();
            String^ MySQL = "Select Count(*) From 客房结帐单 Where 入住编号='" + this->My入住编号 + "'";
            SqlCommand^ MyCommand = gcnew SqlCommand(MySQL, MyConnection);
			int MyCount = Convert::ToInt16(MyCommand->ExecuteScalar()->ToString());
            if (MyCount > 0)
            {
                if (MyConnection->State == ConnectionState::Open)
                {
                    MyConnection->Close();
                }
                return;
            }
            //自动计算自编号            
            MyCommand->CommandText = "Select max(自编号) 最大编号 From 客房结帐单";
			System::Object^ MyResult = MyCommand->ExecuteScalar();
            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 = "JZ0000000" + MyID.ToString();
                    break;
                case 2:
                    MyNewID = "JZ000000" + MyID.ToString();
                    break;
                case 3:
                    MyNewID = "JZ00000" + MyID.ToString();
                    break;
                case 4:
                    MyNewID = "JZ0000" + MyID.ToString();
                    break;
                case 5:
                    MyNewID = "JZ000" + MyID.ToString();
                    break;
                case 6:
                    MyNewID = "JZ00" + MyID.ToString();
                    break;
                case 7:
                    MyNewID = "JZ0" + MyID.ToString();
                    break;
            }
            String^ My自编号= MyNewID;
            MySQL = "INSERT INTO [客房结帐单] ([自编号],[入住编号],[结帐编号], [房号], [客人姓名], [入住日期], [结帐日期], [店内消费], [住宿费], [电话费], [用餐费], [预收押金], [结帐金额], [操作人员],[说明]) VALUES (@自编号,@入住编号,@结帐编号, @房号, @客人姓名, @入住日期, @结帐日期, @店内消费, @住宿费, @电话费, @用餐费, @预收押金, @结帐金额, @操作人员,@说明)";
            MyConnection = gcnew SqlConnection(MySQLConnectionString);
            MyConnection->Open();
            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::DateTime));
            MyCommand->Parameters->Add(gcnew SqlParameter("@结帐日期", SqlDbType::DateTime));
            MyCommand->Parameters->Add(gcnew SqlParameter("@店内消费", SqlDbType::Float));
            MyCommand->Parameters->Add(gcnew SqlParameter("@住宿费", SqlDbType::Float));
            MyCommand->Parameters->Add(gcnew SqlParameter("@电话费", SqlDbType::Float));
            MyCommand->Parameters->Add(gcnew SqlParameter("@用餐费", SqlDbType::Float));
            MyCommand->Parameters->Add(gcnew SqlParameter("@预收押金", SqlDbType::Float));
            MyCommand->Parameters->Add(gcnew SqlParameter("@结帐金额", SqlDbType::Float));            
            MyCommand->Parameters->Add(gcnew SqlParameter("@操作人员", SqlDbType::VarChar));
            MyCommand->Parameters->Add(gcnew SqlParameter("@说明", SqlDbType::VarChar));
            MyCommand->Parameters["@自编号"]->Value = My自编号;
            MyCommand->Parameters["@入住编号"]->Value = this->My入住编号;
            MyCommand->Parameters["@结帐编号"]->Value = this->My结帐编号;
            MyCommand->Parameters["@房号"]->Value = this->酒店房号ComboBox->Text;
            MyCommand->Parameters["@客人姓名"]->Value = this->旅客姓名ComboBox->Text;
            MyCommand->Parameters["@入住日期"]->Value = this->My入住日期;
            MyCommand->Parameters["@结帐日期"]->Value = this->My结帐日期;
            MyCommand->Parameters["@店内消费"]->Value = this->My店内消费;
            MyCommand->Parameters["@住宿费"]->Value = this->My住宿费;
            MyCommand->Parameters["@电话费"]->Value = this->My电话费;
            MyCommand->Parameters["@用餐费"]->Value = this->My用餐费 ;
            MyCommand->Parameters["@预收押金"]->Value = this->My预收押金;
            MyCommand->Parameters["@结帐金额"]->Value = this->My结帐金额;
            MyCommand->Parameters["@操作人员"]->Value = this->MyOperator;
            MyCommand->Parameters["@说明"]->Value = this->说明TextBox->Text;
            MyCommand->ExecuteNonQuery();
            MySQL = "Update 酒店房间 Set 已入住人数=已入住人数-" + this->My住宿人数.ToString() + " WHERE 房号='" + this->酒店房号ComboBox->Text + "'";
            MyCommand->CommandText = MySQL;
            MyCommand->ExecuteNonQuery();
            if (MyConnection->State == ConnectionState::Open)
            {
                MyConnection->Close();
            }
            旅客姓名ComboBox_SelectedIndexChanged(nullptr, nullptr);
		 }
	};
}

⌨️ 快捷键说明

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