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

📄 frmmain.cs

📁 可将ACCESS数据库导入到Oracle数据库
💻 CS
📖 第 1 页 / 共 3 页
字号:
			this.lvMBZD.GridLines = true;
			this.lvMBZD.Location = new System.Drawing.Point(0, 0);
			this.lvMBZD.Name = "lvMBZD";
			this.lvMBZD.Size = new System.Drawing.Size(726, 480);
			this.lvMBZD.TabIndex = 9;
			this.lvMBZD.View = System.Windows.Forms.View.Details;
			this.lvMBZD.MouseDown += new System.Windows.Forms.MouseEventHandler(this.lvMBZD_MouseDown);
			this.lvMBZD.DragDrop += new System.Windows.Forms.DragEventHandler(this.lvMBZD_DragDrop);
			this.lvMBZD.DragEnter += new System.Windows.Forms.DragEventHandler(this.lvMBZD_DragEnter);
			this.lvMBZD.ColumnClick += new System.Windows.Forms.ColumnClickEventHandler(this.lvMBZD_ColumnClick);
			// 
			// splitter1
			// 
			this.splitter1.BackColor = System.Drawing.Color.LightSteelBlue;
			this.splitter1.Location = new System.Drawing.Point(152, 0);
			this.splitter1.Name = "splitter1";
			this.splitter1.Size = new System.Drawing.Size(3, 700);
			this.splitter1.TabIndex = 1;
			this.splitter1.TabStop = false;
			// 
			// panLeft
			// 
			this.panLeft.Controls.Add(this.lbMBB);
			this.panLeft.Controls.Add(this.panel6);
			this.panLeft.Dock = System.Windows.Forms.DockStyle.Left;
			this.panLeft.Location = new System.Drawing.Point(0, 0);
			this.panLeft.Name = "panLeft";
			this.panLeft.Size = new System.Drawing.Size(152, 700);
			this.panLeft.TabIndex = 0;
			// 
			// lbMBB
			// 
			this.lbMBB.Dock = System.Windows.Forms.DockStyle.Fill;
			this.lbMBB.ItemHeight = 12;
			this.lbMBB.Location = new System.Drawing.Point(0, 24);
			this.lbMBB.Name = "lbMBB";
			this.lbMBB.Size = new System.Drawing.Size(152, 676);
			this.lbMBB.TabIndex = 15;
			this.lbMBB.SelectedIndexChanged += new System.EventHandler(this.lbMBB_SelectedIndexChanged);
			// 
			// panel6
			// 
			this.panel6.BackColor = System.Drawing.Color.LightSteelBlue;
			this.panel6.Controls.Add(this.lbTarget);
			this.panel6.Dock = System.Windows.Forms.DockStyle.Top;
			this.panel6.Location = new System.Drawing.Point(0, 0);
			this.panel6.Name = "panel6";
			this.panel6.Size = new System.Drawing.Size(152, 24);
			this.panel6.TabIndex = 0;
			this.panel6.Paint += new System.Windows.Forms.PaintEventHandler(this.panel6_Paint);
			// 
			// lbTarget
			// 
			this.lbTarget.AutoSize = true;
			this.lbTarget.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.lbTarget.ForeColor = System.Drawing.Color.DarkMagenta;
			this.lbTarget.Location = new System.Drawing.Point(0, 5);
			this.lbTarget.Name = "lbTarget";
			this.lbTarget.Size = new System.Drawing.Size(121, 19);
			this.lbTarget.TabIndex = 1;
			this.lbTarget.Text = "=====目标表=====";
			this.lbTarget.Click += new System.EventHandler(this.label3_Click);
			// 
			// splitter2
			// 
			this.splitter2.BackColor = System.Drawing.Color.LightSteelBlue;
			this.splitter2.Dock = System.Windows.Forms.DockStyle.Right;
			this.splitter2.Location = new System.Drawing.Point(885, 0);
			this.splitter2.Name = "splitter2";
			this.splitter2.Size = new System.Drawing.Size(3, 704);
			this.splitter2.TabIndex = 1;
			this.splitter2.TabStop = false;
			// 
			// panRight
			// 
			this.panRight.Controls.Add(this.lbYB);
			this.panRight.Controls.Add(this.panel3);
			this.panRight.Dock = System.Windows.Forms.DockStyle.Right;
			this.panRight.Location = new System.Drawing.Point(888, 0);
			this.panRight.Name = "panRight";
			this.panRight.Size = new System.Drawing.Size(136, 704);
			this.panRight.TabIndex = 0;
			// 
			// lbYB
			// 
			this.lbYB.Dock = System.Windows.Forms.DockStyle.Fill;
			this.lbYB.ItemHeight = 12;
			this.lbYB.Location = new System.Drawing.Point(0, 24);
			this.lbYB.Name = "lbYB";
			this.lbYB.Size = new System.Drawing.Size(136, 676);
			this.lbYB.TabIndex = 7;
			this.lbYB.SelectedIndexChanged += new System.EventHandler(this.lbYB_SelectedIndexChanged);
			// 
			// panel3
			// 
			this.panel3.BackColor = System.Drawing.Color.LightSteelBlue;
			this.panel3.Controls.Add(this.lbSource);
			this.panel3.Dock = System.Windows.Forms.DockStyle.Top;
			this.panel3.ForeColor = System.Drawing.Color.Transparent;
			this.panel3.Location = new System.Drawing.Point(0, 0);
			this.panel3.Name = "panel3";
			this.panel3.Size = new System.Drawing.Size(136, 24);
			this.panel3.TabIndex = 5;
			this.panel3.Paint += new System.Windows.Forms.PaintEventHandler(this.panel3_Paint);
			// 
			// lbSource
			// 
			this.lbSource.AutoSize = true;
			this.lbSource.BackColor = System.Drawing.Color.LightSteelBlue;
			this.lbSource.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.lbSource.ForeColor = System.Drawing.Color.DarkMagenta;
			this.lbSource.Location = new System.Drawing.Point(0, 8);
			this.lbSource.Name = "lbSource";
			this.lbSource.Size = new System.Drawing.Size(106, 19);
			this.lbSource.TabIndex = 0;
			this.lbSource.Text = "=====原表=====";
			// 
			// oleY
			// 
			this.oleY.ConnectionString = "User ID=sa;Data Source=ZM;Tag with column collation when possible=False;Initial C" +
				"atalog=cs;Use Procedure for Prepare=1;Auto Translate=True;Persist Security Info=" +
				"False;Provider=SQLOLEDB;Workstation ID=ZM;Use Encryption for Data=False;Packet S" +
				"ize=4096";
			// 
			// label2
			// 
			this.label2.AutoSize = true;
			this.label2.BackColor = System.Drawing.SystemColors.Control;
			this.label2.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.label2.Location = new System.Drawing.Point(8, 8);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(0, 19);
			this.label2.TabIndex = 0;
			// 
			// frmMain
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.BackColor = System.Drawing.SystemColors.InactiveCaption;
			this.ClientSize = new System.Drawing.Size(1024, 704);
			this.Controls.Add(this.panel1);
			this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
			this.Menu = this.mm;
			this.Name = "frmMain";
			this.Text = "数据转换工具";
			this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
			this.Load += new System.EventHandler(this.frmMain_Load);
			this.panel1.ResumeLayout(false);
			this.panel5.ResumeLayout(false);
			this.panCenter.ResumeLayout(false);
			this.panel8.ResumeLayout(false);
			this.panLeft.ResumeLayout(false);
			this.panel6.ResumeLayout(false);
			this.panRight.ResumeLayout(false);
			this.panel3.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		[STAThread]
		static void Main() 
		{
			Application.Run(new frmMain());
		}

		private void miYSJY_Click(object sender, System.EventArgs e)
		{
			lbYB.Items.Clear();
			frmYSJY winYSJY=new frmYSJY();
			winYSJY.ShowDialog();
			if(oleY.State==System.Data.ConnectionState.Open)
				oleY.Close();
			oleY.ConnectionString=winYSJY.strConn;
			try
			{
				oleY.Open();
			}
			catch(System.Exception a)
			{
				MessageBox.Show("*****连接目标数据库失败!("+a.Message+")*****");
				return;
			}
			DataTable t = oleY.GetOleDbSchemaTable(System.Data.OleDb.OleDbSchemaGuid.Tables,new object[]{null, null, null, "Link"});
			foreach(DataRow ds in t.Rows)
			{
				lbYB.Items.Add(ds[2]);

			}
			t.Clear();
			t = oleY.GetOleDbSchemaTable(System.Data.OleDb.OleDbSchemaGuid.Tables,new object[]{null, null, null, "TABLE"});
			foreach(DataRow ds in t.Rows)
			{
				lbYB.Items.Add(ds[2]);

			}
			oleY.Close();
			
		}


		private void miMBSJY_Click(object sender, System.EventArgs e)
		{
			frmMBSJY winMBSJY=new frmMBSJY();
			winMBSJY.ShowDialog();
			if(trans.TargetConn.State==System.Data.ConnectionState.Open)
				trans.TargetConn.Close();
			trans.TargetConn.ConnectionString=winMBSJY.strConn;
			try
			{
				trans.TargetConn.Open();
			}
			catch(System.Data.OleDb.OleDbException a)
			{
				MessageBox.Show("*****连接目标数据库失败!("+a.Message+")*****");
				return;
			}
			DataTable t = trans.TargetConn.GetOleDbSchemaTable(System.Data.OleDb.OleDbSchemaGuid.Tables,new object[]{null, null, null, "TABLE"});
			foreach(DataRow ds in t.Rows)
			{
				lbMBB.Items.Add(ds[2]);
			}
			trans.TargetConn.Close();
		}

		private void lbYB_SelectedIndexChanged(object sender, System.EventArgs e)
		{
			if(trans.SourceTable.Count<=0)
				trans.SourceTable.Add(lbYB.Items[lbYB.SelectedIndex].ToString());
			else
				trans.SourceTable[0]=lbYB.Items[lbYB.SelectedIndex].ToString();
			_alSourceField=GetFieldListbyTN(trans.SourceConn,trans.SourceTable[0].ToString());
			if(winYBJG==null )
			{
				winYBJG=new frmYBJG(lbYB.SelectedItem.ToString(),_alSourceField);
			}
			else
			{
				if( winYBJG.strTableName!=lbYB.SelectedItem.ToString())
				{
					winYBJG.Dispose();
					winYBJG=new frmYBJG(lbYB.SelectedItem.ToString(),_alSourceField);
				}
			}
			winYBJG.Show();
		}
		/// <summary>
		/// 获得指定表的字段列表
		/// </summary>
		/// <param name="oleConn">目标连接</param>
		/// <param name="strTN">指定的表名</param>
		/// <returns>字段列表</returns>
		private ArrayList GetFieldListbyTN(OleDbConnection oleConn,string strTN)
		{	
			ArrayList strsRe=new ArrayList();
			if(oleConn.State==System.Data.ConnectionState.Closed)
				oleConn.Open();
			/*if(oleConn.State==System.Data.ConnectionState.Closed)
				oleConn.Open();*/
			DataTable schemaTable = oleConn.GetOleDbSchemaTable(OleDbSchemaGuid.Columns,new Object[] {null, null, strTN, null});
			//strsRe=new string[schemaTable.Rows.Count];
			for (int i = 0; i < schemaTable.Rows.Count; i++) 
			{
				strsRe.Add(schemaTable.Rows[i].ItemArray[3].ToString());
			}
			return strsRe;
		}
		private ArrayList GetFieldListTypesbyTN(OleDbConnection oleT,string strTN)
		{
			if(oleT.State==System.Data.ConnectionState.Closed)
				oleT.Open();
			System.Data.OleDb.OleDbCommand dc    =oleT.CreateCommand();//创建一个执行对象用于执行sql查询
			dc.CommandText= "select * from " + strTN.Trim() + " where 1=0";
			System.Data.OleDb.OleDbDataReader dr = dc.ExecuteReader();//执行sql查询
			DataTable schemaTable = dr.GetSchemaTable();
			ArrayList fieldsLX=new ArrayList();
			for(int i = 0;i < schemaTable.Columns.Count;i++)
				if(schemaTable.Columns[i].ColumnName.IndexOf("DataType") >= 0)
					for(int k = 0;k < schemaTable.Rows.Count;k++)
						fieldsLX.Add(schemaTable.Rows[k].ItemArray[i].ToString());
			dr.Close();
			dc.Dispose();
			oleT.Close();
			return fieldsLX;
		}
		/// <summary>
		/// 获得制定表名的所有字段名和字段类型

⌨️ 快捷键说明

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