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

📄 consumeform.h

📁 宾馆酒店管理系统,建议在简体中文版Microsoft Windows Server 2003(SP1)/Microsoft Office 2003(SP2)/Microsoft SQL Server
💻 H
📖 第 1 页 / 共 3 页
字号:
          case 2:
             MyNewID = "XF000000" + MyID.ToString();
             break;
          case 3:
             MyNewID = "XF00000" + MyID.ToString();
             break;
          case 4:
             MyNewID = "XF0000" + MyID.ToString();
             break;
          case 5:
             MyNewID = "XF000" + MyID.ToString();
             break;
          case 6:
             MyNewID = "XF00" + MyID.ToString();
             break;
          case 7:
             MyNewID = "XF0" + MyID.ToString();
             break;
       }
       if (MyConnection->State == ConnectionState::Open)
       {
           MyConnection->Close();
       }
       return  MyNewID;   
    }
	private: System::Void ConsumeForm_Load(System::Object^  sender, System::EventArgs^  e) {
	    this->酒店房号ComboBox->Items->Clear();
        //获取酒店消费品价格信息
        String^ MySQLConnectionString = MyHotelConnectionString;
        String^ MySQL = "Select * From 消费物品 ";
        SqlConnection^ MyConnection = gcnew SqlConnection(MySQLConnectionString);
        MyConnection->Open();
        DataTable^ MyGoodsTable = gcnew DataTable();
        SqlDataAdapter^ MyAdapter = gcnew SqlDataAdapter(MySQL, MyConnection);
        MyAdapter->Fill(MyGoodsTable);
        this->消费品价格DataGridView->DataSource = MyGoodsTable;            
        DataTable^ MyRoomTable = gcnew DataTable();
        //获取酒店已入住房间信息
        MySQL = "Select * From 酒店房间 Where 已入住人数<>0 ";
        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);            
        MyConsumeTable=gcnew DataTable("旅客消费表");
        DataColumn^ MyColumn = gcnew DataColumn();
		MyColumn->DataType = System::Type::GetType("System.Int32");
        MyColumn->ColumnName = "序号";
        MyConsumeTable->Columns->Add(MyColumn);
        MyKey[0] = MyColumn;
        MyConsumeTable->PrimaryKey = MyKey;
        MyConsumeTable->Columns->Add("消费品名称", System::Type::GetType("System.String"));
        MyConsumeTable->Columns->Add("单价", System::Type::GetType("System.Double"));
        MyConsumeTable->Columns->Add("折扣价", System::Type::GetType("System.Double"));		
        MyConsumeTable->Columns->Add("数量", System::Type::GetType("System.Int32"));
        MyConsumeTable->Columns->Add("金额", System::Type::GetType("System.Double"));
        this->旅客消费表DataGridView->DataSource = MyConsumeTable;
	}
	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;
         MyConsumeTable->Rows->Clear();
         MyID = 0;
	}
	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();
        this->单价TextBox->Text = this->消费品价格DataGridView->CurrentRow->Cells[1]->Value->ToString();	
	}
	private: System::Void 添加Button_Click(System::Object^  sender, System::EventArgs^  e) {
	    if (this->消费品名称TextBox->Text->Length < 1)
        {
           return;
        }
        MyID = MyID + 1;
        DataRow^ MyRow = MyConsumeTable->NewRow();
        MyRow[0] = MyID;
        MyRow["消费品名称"] = this->消费品名称TextBox->Text; 
        MyRow["单价"] = Convert::ToDouble(this->单价TextBox->Text);
        MyRow["折扣价"] = Convert::ToDouble(this->折扣价格TextBox->Text);
        MyRow["数量"] = Convert::ToInt16(this->数量TextBox->Text);
		MyRow["金额"] = Convert::ToDouble(MyRow["折扣价"]->ToString())* Convert::ToInt32(MyRow["数量"]->ToString());
        MyConsumeTable->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);
        e->Graphics->DrawString("金额", gcnew System::Drawing::Font("宋体", 12), Brushes::Black, 650, 220);
        int MyPosY = 240 ;
        float MyAmount = 0;
        for (int i = 0; i < MyConsumeTable->Rows->Count; i++)
        {
           e->Graphics->DrawLine(gcnew Pen(Color::Black), 100, MyPosY, 720, MyPosY);
           e->Graphics->DrawString(MyConsumeTable->Rows[i][0]->ToString(), gcnew System::Drawing::Font("宋体", 12), Brushes::Black, 110, MyPosY + 5);
           e->Graphics->DrawString(MyConsumeTable->Rows[i][1]->ToString(), gcnew System::Drawing::Font("宋体", 12), Brushes::Black, 190, MyPosY + 5);
           e->Graphics->DrawString(MyConsumeTable->Rows[i][2]->ToString(), gcnew System::Drawing::Font("宋体", 12), Brushes::Black, 350, MyPosY + 5);
           e->Graphics->DrawString(MyConsumeTable->Rows[i][3]->ToString(), gcnew System::Drawing::Font("宋体", 12), Brushes::Black, 450, MyPosY + 5);
           e->Graphics->DrawString(MyConsumeTable->Rows[i][4]->ToString(), gcnew System::Drawing::Font("宋体", 12), Brushes::Black, 550, MyPosY + 5);
           e->Graphics->DrawString(MyConsumeTable->Rows[i][5]->ToString(), gcnew System::Drawing::Font("宋体", 12), Brushes::Black, 650, MyPosY + 5);
		   MyAmount = MyAmount + Convert::ToDouble(MyConsumeTable->Rows[i][5]->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, 560, 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::Int));
        MyCommand->Parameters->Add(gcnew SqlParameter("@折扣价格", SqlDbType::Float));
        MyCommand->Parameters->Add(gcnew SqlParameter("@操作人员", SqlDbType::VarChar));
        MyCommand->Parameters->Add(gcnew SqlParameter("@记帐时间", SqlDbType::DateTime));
        for (int i = 0; i < MyConsumeTable->Rows->Count; i++)
        {
           MyCommand->Parameters["@自编号"]->Value = GetNewID(); 
           MyCommand->Parameters["@入住编号"]->Value = this->My入住编号;
           MyCommand->Parameters["@消费编号"]->Value = this->My消费编号->ToUpper();
           MyCommand->Parameters["@消费品名称"]->Value = MyConsumeTable->Rows[i][1]->ToString();
           MyCommand->Parameters["@数量"]->Value = Convert::ToInt16(MyConsumeTable->Rows[i][4]->ToString());
           MyCommand->Parameters["@折扣价格"]->Value = Convert::ToDouble(MyConsumeTable->Rows[i][3]->ToString());
           MyCommand->Parameters["@操作人员"]->Value = this->MyOperator;
           MyCommand->Parameters["@记帐时间"]->Value = this->MyDate;
           MyCommand->ExecuteNonQuery();
        }           
        if (MyConnection->State == ConnectionState::Open)
        {
           MyConnection->Close();
        }
        MyConsumeTable->Rows->Clear();
 	 }
  };
}

⌨️ 快捷键说明

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