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

📄 getorginfo.h

📁 Visual C++.net数据库开发经典案例
💻 H
字号:
#pragma once
#include "LinkDataBase.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> 
	/// GetOrgInfo 摘要
	///
	/// 警告: 如果您更改该类的名称,则将需要更改 
	///          与该类所依赖的所有 .resx 文件关联的托管资源编译器工具的 
	///          “资源文件名”属性。  否则,
	///          设计器将不能与此窗体关联的
	///          本地化资源正确交互。
	/// </summary>
	public __gc class GetOrgInfo : public System::Windows::Forms::Form
	{
	//--------------------成员声明------------------------
	private:
		LinkDataBase* MyDataBase;	//数据库连接类
		DataSet* ds;		
		String* strTableName;
	private: System::Windows::Forms::DataGrid *  dgrdOrgDetail;
	protected: System::Windows::Forms::ImageList *  imageList1;
			   String* strSQL;
	//-------------------成员声明结束-----------------------
	public: 
		GetOrgInfo(void)
		{
			InitializeComponent();
			this->MyDataBase = new LinkDataBase();
			this->strSQL = S"SELECT 单位名称, 拼音编码, 单位地址, 单位电话号码, 开户银行, 帐号, 开户全称, 单位编号 FROM 组织机构编码表";
			this->strTableName = S"机构详细信息";
			this->ds = this->MyDataBase->SelectDataBase(this->strSQL,this->strTableName);
			this->dgrdOrgDetail->DataSource = this->ds->Tables->Item[S"机构详细信息"];
			this->DataGridStateControl();
		}
        
	protected: 
		void Dispose(Boolean disposing)
		{
			if (disposing && components)
			{
				components->Dispose();
			}
			__super::Dispose(disposing);
		}
	private: System::Windows::Forms::ToolBar *  toolBar1;

	private: System::Windows::Forms::ToolBarButton *  tBtnSave;
	private: System::Windows::Forms::ToolBarButton *  tBtnQuit;
	private: System::ComponentModel::IContainer *  components;







	private:
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>


		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		void InitializeComponent(void)
		{
			this->components = new System::ComponentModel::Container();
			System::Resources::ResourceManager *  resources = new System::Resources::ResourceManager(__typeof(My::GetOrgInfo));
			this->toolBar1 = new System::Windows::Forms::ToolBar();
			this->tBtnSave = new System::Windows::Forms::ToolBarButton();
			this->tBtnQuit = new System::Windows::Forms::ToolBarButton();
			this->dgrdOrgDetail = new System::Windows::Forms::DataGrid();
			this->imageList1 = new System::Windows::Forms::ImageList(this->components);
			(__try_cast<System::ComponentModel::ISupportInitialize *  >(this->dgrdOrgDetail))->BeginInit();
			this->SuspendLayout();
			// 
			// toolBar1
			// 
			System::Windows::Forms::ToolBarButton* __mcTemp__1[] = new System::Windows::Forms::ToolBarButton*[2];
			__mcTemp__1[0] = this->tBtnSave;
			__mcTemp__1[1] = this->tBtnQuit;
			this->toolBar1->Buttons->AddRange(__mcTemp__1);
			this->toolBar1->DropDownArrows = true;
			this->toolBar1->ImageList = this->imageList1;
			this->toolBar1->Location = System::Drawing::Point(0, 0);
			this->toolBar1->Name = S"toolBar1";
			this->toolBar1->ShowToolTips = true;
			this->toolBar1->Size = System::Drawing::Size(576, 41);
			this->toolBar1->TabIndex = 0;
			this->toolBar1->ButtonClick += new System::Windows::Forms::ToolBarButtonClickEventHandler(this, toolBar1_ButtonClick);
			// 
			// tBtnSave
			// 
			this->tBtnSave->ImageIndex = 0;
			this->tBtnSave->Text = S"保存";
			this->tBtnSave->ToolTipText = S"保存";
			// 
			// tBtnQuit
			// 
			this->tBtnQuit->ImageIndex = 11;
			this->tBtnQuit->Text = S"退出";
			this->tBtnQuit->ToolTipText = S"退出";
			// 
			// dgrdOrgDetail
			// 
			this->dgrdOrgDetail->DataMember = S"";
			this->dgrdOrgDetail->Dock = System::Windows::Forms::DockStyle::Fill;
			this->dgrdOrgDetail->HeaderForeColor = System::Drawing::SystemColors::ControlText;
			this->dgrdOrgDetail->Location = System::Drawing::Point(0, 41);
			this->dgrdOrgDetail->Name = S"dgrdOrgDetail";
			this->dgrdOrgDetail->Size = System::Drawing::Size(576, 301);
			this->dgrdOrgDetail->TabIndex = 1;
			// 
			// imageList1
			// 
			this->imageList1->ImageSize = System::Drawing::Size(16, 16);
			this->imageList1->ImageStream = (__try_cast<System::Windows::Forms::ImageListStreamer *  >(resources->GetObject(S"imageList1.ImageStream")));
			this->imageList1->TransparentColor = System::Drawing::Color::Transparent;
			// 
			// GetOrgInfo
			// 
			this->AutoScaleBaseSize = System::Drawing::Size(6, 14);
			this->ClientSize = System::Drawing::Size(576, 342);
			this->Controls->Add(this->dgrdOrgDetail);
			this->Controls->Add(this->toolBar1);
			this->Name = S"GetOrgInfo";
			this->Text = S"机构详细信息";
			(__try_cast<System::ComponentModel::ISupportInitialize *  >(this->dgrdOrgDetail))->EndInit();
			this->ResumeLayout(false);

		}		
		//------------------设置表格样式----------------------
		void DataGridStateControl()
		{
			DataGridTableStyle* ts = new DataGridTableStyle();
			DataGridTextBoxColumn* 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 DataGridTextBoxColumn();
				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->dgrdOrgDetail->TableStyles->Add(ts);
			this->dgrdOrgDetail->Select(0);
		}
	private: System::Void toolBar1_ButtonClick(System::Object *  sender, System::Windows::Forms::ToolBarButtonClickEventArgs *  e)
			 {
				 if(String::Compare(e->Button->ToolTipText,S"保存") == 0)
				 {
					 this->MyDataBase->UpdateDataBase(this->ds,this->strTableName);
				 }
				 else
				 {
					 this->Close();
				 }
			 }

	};
}

⌨️ 快捷键说明

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