📄 setorginfo.h
字号:
#pragma once
#include "LinkDataBase.h"
#include "DataGridComboboxColumn.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>
/// SetOrgInfo 摘要
///
/// 警告: 如果您更改该类的名称,则将需要更改
/// 与该类所依赖的所有 .resx 文件关联的托管资源编译器工具的
/// “资源文件名”属性。 否则,
/// 设计器将不能与此窗体关联的
/// 本地化资源正确交互。
/// </summary>
public __gc class SetOrgInfo : public System::Windows::Forms::Form
{
//--------------------成员声明------------------------
private:
LinkDataBase* MyDataBase; //数据库连接类
DataSet* ds;
String* strTableName;
String* strSQL;
private: System::Windows::Forms::TreeView * tvOrgTree;
private: System::Windows::Forms::GroupBox * groupBox1;
private: System::Windows::Forms::Label * label2;
private: System::Windows::Forms::Label * label1;
private: System::Windows::Forms::Button * btnDelete;
private: System::Windows::Forms::Button * btnNewChildClass;
private: System::Windows::Forms::Button * btnNewThisClass;
private: System::Windows::Forms::Button * btnNewFirstClass;
private: System::Windows::Forms::Button * btnModify;
private: System::Windows::Forms::Button * btnQuit;
private: System::Windows::Forms::TextBox * tBoxComCode;
private: System::Windows::Forms::TextBox * tBoxCode;
private: System::Windows::Forms::TextBox * tBoxName;
private: System::Windows::Forms::Label * label3;
DataTable* tblSetOrgInfo;
//-------------------成员声明结束-----------------------
public:
SetOrgInfo(void)
{
InitializeComponent();
this->MyDataBase = new LinkDataBase();
this->strSQL = S"SELECT 组织机构编码表.* FROM 组织机构编码表 ORDER BY AbsIndex";
this->strTableName = S"组织机构编码表";
this->ds = this->MyDataBase->SelectDataBase(this->strSQL,this->strTableName);
//this->ds->Tables->Item[S"组织机构编码表"] = this->ds->Tables->Item[S"组织机构编码表"];
//如果数据库中没有记录,则只能添加第一级机构
if(this->ds->Tables->Item[S"组织机构编码表"]->Rows->Count <= 0)
{
this->btnDelete->Enabled = false;
this->btnModify->Enabled = false;
this->btnNewChildClass->Enabled = false;
this->btnNewThisClass->Enabled = false;
}
}
protected:
void Dispose(Boolean disposing)
{
if (disposing && components)
{
components->Dispose();
}
__super::Dispose(disposing);
}
private:
/// <summary>
/// 必需的设计器变量。
/// </summary>
System::ComponentModel::Container* components;
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
void InitializeComponent(void)
{
this->tvOrgTree = new System::Windows::Forms::TreeView();
this->groupBox1 = new System::Windows::Forms::GroupBox();
this->label2 = new System::Windows::Forms::Label();
this->label1 = new System::Windows::Forms::Label();
this->btnDelete = new System::Windows::Forms::Button();
this->btnNewChildClass = new System::Windows::Forms::Button();
this->btnNewThisClass = new System::Windows::Forms::Button();
this->btnNewFirstClass = new System::Windows::Forms::Button();
this->btnModify = new System::Windows::Forms::Button();
this->btnQuit = new System::Windows::Forms::Button();
this->tBoxComCode = new System::Windows::Forms::TextBox();
this->tBoxCode = new System::Windows::Forms::TextBox();
this->tBoxName = new System::Windows::Forms::TextBox();
this->label3 = new System::Windows::Forms::Label();
this->groupBox1->SuspendLayout();
this->SuspendLayout();
//
// tvOrgTree
//
this->tvOrgTree->Dock = System::Windows::Forms::DockStyle::Fill;
this->tvOrgTree->ImageIndex = -1;
this->tvOrgTree->Location = System::Drawing::Point(0, 0);
this->tvOrgTree->Name = S"tvOrgTree";
this->tvOrgTree->SelectedImageIndex = -1;
this->tvOrgTree->Size = System::Drawing::Size(616, 373);
this->tvOrgTree->TabIndex = 0;
this->tvOrgTree->AfterSelect += new System::Windows::Forms::TreeViewEventHandler(this, tvOrgTree_AfterSelect);
//
// groupBox1
//
this->groupBox1->Controls->Add(this->label2);
this->groupBox1->Controls->Add(this->label1);
this->groupBox1->Controls->Add(this->btnDelete);
this->groupBox1->Controls->Add(this->btnNewChildClass);
this->groupBox1->Controls->Add(this->btnNewThisClass);
this->groupBox1->Controls->Add(this->btnNewFirstClass);
this->groupBox1->Controls->Add(this->btnModify);
this->groupBox1->Controls->Add(this->btnQuit);
this->groupBox1->Controls->Add(this->tBoxComCode);
this->groupBox1->Controls->Add(this->tBoxCode);
this->groupBox1->Controls->Add(this->tBoxName);
this->groupBox1->Controls->Add(this->label3);
this->groupBox1->Dock = System::Windows::Forms::DockStyle::Right;
this->groupBox1->Location = System::Drawing::Point(200, 0);
this->groupBox1->Name = S"groupBox1";
this->groupBox1->Size = System::Drawing::Size(416, 373);
this->groupBox1->TabIndex = 1;
this->groupBox1->TabStop = false;
//
// label2
//
this->label2->Location = System::Drawing::Point(28, 150);
this->label2->Name = S"label2";
this->label2->Size = System::Drawing::Size(112, 16);
this->label2->TabIndex = 23;
this->label2->Text = S"本级别编码";
//
// label1
//
this->label1->Location = System::Drawing::Point(28, 78);
this->label1->Name = S"label1";
this->label1->Size = System::Drawing::Size(112, 16);
this->label1->TabIndex = 21;
this->label1->Text = S"机构名称";
//
// btnDelete
//
this->btnDelete->Location = System::Drawing::Point(284, 278);
this->btnDelete->Name = S"btnDelete";
this->btnDelete->Size = System::Drawing::Size(104, 24);
this->btnDelete->TabIndex = 20;
this->btnDelete->Text = S"删除";
this->btnDelete->Click += new System::EventHandler(this, btnDelete_Click);
//
// btnNewChildClass
//
this->btnNewChildClass->Location = System::Drawing::Point(284, 238);
this->btnNewChildClass->Name = S"btnNewChildClass";
this->btnNewChildClass->Size = System::Drawing::Size(104, 24);
this->btnNewChildClass->TabIndex = 19;
this->btnNewChildClass->Text = S"增加为子级别";
this->btnNewChildClass->Click += new System::EventHandler(this, btnNewChildClass_Click);
//
// btnNewThisClass
//
this->btnNewThisClass->Location = System::Drawing::Point(284, 198);
this->btnNewThisClass->Name = S"btnNewThisClass";
this->btnNewThisClass->Size = System::Drawing::Size(104, 24);
this->btnNewThisClass->TabIndex = 18;
this->btnNewThisClass->Text = S"增加为本级别";
this->btnNewThisClass->Click += new System::EventHandler(this, btnNewThisClass_Click);
//
// btnNewFirstClass
//
this->btnNewFirstClass->Location = System::Drawing::Point(284, 158);
this->btnNewFirstClass->Name = S"btnNewFirstClass";
this->btnNewFirstClass->Size = System::Drawing::Size(104, 24);
this->btnNewFirstClass->TabIndex = 17;
this->btnNewFirstClass->Text = S"增加为第一级";
this->btnNewFirstClass->Click += new System::EventHandler(this, btnNewFirstClass_Click);
//
// btnModify
//
this->btnModify->Location = System::Drawing::Point(284, 118);
this->btnModify->Name = S"btnModify";
this->btnModify->Size = System::Drawing::Size(104, 24);
this->btnModify->TabIndex = 16;
this->btnModify->Text = S"修改机构名称";
this->btnModify->Click += new System::EventHandler(this, btnModify_Click);
//
// btnQuit
//
this->btnQuit->Location = System::Drawing::Point(284, 78);
this->btnQuit->Name = S"btnQuit";
this->btnQuit->Size = System::Drawing::Size(104, 24);
this->btnQuit->TabIndex = 15;
this->btnQuit->Text = S"退出";
this->btnQuit->Click += new System::EventHandler(this, btnQuit_Click);
//
// tBoxComCode
//
this->tBoxComCode->Location = System::Drawing::Point(28, 238);
this->tBoxComCode->Name = S"tBoxComCode";
this->tBoxComCode->Size = System::Drawing::Size(192, 21);
this->tBoxComCode->TabIndex = 14;
this->tBoxComCode->Text = S"";
//
// tBoxCode
//
this->tBoxCode->Location = System::Drawing::Point(28, 174);
this->tBoxCode->Name = S"tBoxCode";
this->tBoxCode->Size = System::Drawing::Size(192, 21);
this->tBoxCode->TabIndex = 13;
this->tBoxCode->Text = S"";
//
// tBoxName
//
this->tBoxName->Location = System::Drawing::Point(28, 102);
this->tBoxName->Name = S"tBoxName";
this->tBoxName->Size = System::Drawing::Size(192, 21);
this->tBoxName->TabIndex = 12;
this->tBoxName->Text = S"";
//
// label3
//
this->label3->Location = System::Drawing::Point(28, 214);
this->label3->Name = S"label3";
this->label3->Size = System::Drawing::Size(112, 16);
this->label3->TabIndex = 22;
this->label3->Text = S"机构合成编码";
//
// SetOrgInfo
//
this->AutoScaleBaseSize = System::Drawing::Size(6, 14);
this->ClientSize = System::Drawing::Size(616, 373);
this->Controls->Add(this->groupBox1);
this->Controls->Add(this->tvOrgTree);
this->Name = S"SetOrgInfo";
this->Text = S"机构设置及编码";
this->Load += new System::EventHandler(this, SetOrgInfo_Load);
this->groupBox1->ResumeLayout(false);
this->ResumeLayout(false);
}
private: System::Void SetOrgInfo_Load(System::Object * sender, System::EventArgs * e)
{
String* strEnterpriseName;
//将组织结构表另存为tempTable
DataTable* tempTable = this->ds->Tables->Item[S"组织机构编码表"]->Copy();
//新建一个数据视图
DataView* ViewSetOrgInfo = new DataView(tempTable);
ViewSetOrgInfo->RowFilter = S"ItemLevel = 0";
//将数据集中的所有记录逐个根据它们之间的关系添加到树形表中
int RowLength = ViewSetOrgInfo->Count;
if(RowLength <= 0)
return;
for(int i = 0;i < RowLength; i++)
{
strEnterpriseName = ViewSetOrgInfo->Item[i]->Item[S"单位名称"]->ToString()->Trim();
TreeNode* node = new TreeNode(strEnterpriseName);
this->tvOrgTree->Nodes->Add(node);
//添加子节点的下一级节点
PopulateTreeView(strEnterpriseName,node,ViewSetOrgInfo->Item[i]);
}
this->tvOrgTree->SelectedNode = this->tvOrgTree->Nodes->Item[0];
}
//---------------------递归输入所有节点的信息------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -