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

📄 testcommonieform.cs

📁 C#自定义查询控件
💻 CS
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace TestCommonIE
{
	/// <summary>
	/// Summary description for Form1.
	/// </summary>
	public class TestCommonIEForm : System.Windows.Forms.Form
	{
		private System.Windows.Forms.SaveFileDialog saveFileDialog1;
		private System.Data.SqlClient.SqlConnection sqlConnection1;
		private System.Data.SqlClient.SqlDataAdapter sqlDataAdapter1;
		private System.Data.DataSet dataSet1;
		private System.Data.SqlClient.SqlDataAdapter sqlDataAdapter2;
		private System.Data.SqlClient.SqlCommand sqlSelectCommand1;
		private System.Data.DataTable dataTable1;
		private System.Data.DataTable dataTable2;
		private System.Windows.Forms.Button btnExport;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		public TestCommonIEForm()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			//
			// TODO: Add any constructor code after InitializeComponent call
			//
		}

		/// <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.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog();
			this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();
			this.sqlDataAdapter1 = new System.Data.SqlClient.SqlDataAdapter();
			this.sqlSelectCommand1 = new System.Data.SqlClient.SqlCommand();
			this.dataSet1 = new System.Data.DataSet();
			this.dataTable1 = new System.Data.DataTable();
			this.dataTable2 = new System.Data.DataTable();
			this.btnExport = new System.Windows.Forms.Button();
			this.sqlDataAdapter2 = new System.Data.SqlClient.SqlDataAdapter();
			((System.ComponentModel.ISupportInitialize)(this.dataSet1)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.dataTable1)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.dataTable2)).BeginInit();
			this.SuspendLayout();
			// 
			// sqlConnection1
			// 
			this.sqlConnection1.ConnectionString = "workstation id=GET02C0010;packet size=4096;integrated security=SSPI;data source=\"" +
				"GET02C0010\\MYDATA\";persist security info=False;initial catalog=Northwind";
			// 
			// sqlDataAdapter1
			// 
			this.sqlDataAdapter1.SelectCommand = this.sqlSelectCommand1;
			this.sqlDataAdapter1.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
																									  new System.Data.Common.DataTableMapping("Table", "Orders", new System.Data.Common.DataColumnMapping[] {
																																																				new System.Data.Common.DataColumnMapping("OrderID", "OrderID"),
																																																				new System.Data.Common.DataColumnMapping("CustomerID", "CustomerID"),
																																																				new System.Data.Common.DataColumnMapping("EmployeeID", "EmployeeID"),
																																																				new System.Data.Common.DataColumnMapping("OrderDate", "OrderDate"),
																																																				new System.Data.Common.DataColumnMapping("RequiredDate", "RequiredDate"),
																																																				new System.Data.Common.DataColumnMapping("ShippedDate", "ShippedDate"),
																																																				new System.Data.Common.DataColumnMapping("ShipVia", "ShipVia"),
																																																				new System.Data.Common.DataColumnMapping("Freight", "Freight"),
																																																				new System.Data.Common.DataColumnMapping("ShipName", "ShipName"),
																																																				new System.Data.Common.DataColumnMapping("ShipAddress", "ShipAddress"),
																																																				new System.Data.Common.DataColumnMapping("ShipCity", "ShipCity"),
																																																				new System.Data.Common.DataColumnMapping("ShipRegion", "ShipRegion"),
																																																				new System.Data.Common.DataColumnMapping("ShipPostalCode", "ShipPostalCode"),
																																																				new System.Data.Common.DataColumnMapping("ShipCountry", "ShipCountry"),
																																																				new System.Data.Common.DataColumnMapping("Expr1", "Expr1"),
																																																				new System.Data.Common.DataColumnMapping("ProductID", "ProductID"),
																																																				new System.Data.Common.DataColumnMapping("UnitPrice", "UnitPrice"),
																																																				new System.Data.Common.DataColumnMapping("Quantity", "Quantity"),
																																																				new System.Data.Common.DataColumnMapping("Discount", "Discount")})});
			// 
			// sqlSelectCommand1
			// 
			this.sqlSelectCommand1.CommandText = @"SELECT top 10 Orders.OrderID, Orders.CustomerID, Orders.EmployeeID, Orders.OrderDate, Orders.RequiredDate, Orders.ShippedDate, Orders.ShipVia, Orders.Freight, Orders.ShipName, Orders.ShipAddress, Orders.ShipCity, Orders.ShipRegion, Orders.ShipPostalCode, Orders.ShipCountry, [Order Details].OrderID AS Expr1, [Order Details].ProductID, [Order Details].UnitPrice, [Order Details].Quantity, [Order Details].Discount FROM Orders INNER JOIN [Order Details] ON Orders.OrderID = [Order Details].OrderID";
			this.sqlSelectCommand1.Connection = this.sqlConnection1;
			// 
			// dataSet1
			// 
			this.dataSet1.DataSetName = "NewDataSet";
			this.dataSet1.Locale = new System.Globalization.CultureInfo("zh-CN");
			this.dataSet1.Tables.AddRange(new System.Data.DataTable[] {
																		  this.dataTable1,
																		  this.dataTable2});
			// 
			// dataTable1
			// 
			this.dataTable1.TableName = "Table1";
			// 
			// dataTable2
			// 
			this.dataTable2.TableName = "Table2";
			// 
			// btnExport
			// 
			this.btnExport.Location = new System.Drawing.Point(88, 64);
			this.btnExport.Name = "btnExport";
			this.btnExport.TabIndex = 0;
			this.btnExport.Text = "&Export";
			this.btnExport.Click += new System.EventHandler(this.button1_Click);
			// 
			// sqlDataAdapter2
			// 
			this.sqlDataAdapter2.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
																									  new System.Data.Common.DataTableMapping("Table", "Employees", new System.Data.Common.DataColumnMapping[] {
																																																				   new System.Data.Common.DataColumnMapping("EmployeeID", "EmployeeID"),
																																																				   new System.Data.Common.DataColumnMapping("LastName", "LastName"),
																																																				   new System.Data.Common.DataColumnMapping("FirstName", "FirstName"),
																																																				   new System.Data.Common.DataColumnMapping("Title", "Title"),
																																																				   new System.Data.Common.DataColumnMapping("TitleOfCourtesy", "TitleOfCourtesy"),
																																																				   new System.Data.Common.DataColumnMapping("BirthDate", "BirthDate"),
																																																				   new System.Data.Common.DataColumnMapping("HireDate", "HireDate"),
																																																				   new System.Data.Common.DataColumnMapping("Address", "Address"),
																																																				   new System.Data.Common.DataColumnMapping("City", "City"),
																																																				   new System.Data.Common.DataColumnMapping("Region", "Region"),
																																																				   new System.Data.Common.DataColumnMapping("PostalCode", "PostalCode"),
																																																				   new System.Data.Common.DataColumnMapping("Country", "Country"),
																																																				   new System.Data.Common.DataColumnMapping("HomePhone", "HomePhone"),
																																																				   new System.Data.Common.DataColumnMapping("Extension", "Extension"),
																																																				   new System.Data.Common.DataColumnMapping("Photo", "Photo"),
																																																				   new System.Data.Common.DataColumnMapping("Notes", "Notes"),
																																																				   new System.Data.Common.DataColumnMapping("ReportsTo", "ReportsTo"),
																																																				   new System.Data.Common.DataColumnMapping("PhotoPath", "PhotoPath")})});
			// 
			// TestCommonIEForm
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(272, 157);
			this.Controls.Add(this.btnExport);
			this.Name = "TestCommonIEForm";
			this.Text = "Import/Export Data demo";
			((System.ComponentModel.ISupportInitialize)(this.dataSet1)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.dataTable1)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.dataTable2)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion

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

		private void button1_Click(object sender, System.EventArgs e)
		{
//			sqlDataAdapter1.Fill(dataSet11.Orders);
//			commonExport1.Export();
		}
	
	}
}

⌨️ 快捷键说明

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