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

📄 datatables.cs

📁 东软内部材料(六)ado .net相关
💻 CS
📖 第 1 页 / 共 2 页
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace DataTables
{
	/// <summary>
	/// Summary description for Form1.
	/// </summary>
	public class frmDataSets : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.Label label3;
		private System.Windows.Forms.ListBox lbEmployees;
		private System.Windows.Forms.ListBox lbClients;
		private System.Windows.Forms.DataGrid dgOrders;
		private System.Windows.Forms.Button btnDataSet;
		private System.Windows.Forms.Button btnSelect;
		private System.Windows.Forms.Button btnUnique;
		private System.Windows.Forms.Button btnForeign;
		private System.Windows.Forms.Button btnSchema;
		private System.Windows.Forms.Button btnVersion;
		private System.Windows.Forms.Button btnAddRow;
		private System.Windows.Forms.Button btnCalculate;
		private System.Data.SqlClient.SqlConnection cnNorthwind;
		internal System.Data.SqlClient.SqlDataAdapter daCustomers;
		internal System.Data.SqlClient.SqlCommand cmdSelectCustomers;
		internal System.Data.DataSet dsUntyped;
		internal System.Data.DataTable dtMaster;
		internal System.Data.DataColumn MasterID;
		internal System.Data.DataColumn MasterValue;
		internal System.Data.DataTable dtChild;
		internal System.Data.DataColumn ChildID;
		internal System.Data.DataColumn MasterLink;
		internal System.Data.DataColumn ChildValue;
		internal System.Data.SqlClient.SqlDataAdapter daEmployees;
		internal System.Data.SqlClient.SqlCommand cmdSelectEmployees;
		internal System.Data.SqlClient.SqlDataAdapter daOrders;
		internal System.Data.SqlClient.SqlCommand cmdSelectOrders;
		private DataTables.dsMaster dsMaster1;
		private System.Data.DataSet dsEmployees;
		private System.Windows.Forms.Button btnTable;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

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

			//
			// TODO: Add any constructor code after InitializeComponent call
			//
			this.dsEmployees = new System.Data.DataSet("dsEmployees");
			this.daCustomers.Fill(this.dsMaster1.CustomerList);
			this.daOrders.Fill(this.dsMaster1.OrderTotals);
			this.btnDataSet.Click += new EventHandler(this.btnDataSet_Click);
			this.btnSchema.Click += new EventHandler(this.btnSchema_Click);
			this.btnCalculate.Click += new EventHandler(this.btnCalculate_Click);
			this.btnAddRow.Click += new EventHandler(this.btnAddRow_Click);
			this.btnVersion.Click += new EventHandler(this.btnVersion_Click);
			this.btnForeign.Click += new EventHandler(this.btnForeign_Click);
			this.btnUnique.Click += new EventHandler(this.btnUnique_Click);
			this.btnSelect.Click += new EventHandler(this.btnSelect_Click);
			this.lbClients.SelectedIndexChanged += new EventHandler(this.lbClients_SelectedIndexChanged);
		}

		/// <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.label1 = new System.Windows.Forms.Label();
			this.label2 = new System.Windows.Forms.Label();
			this.label3 = new System.Windows.Forms.Label();
			this.lbEmployees = new System.Windows.Forms.ListBox();
			this.lbClients = new System.Windows.Forms.ListBox();
			this.dsMaster1 = new DataTables.dsMaster();
			this.dgOrders = new System.Windows.Forms.DataGrid();
			this.btnDataSet = new System.Windows.Forms.Button();
			this.btnSelect = new System.Windows.Forms.Button();
			this.btnUnique = new System.Windows.Forms.Button();
			this.btnForeign = new System.Windows.Forms.Button();
			this.btnSchema = new System.Windows.Forms.Button();
			this.btnVersion = new System.Windows.Forms.Button();
			this.btnAddRow = new System.Windows.Forms.Button();
			this.btnCalculate = new System.Windows.Forms.Button();
			this.cnNorthwind = new System.Data.SqlClient.SqlConnection();
			this.daCustomers = new System.Data.SqlClient.SqlDataAdapter();
			this.cmdSelectCustomers = new System.Data.SqlClient.SqlCommand();
			this.dsUntyped = new System.Data.DataSet();
			this.dtMaster = new System.Data.DataTable();
			this.MasterID = new System.Data.DataColumn();
			this.MasterValue = new System.Data.DataColumn();
			this.dtChild = new System.Data.DataTable();
			this.ChildID = new System.Data.DataColumn();
			this.MasterLink = new System.Data.DataColumn();
			this.ChildValue = new System.Data.DataColumn();
			this.daEmployees = new System.Data.SqlClient.SqlDataAdapter();
			this.cmdSelectEmployees = new System.Data.SqlClient.SqlCommand();
			this.daOrders = new System.Data.SqlClient.SqlDataAdapter();
			this.cmdSelectOrders = new System.Data.SqlClient.SqlCommand();
			this.btnTable = new System.Windows.Forms.Button();
			((System.ComponentModel.ISupportInitialize)(this.dsMaster1)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.dgOrders)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.dsUntyped)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.dtMaster)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.dtChild)).BeginInit();
			this.SuspendLayout();
			// 
			// label1
			// 
			this.label1.AutoSize = true;
			this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.label1.Location = new System.Drawing.Point(8, 8);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(66, 13);
			this.label1.TabIndex = 0;
			this.label1.Text = "Employees:";
			// 
			// label2
			// 
			this.label2.AutoSize = true;
			this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.label2.Location = new System.Drawing.Point(200, 8);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(44, 13);
			this.label2.TabIndex = 1;
			this.label2.Text = "Clients:";
			// 
			// label3
			// 
			this.label3.AutoSize = true;
			this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.label3.Location = new System.Drawing.Point(8, 136);
			this.label3.Name = "label3";
			this.label3.Size = new System.Drawing.Size(43, 13);
			this.label3.TabIndex = 2;
			this.label3.Text = "Orders:";
			// 
			// lbEmployees
			// 
			this.lbEmployees.Location = new System.Drawing.Point(8, 24);
			this.lbEmployees.Name = "lbEmployees";
			this.lbEmployees.Size = new System.Drawing.Size(184, 95);
			this.lbEmployees.TabIndex = 3;
			// 
			// lbClients
			// 
			this.lbClients.DataSource = this.dsMaster1.CustomerList;
			this.lbClients.DisplayMember = "CompanyName";
			this.lbClients.Location = new System.Drawing.Point(200, 24);
			this.lbClients.Name = "lbClients";
			this.lbClients.Size = new System.Drawing.Size(200, 95);
			this.lbClients.TabIndex = 4;
			this.lbClients.ValueMember = "CustomerID";
			// 
			// dsMaster1
			// 
			this.dsMaster1.DataSetName = "dsMaster";
			this.dsMaster1.Locale = new System.Globalization.CultureInfo("en-US");
			this.dsMaster1.Namespace = "http://www.tempuri.org/dsMaster.xsd";
			// 
			// dgOrders
			// 
			this.dgOrders.DataMember = "";
			this.dgOrders.HeaderForeColor = System.Drawing.SystemColors.ControlText;
			this.dgOrders.Location = new System.Drawing.Point(8, 152);
			this.dgOrders.Name = "dgOrders";
			this.dgOrders.Size = new System.Drawing.Size(392, 208);
			this.dgOrders.TabIndex = 5;
			// 
			// btnDataSet
			// 
			this.btnDataSet.Location = new System.Drawing.Point(416, 56);
			this.btnDataSet.Name = "btnDataSet";
			this.btnDataSet.Size = new System.Drawing.Size(96, 24);
			this.btnDataSet.TabIndex = 6;
			this.btnDataSet.Text = "Dataset Table";
			// 
			// btnSelect
			// 
			this.btnSelect.Location = new System.Drawing.Point(416, 280);
			this.btnSelect.Name = "btnSelect";
			this.btnSelect.Size = new System.Drawing.Size(96, 24);
			this.btnSelect.TabIndex = 7;
			this.btnSelect.Text = "Select";
			// 
			// btnUnique
			// 
			this.btnUnique.Location = new System.Drawing.Point(416, 248);
			this.btnUnique.Name = "btnUnique";
			this.btnUnique.Size = new System.Drawing.Size(96, 24);
			this.btnUnique.TabIndex = 8;
			this.btnUnique.Text = "Unique";
			// 
			// btnForeign
			// 
			this.btnForeign.Location = new System.Drawing.Point(416, 216);
			this.btnForeign.Name = "btnForeign";
			this.btnForeign.Size = new System.Drawing.Size(96, 24);
			this.btnForeign.TabIndex = 9;
			this.btnForeign.Text = "Foreign Key";
			// 
			// btnSchema
			// 
			this.btnSchema.Location = new System.Drawing.Point(416, 184);
			this.btnSchema.Name = "btnSchema";
			this.btnSchema.Size = new System.Drawing.Size(96, 24);
			this.btnSchema.TabIndex = 10;
			this.btnSchema.Text = "FillSchema";
			// 
			// btnVersion
			// 
			this.btnVersion.Location = new System.Drawing.Point(416, 152);
			this.btnVersion.Name = "btnVersion";
			this.btnVersion.Size = new System.Drawing.Size(96, 24);
			this.btnVersion.TabIndex = 11;
			this.btnVersion.Text = "Row Version";
			// 
			// btnAddRow
			// 
			this.btnAddRow.Location = new System.Drawing.Point(416, 120);
			this.btnAddRow.Name = "btnAddRow";
			this.btnAddRow.Size = new System.Drawing.Size(96, 24);
			this.btnAddRow.TabIndex = 12;
			this.btnAddRow.Text = "Add DataRow";
			// 
			// btnCalculate
			// 
			this.btnCalculate.Location = new System.Drawing.Point(416, 88);
			this.btnCalculate.Name = "btnCalculate";
			this.btnCalculate.Size = new System.Drawing.Size(96, 24);
			this.btnCalculate.TabIndex = 13;
			this.btnCalculate.Text = "Calculate";
			// 
			// cnNorthwind
			// 
			this.cnNorthwind.ConnectionString = "data source=localhost;initial catalog=nwind;integrated security=SSPI;persist " +
				"security info=False;packet size=4096";
			// 
			// daCustomers
			// 
			this.daCustomers.SelectCommand = this.cmdSelectCustomers;
			this.daCustomers.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
																								  new System.Data.Common.DataTableMapping("Table", "CustomerList", new System.Data.Common.DataColumnMapping[] {
																																																				  new System.Data.Common.DataColumnMapping("CustomerID", "CustomerID"),
																																																				  new System.Data.Common.DataColumnMapping("CompanyName", "CompanyName"),
																																																				  new System.Data.Common.DataColumnMapping("City", "City"),
																																																				  new System.Data.Common.DataColumnMapping("Country", "Country"),
																																																				  new System.Data.Common.DataColumnMapping("PostalCode", "PostalCode"),
																																																				  new System.Data.Common.DataColumnMapping("Region", "Region")})});
			// 
			// cmdSelectCustomers
			// 
			this.cmdSelectCustomers.CommandText = "SELECT CustomerID, CompanyName, City, Country, PostalCode, Region FROM CustomerLi" +
				"st";
			this.cmdSelectCustomers.Connection = this.cnNorthwind;
			// 
			// dsUntyped
			// 
			this.dsUntyped.DataSetName = "dsUntyped";
			this.dsUntyped.Locale = new System.Globalization.CultureInfo("en-US");
			this.dsUntyped.Tables.AddRange(new System.Data.DataTable[] {
																		   this.dtMaster,
																		   this.dtChild});
			// 
			// dtMaster
			// 
			this.dtMaster.Columns.AddRange(new System.Data.DataColumn[] {
																			this.MasterID,
																			this.MasterValue});
			this.dtMaster.TableName = "dtMaster";
			// 
			// MasterID
			// 

⌨️ 快捷键说明

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