简易类生成工具

namespace ClassGenerator
{
    partial class Form1
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (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.tabControl1 = new System.Windows.Forms.TabControl();
            this.tabPage1 = new System.Windows.Forms.TabPage();
            this.splitContainer4 = new System.Windows.Forms.SplitContainer();
            this.splitContainer1 = new System.Windows.Forms.SplitContainer();
            this.txtSql = new System.Windows.Forms.TextBox();
            this.label2 = new System.Windows.Forms.Label();
            this.label8 = new System.Windows.Forms.Label();
            this.txtClass = new System.Windows.Forms.TextBox();
            this.dgvResult = new System.Windows.Forms.DataGridView();
            this.btnGenerate = new System.Windows.Forms.Button();
            this.btnViewFields = new System.Windows.Forms.Button();
            this.panel1 = new System.Windows.Forms.Panel();
            this.splitContainer2 = new System.Windows.Forms.SplitContainer();
            this.lstConnections = new System.Windows.Forms.ComboBox();
            this.label1 = new System.Windows.Forms.Label();
            this.lstClassTemplate = new System.Windows.Forms.ComboBox();
            this.label3 = new System.Windows.Forms.Label();
            this.tabPage2 = new System.Windows.Forms.TabPage();
            this.txtTemplateName = new System.Windows.Forms.TextBox();
            this.btnCreateTemplate = new System.Windows.Forms.Button();
            this.btnDeleteTemplate = new System.Windows.Forms.Button();
            this.btnSaveTemplate = new System.Windows.Forms.Button();
            this.cmbClassTemplate = new System.Windows.Forms.ComboBox();
            this.txtClassTemplate = new System.Windows.Forms.TextBox();
            this.tabPage3 = new System.Windows.Forms.TabPage();
            this.btnNewConnection = new System.Windows.Forms.Button();
            this.txtConnectionName = new System.Windows.Forms.TextBox();
            this.cmbConnections = new System.Windows.Forms.ComboBox();
            this.btnDelete = new System.Windows.Forms.Button();
            this.btnTestConnection = new System.Windows.Forms.Button();
            this.btnSaveConnection = new System.Windows.Forms.Button();
            this.txtConnectionString = new System.Windows.Forms.TextBox();
            this.tabControl1.SuspendLayout();
            this.tabPage1.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.splitContainer4)).BeginInit();
            this.splitContainer4.Panel1.SuspendLayout();
            this.splitContainer4.Panel2.SuspendLayout();
            this.splitContainer4.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
            this.splitContainer1.Panel1.SuspendLayout();
            this.splitContainer1.Panel2.SuspendLayout();
            this.splitContainer1.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.dgvResult)).BeginInit();
            this.panel1.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).BeginInit();
            this.splitContainer2.Panel1.SuspendLayout();
            this.splitContainer2.Panel2.SuspendLayout();
            this.splitContainer2.SuspendLayout();
            this.tabPage2.SuspendLayout();
            this.tabPage3.SuspendLayout();
            this.SuspendLayout();
            // 
            // tabControl1
            // 
            this.tabControl1.Appearance = System.Windows.Forms.TabAppearance.FlatButtons;
            this.tabControl1.Controls.Add(this.tabPage1);
            this.tabControl1.Controls.Add(this.tabPage2);
            this.tabControl1.Controls.Add(this.tabPage3);
            this.tabControl1.Dock = System.Windows.Forms.DockStyle.Fill;
            this.tabControl1.Location = new System.Drawing.Point(0, 0);
            this.tabControl1.Name = "tabControl1";
            this.tabControl1.SelectedIndex = 0;
            this.tabControl1.Size = new System.Drawing.Size(830, 620);
            this.tabControl1.TabIndex = 3;
            // 
            // tabPage1
            // 
            this.tabPage1.AutoScroll = true;
            this.tabPage1.Controls.Add(this.splitContainer4);
            this.tabPage1.Controls.Add(this.panel1);
            this.tabPage1.Location = new System.Drawing.Point(4, 25);
            this.tabPage1.Name = "tabPage1";
            this.tabPage1.Padding = new System.Windows.Forms.Padding(3);
            this.tabPage1.Size = new System.Drawing.Size(822, 591);
            this.tabPage1.TabIndex = 0;
            this.tabPage1.Text = "Generate";
            this.tabPage1.UseVisualStyleBackColor = true;
            // 
            // splitContainer4
            // 
            this.splitContainer4.Dock = System.Windows.Forms.DockStyle.Fill;
            this.splitContainer4.FixedPanel = System.Windows.Forms.FixedPanel.Panel2;
            this.splitContainer4.Location = new System.Drawing.Point(3, 34);
            this.splitContainer4.Name = "splitContainer4";
            this.splitContainer4.Orientation = System.Windows.Forms.Orientation.Horizontal;
            // 
            // splitContainer4.Panel1
            // 
            this.splitContainer4.Panel1.Controls.Add(this.splitContainer1);
            // 
            // splitContainer4.Panel2
            // 
            this.splitContainer4.Panel2.Controls.Add(this.dgvResult);
            this.splitContainer4.Panel2.Controls.Add(this.btnGenerate);
            this.splitContainer4.Panel2.Controls.Add(this.btnViewFields);
            this.splitContainer4.Size = new System.Drawing.Size(816, 554);
            this.splitContainer4.SplitterDistance = 418;
            this.splitContainer4.TabIndex = 13;
            // 
            // splitContainer1
            // 
            this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
            this.splitContainer1.Location = new System.Drawing.Point(0, 0);
            this.splitContainer1.Name = "splitContainer1";
            // 
            // splitContainer1.Panel1
            // 
            this.splitContainer1.Panel1.Controls.Add(this.txtSql);
            this.splitContainer1.Panel1.Controls.Add(this.label2);
            // 
            // splitContainer1.Panel2
            // 
            this.splitContainer1.Panel2.Controls.Add(this.label8);
            this.splitContainer1.Panel2.Controls.Add(this.txtClass);
            this.splitContainer1.Size = new System.Drawing.Size(816, 418);
            this.splitContainer1.SplitterDistance = 380;
            this.splitContainer1.TabIndex = 11;
            // 
            // txtSql
            // 
            this.txtSql.AcceptsReturn = true;
            this.txtSql.AcceptsTab = true;
            this.txtSql.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
            | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.txtSql.BackColor = System.Drawing.Color.AliceBlue;
            this.txtSql.Location = new System.Drawing.Point(0, 16);
            this.txtSql.Multiline = true;
            this.txtSql.Name = "txtSql";
            this.txtSql.ScrollBars = System.Windows.Forms.ScrollBars.Both;
            this.txtSql.Size = new System.Drawing.Size(377, 402);
            this.txtSql.TabIndex = 15;
            this.txtSql.WordWrap = false;
            // 
            // label2
            // 
            this.label2.AutoSize = true;
            this.label2.Dock = System.Windows.Forms.DockStyle.Top;
            this.label2.Location = new System.Drawing.Point(0, 0);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(31, 13);
            this.label2.TabIndex = 0;
            this.label2.Text = "SQL:";
            // 
            // label8
            // 
            this.label8.AutoSize = true;
            this.label8.Dock = System.Windows.Forms.DockStyle.Top;
            this.label8.Location = new System.Drawing.Point(0, 0);
            this.label8.Name = "label8";
            this.label8.Size = new System.Drawing.Size(35, 13);
            this.label8.TabIndex = 13;
            this.label8.Text = "Code:";
            // 
            // txtClass
            // 
            this.txtClass.AcceptsReturn = true;
            this.txtClass.AcceptsTab = true;
            this.txtClass.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
            | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.txtClass.Location = new System.Drawing.Point(0, 16);
            this.txtClass.Multiline = true;
            this.txtClass.Name = "txtClass";
            this.txtClass.ScrollBars = System.Windows.Forms.ScrollBars.Both;
            this.txtClass.Size = new System.Drawing.Size(432, 402);
            this.txtClass.TabIndex = 12;
            this.txtClass.WordWrap = false;
            // 
            // dgvResult
            // 
            this.dgvResult.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
            | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.dgvResult.BackgroundColor = System.Drawing.SystemColors.Window;
            this.dgvResult.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
            this.dgvResult.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
            this.dgvResult.Location = new System.Drawing.Point(3, 3);
            this.dgvResult.Name = "dgvResult";
            this.dgvResult.Size = new System.Drawing.Size(813, 92);
            this.dgvResult.TabIndex = 11;
            // 
            // btnGenerate
            // 
            this.btnGenerate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
            this.btnGenerate.Location = new System.Drawing.Point(698, 101);
            this.btnGenerate.Name = "btnGenerate";
            this.btnGenerate.Size = new System.Drawing.Size(113, 26);
            this.btnGenerate.TabIndex = 10;
            this.btnGenerate.Text = "Generate Class";
            this.btnGenerate.UseVisualStyleBackColor = true;
            this.btnGenerate.Click += new System.EventHandler(this.btnGenerate_Click);
            // 
            // btnViewFields
            // 
            this.btnViewFields.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
            this.btnViewFields.Location = new System.Drawing.Point(579, 101);
            this.btnViewFields.Name = "btnViewFields";
            this.btnViewFields.Size = new System.Drawing.Size(113, 26);
            this.btnViewFields.TabIndex = 9;
            this.btnViewFields.Text = "View Fileds";
            this.btnViewFields.UseVisualStyleBackColor = true;
            this.btnViewFields.Click += new System.EventHandler(this.btnViewFields_Click);
            // 
            // panel1
            // 
            this.panel1.Controls.Add(this.splitContainer2);
            this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
            this.panel1.Location = new System.Drawing.Point(3, 3);
            this.panel1.Name = "panel1";
            this.panel1.Size = new System.Drawing.Size(816, 31);
            this.panel1.TabIndex = 9;
            // 
            // splitContainer2
            // 
            this.splitContainer2.Dock = System.Windows.Forms.DockStyle.Fill;
            this.splitContainer2.Location = new System.Drawing.Point(0, 0);
            this.splitContainer2.Name = "splitContainer2";
            // 
            // splitContainer2.Panel1
            // 
            this.splitContainer2.Panel1.Controls.Add(this.lstConnections);
            this.splitContainer2.Panel1.Controls.Add(this.label1);
            // 
            // splitContainer2.Panel2
            // 
            this.splitContainer2.Panel2.Controls.Add(this.lstClassTemplate);
            this.splitContainer2.Panel2.Controls.Add(this.label3);
            this.splitContainer2.Size = new System.Drawing.Size(816, 31);
            this.splitContainer2.SplitterDistance = 378;
            this.splitContainer2.TabIndex = 0;
            // 
            // lstConnections
            // 
            this.lstConnections.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
            | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.lstConnections.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
            this.lstConnections.FormattingEnabled = true;
            this.lstConnections.Location = new System.Drawing.Point(98, 5);
            this.lstConnections.Name = "lstConnections";
            this.lstConnections.Size = new System.Drawing.Size(274, 21);
            this.lstConnections.TabIndex = 15;
            // 
            // label1
            // 
            this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
            | System.Windows.Forms.AnchorStyles.Left)));
            this.label1.AutoSize = true;
            this.label1.Location = new System.Drawing.Point(5, 8);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(94, 13);
            this.label1.TabIndex = 14;
            this.label1.Text = "Connection String:";
            // 
            // lstClassTemplate
            // 
            this.lstClassTemplate.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
            | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.lstClassTemplate.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
            this.lstClassTemplate.FormattingEnabled = true;
            this.lstClassTemplate.Location = new System.Drawing.Point(91, 5);
            this.lstClassTemplate.Name = "lstClassTemplate";
            this.lstClassTemplate.Size = new System.Drawing.Size(343, 21);
            this.lstClassTemplate.TabIndex = 17;
            // 
            // label3
            // 
            this.label3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
            | System.Windows.Forms.AnchorStyles.Left)));
            this.label3.AutoSize = true;
            this.label3.Location = new System.Drawing.Point(3, 8);
            this.label3.Name = "label3";
            this.label3.Size = new System.Drawing.Size(82, 13);
            this.label3.TabIndex = 16;
            this.label3.Text = "Class Template:";
            // 
            // tabPage2
            // 
            this.tabPage2.BackColor = System.Drawing.SystemColors.Control;
            this.tabPage2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
            this.tabPage2.Controls.Add(this.txtTemplateName);
            this.tabPage2.Controls.Add(this.btnCreateTemplate);
            this.tabPage2.Controls.Add(this.btnDeleteTemplate);
            this.tabPage2.Controls.Add(this.btnSaveTemplate);
            this.tabPage2.Controls.Add(this.cmbClassTemplate);
            this.tabPage2.Controls.Add(this.txtClassTemplate);
            this.tabPage2.Location = new System.Drawing.Point(4, 25);
            this.tabPage2.Name = "tabPage2";
            this.tabPage2.Padding = new System.Windows.Forms.Padding(3);
            this.tabPage2.Size = new System.Drawing.Size(822, 591);
            this.tabPage2.TabIndex = 1;
            this.tabPage2.Text = "Class Template";
            // 
            // txtTemplateName
            // 
            this.txtTemplateName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.txtTemplateName.Location = new System.Drawing.Point(3, 531);
            this.txtTemplateName.Name = "txtTemplateName";
            this.txtTemplateName.Size = new System.Drawing.Size(816, 20);
            this.txtTemplateName.TabIndex = 12;
            // 
            // btnCreateTemplate
            // 
            this.btnCreateTemplate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
            this.btnCreateTemplate.Location = new System.Drawing.Point(552, 557);
            this.btnCreateTemplate.Name = "btnCreateTemplate";
            this.btnCreateTemplate.Size = new System.Drawing.Size(84, 26);
            this.btnCreateTemplate.TabIndex = 11;
            this.btnCreateTemplate.Text = "Create";
            this.btnCreateTemplate.UseVisualStyleBackColor = true;
            this.btnCreateTemplate.Click += new System.EventHandler(this.btnCreateTemplate_Click);
            // 
            // btnDeleteTemplate
            // 
            this.btnDeleteTemplate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
            this.btnDeleteTemplate.Location = new System.Drawing.Point(642, 557);
            this.btnDeleteTemplate.Name = "btnDeleteTemplate";
            this.btnDeleteTemplate.Size = new System.Drawing.Size(84, 26);
            this.btnDeleteTemplate.TabIndex = 11;
            this.btnDeleteTemplate.Text = "Delete";
            this.btnDeleteTemplate.UseVisualStyleBackColor = true;
            this.btnDeleteTemplate.Click += new System.EventHandler(this.btnDeleteTemplate_Click);
            // 
            // btnSaveTemplate
            // 
            this.btnSaveTemplate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
            this.btnSaveTemplate.Location = new System.Drawing.Point(732, 557);
            this.btnSaveTemplate.Name = "btnSaveTemplate";
            this.btnSaveTemplate.Size = new System.Drawing.Size(84, 26);
            this.btnSaveTemplate.TabIndex = 11;
            this.btnSaveTemplate.Text = "Save";
            this.btnSaveTemplate.UseVisualStyleBackColor = true;
            this.btnSaveTemplate.Click += new System.EventHandler(this.btnSaveTemplate_Click);
            // 
            // cmbClassTemplate
            // 
            this.cmbClassTemplate.Dock = System.Windows.Forms.DockStyle.Top;
            this.cmbClassTemplate.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
            this.cmbClassTemplate.FormattingEnabled = true;
            this.cmbClassTemplate.Location = new System.Drawing.Point(3, 3);
            this.cmbClassTemplate.Name = "cmbClassTemplate";
            this.cmbClassTemplate.Size = new System.Drawing.Size(816, 21);
            this.cmbClassTemplate.TabIndex = 1;
            this.cmbClassTemplate.SelectedIndexChanged += new System.EventHandler(this.cmbClassTemplate_SelectedIndexChanged);
            // 
            // txtClassTemplate
            // 
            this.txtClassTemplate.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
            | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.txtClassTemplate.Location = new System.Drawing.Point(3, 30);
            this.txtClassTemplate.Multiline = true;
            this.txtClassTemplate.Name = "txtClassTemplate";
            this.txtClassTemplate.Size = new System.Drawing.Size(816, 495);
            this.txtClassTemplate.TabIndex = 0;
            // 
            // tabPage3
            // 
            this.tabPage3.BackColor = System.Drawing.SystemColors.Control;
            this.tabPage3.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
            this.tabPage3.Controls.Add(this.btnNewConnection);
            this.tabPage3.Controls.Add(this.txtConnectionName);
            this.tabPage3.Controls.Add(this.cmbConnections);
            this.tabPage3.Controls.Add(this.btnDelete);
            this.tabPage3.Controls.Add(this.btnTestConnection);
            this.tabPage3.Controls.Add(this.btnSaveConnection);
            this.tabPage3.Controls.Add(this.txtConnectionString);
            this.tabPage3.Location = new System.Drawing.Point(4, 25);
            this.tabPage3.Name = "tabPage3";
            this.tabPage3.Size = new System.Drawing.Size(822, 591);
            this.tabPage3.TabIndex = 2;
            this.tabPage3.Text = "Connection Strings";
            this.tabPage3.UseVisualStyleBackColor = true;
            // 
            // btnNewConnection
            // 
            this.btnNewConnection.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.btnNewConnection.Location = new System.Drawing.Point(463, 136);
            this.btnNewConnection.Name = "btnNewConnection";
            this.btnNewConnection.Size = new System.Drawing.Size(84, 26);
            this.btnNewConnection.TabIndex = 11;
            this.btnNewConnection.Text = "Create";
            this.btnNewConnection.UseVisualStyleBackColor = true;
            this.btnNewConnection.Click += new System.EventHandler(this.btnNewConnection_Click);
            // 
            // txtConnectionName
            // 
            this.txtConnectionName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.txtConnectionName.Location = new System.Drawing.Point(3, 110);
            this.txtConnectionName.Name = "txtConnectionName";
            this.txtConnectionName.Size = new System.Drawing.Size(816, 20);
            this.txtConnectionName.TabIndex = 10;
            // 
            // cmbConnections
            // 
            this.cmbConnections.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
            this.cmbConnections.FormattingEnabled = true;
            this.cmbConnections.Location = new System.Drawing.Point(3, 0);
            this.cmbConnections.Name = "cmbConnections";
            this.cmbConnections.Size = new System.Drawing.Size(816, 21);
            this.cmbConnections.TabIndex = 9;
            this.cmbConnections.SelectedIndexChanged += new System.EventHandler(this.cmbConnections_SelectedIndexChanged);
            // 
            // btnDelete
            // 
            this.btnDelete.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.btnDelete.Location = new System.Drawing.Point(643, 136);
            this.btnDelete.Name = "btnDelete";
            this.btnDelete.Size = new System.Drawing.Size(84, 26);
            this.btnDelete.TabIndex = 8;
            this.btnDelete.Text = "Delete";
            this.btnDelete.UseVisualStyleBackColor = true;
            this.btnDelete.Click += new System.EventHandler(this.btnDelete_Click);
            // 
            // btnTestConnection
            // 
            this.btnTestConnection.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.btnTestConnection.Location = new System.Drawing.Point(553, 136);
            this.btnTestConnection.Name = "btnTestConnection";
            this.btnTestConnection.Size = new System.Drawing.Size(84, 26);
            this.btnTestConnection.TabIndex = 7;
            this.btnTestConnection.Text = "Test";
            this.btnTestConnection.UseVisualStyleBackColor = true;
            this.btnTestConnection.Click += new System.EventHandler(this.btnTestConnection_Click);
            // 
            // btnSaveConnection
            // 
            this.btnSaveConnection.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.btnSaveConnection.Location = new System.Drawing.Point(733, 136);
            this.btnSaveConnection.Name = "btnSaveConnection";
            this.btnSaveConnection.Size = new System.Drawing.Size(84, 26);
            this.btnSaveConnection.TabIndex = 3;
            this.btnSaveConnection.Text = "Save";
            this.btnSaveConnection.UseVisualStyleBackColor = true;
            this.btnSaveConnection.Click += new System.EventHandler(this.btnSaveConnection_Click);
            // 
            // txtConnectionString
            // 
            this.txtConnectionString.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.txtConnectionString.Location = new System.Drawing.Point(3, 27);
            this.txtConnectionString.Multiline = true;
            this.txtConnectionString.Name = "txtConnectionString";
            this.txtConnectionString.Size = new System.Drawing.Size(816, 77);
            this.txtConnectionString.TabIndex = 1;
            // 
            // Form1
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(830, 620);
            this.Controls.Add(this.tabControl1);
            this.Name = "Form1";
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
            this.Text = "Class Generator";
            this.Load += new System.EventHandler(this.Form1_Load);
            this.tabControl1.ResumeLayout(false);
            this.tabPage1.ResumeLayout(false);
            this.splitContainer4.Panel1.ResumeLayout(false);
            this.splitContainer4.Panel2.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.splitContainer4)).EndInit();
            this.splitContainer4.ResumeLayout(false);
            this.splitContainer1.Panel1.ResumeLayout(false);
            this.splitContainer1.Panel1.PerformLayout();
            this.splitContainer1.Panel2.ResumeLayout(false);
            this.splitContainer1.Panel2.PerformLayout();
            ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
            this.splitContainer1.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.dgvResult)).EndInit();
            this.panel1.ResumeLayout(false);
            this.splitContainer2.Panel1.ResumeLayout(false);
            this.splitContainer2.Panel1.PerformLayout();
            this.splitContainer2.Panel2.ResumeLayout(false);
            this.splitContainer2.Panel2.PerformLayout();
            ((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).EndInit();
            this.splitContainer2.ResumeLayout(false);
            this.tabPage2.ResumeLayout(false);
            this.tabPage2.PerformLayout();
            this.tabPage3.ResumeLayout(false);
            this.tabPage3.PerformLayout();
            this.ResumeLayout(false);

        }

        #endregion

        private System.Windows.Forms.TabControl tabControl1;
        private System.Windows.Forms.TabPage tabPage1;
        private System.Windows.Forms.TabPage tabPage2;
        private System.Windows.Forms.TextBox txtClassTemplate;
        private System.Windows.Forms.TabPage tabPage3;
        private System.Windows.Forms.Button btnSaveConnection;
        private System.Windows.Forms.TextBox txtConnectionString;
        private System.Windows.Forms.Button btnTestConnection;
        private System.Windows.Forms.Button btnDelete;
        private System.Windows.Forms.Panel panel1;
        private System.Windows.Forms.SplitContainer splitContainer4;
        private System.Windows.Forms.SplitContainer splitContainer1;
        private System.Windows.Forms.TextBox txtSql;
        private System.Windows.Forms.Label label2;
        private System.Windows.Forms.Label label8;
        private System.Windows.Forms.TextBox txtClass;
        private System.Windows.Forms.Button btnGenerate;
        private System.Windows.Forms.Button btnViewFields;
        private System.Windows.Forms.DataGridView dgvResult;
        private System.Windows.Forms.ComboBox cmbClassTemplate;
        private System.Windows.Forms.Button btnCreateTemplate;
        private System.Windows.Forms.Button btnDeleteTemplate;
        private System.Windows.Forms.Button btnSaveTemplate;
        private System.Windows.Forms.ComboBox cmbConnections;
        private System.Windows.Forms.TextBox txtConnectionName;
        private System.Windows.Forms.Button btnNewConnection;
        private System.Windows.Forms.TextBox txtTemplateName;
        private System.Windows.Forms.SplitContainer splitContainer2;
        private System.Windows.Forms.ComboBox lstConnections;
        private System.Windows.Forms.Label label1;
        private System.Windows.Forms.ComboBox lstClassTemplate;
        private System.Windows.Forms.Label label3;
    }
}

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.VisualBasic;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Configuration;
using System.Text.RegularExpressions;
using ClassGenerator.ConfigSection;

namespace ClassGenerator
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        public bool IsNewConnection = true;
        public bool IsNewTemplate = true;
        public Dictionary<string, string> Connections { get; set; }
        public Dictionary<string, string> Templates { get; set; }
        public Dictionary<string, string> DefinedType = new Dictionary<string, string>();

        private void btnSaveConnection_Click(object sender, EventArgs e)
        {
            if (txtConnectionName.Text == string.Empty)
            {
                Interaction.MsgBox("Connection String Name can not be empty!", MsgBoxStyle.OkOnly);
                return;
            }

            if (cmbConnections.Items.Cast<KeyValuePair<string,string>>().ToList()
                .Exists(x => x.Key.Trim().ToUpper() == txtConnectionName.Text.Trim().ToUpper()))
            {
                if (IsNewConnection)
                {
                    Interaction.MsgBox("Connection String Name is aready exist!", MsgBoxStyle.OkOnly);
                    return;
                }
            }

            if (Program.MyConfigSection.Connections.Exists(txtConnectionName.Text))
            {
                Program.MyConfigSection.Connections[txtConnectionName.Text].Value = txtConnectionString.Text;
                Program.SaveMyConfigSection();
            }
            else
            {
                Program.MyConfigSection.Connections.Add(new ConfigSection.MyKeyValuePair(txtConnectionName.Text, txtConnectionString.Text));
                Program.SaveMyConfigSection();
            }

            Interaction.MsgBox("Connection String Save Completed !", MsgBoxStyle.OkOnly);

            RefreshConnectionList(txtConnectionName.Text);
        }

        private void RefreshConnectionList(string selectedKey = null)
        {
            Connections = new Dictionary<string, string>();
            Program.MyConfigSection.Connections.Cast<MyKeyValuePair>().ToList().ForEach(x => 
            {
                Connections.Add(x.Key, x.Value);
                Program.SaveMyConfigSection();
            });
                          

            var connectionName = cmbConnections.Text;
            cmbConnections.DataSource = new BindingSource(Connections, null);
            cmbConnections.DisplayMember = "Key";
            cmbConnections.ValueMember = "Value";

            lstConnections.DataSource = new BindingSource(Connections, null);
            lstConnections.DisplayMember = "Key";
            lstConnections.ValueMember = "Value";

            if (!string.IsNullOrWhiteSpace(selectedKey))
            {
                for (var i = 0; i < lstConnections.Items.Count; i++)
                {

                    var item = (KeyValuePair<string, string>)lstConnections.Items[i];
                    if (item.Key == selectedKey)
                    {
                        lstConnections.SelectedIndex = i;
                        cmbConnections.SelectedIndex = i;
                        return;
                    }
                }
            }

            if (lstConnections.Items.Count > 0)
            {
                lstConnections.SelectedIndex = 0;
                cmbConnections.SelectedIndex = 0;
            }
        }

        private void RefreshClassTemplateList(string selectedKey = null)
        {
            Templates = new Dictionary<string, string>();
            Program.MyConfigSection.Templates.Cast<MyKeyTextPair>().ToList().ForEach(x => 
            {
                Templates.Add(x.Key, x.Text);
                Program.SaveMyConfigSection();
            });

            cmbClassTemplate.DataSource = new BindingSource(Templates, null);
            cmbClassTemplate.DisplayMember = "Key";
            cmbClassTemplate.ValueMember = "Value";

            lstClassTemplate.DataSource = new BindingSource(Templates, null);
            lstClassTemplate.DisplayMember = "Key";
            lstClassTemplate.ValueMember = "Value";

            if (selectedKey != null)
            {
                for (var i = 0; i < cmbClassTemplate.Items.Count; i++)
                {
                    var item = (KeyValuePair<string, string>)cmbClassTemplate.Items[i];
                    if (item.Key == selectedKey)
                    {
                        cmbClassTemplate.SelectedIndex = i;
                        lstClassTemplate.SelectedIndex = i;
                        return;
                    }
                }
            }
            if (cmbClassTemplate.Items.Count > 0)
            {
                cmbClassTemplate.SelectedIndex = 0;
                lstClassTemplate.SelectedIndex = 0;
            }
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            Program.MyConfigSection.MappingTypes.Cast<MyKeyValuePair>().ToList().ForEach(item =>
            {
                this.DefinedType.Add(item.Key ,item.Value);
            });

            RefreshConnectionList();

            RefreshClassTemplateList();

            txtClassTemplate.Text = this.DefaultTemplate.Value;
        }

        private void cmbConnections_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cmbConnections.SelectedIndex > -1)
            {
                var item = (KeyValuePair<string,string>)cmbConnections.SelectedItem;
                txtConnectionString.Text = item.Value;
                txtConnectionName.Text = item.Key;
                IsNewConnection = false;
            }
        }

        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (Interaction.MsgBox("确定要删除吗?", MsgBoxStyle.YesNo) == MsgBoxResult.Yes)
            {
                if (cmbConnections.SelectedIndex > -1)
                {
                    if (Program.MyConfigSection.Connections.Exists(cmbConnections.Text))
                    {
                        Program.MyConfigSection.Connections.Remove(cmbConnections.Text);
                        Program.SaveMyConfigSection();
                    }
                    RefreshConnectionList();
                    if (cmbConnections.Items.Count > 0)
                        cmbConnections.SelectedIndex = 0;
                }
            }
        }

        private void btnTestConnection_Click(object sender, EventArgs e)
        {
            if (txtConnectionString.Text == string.Empty)
            {
                Interaction.MsgBox("请填写连接字符串!");
                return;
            }
            SqlConnection conn = new SqlConnection(txtConnectionString.Text);
            try
            {
                conn.Open();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                return;
            }

            MessageBox.Show("连接成功!");
            conn.Close();
        }

        private void btnGenerate_Click(object sender, EventArgs e)
        {

            
            try
            {
                btnGenerate.Enabled = false;
                using (var conn = new SqlConnection(Connections[lstConnections.Text]))
                {
                    var command = new SqlCommand(txtSql.Text, conn);
                    conn.Open();

                    StringBuilder sb = new StringBuilder();

                    var clsResult = command.ExecuteReader();
                    for (var i = 0; i < clsResult.GetSchemaTable().Rows.Count; i++)
                    {
                        var columName = clsResult.GetSchemaTable().Rows[i]["ColumnName"].ToString();
                        columName = columName.Replace(" ", string.Empty);
                        var firstUpperColumnName = string.IsNullOrEmpty(columName) ? string.Empty : columName.ToUpper()[0] + columName.Substring(1);

                        var item = ((KeyValuePair<string, string>)lstClassTemplate.SelectedItem).Value;

                        for (var j = 0; j < clsResult.GetSchemaTable().Columns.Count; j++)
                        {
                            var propertyName = clsResult.GetSchemaTable().Columns[j].ColumnName;
                            var propertyValue = clsResult.GetSchemaTable().Rows[i][clsResult.GetSchemaTable().Columns[j].ColumnName].ToString();

                            var exp = string.Format(@"{{${0}}}", propertyName);
                            item = item.Replace(exp, propertyValue);

                            exp = string.Format(@"{{$FisrtUpper({0})}}", propertyName);
                            item = item.Replace(exp, FirstUpper(propertyValue));

                            exp = string.Format(@"{{$DeleteSpace({0})}}", propertyName);
                            item = item.Replace(exp, DeleteSpace(propertyValue));

                            exp = string.Format(@"{{$SQLType({0})}}", propertyName);
                            item = item.Replace(exp, GetSqlTypeName(propertyValue));

                            exp = string.Format(@"{{$NullableType({0})}}", propertyName);
                            item = item.Replace(exp, GetSqlTypeName(propertyValue));
                        }

                        var pattern = @"\{\$DBNULL[^\}]+\}";
                        foreach (Match match in Regex.Matches(item, pattern))
                        {
                            var flag = match.Value.Replace(@"{$DBNULL(", string.Empty).Replace(")}", string.Empty);
                            var dataType = clsResult.GetSchemaTable().Rows[i]["DataType"] as Type;
                            var allowDBNull = (bool)clsResult.GetSchemaTable().Rows[i]["AllowDBNull"];
                            if (dataType.IsValueType && allowDBNull)
                            {
                                item = item.Replace(match.Value, flag);
                            }
                            else
                            {
                                item = item.Replace(match.Value, string.Empty);
                            }
                        }

                        sb.AppendLine(item);
                    }

                    sb.Insert(0, "\r\n");
                    sb.Replace("\r\n", "\r\n\t");
                    sb.Insert(0, "class Class1 {");
                    sb.AppendLine("\r\n}");

                    txtClass.Text = sb.ToString();

                    var dt = new DataTable();
                    dt.Load(clsResult);

                    dgvResult.DataSource = dt;
                    btnGenerate.Enabled = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                btnGenerate.Enabled = true;
            }
            
        }

        private void btnViewFields_Click(object sender, EventArgs e)
        {
            try
            {
                btnViewFields.Enabled = false;
                using (var conn = new SqlConnection(Connections[lstConnections.Text]))
                {
                    var command = new SqlCommand(txtSql.Text, conn);
                    conn.Open();

                    var fieldList = new DataTable();
                    var clsResult = command.ExecuteReader();
                    for (var i = 0; i < clsResult.GetSchemaTable().Columns.Count; i++)
                    {
                        fieldList.Columns.Add(clsResult.GetSchemaTable().Columns[i].ColumnName, typeof(string));
                    }

                    for (var i = 0; i < clsResult.GetSchemaTable().Rows.Count; i++)
                    {
                        var row = fieldList.NewRow();
                        for (var j = 0; j < clsResult.GetSchemaTable().Columns.Count; j++)
                        {
                            row[clsResult.GetSchemaTable().Columns[j].ColumnName] = clsResult.GetSchemaTable().Rows[i][clsResult.GetSchemaTable().Columns[j].ColumnName].ToString();
                        }
                        fieldList.Rows.Add(row);
                    }

                    var frm = new frmFieldInfo();
                    frm.ResultList.DataSource = fieldList;
                    frm.Show(this);

                    btnViewFields.Enabled = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                btnViewFields.Enabled = true;
            }
        }

        private string GetSqlTypeName(string sqlTypeName)
        {
            if (this.DefinedType.ContainsKey(sqlTypeName))
            {
                return this.DefinedType[sqlTypeName];
            }
            else
            {
                return string.Format("Undefined Sql Type '{0}'", sqlTypeName);
            }
        }

        private string FirstUpper(string property)
        {
            if (property.Length > 0)
            {
                var firstChar = property[0];
                return firstChar.ToString().ToUpper() + property.Substring(1);
            }
            else
            {
                return property;
            }
        }

        private string DeleteSpace(string property)
        {
            return property.Replace(" ", "");
        }

        private string GetDBNullType(string property)
        {
            return null;
        }

        private KeyValuePair<string,string> DefaultTemplate
        {
            get
            {
                var item = "[DataMapping(\"{$ColumnName}\", DbType.{$SQLType(DataTypeName)})]";
                item += "\r\n";
                item += "public {$DataType}{$DBNULL(?)} {$ColumnName} { get; set; }";
                item += "\r\n";

                return new KeyValuePair<string, string>("SampleTemplate", item);
            }
        }

        private void btnNewConnection_Click(object sender, EventArgs e)
        {
            cmbConnections.SelectedIndex = -1;
            txtConnectionString.Text = string.Empty;
            txtConnectionName.Text = string.Empty;
            IsNewConnection = true;
        }

        private void btnCreateTemplate_Click(object sender, EventArgs e)
        {
            cmbClassTemplate.SelectedIndex = -1;
            txtClassTemplate.Text = string.Empty;
            txtTemplateName.Text = string.Empty;
            IsNewTemplate = true;
        }

        private void btnSaveTemplate_Click(object sender, EventArgs e)
        {
            if (txtTemplateName.Text == string.Empty)
            {
                Interaction.MsgBox("Template Name can not be empty!", MsgBoxStyle.OkOnly);
                return;
            }

            if (cmbClassTemplate.Items.Cast<KeyValuePair<string,string>>().ToList().
                Exists(x => x.Key.Trim().ToUpper() == txtTemplateName.Text.Trim().ToUpper()))
            {
                if (IsNewTemplate)
                {
                    Interaction.MsgBox("Template Name is aready exist!", MsgBoxStyle.OkOnly);
                    return;
                }
            }

            if (Program.MyConfigSection.Templates.Exists(txtTemplateName.Text))
            {
                
                Program.MyConfigSection.Templates[txtTemplateName.Text].Text = txtClassTemplate.Text;
                Program.SaveMyConfigSection();
            }
            else
            {
                Program.MyConfigSection.Templates.Add(new MyKeyTextPair(txtTemplateName.Text, txtClassTemplate.Text));
                Program.SaveMyConfigSection();
            }

            Interaction.MsgBox("Template Save Completed !", MsgBoxStyle.OkOnly);

            RefreshClassTemplateList(txtTemplateName.Text);
        }

        private void btnDeleteTemplate_Click(object sender, EventArgs e)
        {
            if (Interaction.MsgBox("确定要删除吗?", MsgBoxStyle.YesNo) == MsgBoxResult.Yes)
            {
                if (cmbClassTemplate.SelectedIndex > -1)
                {
                    if (Program.MyConfigSection.Templates.Exists(txtTemplateName.Text))
                    {
                        Program.MyConfigSection.Templates.Remove(txtTemplateName.Text);
                        Program.SaveMyConfigSection();
                    }
                    RefreshClassTemplateList();
                    if (cmbClassTemplate.Items.Count > 0)
                        cmbClassTemplate.SelectedIndex = 0;
                }
            }
        }

        private void cmbClassTemplate_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cmbClassTemplate.SelectedIndex > -1)
            {
                var item = (KeyValuePair<string,string>)cmbClassTemplate.SelectedItem;
                txtClassTemplate.Text = item.Value;
                txtTemplateName.Text = item.Key;
                IsNewTemplate = false;
            }
        }
    }
}

 

posted on 2012-06-28 16:44  空明流光  阅读(300)  评论(0编辑  收藏  举报

导航