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

📄 gaspaymentform.h

📁 小区物业管理系统
💻 H
📖 第 1 页 / 共 3 页
字号:
			this->收据编号Label->TabIndex = 47;
			this->收据编号Label->Text = L"收据编号:";
			// 
			// 楼栋信息TableAdapter
			// 
			this->楼栋信息TableAdapter->ClearBeforeFill = true;
			// 
			// GasPaymentForm
			// 
			this->AutoScaleDimensions = System::Drawing::SizeF(6, 12);
			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
			this->ClientSize = System::Drawing::Size(542, 416);
			this->Controls->Add(this->移除Button);
			this->Controls->Add(this->添加Button);
			this->Controls->Add(this->明细DataGridView);
			this->Controls->Add(this->label1);
			this->Controls->Add(this->未交DataGridView);
			this->Controls->Add(this->查询Button);
			this->Controls->Add(this->业主姓名ComboBox);
			this->Controls->Add(this->业主姓名Label);
			this->Controls->Add(this->楼栋名称ComboBox);
			this->Controls->Add(this->楼栋名称Label);
			this->Controls->Add(this->保存Button);
			this->Controls->Add(this->打印Button);
			this->Controls->Add(this->新增Button);
			this->Controls->Add(this->补充说明Label);
			this->Controls->Add(this->补充说明TextBox);
			this->Controls->Add(this->收款事由TextBox);
			this->Controls->Add(this->收款事由Label);
			this->Controls->Add(this->收款人员TextBox);
			this->Controls->Add(this->收款人员Label);
			this->Controls->Add(this->收款形式TextBox);
			this->Controls->Add(this->收款形式Label);
			this->Controls->Add(this->收款金额TextBox);
			this->Controls->Add(this->收款金额Label);
			this->Controls->Add(this->交款人员TextBox);
			this->Controls->Add(this->交款人员Label);
			this->Controls->Add(this->收款日期TextBox);
			this->Controls->Add(this->收款日期Label);
			this->Controls->Add(this->收据编号TextBox);
			this->Controls->Add(this->收据编号Label);
			this->Name = L"GasPaymentForm";
			this->ShowInTaskbar = false;
			this->StartPosition = System::Windows::Forms::FormStartPosition::CenterParent;
			this->Text = L"费用管理[水电气费交纳]";
			this->Load += gcnew System::EventHandler(this, &GasPaymentForm::GasPaymentForm_Load);
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->明细DataGridView))->EndInit();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->未交DataGridView))->EndInit();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->楼栋信息BindingSource))->EndInit();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->DBCommunityDataSet))->EndInit();
			this->ResumeLayout(false);
			this->PerformLayout();

		}
#pragma endregion
	public: String^ MyCommunity;
	public: String^ MyOperator;
	public:String^ MySQLConnectionString;
	private: System::Data::DataTable^ MyGasTable;
	private: System::Void GasPaymentForm_Load(System::Object^  sender, System::EventArgs^  e) 
	{// TODO: 这行代码将数据加载到表“DBCommunityDataSet.楼栋信息”中
	  this->楼栋信息TableAdapter->Fill(this->DBCommunityDataSet->楼栋信息);
	  MyGasTable = gcnew System::Data::DataTable("水电气费明细表");
	  //创建无连接的数据表
	  array<System::Data::DataColumn^>^ MyKey=gcnew array<System::Data::DataColumn^>(1);
      DataColumn^ MyColumn = gcnew DataColumn();
	  MyColumn->DataType = System::Type::GetType("System.Int16");
      MyColumn->ColumnName = "序号";
      MyGasTable->Columns->Add(MyColumn);
      MyKey[0] = MyColumn;
      MyGasTable->PrimaryKey = MyKey;
      MyGasTable->Columns->Add("年份", System::Type::GetType("System.Int16"));
      MyGasTable->Columns->Add("月份", System::Type::GetType("System.Int16"));
      MyGasTable->Columns->Add("类型", System::Type::GetType("System.String"));
      MyGasTable->Columns->Add("表号", System::Type::GetType("System.String"));
      MyGasTable->Columns->Add("底数", System::Type::GetType("System.Double"));
      MyGasTable->Columns->Add("止数", System::Type::GetType("System.Double"));
      MyGasTable->Columns->Add("用量", System::Type::GetType("System.Double"));
      MyGasTable->Columns->Add("单价", System::Type::GetType("System.Double"));
      MyGasTable->Columns->Add("金额", System::Type::GetType("System.Double"));
      this->明细DataGridView->DataSource = MyGasTable;
	}
	private: System::Void 楼栋名称ComboBox_SelectedIndexChanged(System::Object^  sender, System::EventArgs^  e) 
	{//获取指定楼栋的业主信息
      String^ My楼栋名称 = this->楼栋名称ComboBox->Text;
      String^ MySQL = "SELECT * FROM [业主信息] WHERE ([楼栋名称] = '" + My楼栋名称 + "')";
      SqlConnection^ MyConnection = gcnew SqlConnection(MySQLConnectionString);
      MyConnection->Open();
      System::Data::DataTable^ MyTable = gcnew System::Data::DataTable();
      SqlDataAdapter^ MyAdapter = gcnew SqlDataAdapter(MySQL, MyConnection);
      MyAdapter->Fill(MyTable);
      this->业主姓名ComboBox->DataSource = MyTable;
      this->业主姓名ComboBox->DisplayMember = "业主姓名";
      this->业主姓名ComboBox->ValueMember = "业主编号";
      if (MyConnection->State == ConnectionState::Open)
      {
         MyConnection->Close();
      }
	}
	private: System::Void 查询Button_Click(System::Object^  sender, System::EventArgs^  e) 
	{//查询业主未交费信息
      String^ My业主编号 = "";
      if (this->业主姓名ComboBox->SelectedValue->ToString() != "System.Data.DataRowView")
      {
        My业主编号= this->业主姓名ComboBox->SelectedValue->ToString();
      }
      String^ MySQL = "SELECT [自动编号], [计费年份], [计费月份], [费用类型], [表编号], [表底数], [表止数], [表用量], [计费单价], [应交金额] FROM [水电气费] WHERE ([业主编号] ='" + My业主编号 + "') AND (费用状态='未交费')";
      SqlConnection^ MyConnection = gcnew SqlConnection(MySQLConnectionString);
      MyConnection->Open();
      System::Data::DataTable^ MyTable = gcnew System::Data::DataTable();
      SqlDataAdapter^ MyAdapter = gcnew SqlDataAdapter(MySQL, MyConnection);
      MyAdapter->Fill(MyTable);
      this->未交DataGridView->DataSource = MyTable;
      this->交款人员TextBox->Text = this->业主姓名ComboBox->Text;
	}
    private: System::Void 新增Button_Click(System::Object^  sender, System::EventArgs^  e) 
	{//新增收据信息
	  this->收据编号TextBox->Text= System::Guid::NewGuid().ToString()->ToUpper();
	  this->收款日期TextBox->Text  = DateTime::Now.ToShortDateString();
      this->收款人员TextBox->Text  = this->MyOperator;
      this->收款金额TextBox->Text = "0";
      MyGasTable->Rows->Clear();
    }
	private: System::Void 添加Button_Click(System::Object^  sender, System::EventArgs^  e) 
	{//添加交款明细项目
      if ((this->收据编号TextBox->Text->Length> 1) && (this->交款人员TextBox->Text->Length > 1))
      {
        System::Data::DataRow^ MyRow = MyGasTable->NewRow();
        MyRow[0] = Convert::ToInt16(this->未交DataGridView->CurrentRow->Cells[0]->Value->ToString());
        MyRow["年份"] = Convert::ToInt16(this->未交DataGridView->CurrentRow->Cells[1]->Value->ToString());
        MyRow["月份"] = Convert::ToInt16(this->未交DataGridView->CurrentRow->Cells[2]->Value->ToString());
        MyRow["类型"] = this->未交DataGridView->CurrentRow->Cells[3]->Value->ToString();
        MyRow["表号"] = this->未交DataGridView->CurrentRow->Cells[4]->Value->ToString();
        MyRow["底数"] = Convert::ToDouble(this->未交DataGridView->CurrentRow->Cells[5]->Value->ToString());
        MyRow["止数"] = Convert::ToDouble(this->未交DataGridView->CurrentRow->Cells[6]->Value->ToString());
        MyRow["用量"] = Convert::ToDouble(this->未交DataGridView->CurrentRow->Cells[7]->Value->ToString());
        MyRow["单价"] = Convert::ToDouble(this->未交DataGridView->CurrentRow->Cells[8]->Value->ToString());
        MyRow["金额"] = Convert::ToDouble(this->未交DataGridView->CurrentRow->Cells[9]->Value->ToString());
        MyGasTable->Rows->Add(MyRow);
        double MyAmount = Convert::ToDouble(this->收款金额TextBox->Text);
        MyAmount += Convert::ToDouble(this->未交DataGridView->CurrentRow->Cells[9]->Value->ToString());
        this->收款金额TextBox->Text = MyAmount.ToString();
      }
	}
	private: System::Void 移除Button_Click(System::Object^  sender, System::EventArgs^  e) 
	{//移除交款明细项目
      try
      {
        double MyAmount = Convert::ToDouble(this->收款金额TextBox->Text);
        MyAmount -= Convert::ToDouble(this->明细DataGridView->CurrentRow->Cells[9]->Value->ToString());
        this->收款金额TextBox->Text = MyAmount.ToString();
        MyGasTable->Rows->RemoveAt(this->明细DataGridView->CurrentRow->Index);
      }
      catch(Exception^ ex)
      {}
	}
	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->MyCommunity + "水电气费交款收据", gcnew System::Drawing::Font("宋体", 20), Brushes::Black, 180, 90);
      e->Graphics->DrawString("收据编号:" +this->收据编号TextBox->Text, gcnew System::Drawing::Font("宋体", 10), Brushes::Black, 100, 145);
      e->Graphics->DrawString("收款日期:" + this->收款日期TextBox->Text, gcnew System::Drawing::Font("宋体", 10), Brushes::Black, 550, 145);
      e->Graphics->DrawLine(gcnew Pen(Color::Black, (float)3.00), 100, 165, 720, 165);
      e->Graphics->DrawString("交款人员:" + this->交款人员TextBox->Text, gcnew System::Drawing::Font("宋体", 10), Brushes::Black, 100, 175);
      e->Graphics->DrawString("收款金额:" + this->收款金额TextBox->Text+"元", gcnew System::Drawing::Font("宋体", 10), Brushes::Black, 230, 175);
      e->Graphics->DrawString("收款形式:" + this->收款形式TextBox->Text, gcnew System::Drawing::Font("宋体", 10), Brushes::Black, 380, 175);
      e->Graphics->DrawString("收款事由:" + this->收款事由TextBox->Text, gcnew System::Drawing::Font("宋体", 10), Brushes::Black, 500, 175);
      e->Graphics->DrawLine(gcnew Pen(Color::Black), 100, 195, 720, 195);
      e->Graphics->DrawString("补充说明:" +this->补充说明TextBox->Text, gcnew System::Drawing::Font("宋体", 10), Brushes::Black, 100, 200);
      e->Graphics->DrawLine(gcnew Pen(Color::Black), 100, 220, 720, 220);
      e->Graphics->DrawString("序号", gcnew System::Drawing::Font("宋体", 10), Brushes::Black, 100, 225);
      e->Graphics->DrawString("年份", gcnew System::Drawing::Font("宋体", 10), Brushes::Black, 150, 225);
      e->Graphics->DrawString("月份", gcnew System::Drawing::Font("宋体", 10), Brushes::Black, 230, 225);
      e->Graphics->DrawString("类型", gcnew System::Drawing::Font("宋体", 10), Brushes::Black, 280, 225);
      e->Graphics->DrawString("表号", gcnew System::Drawing::Font("宋体", 10), Brushes::Black, 360, 225);
      e->Graphics->DrawString("底数", gcnew System::Drawing::Font("宋体", 10), Brushes::Black, 430, 225);
      e->Graphics->DrawString("止数", gcnew System::Drawing::Font("宋体", 10), Brushes::Black, 480, 225);
      e->Graphics->DrawString("用量", gcnew System::Drawing::Font("宋体", 10), Brushes::Black, 530, 225);
      e->Graphics->DrawString("单价", gcnew System::Drawing::Font("宋体", 10), Brushes::Black, 580, 225);
      e->Graphics->DrawString("金额", gcnew System::Drawing::Font("宋体", 10), Brushes::Black, 630, 225);
      int MyPosY = 245;
      int MyID=1;
      for each (System::Data::DataRow^ MyRow in this->MyGasTable->Rows)
      {
        e->Graphics->DrawString(MyID.ToString(), gcnew System::Drawing::Font("宋体", 10), Brushes::Black, 100, MyPosY);
        e->Graphics->DrawString(MyRow[1]->ToString(), gcnew System::Drawing::Font("宋体", 10), Brushes::Black, 150, MyPosY);
        e->Graphics->DrawString(MyRow[2]->ToString(), gcnew System::Drawing::Font("宋体", 10), Brushes::Black, 230, MyPosY);
        e->Graphics->DrawString(MyRow[3]->ToString(), gcnew System::Drawing::Font("宋体", 10), Brushes::Black, 280, MyPosY);
        e->Graphics->DrawString(MyRow[4]->ToString(), gcnew System::Drawing::Font("宋体", 10), Brushes::Black, 330, MyPosY);
        e->Graphics->DrawString(MyRow[5]->ToString(), gcnew System::Drawing::Font("宋体", 10), Brushes::Black, 430, MyPosY);
        e->Graphics->DrawString(MyRow[6]->ToString(), gcnew System::Drawing::Font("宋体", 10), Brushes::Black, 480, MyPosY);
        e->Graphics->DrawString(MyRow[7]->ToString(), gcnew System::Drawing::Font("宋体", 10), Brushes::Black, 530, MyPosY);
        e->Graphics->DrawString(MyRow[8]->ToString(), gcnew System::Drawing::Font("宋体", 10), Brushes::Black, 580, MyPosY);
        e->Graphics->DrawString(MyRow[9]->ToString(), gcnew System::Drawing::Font("宋体", 10), Brushes::Black, 630, MyPosY);
        MyPosY += 20;
        MyID += 1;
      }
      e->Graphics->DrawLine(gcnew Pen(Color::Black, (float)3.00), 100, 400, 720, 400);
      e->Graphics->DrawString("收款人员:" + this->收款人员TextBox->Text, gcnew System::Drawing::Font("宋体", 10), Brushes::Black, 100, 410);            
	}
	private: System::Void 保存Button_Click(System::Object^  sender, System::EventArgs^  e) 
	{//保存水电气费交款信息
	  if(Convert::ToDouble(this->收款金额TextBox->Text)==0)
	  {
		return;
	  }
      String^ MySaveInfo = "现在将保存业主交纳的水电气费数据,是否继续?";
	  if (MessageBox::Show(MySaveInfo, "信息提示", MessageBoxButtons::YesNo, MessageBoxIcon::Question) == System::Windows::Forms::DialogResult::No)
      {
        return;
      }
      SqlConnection^ MyConnection = gcnew SqlConnection(MySQLConnectionString);
      MyConnection->Open();
      SqlCommand^ MyCommand = MyConnection->CreateCommand();
      String^ MySQL = "INSERT INTO 费用收据(收据编号,收款日期,交款人员,收款金额,收款形式,收款人员,收款事由,补充说明) VALUES('";
      MySQL += this->收据编号TextBox->Text + "','";
      MySQL +=this->收款日期TextBox->Text + "','";
      MySQL +=this->交款人员TextBox->Text + "',";
      MySQL +=this->收款金额TextBox->Text + ",'";
      MySQL +=this->收款形式TextBox->Text + "','";
      MySQL +=this->收款人员TextBox->Text + "','";
      MySQL +=this->收款事由TextBox->Text + "','";
      MySQL +=this->补充说明TextBox->Text + "');";
      MyCommand->CommandText = MySQL;
      MyCommand->ExecuteNonQuery();
      for each (System::Data::DataRow^ MyRow in MyGasTable->Rows)
      {
        String^ My原编号 = MyRow[0]->ToString();
        String^ My收据编号 = this->收据编号TextBox->Text;
        MySQL = "UPDATE 水电气费 SET 费用状态='已交费',收据编号='" + My收据编号 + "' WHERE 自动编号=" + My原编号;
        MyCommand->CommandText = MySQL;
        MyCommand->ExecuteNonQuery();
      }
      if (MyConnection->State == ConnectionState::Open)
      {
        MyConnection->Close();
      }
      查询Button_Click(nullptr, nullptr);
      MyGasTable->Rows->Clear();
	  新增Button_Click(nullptr, nullptr); 		  
	}
  };
}

⌨️ 快捷键说明

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