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

📄 financialreport.h

📁 Visual C++.net数据库开发经典案例
💻 H
字号:
#pragma once
#include "LinkDataBase.h"
//#using <C:\Program Files\Common Files\Crystal Decisions\1.1\Managed\CrystalDecisions.CrystalReports.Engine.dll>
//#using <C:\Program Files\Common Files\Crystal Decisions\1.1\Managed\CrystalDecisions.Windows.Forms.dll>

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 CrystalDecisions::CrystalReports::Engine;
using namespace CrystalDecisions::Windows::Forms;


namespace My
{
	/// <summary> 
	/// FinancialReport 摘要
	///
	/// 警告: 如果您更改该类的名称,则将需要更改 
	///          与该类所依赖的所有 .resx 文件关联的托管资源编译器工具的 
	///          “资源文件名”属性。  否则,
	///          设计器将不能与此窗体关联的
	///          本地化资源正确交互。
	/// </summary>
	public __gc class FinancialReport : public System::Windows::Forms::Form
	{
	//--------------------成员声明------------------------	

		LinkDataBase* MyDataBase;	//数据库连接类

	//-------------------成员声明结束-----------------------
	public: 
		FinancialReport(void)
		{
			InitializeComponent();
			this->MyDataBase = new LinkDataBase();
			this->FinancialAdapter->Fill(this->dataSet21);
		}
        
	protected: 
		void Dispose(Boolean disposing)
		{
			if (disposing && components)
			{
				components->Dispose();
			}
			__super::Dispose(disposing);
		}
	private: System::Windows::Forms::GroupBox *  groupBox1;
	private: System::Windows::Forms::NumericUpDown *  numericUpDown1;
	private: System::Windows::Forms::Label *  label1;
	private: System::Windows::Forms::Button *  btnShowReport;
	private: CrystalDecisions::Windows::Forms::CrystalReportViewer *  crystalReportViewer1;
    private: System::Data::SqlClient::SqlDataAdapter *  FinancialAdapter;
	private: System::Data::SqlClient::SqlCommand *  sqlSelectCommand1;
	private: My::DataSet2 *  dataSet21;
	private: System::Data::SqlClient::SqlConnection *  FinancialConnection;


	private:
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		System::ComponentModel::Container* components;

		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		void InitializeComponent(void)
		{
			this->groupBox1 = new System::Windows::Forms::GroupBox();
			this->btnShowReport = new System::Windows::Forms::Button();
			this->label1 = new System::Windows::Forms::Label();
			this->numericUpDown1 = new System::Windows::Forms::NumericUpDown();
			this->crystalReportViewer1 = new CrystalDecisions::Windows::Forms::CrystalReportViewer();
			this->FinancialAdapter = new System::Data::SqlClient::SqlDataAdapter();
			this->sqlSelectCommand1 = new System::Data::SqlClient::SqlCommand();
			this->FinancialConnection = new System::Data::SqlClient::SqlConnection();
			this->dataSet21 = new My::DataSet2();
			this->groupBox1->SuspendLayout();
			(__try_cast<System::ComponentModel::ISupportInitialize *  >(this->numericUpDown1))->BeginInit();
			(__try_cast<System::ComponentModel::ISupportInitialize *  >(this->dataSet21))->BeginInit();
			this->SuspendLayout();
			// 
			// groupBox1
			// 
			this->groupBox1->Controls->Add(this->btnShowReport);
			this->groupBox1->Controls->Add(this->label1);
			this->groupBox1->Controls->Add(this->numericUpDown1);
			this->groupBox1->Dock = System::Windows::Forms::DockStyle::Top;
			this->groupBox1->Location = System::Drawing::Point(0, 0);
			this->groupBox1->Name = S"groupBox1";
			this->groupBox1->Size = System::Drawing::Size(720, 80);
			this->groupBox1->TabIndex = 0;
			this->groupBox1->TabStop = false;
			// 
			// btnShowReport
			// 
			this->btnShowReport->Location = System::Drawing::Point(408, 32);
			this->btnShowReport->Name = S"btnShowReport";
			this->btnShowReport->Size = System::Drawing::Size(104, 24);
			this->btnShowReport->TabIndex = 2;
			this->btnShowReport->Text = S"显示报表";
			this->btnShowReport->Click += new System::EventHandler(this, btnShowReport_Click);
			// 
			// label1
			// 
			this->label1->Location = System::Drawing::Point(192, 37);
			this->label1->Name = S"label1";
			this->label1->Size = System::Drawing::Size(80, 16);
			this->label1->TabIndex = 1;
			this->label1->Text = S"统计会计期间";
			// 
			// numericUpDown1
			// 
			this->numericUpDown1->Location = System::Drawing::Point(280, 32);
			System::Int32 __mcTemp__1[] = new System::Int32[4];
			__mcTemp__1[0] = 1;
			__mcTemp__1[1] = 0;
			__mcTemp__1[2] = 0;
			__mcTemp__1[3] = 0;
			this->numericUpDown1->Minimum = System::Decimal(__mcTemp__1);
			this->numericUpDown1->Name = S"numericUpDown1";
			this->numericUpDown1->Size = System::Drawing::Size(88, 21);
			this->numericUpDown1->TabIndex = 0;
			System::Int32 __mcTemp__2[] = new System::Int32[4];
			__mcTemp__2[0] = 1;
			__mcTemp__2[1] = 0;
			__mcTemp__2[2] = 0;
			__mcTemp__2[3] = 0;
			this->numericUpDown1->Value = System::Decimal(__mcTemp__2);
			// 
			// crystalReportViewer1
			// 
			this->crystalReportViewer1->ActiveViewIndex = -1;
			this->crystalReportViewer1->DisplayGroupTree = false;
			this->crystalReportViewer1->Dock = System::Windows::Forms::DockStyle::Fill;
			this->crystalReportViewer1->Location = System::Drawing::Point(0, 80);
			this->crystalReportViewer1->Name = S"crystalReportViewer1";
			this->crystalReportViewer1->ReportSource = 0;
			this->crystalReportViewer1->Size = System::Drawing::Size(720, 277);
			this->crystalReportViewer1->TabIndex = 1;
			// 
			// FinancialAdapter
			// 
			this->FinancialAdapter->SelectCommand = this->sqlSelectCommand1;
			System::Data::Common::DataTableMapping* __mcTemp__3[] = new System::Data::Common::DataTableMapping*[1];
			System::Data::Common::DataColumnMapping* __mcTemp__4[] = new System::Data::Common::DataColumnMapping*[22];
			__mcTemp__4[0] = new System::Data::Common::DataColumnMapping(S"会计期间", S"A1");
			__mcTemp__4[1] = new System::Data::Common::DataColumnMapping(S"现金及现金等价物", S"A2");
			__mcTemp__4[2] = new System::Data::Common::DataColumnMapping(S"应收帐款", S"A3");
			__mcTemp__4[3] = new System::Data::Common::DataColumnMapping(S"坏帐准备", S"A4");
			__mcTemp__4[4] = new System::Data::Common::DataColumnMapping(S"应收帐款净值", S"A5");
			__mcTemp__4[5] = new System::Data::Common::DataColumnMapping(S"流动资产总计", S"A6");
			__mcTemp__4[6] = new System::Data::Common::DataColumnMapping(S"固定资产原值", S"A7");
			__mcTemp__4[7] = new System::Data::Common::DataColumnMapping(S"累计折旧", S"A8");
			__mcTemp__4[8] = new System::Data::Common::DataColumnMapping(S"固定资产总计", S"A9");
			__mcTemp__4[9] = new System::Data::Common::DataColumnMapping(S"其他资产", S"A10");
			__mcTemp__4[10] = new System::Data::Common::DataColumnMapping(S"资产总计", S"A11");
			__mcTemp__4[11] = new System::Data::Common::DataColumnMapping(S"应付帐款", S"A12");
			__mcTemp__4[12] = new System::Data::Common::DataColumnMapping(S"预收帐款", S"A13");
			__mcTemp__4[13] = new System::Data::Common::DataColumnMapping(S"应付工资", S"A14");
			__mcTemp__4[14] = new System::Data::Common::DataColumnMapping(S"其他负债", S"A15");
			__mcTemp__4[15] = new System::Data::Common::DataColumnMapping(S"负债总计", S"A16");
			__mcTemp__4[16] = new System::Data::Common::DataColumnMapping(S"实收资本", S"A17");
			__mcTemp__4[17] = new System::Data::Common::DataColumnMapping(S"资本公积", S"A18");
			__mcTemp__4[18] = new System::Data::Common::DataColumnMapping(S"赢余公积", S"A19");
			__mcTemp__4[19] = new System::Data::Common::DataColumnMapping(S"未分配利润", S"A20");
			__mcTemp__4[20] = new System::Data::Common::DataColumnMapping(S"所有者权益总计", S"A21");
			__mcTemp__4[21] = new System::Data::Common::DataColumnMapping(S"负债及所有者权益总计", S"A22");
			__mcTemp__3[0] = new System::Data::Common::DataTableMapping(S"Table", S"A0", __mcTemp__4);
			this->FinancialAdapter->TableMappings->AddRange(__mcTemp__3);
			// 
			// sqlSelectCommand1
			// 
			this->sqlSelectCommand1->CommandText = S"SELECT 资产负债表.* FROM 资产负债表";
			this->sqlSelectCommand1->Connection = this->FinancialConnection;
			// 
			// FinancialConnection
			// 
			this->FinancialConnection->ConnectionString = S"workstation id=localhost;packet size=4096;integrated security=SSPI;initial catalo" 
				S"g=caiwubook;persist security info=False";
			// 
			// dataSet21
			// 
			this->dataSet21->DataSetName = S"DataSet2";
			this->dataSet21->Locale = new System::Globalization::CultureInfo(S"zh-CN");
			// 
			// FinancialReport
			// 
			this->AutoScaleBaseSize = System::Drawing::Size(6, 14);
			this->ClientSize = System::Drawing::Size(720, 357);
			this->Controls->Add(this->crystalReportViewer1);
			this->Controls->Add(this->groupBox1);
			this->Name = S"FinancialReport";
			this->Text = S"资产负债表";
			this->groupBox1->ResumeLayout(false);
			(__try_cast<System::ComponentModel::ISupportInitialize *  >(this->numericUpDown1))->EndInit();
			(__try_cast<System::ComponentModel::ISupportInitialize *  >(this->dataSet21))->EndInit();
			this->ResumeLayout(false);

		}		
private: System::Void btnShowReport_Click(System::Object *  sender, System::EventArgs *  e)
		{
			//计算当前会计期
			String* tempSQL = String::Format(S"exec sf_计算资产负债表 {0}",this->numericUpDown1->Value.ToString());
			this->MyDataBase->SQLOperate(tempSQL);			
			this->FinancialAdapter->SelectCommand->CommandText = String::Format(S"Select * From 资产负债表 Where 会计期间 = {0}",this->numericUpDown1->Value.ToString());
			this->dataSet21->Clear();
			this->FinancialAdapter->Fill(this->dataSet21);
			//设置报表数据源
			ReportDocument* oRpt = new ReportDocument();

			oRpt->Load(".\\Financial.rpt");				 
			oRpt->SetDataSource(this->dataSet21->Tables->Item[0]);	 

            
			crystalReportViewer1->ReportSource = oRpt;
		}

};
}

⌨️ 快捷键说明

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