SetOrgInfo.cs
资源名称:VCSDB.rar [点击查看]
上传用户:hjieqiu
上传日期:2013-05-11
资源大小:16494k
文件大小:38k
源码类别:
企业管理
开发平台:
C#
- using System;
- using System.Drawing;
- using System.Collections;
- using System.ComponentModel;
- using System.Windows.Forms;
- using System.Data;
- namespace 人力资源管理系统
- {
- /// <summary>
- /// SetOrgInfo 的摘要说明。
- /// </summary>
- public class SetOrgInfo : System.Windows.Forms.Form
- {
- private DataTable tblSetOrgInfo = new DataTable();//储存读入的数据
- private string strTextBox3_Text = "";
- private System.Windows.Forms.TreeView treeView1;
- private System.Windows.Forms.GroupBox groupBox1;
- private System.Windows.Forms.TextBox textBox3;
- private System.Windows.Forms.TextBox textBox2;
- private System.Windows.Forms.TextBox textBox1;
- private System.Windows.Forms.Label label3;
- private System.Windows.Forms.Label label2;
- private System.Windows.Forms.Label label1;
- private System.Data.SqlClient.SqlDataAdapter sqlDataAdapter1;
- 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.Data.SqlClient.SqlCommand sqlSelectCommand1;
- private System.Data.SqlClient.SqlCommand sqlInsertCommand1;
- private System.Data.SqlClient.SqlCommand sqlUpdateCommand1;
- private System.Data.SqlClient.SqlCommand sqlDeleteCommand1;
- private System.Data.SqlClient.SqlConnection sqlConnection1;
- /// <summary>
- /// 必需的设计器变量。
- /// </summary>
- private System.ComponentModel.Container components = null;
- public SetOrgInfo()
- {
- //
- // Windows 窗体设计器支持所必需的
- //
- InitializeComponent();
- //
- // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
- //
- }
- /// <summary>
- /// 清理所有正在使用的资源。
- /// </summary>
- protected override void Dispose( bool disposing )
- {
- if( disposing )
- {
- if(components != null)
- {
- components.Dispose();
- }
- }
- base.Dispose( disposing );
- }
- #region Windows 窗体设计器生成的代码
- /// <summary>
- /// 设计器支持所需的方法 - 不要使用代码编辑器修改
- /// 此方法的内容。
- /// </summary>
- private void InitializeComponent()
- {
- System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(SetOrgInfo));
- this.treeView1 = new System.Windows.Forms.TreeView();
- this.groupBox1 = new System.Windows.Forms.GroupBox();
- this.textBox3 = new System.Windows.Forms.TextBox();
- this.textBox2 = new System.Windows.Forms.TextBox();
- this.textBox1 = new System.Windows.Forms.TextBox();
- this.label3 = new System.Windows.Forms.Label();
- this.label2 = new System.Windows.Forms.Label();
- this.label1 = new System.Windows.Forms.Label();
- this.btnQuit = 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.btnDelete = new System.Windows.Forms.Button();
- this.sqlDataAdapter1 = new System.Data.SqlClient.SqlDataAdapter();
- this.sqlDeleteCommand1 = new System.Data.SqlClient.SqlCommand();
- this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();
- this.sqlInsertCommand1 = new System.Data.SqlClient.SqlCommand();
- this.sqlSelectCommand1 = new System.Data.SqlClient.SqlCommand();
- this.sqlUpdateCommand1 = new System.Data.SqlClient.SqlCommand();
- this.groupBox1.SuspendLayout();
- this.SuspendLayout();
- //
- // treeView1
- //
- this.treeView1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
- | System.Windows.Forms.AnchorStyles.Left)));
- this.treeView1.ImageIndex = -1;
- this.treeView1.Location = new System.Drawing.Point(0, 3);
- this.treeView1.Name = "treeView1";
- this.treeView1.SelectedImageIndex = -1;
- this.treeView1.Size = new System.Drawing.Size(240, 413);
- this.treeView1.TabIndex = 9;
- this.treeView1.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeView1_AfterSelect);
- //
- // groupBox1
- //
- this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
- | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.groupBox1.Controls.Add(this.textBox3);
- this.groupBox1.Controls.Add(this.textBox2);
- this.groupBox1.Controls.Add(this.textBox1);
- this.groupBox1.Controls.Add(this.label3);
- this.groupBox1.Controls.Add(this.label2);
- this.groupBox1.Controls.Add(this.label1);
- this.groupBox1.Controls.Add(this.btnQuit);
- 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.btnDelete);
- this.groupBox1.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
- this.groupBox1.Location = new System.Drawing.Point(248, -4);
- this.groupBox1.Name = "groupBox1";
- this.groupBox1.Size = new System.Drawing.Size(416, 420);
- this.groupBox1.TabIndex = 1;
- this.groupBox1.TabStop = false;
- //
- // textBox3
- //
- this.textBox3.Location = new System.Drawing.Point(56, 280);
- this.textBox3.Name = "textBox3";
- this.textBox3.ReadOnly = true;
- this.textBox3.Size = new System.Drawing.Size(176, 21);
- this.textBox3.TabIndex = 2;
- this.textBox3.Text = "";
- //
- // textBox2
- //
- this.textBox2.Location = new System.Drawing.Point(56, 200);
- this.textBox2.Name = "textBox2";
- this.textBox2.ReadOnly = true;
- this.textBox2.Size = new System.Drawing.Size(176, 21);
- this.textBox2.TabIndex = 1;
- this.textBox2.Text = "";
- //
- // textBox1
- //
- this.textBox1.Location = new System.Drawing.Point(56, 112);
- this.textBox1.Name = "textBox1";
- this.textBox1.Size = new System.Drawing.Size(176, 21);
- this.textBox1.TabIndex = 0;
- this.textBox1.Text = "";
- //
- // label3
- //
- this.label3.Location = new System.Drawing.Point(56, 240);
- this.label3.Name = "label3";
- this.label3.TabIndex = 14;
- this.label3.Text = "机构合成编码";
- //
- // label2
- //
- this.label2.Location = new System.Drawing.Point(56, 160);
- this.label2.Name = "label2";
- this.label2.TabIndex = 13;
- this.label2.Text = "本级别编码";
- //
- // label1
- //
- this.label1.Location = new System.Drawing.Point(56, 80);
- this.label1.Name = "label1";
- this.label1.TabIndex = 12;
- this.label1.Text = "机构名称";
- //
- // btnQuit
- //
- this.btnQuit.Location = new System.Drawing.Point(280, 80);
- this.btnQuit.Name = "btnQuit";
- this.btnQuit.Size = new System.Drawing.Size(112, 23);
- this.btnQuit.TabIndex = 15;
- this.btnQuit.Text = "退出";
- this.btnQuit.Click += new System.EventHandler(this.btnQuit_Click);
- //
- // btnNewChildClass
- //
- this.btnNewChildClass.Location = new System.Drawing.Point(280, 240);
- this.btnNewChildClass.Name = "btnNewChildClass";
- this.btnNewChildClass.Size = new System.Drawing.Size(112, 23);
- this.btnNewChildClass.TabIndex = 6;
- this.btnNewChildClass.Text = "增加为子级别(&C)";
- this.btnNewChildClass.Click += new System.EventHandler(this.btnNewChildClass_Click);
- //
- // btnNewThisClass
- //
- this.btnNewThisClass.Location = new System.Drawing.Point(280, 200);
- this.btnNewThisClass.Name = "btnNewThisClass";
- this.btnNewThisClass.Size = new System.Drawing.Size(112, 23);
- this.btnNewThisClass.TabIndex = 5;
- this.btnNewThisClass.Text = "增加为本级别(&A)";
- this.btnNewThisClass.Click += new System.EventHandler(this.btnNewThisClass_Click);
- //
- // btnNewFirstClass
- //
- this.btnNewFirstClass.Location = new System.Drawing.Point(280, 160);
- this.btnNewFirstClass.Name = "btnNewFirstClass";
- this.btnNewFirstClass.Size = new System.Drawing.Size(112, 23);
- this.btnNewFirstClass.TabIndex = 4;
- this.btnNewFirstClass.Text = "增加为第一级(&B)";
- this.btnNewFirstClass.Click += new System.EventHandler(this.btnNewFirstClass_Click);
- //
- // btnModify
- //
- this.btnModify.Location = new System.Drawing.Point(280, 120);
- this.btnModify.Name = "btnModify";
- this.btnModify.Size = new System.Drawing.Size(112, 23);
- this.btnModify.TabIndex = 3;
- this.btnModify.Text = "修改(&M)";
- this.btnModify.Click += new System.EventHandler(this.btnModify_Click);
- //
- // btnDelete
- //
- this.btnDelete.Location = new System.Drawing.Point(280, 280);
- this.btnDelete.Name = "btnDelete";
- this.btnDelete.Size = new System.Drawing.Size(112, 23);
- this.btnDelete.TabIndex = 8;
- this.btnDelete.Text = "删除(&D)";
- this.btnDelete.Click += new System.EventHandler(this.btnDelete_Click);
- //
- // sqlDataAdapter1
- //
- this.sqlDataAdapter1.DeleteCommand = this.sqlDeleteCommand1;
- this.sqlDataAdapter1.InsertCommand = this.sqlInsertCommand1;
- this.sqlDataAdapter1.SelectCommand = this.sqlSelectCommand1;
- this.sqlDataAdapter1.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
- new System.Data.Common.DataTableMapping("Table", "组织机构编码表", new System.Data.Common.DataColumnMapping[] {
- new System.Data.Common.DataColumnMapping("内部编号", "内部编号"),
- new System.Data.Common.DataColumnMapping("类别", "类别"),
- new System.Data.Common.DataColumnMapping("AbsIndex", "AbsIndex"),
- new System.Data.Common.DataColumnMapping("ItemIndex", "ItemIndex"),
- new System.Data.Common.DataColumnMapping("ItemLevel", "ItemLevel"),
- new System.Data.Common.DataColumnMapping("ParentIndex", "ParentIndex"),
- new System.Data.Common.DataColumnMapping("类别号", "类别号"),
- new System.Data.Common.DataColumnMapping("单位编号", "单位编号"),
- new System.Data.Common.DataColumnMapping("单位名称", "单位名称"),
- new System.Data.Common.DataColumnMapping("拼音编码", "拼音编码"),
- new System.Data.Common.DataColumnMapping("单位地址", "单位地址"),
- new System.Data.Common.DataColumnMapping("单位电话号码", "单位电话号码"),
- new System.Data.Common.DataColumnMapping("开户银行", "开户银行"),
- new System.Data.Common.DataColumnMapping("帐号", "帐号"),
- new System.Data.Common.DataColumnMapping("开户全称", "开户全称")})});
- this.sqlDataAdapter1.UpdateCommand = this.sqlUpdateCommand1;
- //
- // sqlDeleteCommand1
- //
- this.sqlDeleteCommand1.CommandText = @"DELETE FROM 组织机构编码表 WHERE (单位编号 = @Original_单位编号) AND (AbsIndex = @Original_AbsIndex OR @Original_AbsIndex IS NULL AND AbsIndex IS NULL) AND (ItemIndex = @Original_ItemIndex OR @Original_ItemIndex IS NULL AND ItemIndex IS NULL) AND (ItemLevel = @Original_ItemLevel OR @Original_ItemLevel IS NULL AND ItemLevel IS NULL) AND (ParentIndex = @Original_ParentIndex OR @Original_ParentIndex IS NULL AND ParentIndex IS NULL) AND (内部编号 = @Original_内部编号) AND (单位名称 = @Original_单位名称 OR @Original_单位名称 IS NULL AND 单位名称 IS NULL) AND (单位地址 = @Original_单位地址 OR @Original_单位地址 IS NULL AND 单位地址 IS NULL) AND (单位电话号码 = @Original_单位电话号码 OR @Original_单位电话号码 IS NULL AND 单位电话号码 IS NULL) AND (帐号 = @Original_帐号 OR @Original_帐号 IS NULL AND 帐号 IS NULL) AND (开户全称 = @Original_开户全称 OR @Original_开户全称 IS NULL AND 开户全称 IS NULL) AND (开户银行 = @Original_开户银行 OR @Original_开户银行 IS NULL AND 开户银行 IS NULL) AND (拼音编码 = @Original_拼音编码 OR @Original_拼音编码 IS NULL AND 拼音编码 IS NULL) AND (类别 = @Original_类别 OR @Original_类别 IS NULL AND 类别 IS NULL) AND (类别号 = @Original_类别号 OR @Original_类别号 IS NULL AND 类别号 IS NULL)";
- this.sqlDeleteCommand1.Connection = this.sqlConnection1;
- this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_单位编号", System.Data.SqlDbType.VarChar, 20, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "单位编号", System.Data.DataRowVersion.Original, null));
- this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_AbsIndex", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "AbsIndex", System.Data.DataRowVersion.Original, null));
- this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_ItemIndex", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "ItemIndex", System.Data.DataRowVersion.Original, null));
- this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_ItemLevel", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "ItemLevel", System.Data.DataRowVersion.Original, null));
- this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_ParentIndex", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "ParentIndex", System.Data.DataRowVersion.Original, null));
- this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_内部编号", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "内部编号", System.Data.DataRowVersion.Original, null));
- this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_单位名称", System.Data.SqlDbType.VarChar, 100, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "单位名称", System.Data.DataRowVersion.Original, null));
- this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_单位地址", System.Data.SqlDbType.VarChar, 100, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "单位地址", System.Data.DataRowVersion.Original, null));
- this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_单位电话号码", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "单位电话号码", System.Data.DataRowVersion.Original, null));
- this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_帐号", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "帐号", System.Data.DataRowVersion.Original, null));
- this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_开户全称", System.Data.SqlDbType.VarChar, 100, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "开户全称", System.Data.DataRowVersion.Original, null));
- this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_开户银行", System.Data.SqlDbType.VarChar, 100, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "开户银行", System.Data.DataRowVersion.Original, null));
- this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_拼音编码", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "拼音编码", System.Data.DataRowVersion.Original, null));
- this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_类别", System.Data.SqlDbType.VarChar, 100, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "类别", System.Data.DataRowVersion.Original, null));
- this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_类别号", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "类别号", System.Data.DataRowVersion.Original, null));
- //
- // sqlConnection1
- //
- this.sqlConnection1.ConnectionString = "workstation id=localhost;Integrated Security=SSPI;Database=hrmbook;";
- //
- // sqlInsertCommand1
- //
- this.sqlInsertCommand1.CommandText = @"INSERT INTO 组织机构编码表(类别, AbsIndex, ItemIndex, ItemLevel, ParentIndex, 类别号, 单位编号, 单位名称, 拼音编码, 单位地址, 单位电话号码, 开户银行, 帐号, 开户全称) VALUES (@类别, @AbsIndex, @ItemIndex, @ItemLevel, @ParentIndex, @类别号, @单位编号, @单位名称, @拼音编码, @单位地址, @单位电话号码, @开户银行, @帐号, @开户全称); SELECT 内部编号, 类别, AbsIndex, ItemIndex, ItemLevel, ParentIndex, 类别号, 单位编号, 单位名称, 拼音编码, 单位地址, 单位电话号码, 开户银行, 帐号, 开户全称 FROM 组织机构编码表 WHERE (单位编号 = @单位编号) ORDER BY AbsIndex";
- this.sqlInsertCommand1.Connection = this.sqlConnection1;
- this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@类别", System.Data.SqlDbType.VarChar, 100, "类别"));
- this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@AbsIndex", System.Data.SqlDbType.Int, 4, "AbsIndex"));
- this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@ItemIndex", System.Data.SqlDbType.Int, 4, "ItemIndex"));
- this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@ItemLevel", System.Data.SqlDbType.Int, 4, "ItemLevel"));
- this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@ParentIndex", System.Data.SqlDbType.Int, 4, "ParentIndex"));
- this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@类别号", System.Data.SqlDbType.VarChar, 10, "类别号"));
- this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@单位编号", System.Data.SqlDbType.VarChar, 20, "单位编号"));
- this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@单位名称", System.Data.SqlDbType.VarChar, 100, "单位名称"));
- this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@拼音编码", System.Data.SqlDbType.VarChar, 50, "拼音编码"));
- this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@单位地址", System.Data.SqlDbType.VarChar, 100, "单位地址"));
- this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@单位电话号码", System.Data.SqlDbType.VarChar, 50, "单位电话号码"));
- this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@开户银行", System.Data.SqlDbType.VarChar, 100, "开户银行"));
- this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@帐号", System.Data.SqlDbType.VarChar, 50, "帐号"));
- this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@开户全称", System.Data.SqlDbType.VarChar, 100, "开户全称"));
- //
- // sqlSelectCommand1
- //
- this.sqlSelectCommand1.CommandText = "SELECT 内部编号, 类别, AbsIndex, ItemIndex, ItemLevel, ParentIndex, 类别号, 单位编号, 单位名称, 拼音" +
- "编码, 单位地址, 单位电话号码, 开户银行, 帐号, 开户全称 FROM 组织机构编码表 ORDER BY AbsIndex";
- this.sqlSelectCommand1.Connection = this.sqlConnection1;
- //
- // sqlUpdateCommand1
- //
- this.sqlUpdateCommand1.CommandText = @"UPDATE 组织机构编码表 SET 类别 = @类别, AbsIndex = @AbsIndex, ItemIndex = @ItemIndex, ItemLevel = @ItemLevel, ParentIndex = @ParentIndex, 类别号 = @类别号, 单位编号 = @单位编号, 单位名称 = @单位名称, 拼音编码 = @拼音编码, 单位地址 = @单位地址, 单位电话号码 = @单位电话号码, 开户银行 = @开户银行, 帐号 = @帐号, 开户全称 = @开户全称 WHERE (单位编号 = @Original_单位编号) AND (AbsIndex = @Original_AbsIndex OR @Original_AbsIndex IS NULL AND AbsIndex IS NULL) AND (ItemIndex = @Original_ItemIndex OR @Original_ItemIndex IS NULL AND ItemIndex IS NULL) AND (ItemLevel = @Original_ItemLevel OR @Original_ItemLevel IS NULL AND ItemLevel IS NULL) AND (ParentIndex = @Original_ParentIndex OR @Original_ParentIndex IS NULL AND ParentIndex IS NULL) AND (单位名称 = @Original_单位名称 OR @Original_单位名称 IS NULL AND 单位名称 IS NULL) AND (单位地址 = @Original_单位地址 OR @Original_单位地址 IS NULL AND 单位地址 IS NULL) AND (单位电话号码 = @Original_单位电话号码 OR @Original_单位电话号码 IS NULL AND 单位电话号码 IS NULL) AND (帐号 = @Original_帐号 OR @Original_帐号 IS NULL AND 帐号 IS NULL) AND (开户全称 = @Original_开户全称 OR @Original_开户全称 IS NULL AND 开户全称 IS NULL) AND (开户银行 = @Original_开户银行 OR @Original_开户银行 IS NULL AND 开户银行 IS NULL) AND (拼音编码 = @Original_拼音编码 OR @Original_拼音编码 IS NULL AND 拼音编码 IS NULL) AND (类别 = @Original_类别 OR @Original_类别 IS NULL AND 类别 IS NULL) AND (类别号 = @Original_类别号 OR @Original_类别号 IS NULL AND 类别号 IS NULL); SELECT 内部编号, 类别, AbsIndex, ItemIndex, ItemLevel, ParentIndex, 类别号, 单位编号, 单位名称, 拼音编码, 单位地址, 单位电话号码, 开户银行, 帐号, 开户全称 FROM 组织机构编码表 WHERE (单位编号 = @单位编号) ORDER BY AbsIndex";
- this.sqlUpdateCommand1.Connection = this.sqlConnection1;
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@类别", System.Data.SqlDbType.VarChar, 100, "类别"));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@AbsIndex", System.Data.SqlDbType.Int, 4, "AbsIndex"));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@ItemIndex", System.Data.SqlDbType.Int, 4, "ItemIndex"));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@ItemLevel", System.Data.SqlDbType.Int, 4, "ItemLevel"));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@ParentIndex", System.Data.SqlDbType.Int, 4, "ParentIndex"));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@类别号", System.Data.SqlDbType.VarChar, 10, "类别号"));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@单位编号", System.Data.SqlDbType.VarChar, 20, "单位编号"));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@单位名称", System.Data.SqlDbType.VarChar, 100, "单位名称"));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@拼音编码", System.Data.SqlDbType.VarChar, 50, "拼音编码"));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@单位地址", System.Data.SqlDbType.VarChar, 100, "单位地址"));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@单位电话号码", System.Data.SqlDbType.VarChar, 50, "单位电话号码"));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@开户银行", System.Data.SqlDbType.VarChar, 100, "开户银行"));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@帐号", System.Data.SqlDbType.VarChar, 50, "帐号"));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@开户全称", System.Data.SqlDbType.VarChar, 100, "开户全称"));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_单位编号", System.Data.SqlDbType.VarChar, 20, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "单位编号", System.Data.DataRowVersion.Original, null));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_AbsIndex", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "AbsIndex", System.Data.DataRowVersion.Original, null));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_ItemIndex", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "ItemIndex", System.Data.DataRowVersion.Original, null));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_ItemLevel", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "ItemLevel", System.Data.DataRowVersion.Original, null));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_ParentIndex", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "ParentIndex", System.Data.DataRowVersion.Original, null));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_单位名称", System.Data.SqlDbType.VarChar, 100, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "单位名称", System.Data.DataRowVersion.Original, null));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_单位地址", System.Data.SqlDbType.VarChar, 100, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "单位地址", System.Data.DataRowVersion.Original, null));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_单位电话号码", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "单位电话号码", System.Data.DataRowVersion.Original, null));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_帐号", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "帐号", System.Data.DataRowVersion.Original, null));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_开户全称", System.Data.SqlDbType.VarChar, 100, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "开户全称", System.Data.DataRowVersion.Original, null));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_开户银行", System.Data.SqlDbType.VarChar, 100, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "开户银行", System.Data.DataRowVersion.Original, null));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_拼音编码", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "拼音编码", System.Data.DataRowVersion.Original, null));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_类别", System.Data.SqlDbType.VarChar, 100, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "类别", System.Data.DataRowVersion.Original, null));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_类别号", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "类别号", System.Data.DataRowVersion.Original, null));
- //
- // SetOrgInfo
- //
- this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
- this.ClientSize = new System.Drawing.Size(672, 421);
- this.Controls.Add(this.groupBox1);
- this.Controls.Add(this.treeView1);
- this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
- this.Name = "SetOrgInfo";
- this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
- this.Text = "【机构设置及编码】";
- this.Load += new System.EventHandler(this.SetOrgInfo_Load);
- this.groupBox1.ResumeLayout(false);
- this.ResumeLayout(false);
- }
- #endregion
- ///
- //-------------在窗体初始化时,根据数据库中的记录创建树形图----------------
- private void SetOrgInfo_Load(object sender, System.EventArgs e)
- {
- this.sqlDataAdapter1.Fill(tblSetOrgInfo);//读入数据
- DataTable tempDataTable = tblSetOrgInfo.Copy();//将组织机构表另存一份为tempDataTable
- DataView viewSetOrgInfo = new DataView(tempDataTable);//新建一个数据视图
- viewSetOrgInfo.RowFilter = "ItemLevel = 0";
- //将数据集中的所有记录逐个根据他们之间的关系添加到树形表中去
- if (viewSetOrgInfo.Count > 0)
- {
- foreach (DataRowView myRow in viewSetOrgInfo)
- {
- string strEnterpriseName = myRow["单位名称"].ToString().Trim();
- //此处是添加第一个节点“省医药集团”
- this.treeView1.Nodes.Add(new TreeNode(strEnterpriseName));
- //此处初始化参数是第一个节点“省医药集团”,然后该函数会递归添加所有子节点
- PopulateTreeView(strEnterpriseName,treeView1.Nodes[0],myRow);
- treeView1.SelectedNode = treeView1.Nodes[0]; //选中第一个节点
- }
- }
- }
- //---------------根据输入的节点信息,递归调用最终添加所有的节点-----------------------
- private void PopulateTreeView(string parentPart,TreeNode parentNode,DataRowView parentRow)
- {
- string strEnterpriseName = "";
- DataTable tempDataTable = tblSetOrgInfo.Copy();
- DataView viewSetOrgInfo = new DataView(tempDataTable);
- //筛选获得当前传递过来的节点的子项,并将其添加到树形图中
- //判断方法是凡parentIndex等于传递过来的节点的absIndex的,就是该节点的子项
- viewSetOrgInfo.RowFilter = "ParentIndex = '" + parentRow["AbsIndex"].ToString().Trim() + "'";
- //递归的添加每一个节点的所有子节点
- foreach (DataRowView myRow in viewSetOrgInfo)
- {
- strEnterpriseName = myRow["单位名称"].ToString().Trim();
- TreeNode myNode = new TreeNode(strEnterpriseName);
- parentNode.Nodes.Add(myNode);
- //函数递归调用,将所有节点按顺序添加完毕
- PopulateTreeView(strEnterpriseName,myNode,myRow);
- }
- }
- //-----------当选中某一个节点时,在右边的文本框中显示其详细信息-------------------
- private void treeView1_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e)
- {
- this.textBox1.Text = e.Node.Text.Trim();
- InputTextBox2AndTextBox3(e.Node); //填写TextBox2和TextBox3
- }
- //-----------根据父节点和节点所处的位置,计算合成编码,编码算法见章节中叙述-------------------
- private void CalParentNodesCount(TreeNode myNode)
- {
- if (myNode == null)
- {
- return;
- }
- if (myNode.Index>=10 || myNode.Parent == null)
- strTextBox3_Text = myNode.Index.ToString().Trim() + strTextBox3_Text;
- else
- strTextBox3_Text = "0" + myNode.Index.ToString().Trim() + strTextBox3_Text;
- if (myNode.Parent != null)
- {
- CalParentNodesCount(myNode.Parent);
- }
- }
- //-----------------根据节点位置,显示本级别编码和机构合成编码信息---------------------
- private void InputTextBox2AndTextBox3(TreeNode myNode)
- {
- if (myNode.Index>=10 || myNode.Parent == null) //第二个条件是使根节点的编码为0
- this.textBox2.Text = myNode.Index.ToString();
- else
- this.textBox2.Text = "0" + myNode.Index.ToString();
- strTextBox3_Text = "";
- CalParentNodesCount(myNode);//计算机构合成编码信息
- this.textBox3.Text = strTextBox3_Text;
- }
- //---------------------退出窗体--------------------------------
- private void btnQuit_Click(object sender, System.EventArgs e)
- {
- this.Close();
- }
- //----------------------修改机构名称--------------------------------
- private void btnModify_Click(object sender, System.EventArgs e)
- {
- string strNewEnterpriseName = this.textBox1.Text.Trim();
- this.treeView1.SelectedNode.Text = strNewEnterpriseName;
- string strFilter = "单位编号 = '" + this.textBox3.Text.Trim() + "'";
- //通过单位编号在数据集中查找到数据项,并修改其名称和类别
- try
- {
- DataRow[] myRow = this.tblSetOrgInfo.Select(strFilter);
- if (myRow.Length ==1)
- {
- myRow[0]["类别"] = strNewEnterpriseName;
- myRow[0]["单位名称"] = strNewEnterpriseName;
- }
- }
- catch(Exception express)
- {
- MessageBox.Show(express.ToString(),"提示",MessageBoxButtons.OK,MessageBoxIcon.Error);
- }
- SaveModify();//向数据库中提交修改,并保存
- }
- //-----------------将某个项目增加为第一级项目--------------------------
- private void btnNewFirstClass_Click(object sender, System.EventArgs e)
- {
- string strNewEnterpriseName = this.textBox1.Text.Trim();
- TreeNode newNode = new TreeNode(strNewEnterpriseName);
- this.treeView1.Nodes.Add(newNode);//增加为第一级别
- this.treeView1.SelectedNode = newNode;
- InputTextBox2AndTextBox3(newNode); //填写TextBox2和TextBox3
- //为新插入的项计算各个数据,如ItemIndex,AbsIndex等
- int lastRowIndex = this.tblSetOrgInfo.Rows.Count-1;
- string strAbsIndex = this.tblSetOrgInfo.Rows[lastRowIndex]["AbsIndex"].ToString().Trim();
- int intAbsIndex = Int32.Parse(strAbsIndex) + 1;
- string strItemIndex = this.textBox2.Text.Trim();
- int intItemIndex = Int32.Parse(strItemIndex);
- string strEnterpriseID = this.textBox3.Text.Trim();
- int intItemLevel = 0;
- int intParentIndex = -1;
- try
- {
- DataRow newRow = this.tblSetOrgInfo.NewRow();
- newRow[1] = strNewEnterpriseName;
- newRow[2] = intAbsIndex;
- newRow[3] = intItemIndex;
- newRow[4] = intItemLevel;
- newRow[5] = intParentIndex;
- newRow[6] = strItemIndex;
- newRow[7] = strEnterpriseID;
- newRow[8] = strNewEnterpriseName;
- this.tblSetOrgInfo.Rows.Add(newRow);
- }
- catch(Exception express)
- {
- MessageBox.Show(express.ToString(),"提示",MessageBoxButtons.OK,MessageBoxIcon.Error);
- tblSetOrgInfo.RejectChanges();
- }
- SaveModify();//向数据库保存修改
- }
- //-----------添加同级项-------------------
- private void btnNewThisClass_Click(object sender, System.EventArgs e)
- {
- AddRecord(true);
- }
- //-----------添加子项-------------------
- private void btnNewChildClass_Click(object sender, System.EventArgs e)
- {
- AddRecord(false);
- }
- //-----------根据输入参数确定向树形图中添加同级项还是子项-------------------
- private void AddRecord(bool blAddInThisClass)
- {
- string strItemLevel = "";
- string strParentIndex = "";
- string strFilter = "单位编号 = '" + this.textBox3.Text.Trim() + "'";
- try
- {
- DataRow[] myRow = this.tblSetOrgInfo.Select(strFilter);//通过单位编号在数据集中查找到数据项
- if (myRow.Length == 1)
- {
- strItemLevel = myRow[0]["ItemLevel"].ToString().Trim();
- //向数据集中添加新项
- if (blAddInThisClass == true)
- strParentIndex = myRow[0]["ParentIndex"].ToString().Trim();
- else
- strParentIndex = myRow[0]["AbsIndex"].ToString().Trim();
- }
- }
- catch(Exception express)
- {
- MessageBox.Show(express.ToString(),"提示",MessageBoxButtons.OK,MessageBoxIcon.Error);
- }
- //向树形图中添加新项
- string strNewEnterpriseName = this.textBox1.Text.Trim();
- TreeNode newNode = new TreeNode(strNewEnterpriseName);
- if (blAddInThisClass == true)
- {
- if (this.treeView1.SelectedNode.Parent == null) //当为第一级添加子节点时
- this.treeView1.Nodes.Add(newNode);
- else
- this.treeView1.SelectedNode.Parent.Nodes.Add(newNode);
- }
- else
- this.treeView1.SelectedNode.Nodes.Add(newNode);
- this.treeView1.SelectedNode = newNode;
- InputTextBox2AndTextBox3(newNode); //填写TextBox2和TextBox3
- //为新插入的项计算各个数据,如ItemIndex,AbsIndex等
- int lastRowIndex = this.tblSetOrgInfo.Rows.Count-1;
- string strAbsIndex = this.tblSetOrgInfo.Rows[lastRowIndex]["AbsIndex"].ToString().Trim();
- int intAbsIndex = Int32.Parse(strAbsIndex) + 1;
- string strItemIndex = this.textBox2.Text.Trim();
- int intItemIndex = Int32.Parse(strItemIndex);
- string strEnterpriseID = this.textBox3.Text.Trim();
- int intItemLevel = 0;
- if (blAddInThisClass == true)
- intItemLevel = Int32.Parse(strItemLevel);
- else
- intItemLevel = Int32.Parse(strItemLevel) + 1;
- int intParentIndex = Int32.Parse(strParentIndex);
- try
- {
- DataRow newRow = this.tblSetOrgInfo.NewRow();
- newRow[1] = strNewEnterpriseName;
- newRow[2] = intAbsIndex;
- newRow[3] = intItemIndex;
- newRow[4] = intItemLevel;
- newRow[5] = intParentIndex;
- newRow[6] = strItemIndex;
- newRow[7] = strEnterpriseID;
- newRow[8] = strNewEnterpriseName;
- this.tblSetOrgInfo.Rows.Add(newRow);
- }
- catch(Exception express)
- {
- MessageBox.Show(express.ToString(),"提示",MessageBoxButtons.OK,MessageBoxIcon.Error);
- tblSetOrgInfo.RejectChanges();
- }
- //将更改保存入数据库
- SaveModify();
- }
- //-----------删除在树形图中选中的项目-------------------
- private void btnDelete_Click(object sender, System.EventArgs e)
- {
- string strEnterpriseID = this.textBox3.Text.Trim();
- string strFilter = "单位编号 = '" + strEnterpriseID + "'";
- try
- {
- DataRow[] myRow = this.tblSetOrgInfo.Select(strFilter);
- if (myRow.Length ==1)//找到该条记录,并从数据集中删除
- {
- string strFilter_ParentIndex = "ParentIndex = '" + myRow[0]["AbsIndex"].ToString().Trim() + "'";
- DataRow[] myChildRows = this.tblSetOrgInfo.Select(strFilter_ParentIndex);
- myRow[0].Delete();
- foreach (DataRow aRow in myChildRows)//如果该项目有子项,则将子项也一并全部删除
- {
- aRow.Delete();
- }
- }
- }
- catch(Exception express)
- {
- MessageBox.Show(express.ToString(),"提示",MessageBoxButtons.OK,MessageBoxIcon.Error);
- }
- this.treeView1.SelectedNode.Remove();
- SaveModify();//将更改保存入数据库
- }
- //-----------将数据集中的输入保存到数据库中-------------------
- private void SaveModify()
- {
- try
- {
- this.sqlDataAdapter1.Update(this.tblSetOrgInfo);
- }
- catch(Exception express)
- {
- MessageBox.Show(express.ToString(),"提示",MessageBoxButtons.OK,MessageBoxIcon.Error);
- tblSetOrgInfo.RejectChanges();
- }
- }
- }
- }