📄 frmfieldassociate.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace DataC
{
/// <summary>
/// Summary description for frmFieldAssociate.
/// </summary>
public class frmFieldAssociate : System.Windows.Forms.Form
{
private
System.Collections.ArrayList _alSourceTable;
System.Collections.ArrayList _alTargetTable;
System.Collections.ArrayList _alSourceFieldList;
System.Collections.ArrayList _alTargetFieldList;
System.Collections.Hashtable _htTargetFieldAndType;
System.Collections.Hashtable _htSourceFieldAndType;
System.Collections.ArrayList _alFieldAssociate;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.GroupBox groupBox3;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Button btAddAsso;
private System.Windows.Forms.ComboBox cbTargetTable;
private System.Windows.Forms.ComboBox cbSourceTable;
private System.Windows.Forms.ComboBox cbTargetField;
private System.Windows.Forms.ComboBox cbSourceField;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.ListView lv;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public frmFieldAssociate()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
_alSourceTable=new ArrayList();
_alTargetTable=new ArrayList();
_alSourceFieldList=new ArrayList();
_alTargetFieldList=new ArrayList();
_alFieldAssociate=new ArrayList();
_htTargetFieldAndType=new Hashtable();
_htSourceFieldAndType=new Hashtable();
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.lv = new System.Windows.Forms.ListView();
this.button1 = new System.Windows.Forms.Button();
this.btAddAsso = new System.Windows.Forms.Button();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.label3 = new System.Windows.Forms.Label();
this.cbSourceField = new System.Windows.Forms.ComboBox();
this.label1 = new System.Windows.Forms.Label();
this.cbSourceTable = new System.Windows.Forms.ComboBox();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.label4 = new System.Windows.Forms.Label();
this.cbTargetField = new System.Windows.Forms.ComboBox();
this.label2 = new System.Windows.Forms.Label();
this.cbTargetTable = new System.Windows.Forms.ComboBox();
this.groupBox1.SuspendLayout();
this.groupBox3.SuspendLayout();
this.groupBox2.SuspendLayout();
this.SuspendLayout();
//
// groupBox1
//
this.groupBox1.Controls.Add(this.lv);
this.groupBox1.Controls.Add(this.button1);
this.groupBox1.Controls.Add(this.btAddAsso);
this.groupBox1.Controls.Add(this.groupBox3);
this.groupBox1.Controls.Add(this.groupBox2);
this.groupBox1.Location = new System.Drawing.Point(1, -4);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(488, 308);
this.groupBox1.TabIndex = 0;
this.groupBox1.TabStop = false;
this.groupBox1.Enter += new System.EventHandler(this.groupBox1_Enter);
//
// lv
//
this.lv.Location = new System.Drawing.Point(8, 112);
this.lv.Name = "lv";
this.lv.Size = new System.Drawing.Size(472, 160);
this.lv.TabIndex = 7;
//
// button1
//
this.button1.Location = new System.Drawing.Point(200, 280);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 24);
this.button1.TabIndex = 6;
this.button1.Text = "开始转换";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// btAddAsso
//
this.btAddAsso.Location = new System.Drawing.Point(208, 76);
this.btAddAsso.Name = "btAddAsso";
this.btAddAsso.Size = new System.Drawing.Size(64, 32);
this.btAddAsso.TabIndex = 5;
this.btAddAsso.Text = "添加";
this.btAddAsso.Click += new System.EventHandler(this.btAddAsso_Click);
//
// groupBox3
//
this.groupBox3.Controls.Add(this.label3);
this.groupBox3.Controls.Add(this.cbSourceField);
this.groupBox3.Controls.Add(this.label1);
this.groupBox3.Controls.Add(this.cbSourceTable);
this.groupBox3.Location = new System.Drawing.Point(273, 9);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(207, 100);
this.groupBox3.TabIndex = 3;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "源表";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(8, 56);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(42, 17);
this.label3.TabIndex = 5;
this.label3.Text = "字段名";
//
// cbSourceField
//
this.cbSourceField.Location = new System.Drawing.Point(56, 56);
this.cbSourceField.Name = "cbSourceField";
this.cbSourceField.Size = new System.Drawing.Size(121, 20);
this.cbSourceField.TabIndex = 4;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(16, 24);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(29, 17);
this.label1.TabIndex = 3;
this.label1.Text = "表名";
//
// cbSourceTable
//
this.cbSourceTable.Location = new System.Drawing.Point(56, 24);
this.cbSourceTable.Name = "cbSourceTable";
this.cbSourceTable.Size = new System.Drawing.Size(121, 20);
this.cbSourceTable.TabIndex = 2;
//
// groupBox2
//
this.groupBox2.Controls.Add(this.label4);
this.groupBox2.Controls.Add(this.cbTargetField);
this.groupBox2.Controls.Add(this.label2);
this.groupBox2.Controls.Add(this.cbTargetTable);
this.groupBox2.Location = new System.Drawing.Point(8, 9);
this.groupBox2.Name = "groupBox2";
this.groupBox2.TabIndex = 2;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "目标表";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(8, 56);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(42, 17);
this.label4.TabIndex = 6;
this.label4.Text = "字段名";
//
// cbTargetField
//
this.cbTargetField.Location = new System.Drawing.Point(64, 56);
this.cbTargetField.Name = "cbTargetField";
this.cbTargetField.Size = new System.Drawing.Size(121, 20);
this.cbTargetField.TabIndex = 3;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(16, 24);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(29, 17);
this.label2.TabIndex = 2;
this.label2.Text = "表名";
//
// cbTargetTable
//
this.cbTargetTable.Location = new System.Drawing.Point(64, 24);
this.cbTargetTable.Name = "cbTargetTable";
this.cbTargetTable.Size = new System.Drawing.Size(121, 20);
this.cbTargetTable.TabIndex = 1;
//
// frmFieldAssociate
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(490, 304);
this.ControlBox = false;
this.Controls.Add(this.groupBox1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.Name = "frmFieldAssociate";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "设置表间关联";
this.Load += new System.EventHandler(this.frmFieldAssociate_Load);
this.groupBox1.ResumeLayout(false);
this.groupBox3.ResumeLayout(false);
this.groupBox2.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
public System.Collections.ArrayList SourceTable
{
get { return _alSourceTable;}
set { _alSourceTable = value;}
}
public System.Collections.ArrayList TargetTable
{
get { return _alTargetTable;}
set { _alTargetTable = value;}
}
public System.Collections.ArrayList SourceFieldList
{
get { return _alSourceFieldList;}
set { _alSourceFieldList=value;}
}
public System.Collections.ArrayList TargetFieldList
{
get { return _alTargetFieldList;}
set { _alTargetFieldList=value;}
}
public System.Collections.ArrayList FieldAssociate
{
get
{
for(int i=0;i<lv.Items.Count;i++)
{
TFieldAssociate temp=new TFieldAssociate();
temp=(TFieldAssociate)lv.Items[i].Tag;
_alFieldAssociate.Add(temp);
}
return _alFieldAssociate;
}
}
public System.Collections.Hashtable SourceFieldAndType
{
get { return _htSourceFieldAndType;}
set { _htSourceFieldAndType=value;}
}
public System.Collections.Hashtable TargetFieldAndType
{
get { return _htTargetFieldAndType;}
set { _htTargetFieldAndType=value;}
}
private void button1_Click(object sender, System.EventArgs e)
{
this.Close();
}
private void btAddAsso_Click(object sender, System.EventArgs e)
{
ListViewItem temp=new ListViewItem();
TFieldAssociate tf=new TFieldAssociate();
tf.m_strTargetField=cbTargetTable.Text+"."+cbTargetField.Text;
tf.m_strTargetFieldType=this.TargetFieldAndType[cbTargetField.Text].ToString();
tf.m_strSourceField=cbSourceTable.Text+"."+cbSourceField.Text;
tf.m_strSourceFieldType=this.SourceFieldAndType[cbSourceField.Text].ToString();
temp.Text=cbTargetTable.Text+"."+cbTargetField.Text;
temp.SubItems.Add(this.TargetFieldAndType[cbTargetField.Text].ToString());
temp.SubItems.Add(cbSourceTable.Text+"."+cbSourceField.Text);
temp.SubItems.Add(this.SourceFieldAndType[cbSourceField.Text].ToString());
temp.Tag=tf;
lv.Items.Add(temp);
}
private void frmFieldAssociate_Load(object sender, System.EventArgs e)
{
ColumnHeader a=new ColumnHeader();
a.Text="目标表字段";
a.Width=120;
ColumnHeader b=new ColumnHeader();
b.Text="目标表字段类型";
b.Width=120;
ColumnHeader c=new ColumnHeader();
c.Text="源表字段";
c.Width=120;
ColumnHeader d=new ColumnHeader();
d.Text="源表字段类型";
d.Width=120;
lv.Columns.Add(a);
lv.Columns.Add(b);
lv.Columns.Add(c);
lv.Columns.Add(d);
lv.View=View.Details;
for(int i=0;i<this.TargetTable.Count;i++)
{
cbTargetTable.Items.Add(this.TargetTable[i].ToString());
}
cbTargetTable.Text=cbTargetTable.Items[0].ToString();
for(int i=0;i<this.SourceTable.Count;i++)
{
cbSourceTable.Items.Add(this.SourceTable[i].ToString());
}
cbSourceTable.Text=cbSourceTable.Items[0].ToString();
for(int i=0;i<this.TargetFieldList.Count;i++)
{
cbTargetField.Items.Add(this.TargetFieldList[i].ToString());
}
cbTargetField.Text=cbTargetField.Items[0].ToString();
for(int i=0;i<this.SourceFieldList.Count;i++)
{
cbSourceField.Items.Add(this.SourceFieldList[i].ToString());
}
cbSourceField.Text=cbSourceField.Items[0].ToString();
}
private void groupBox1_Enter(object sender, System.EventArgs e)
{
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -