📄 testcommonqueryform.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using CommonComponent.CommonQuery;
namespace TestCommonQuery
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class TestCommonQueryForm : System.Windows.Forms.Form
{
private System.Windows.Forms.Button btnOpen;
private System.Windows.Forms.Button btnTest;
private System.Data.SqlClient.SqlConnection sqlConnection1;
private TestCommonIE.DataSet1 dataSet11;
private CommonComponent.CommonQuery.CommonQuery commonQuery1;
private System.Data.SqlClient.SqlDataAdapter sqlDataAdapter1;
private System.Data.SqlClient.SqlCommand sqlSelectCommand1;
private System.Data.SqlClient.SqlConnection sqlConnection2;
private TestComponent.DataSet1 dataSet13;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public TestCommonQueryForm()
{
//
// 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.btnTest = new System.Windows.Forms.Button();
this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();
this.btnOpen = new System.Windows.Forms.Button();
this.dataSet11 = new TestCommonIE.DataSet1();
this.commonQuery1 = new CommonComponent.CommonQuery.CommonQuery();
this.sqlConnection2 = new System.Data.SqlClient.SqlConnection();
this.dataSet13 = new TestComponent.DataSet1();
this.sqlDataAdapter1 = new System.Data.SqlClient.SqlDataAdapter();
this.sqlSelectCommand1 = new System.Data.SqlClient.SqlCommand();
((System.ComponentModel.ISupportInitialize)(this.dataSet11)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.dataSet13)).BeginInit();
this.SuspendLayout();
//
// btnTest
//
this.btnTest.Location = new System.Drawing.Point(168, 64);
this.btnTest.Name = "btnTest";
this.btnTest.TabIndex = 0;
this.btnTest.Text = "Test";
this.btnTest.Click += new System.EventHandler(this.btnTest_Click);
//
// sqlConnection1
//
this.sqlConnection1.ConnectionString = "workstation id=GET02C0027;packet size=4096;integrated security=SSPI;data source=\"" +
"GET-ITTEST03\";persist security info=False;initial catalog=QualityDB";
//
// btnOpen
//
this.btnOpen.Location = new System.Drawing.Point(56, 64);
this.btnOpen.Name = "btnOpen";
this.btnOpen.TabIndex = 2;
this.btnOpen.Text = "Open";
this.btnOpen.Click += new System.EventHandler(this.btnOpen_Click);
//
// dataSet11
//
this.dataSet11.DataSetName = "DataSet1";
this.dataSet11.Locale = new System.Globalization.CultureInfo("zh-CN");
//
// commonQuery1
//
this.commonQuery1.AutoClear = true;
this.commonQuery1.AutoField = null;
this.commonQuery1.AutoTable = null;
this.commonQuery1.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.commonQuery1.ButtonStyle = System.Windows.Forms.FlatStyle.Standard;
this.commonQuery1.SqlConnection = this.sqlConnection2;
this.commonQuery1.SqlConnectionString = null;
//
// sqlConnection2
//
this.sqlConnection2.ConnectionString = "workstation id=GET02C0027;packet size=4096;integrated security=SSPI;data source=\"" +
"GEK-MIS01\";persist security info=False;initial catalog=QualityDB";
//
// dataSet13
//
this.dataSet13.DataSetName = "DataSet1";
this.dataSet13.Locale = new System.Globalization.CultureInfo("zh-CN");
//
// sqlDataAdapter1
//
this.sqlDataAdapter1.SelectCommand = this.sqlSelectCommand1;
this.sqlDataAdapter1.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
new System.Data.Common.DataTableMapping("Table", "QAInspectFabricHeader", new System.Data.Common.DataColumnMapping[] {
new System.Data.Common.DataColumnMapping("Fabric_No", "Fabric_No"),
new System.Data.Common.DataColumnMapping("Check_Times", "Check_Times"),
new System.Data.Common.DataColumnMapping("PPo_No", "PPo_No"),
new System.Data.Common.DataColumnMapping("Lot_No", "Lot_No"),
new System.Data.Common.DataColumnMapping("Batch_No", "Batch_No"),
new System.Data.Common.DataColumnMapping("Defect_Type", "Defect_Type"),
new System.Data.Common.DataColumnMapping("Defect_Name", "Defect_Name"),
new System.Data.Common.DataColumnMapping("Defect_Bulk", "Defect_Bulk"),
new System.Data.Common.DataColumnMapping("Defect_Sort", "Defect_Sort"),
new System.Data.Common.DataColumnMapping("Defect_Start", "Defect_Start"),
new System.Data.Common.DataColumnMapping("Defect_End", "Defect_End"),
new System.Data.Common.DataColumnMapping("Defect_ToLeft", "Defect_ToLeft")})});
//
// sqlSelectCommand1
//
this.sqlSelectCommand1.CommandText = @"SELECT A.Fabric_No, A.Check_Times, A.PPo_No, A.Lot_No, A.Batch_No, B.Defect_Type, B.Defect_Name, B.Defect_Bulk, B.Defect_Sort, B.Defect_Start, B.Defect_End, B.Defect_ToLeft FROM dbo.QAInspectFabricHeader A INNER JOIN dbo.QAFabricDefectDetail B ON A.Fabric_No = B.Fabric_No AND A.Check_Times = B.Check_Times";
this.sqlSelectCommand1.Connection = this.sqlConnection2;
//
// TestCommonQueryForm
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(328, 157);
this.Controls.Add(this.btnOpen);
this.Controls.Add(this.btnTest);
this.Name = "TestCommonQueryForm";
this.Text = "Common Query Component demo";
this.Load += new System.EventHandler(this.Form1_Load);
((System.ComponentModel.ISupportInitialize)(this.dataSet11)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.dataSet13)).EndInit();
this.ResumeLayout(false);
}
#endregion
private void Form1_Load(object sender, System.EventArgs e)
{
}
private void btnTest_Click(object sender, System.EventArgs e)
{
commonQuery1.SqlConnection = sqlConnection2;
IQuery iq = commonQuery1;
MessageBox.Show(iq.Condition());
// iq.Condition();
}
private void btnOpen_Click(object sender, System.EventArgs e)
{
if( sqlConnection2.State == System.Data.ConnectionState.Closed )
sqlConnection2.Open();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -