📄 querydepositform.h
字号:
//文件名:QueryDepositForm.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>
/// QueryDepositForm 摘要
///
/// 警告: 如果更改此类的名称,则需要更改
/// 与此类所依赖的所有 .resx 文件关联的托管资源编译器工具的
/// “资源文件名”属性。否则,
/// 设计器将不能与此窗体的关联
/// 本地化资源正确交互。
/// </summary>
public ref class QueryDepositForm : public System::Windows::Forms::Form
{
public:
QueryDepositForm(void)
{
InitializeComponent();
//
//TODO: 在此处添加构造函数代码
//
}
protected:
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
~QueryDepositForm()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::DataGridViewTextBoxColumn^ 用餐费;
protected:
private: System::Windows::Forms::DataGridViewTextBoxColumn^ 住宿费;
private: System::Windows::Forms::DataGridViewTextBoxColumn^ 费用金额;
private: System::Windows::Forms::Button^ 查询Button;
private: System::Windows::Forms::DataGridViewTextBoxColumn^ 电话费;
private: System::Windows::Forms::DataGridViewTextBoxColumn^ 店内消费;
private: System::Windows::Forms::DataGridViewTextBoxColumn^ 预收押金;
private: System::Windows::Forms::DateTimePicker^ 截止日期DateTimePicker;
private: System::Windows::Forms::DataGridView^ 押金DataGridView;
private: System::Windows::Forms::DataGridViewTextBoxColumn^ 入住编号;
private: System::Windows::Forms::DataGridViewTextBoxColumn^ 客人姓名;
private: System::Windows::Forms::DataGridViewTextBoxColumn^ 房号;
private: System::Windows::Forms::DataGridViewTextBoxColumn^ 应补金额;
private:
/// <summary>
/// 必需的设计器变量。
/// </summary>
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
/// <summary>
/// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。
/// </summary>
void InitializeComponent(void)
{
System::Windows::Forms::Label^ 截止日期Label;
System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(QueryDepositForm::typeid));
System::Windows::Forms::DataGridViewCellStyle^ dataGridViewCellStyle1 = (gcnew System::Windows::Forms::DataGridViewCellStyle());
this->用餐费 = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
this->住宿费 = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
this->费用金额 = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
this->查询Button = (gcnew System::Windows::Forms::Button());
this->电话费 = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
this->店内消费 = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
this->预收押金 = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
this->截止日期DateTimePicker = (gcnew System::Windows::Forms::DateTimePicker());
this->押金DataGridView = (gcnew System::Windows::Forms::DataGridView());
this->入住编号 = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
this->客人姓名 = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
this->房号 = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
this->应补金额 = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
截止日期Label = (gcnew System::Windows::Forms::Label());
(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->押金DataGridView))->BeginInit();
this->SuspendLayout();
//
// 截止日期Label
//
截止日期Label->AutoSize = true;
截止日期Label->Location = System::Drawing::Point(1, 6);
截止日期Label->Name = L"截止日期Label";
截止日期Label->Size = System::Drawing::Size(59, 12);
截止日期Label->TabIndex = 71;
截止日期Label->Text = L"截止日期:";
//
// 用餐费
//
this->用餐费->HeaderText = L"用餐费";
this->用餐费->Name = L"用餐费";
this->用餐费->ReadOnly = true;
//
// 住宿费
//
this->住宿费->HeaderText = L"住宿费";
this->住宿费->Name = L"住宿费";
this->住宿费->ReadOnly = true;
//
// 费用金额
//
this->费用金额->HeaderText = L"费用金额";
this->费用金额->Name = L"费用金额";
this->费用金额->ReadOnly = true;
//
// 查询Button
//
this->查询Button->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"查询Button.Image")));
this->查询Button->Location = System::Drawing::Point(443, 1);
this->查询Button->Name = L"查询Button";
this->查询Button->Size = System::Drawing::Size(95, 23);
this->查询Button->TabIndex = 73;
this->查询Button->Text = L"查询";
this->查询Button->TextAlign = System::Drawing::ContentAlignment::MiddleRight;
this->查询Button->TextImageRelation = System::Windows::Forms::TextImageRelation::ImageBeforeText;
this->查询Button->UseVisualStyleBackColor = true;
this->查询Button->Click += gcnew System::EventHandler(this, &QueryDepositForm::查询Button_Click);
//
// 电话费
//
this->电话费->HeaderText = L"电话费";
this->电话费->Name = L"电话费";
this->电话费->ReadOnly = true;
//
// 店内消费
//
this->店内消费->HeaderText = L"店内消费";
this->店内消费->Name = L"店内消费";
this->店内消费->ReadOnly = true;
//
// 预收押金
//
this->预收押金->HeaderText = L"预收押金";
this->预收押金->Name = L"预收押金";
this->预收押金->ReadOnly = true;
//
// 截止日期DateTimePicker
//
this->截止日期DateTimePicker->Location = System::Drawing::Point(66, 2);
this->截止日期DateTimePicker->Name = L"截止日期DateTimePicker";
this->截止日期DateTimePicker->Size = System::Drawing::Size(374, 21);
this->截止日期DateTimePicker->TabIndex = 72;
//
// 押金DataGridView
//
this->押金DataGridView->BackgroundColor = System::Drawing::SystemColors::MenuHighlight;
this->押金DataGridView->ColumnHeadersHeightSizeMode = System::Windows::Forms::DataGridViewColumnHeadersHeightSizeMode::AutoSize;
this->押金DataGridView->Columns->AddRange(gcnew cli::array< System::Windows::Forms::DataGridViewColumn^ >(10) {this->入住编号,
this->客人姓名, this->房号, this->应补金额, this->预收押金, this->费用金额, this->住宿费, this->用餐费, this->店内消费, this->电话费});
this->押金DataGridView->Location = System::Drawing::Point(3, 25);
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(535, 385);
this->押金DataGridView->TabIndex = 70;
//
// 入住编号
//
this->入住编号->HeaderText = L"入住编号";
this->入住编号->Name = L"入住编号";
this->入住编号->ReadOnly = true;
//
// 客人姓名
//
this->客人姓名->HeaderText = L"客人姓名";
this->客人姓名->Name = L"客人姓名";
this->客人姓名->ReadOnly = true;
//
// 房号
//
this->房号->HeaderText = L"房号";
this->房号->Name = L"房号";
this->房号->ReadOnly = true;
//
// 应补金额
//
this->应补金额->HeaderText = L"应补金额";
this->应补金额->Name = L"应补金额";
this->应补金额->ReadOnly = true;
//
// QueryDepositForm
//
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(截止日期Label);
this->Controls->Add(this->截止日期DateTimePicker);
this->Controls->Add(this->押金DataGridView);
this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::Fixed3D;
this->MaximizeBox = false;
this->MinimizeBox = false;
this->Name = L"QueryDepositForm";
this->StartPosition = System::Windows::Forms::FormStartPosition::CenterParent;
this->Text = L"查询当前未结帐旅客押金信息";
(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->押金DataGridView))->EndInit();
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
private: static String^ MyHotelConnectionString= L"Data Source=.;Initial Catalog=MyHotel;Integrated Security=True;Pooling=False";
private: System::Void 查询Button_Click(System::Object^ sender, System::EventArgs^ e) {
this->押金DataGridView->Rows->Clear();
String^ MySQLConnectionString = MyHotelConnectionString;
SqlConnection^ MyConnection = gcnew SqlConnection(MySQLConnectionString);
MyConnection->Open();
System::Data::DataTable^ MyGuestTable = gcnew System::Data::DataTable();
String^ MySQL = "Select 入住编号,客人姓名,房号,预收押金,折扣价格,入住日期,住宿人数 From 客房入住单 Where 入住编号 NOT IN (Select 入住编号 From 客房结帐单)";
SqlDataAdapter^ MyAdapter = gcnew SqlDataAdapter(MySQL, MyConnection);
MyAdapter->Fill(MyGuestTable);
for each (DataRow^ MyRow in MyGuestTable->Rows)
{
String^ My入住编号 = MyRow[0]->ToString();
String^ My客人姓名 = MyRow[1]->ToString();
String^ My房号 = MyRow[2]->ToString();
String^ My预收押金 = MyRow[3]->ToString();
String^ My折扣价格 = MyRow[4]->ToString();
int My住宿人数 = Convert::ToInt16(MyRow[6]->ToString());
double MyD店内消费 = 0;
double MyD电话费 = 0;
double MyD用餐费 = 0;
double MyD住宿费 = 0;
DateTime My入住日期 = (DateTime)MyRow[5];
TimeSpan^ MySpan = this->截止日期DateTimePicker->Value.Subtract(My入住日期);
MyD住宿费 = Convert::ToDouble(My折扣价格) * Math::Round(MySpan->TotalDays, 0) * My住宿人数;
MySQL = "Select SUM(金额) From 话费入帐 Where 入住编号='" + My入住编号 + "'";
SqlCommand^ MyCommand = gcnew SqlCommand(MySQL, MyConnection);
String^ My电话费 = MyCommand->ExecuteScalar()->ToString();
if (My电话费->Length > 0)
{
MyD电话费 = Convert::ToDouble(My电话费);
}
MySQL = "Select SUM(金额) From 餐费入帐 Where 入住编号='" + My入住编号 + "'";
MyCommand = gcnew SqlCommand(MySQL, MyConnection);
String^ My用餐费 = MyCommand->ExecuteScalar()->ToString();
if (My用餐费->Length > 0)
{
MyD用餐费 = Convert::ToDouble(My用餐费);
}
MySQL = "Select SUM(数量*折扣价格) From 消费入帐 Where 入住编号='" + My入住编号 + "'";
MyCommand = gcnew SqlCommand(MySQL, MyConnection);
String^ My店内消费 = MyCommand->ExecuteScalar()->ToString();
if (My店内消费->Length > 0)
{
MyD店内消费 = Convert::ToDouble(My店内消费);
}
double MyD费用总额 = MyD住宿费 + MyD电话费 + MyD用餐费 + MyD店内消费;
double MyD应补金额 = MyD费用总额 - Convert::ToDouble(My预收押金);
array<System::Object^ >^ MyCells = { My入住编号, My客人姓名, My房号, MyD应补金额.ToString(),My预收押金,MyD费用总额.ToString(),MyD住宿费.ToString(),My用餐费,My店内消费,My电话费};
this->押金DataGridView->Rows->Add(MyCells);
}
if (MyConnection->State == ConnectionState::Open)
{
MyConnection->Close();
}
}
};
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -