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

📄 ledgerquery.h

📁 Visual C++.net数据库开发经典案例
💻 H
字号:
#pragma once

#include "LinkDataBase.h"
#include "DataGridNoActiveCellColumn.h"

using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;


namespace My
{
	/// <summary> 
	/// LedgerQuery 摘要
	///
	/// 警告: 如果您更改该类的名称,则将需要更改 
	///          与该类所依赖的所有 .resx 文件关联的托管资源编译器工具的 
	///          “资源文件名”属性。  否则,
	///          设计器将不能与此窗体关联的
	///          本地化资源正确交互。
	/// </summary>
	public __gc class LedgerQuery : public System::Windows::Forms::Form
	{
	//--------------------成员声明------------------------
	private:
		LinkDataBase* MyDataBase;	//数据库连接类
		DataSet* ds;		
		String* strSQL;		
		SqlDataAdapter* WarrentAdapter;
		DataView* WarrentView;
	private: System::Windows::Forms::TextBox *  tBoxWarrentCode;
			 String* WarrentID;
	//-------------------成员声明结束-----------------------
	public: 
		LedgerQuery(void)
		{
			InitializeComponent();
			this->MyDataBase = new LinkDataBase();
			this->WarrentAdapter = new SqlDataAdapter();
			this->WarrentView = new DataView();
			this->ds = new DataSet();
			this->strSQL = S"SELECT 科目表.科目名称,本期汇总帐簿.* FROM  本期汇总帐簿,科目表 WHERE 本期汇总帐簿.科目代码 = 科目表.科目代码";								
			this->MyDataBase->SelectDataBase(this->WarrentAdapter,this->ds,this->strSQL,S"本期汇总帐簿");
		}
        
	protected: 
		void Dispose(Boolean disposing)
		{
			if (disposing && components)
			{
				components->Dispose();
			}
			__super::Dispose(disposing);
		}
	private: System::Windows::Forms::GroupBox *  groupBox2;
	private: System::Windows::Forms::Button *  btnSearch;
	private: System::Windows::Forms::Label *  label10;
	private: System::Windows::Forms::DataGrid *  dgrdLedger;

	private: System::Windows::Forms::CheckBox *  chkIsShowCash;


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

		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		void InitializeComponent(void)
		{
			this->groupBox2 = new System::Windows::Forms::GroupBox();
			this->chkIsShowCash = new System::Windows::Forms::CheckBox();
			this->btnSearch = new System::Windows::Forms::Button();
			this->label10 = new System::Windows::Forms::Label();
			this->tBoxWarrentCode = new System::Windows::Forms::TextBox();
			this->dgrdLedger = new System::Windows::Forms::DataGrid();
			this->groupBox2->SuspendLayout();
			(__try_cast<System::ComponentModel::ISupportInitialize *  >(this->dgrdLedger))->BeginInit();
			this->SuspendLayout();
			// 
			// groupBox2
			// 
			this->groupBox2->Controls->Add(this->chkIsShowCash);
			this->groupBox2->Controls->Add(this->btnSearch);
			this->groupBox2->Controls->Add(this->label10);
			this->groupBox2->Controls->Add(this->tBoxWarrentCode);
			this->groupBox2->Dock = System::Windows::Forms::DockStyle::Top;
			this->groupBox2->Location = System::Drawing::Point(0, 0);
			this->groupBox2->Name = S"groupBox2";
			this->groupBox2->Size = System::Drawing::Size(736, 96);
			this->groupBox2->TabIndex = 6;
			this->groupBox2->TabStop = false;
			// 
			// chkIsShowCash
			// 
			this->chkIsShowCash->Location = System::Drawing::Point(496, 40);
			this->chkIsShowCash->Name = S"chkIsShowCash";
			this->chkIsShowCash->Size = System::Drawing::Size(176, 24);
			this->chkIsShowCash->TabIndex = 38;
			this->chkIsShowCash->Text = S"若无发生金额则不显示";
			this->chkIsShowCash->CheckedChanged += new System::EventHandler(this, chkIsShowCash_CheckedChanged);
			// 
			// btnSearch
			// 
			this->btnSearch->Location = System::Drawing::Point(56, 40);
			this->btnSearch->Name = S"btnSearch";
			this->btnSearch->Size = System::Drawing::Size(88, 24);
			this->btnSearch->TabIndex = 37;
			this->btnSearch->Text = S"查询";
			this->btnSearch->Click += new System::EventHandler(this, btnSearch_Click);
			// 
			// label10
			// 
			this->label10->Location = System::Drawing::Point(184, 43);
			this->label10->Name = S"label10";
			this->label10->Size = System::Drawing::Size(56, 16);
			this->label10->TabIndex = 32;
			this->label10->Text = S"科目代码";
			// 
			// tBoxWarrentCode
			// 
			this->tBoxWarrentCode->Location = System::Drawing::Point(256, 40);
			this->tBoxWarrentCode->Name = S"tBoxWarrentCode";
			this->tBoxWarrentCode->Size = System::Drawing::Size(168, 21);
			this->tBoxWarrentCode->TabIndex = 27;
			this->tBoxWarrentCode->Text = S"";
			// 
			// dgrdLedger
			// 
			this->dgrdLedger->AllowNavigation = false;
			this->dgrdLedger->DataMember = S"";
			this->dgrdLedger->Dock = System::Windows::Forms::DockStyle::Fill;
			this->dgrdLedger->HeaderForeColor = System::Drawing::SystemColors::ControlText;
			this->dgrdLedger->Location = System::Drawing::Point(0, 96);
			this->dgrdLedger->Name = S"dgrdLedger";
			this->dgrdLedger->ReadOnly = true;
			this->dgrdLedger->Size = System::Drawing::Size(736, 285);
			this->dgrdLedger->TabIndex = 7;
			// 
			// LedgerQuery
			// 
			this->AutoScaleBaseSize = System::Drawing::Size(6, 14);
			this->ClientSize = System::Drawing::Size(736, 381);
			this->Controls->Add(this->dgrdLedger);
			this->Controls->Add(this->groupBox2);
			this->Name = S"LedgerQuery";
			this->Text = S"总分类账查询";
			this->Load += new System::EventHandler(this, LedgerQuery_Load);
			this->groupBox2->ResumeLayout(false);
			(__try_cast<System::ComponentModel::ISupportInitialize *  >(this->dgrdLedger))->EndInit();
			this->ResumeLayout(false);

		}		

private: System::Void LedgerQuery_Load(System::Object *  sender, System::EventArgs *  e)
		{				
			this->WarrentView->Table = this->ds->Tables->Item[S"本期汇总帐簿"];
			this->dgrdLedger->DataSource = this->WarrentView;
			this->DataGridStateControl();
		}
		//------------------设置表格样式----------------------
		void DataGridStateControl()
		{
			DataGridTableStyle* ts = new DataGridTableStyle();
			DataGridNoActiveCellColumn* aTextColumn;
			ts->AlternatingBackColor = Color::LightGray;
			ts->MappingName = this->ds->Tables->Item[S"本期汇总帐簿"]->TableName;

			int numCols = this->ds->Tables->Item[S"本期汇总帐簿"]->Columns->Count;
			for(int i = 0;i < numCols;i++)
			{
				aTextColumn = new DataGridNoActiveCellColumn();
				aTextColumn->get_TextBox()->Enabled = false;
				aTextColumn->MappingName = this->ds->Tables->Item[S"本期汇总帐簿"]->Columns->Item[i]->ColumnName;
				aTextColumn->HeaderText = this->ds->Tables->Item[S"本期汇总帐簿"]->Columns->Item[i]->ColumnName;
				aTextColumn->NullText = S"";
				aTextColumn->Format = S"D";
				ts->GridColumnStyles->Add(aTextColumn);
			}
			this->dgrdLedger->TableStyles->Add(ts);
		}
private: System::Void btnSearch_Click(System::Object *  sender, System::EventArgs *  e)
		{
			this->ds->Tables->Item[S"本期汇总帐簿"]->Clear();
			this->strSQL = String::Format(S"SELECT 科目表.科目名称,本期汇总帐簿.* FROM  本期汇总帐簿,科目表 WHERE 本期汇总帐簿.科目代码 = 科目表.科目代码 AND 本期汇总帐簿.科目代码 LIKE '{0}'",this->tBoxWarrentCode->Text);
			this->MyDataBase->SelectDataBase(this->WarrentAdapter,this->ds,this->strSQL,S"本期汇总帐簿");
		}
private: System::Void chkIsShowCash_CheckedChanged(System::Object *  sender, System::EventArgs *  e)
		{
			if(this->chkIsShowCash->Checked)
			{
				this->WarrentView->RowFilter = S"余额 <> 0";
			}
			else
			{
				this->WarrentView->RowFilter = "";
			}
		}

};
}

⌨️ 快捷键说明

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