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

📄 selltablereportform.h

📁 Visual C++.net数据库开发经典案例
💻 H
字号:
#pragma once
#include "LinkDataBase.h"
#include "DataGridComboBoxColumn.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 CrystalDecisions::CrystalReports::Engine;
using namespace CrystalDecisions::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;


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


	public: 
		SellTableReportForm(String* strID)
		{
			InitializeComponent();
			this->ID = strID;
		}
        
	protected: 
		void Dispose(Boolean disposing)
		{
			if (disposing && components)
			{
				components->Dispose();
			}
			__super::Dispose(disposing);
		}
	private: CrystalDecisions::Windows::Forms::CrystalReportViewer *  crystalReportViewer1;
	private: System::Data::SqlClient::SqlDataAdapter *  sqlDataAdapter1;

	private: System::Data::SqlClient::SqlConnection *  sqlConnection1;

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

		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		void InitializeComponent(void)
		{
			this->crystalReportViewer1 = new CrystalDecisions::Windows::Forms::CrystalReportViewer();
			this->sqlDataAdapter1 = new System::Data::SqlClient::SqlDataAdapter();
			this->sqlSelectCommand1 = new System::Data::SqlClient::SqlCommand();
			this->sqlConnection1 = new System::Data::SqlClient::SqlConnection();
			this->dataSetSellTable1 = new My::DataSetSellTable();
			(__try_cast<System::ComponentModel::ISupportInitialize *  >(this->dataSetSellTable1))->BeginInit();
			this->SuspendLayout();
			// 
			// crystalReportViewer1
			// 
			this->crystalReportViewer1->ActiveViewIndex = -1;
			this->crystalReportViewer1->DisplayGroupTree = false;
			this->crystalReportViewer1->Dock = System::Windows::Forms::DockStyle::Fill;
			this->crystalReportViewer1->Location = System::Drawing::Point(0, 0);
			this->crystalReportViewer1->Name = S"crystalReportViewer1";
			this->crystalReportViewer1->ReportSource = 0;
			this->crystalReportViewer1->Size = System::Drawing::Size(616, 397);
			this->crystalReportViewer1->TabIndex = 0;
			// 
			// sqlDataAdapter1
			// 
			this->sqlDataAdapter1->SelectCommand = this->sqlSelectCommand1;
			System::Data::Common::DataTableMapping* __mcTemp__1[] = new System::Data::Common::DataTableMapping*[1];
			System::Data::Common::DataColumnMapping* __mcTemp__2[] = new System::Data::Common::DataColumnMapping*[10];
			__mcTemp__2[0] = new System::Data::Common::DataColumnMapping(S"Date", S"Date");
			__mcTemp__2[1] = new System::Data::Common::DataColumnMapping(S"Total", S"Total");
			__mcTemp__2[2] = new System::Data::Common::DataColumnMapping(S"Quantity", S"Quantity");
			__mcTemp__2[3] = new System::Data::Common::DataColumnMapping(S"Price", S"Price");
			__mcTemp__2[4] = new System::Data::Common::DataColumnMapping(S"DetailTotal", S"DetailTotal");
			__mcTemp__2[5] = new System::Data::Common::DataColumnMapping(S"Discount", S"Discount");
			__mcTemp__2[6] = new System::Data::Common::DataColumnMapping(S"Depot", S"Depot");
			__mcTemp__2[7] = new System::Data::Common::DataColumnMapping(S"TaxRate", S"TaxRate");
			__mcTemp__2[8] = new System::Data::Common::DataColumnMapping(S"WareName", S"WareName");
			__mcTemp__2[9] = new System::Data::Common::DataColumnMapping(S"Customer", S"Customer");
			__mcTemp__1[0] = new System::Data::Common::DataTableMapping(S"Table", S"SellTable", __mcTemp__2);
			this->sqlDataAdapter1->TableMappings->AddRange(__mcTemp__1);
			// 
			// sqlSelectCommand1
			// 
			this->sqlSelectCommand1->CommandText = S"SELECT 销售单.销售日期 AS Date, 销售单.税价合计 AS Total, 销售单明细.销售数量 AS Quantity, 销售单明细.销售价 AS " 
				S"Price, 销售单明细.税价合计 AS DetailTotal, 销售单明细.扣率 AS Discount, 销售单明细.仓库 AS Depot, 销售单明细" 
				S".税率 AS TaxRate, 商品清单.品名 AS WareName, 客户清单.名称 AS Customer FROM 销售单 INNER JOIN 销售单" 
				S"明细 ON 销售单.编号 = 销售单明细.销售单号 INNER JOIN 商品清单 ON 销售单明细.货号 = 商品清单.货号 INNER JOIN 客户清单 " 
				S"ON 销售单.客户编号 = 客户清单.客户编号 WHERE (销售单.编号 = @ID)";
			this->sqlSelectCommand1->Connection = this->sqlConnection1;
			this->sqlSelectCommand1->Parameters->Add(new System::Data::SqlClient::SqlParameter(S"@ID", System::Data::SqlDbType::VarChar, 14, System::Data::ParameterDirection::Input, false, (System::Byte)0, (System::Byte)0, S"", System::Data::DataRowVersion::Default, 0));
			// 
			// sqlConnection1
			// 
			this->sqlConnection1->ConnectionString = S"workstation id=localhost;packet size=4096;integrated security=SSPI;initial catalo" 
				S"g=jxcbook;persist security info=False";
			// 
			// dataSetSellTable1
			// 
			this->dataSetSellTable1->DataSetName = S"DataSetSellTable";
			this->dataSetSellTable1->Locale = new System::Globalization::CultureInfo(S"zh-CN");
			// 
			// SellTableReportForm
			// 
			this->AutoScaleBaseSize = System::Drawing::Size(6, 14);
			this->ClientSize = System::Drawing::Size(616, 397);
			this->Controls->Add(this->crystalReportViewer1);
			this->Name = S"SellTableReportForm";
			this->Text = S"SellTableReportForm";
			this->Load += new System::EventHandler(this, SellTableReportForm_Load);
			(__try_cast<System::ComponentModel::ISupportInitialize *  >(this->dataSetSellTable1))->EndInit();
			this->ResumeLayout(false);

		}		
	private: System::Void SellTableReportForm_Load(System::Object *  sender, System::EventArgs *  e)
			 {
				 this->sqlSelectCommand1->Parameters->Item[S"@ID"]->Value = this->ID;
				 this->sqlDataAdapter1->Fill(this->dataSetSellTable1,S"销售报表");
					 
				 //设置报表数据源
				 ReportDocument* oRpt = new ReportDocument();
                 				 
				 oRpt->Load(".\\SellTableReport.rpt");				 
				 oRpt->SetDataSource(this->dataSetSellTable1->Tables->Item[S"销售报表"]);	 
				 

				 crystalReportViewer1->ReportSource = oRpt;
			 }

};
}

⌨️ 快捷键说明

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