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

📄 autocreatecode.cs

📁 一款自动编码工具
💻 CS
📖 第 1 页 / 共 4 页
字号:
using System;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Text;
namespace AutoCreateCode
{
	/// <summary>
	/// Form1 的摘要说明。
	/// </summary>
	public class AutoCreateCode : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Button button_create;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.DataGridTableStyle tabcolumns;
		private System.Windows.Forms.DataGridTextBoxColumn column_name;
		private System.Windows.Forms.DataGridTextBoxColumn type_name;
		private System.Windows.Forms.DataGridTextBoxColumn length;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.TextBox textBox_Username;
		private System.Windows.Forms.StatusBar statusBar1;
		private System.Windows.Forms.MainMenu mainMenu1;
		private System.Windows.Forms.MenuItem menuItem1;
		private System.Windows.Forms.MenuItem menuItem2;
		private System.Windows.Forms.TextBox txttabname;
		private System.Windows.Forms.MenuItem menuItem3;
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;
		private System.Windows.Forms.TreeView DBTreeView;
		private System.Windows.Forms.RichTextBox richTextBox;
		private System.Windows.Forms.MenuItem cut;
		private System.Windows.Forms.ContextMenu contextMenu;
		private System.Windows.Forms.MenuItem Copy;
		private System.Windows.Forms.MenuItem Paste;
		private System.Windows.Forms.MenuItem Del;
		private System.Windows.Forms.Label label3;
		private System.Windows.Forms.TextBox txtNameSpace;
		private static DBConn sqlconn;
		public AutoCreateCode()
		{
			
			//
			// Windows 窗体设计器支持所必需的
			//
			InitializeComponent();

			string filePath		=	Application.StartupPath+@"\config.ini";
			sqlconn = new DBConn( filePath );
			
			//LoadData();
				
			//
			// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
			//
		}

		/// <summary>
		/// 清理所有正在使用的资源。
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if (components != null) 
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows 窗体设计器生成的代码
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{
			this.button_create = new System.Windows.Forms.Button();
			this.label1 = new System.Windows.Forms.Label();
			this.txttabname = new System.Windows.Forms.TextBox();
			this.tabcolumns = new System.Windows.Forms.DataGridTableStyle();
			this.column_name = new System.Windows.Forms.DataGridTextBoxColumn();
			this.type_name = new System.Windows.Forms.DataGridTextBoxColumn();
			this.length = new System.Windows.Forms.DataGridTextBoxColumn();
			this.label2 = new System.Windows.Forms.Label();
			this.textBox_Username = new System.Windows.Forms.TextBox();
			this.statusBar1 = new System.Windows.Forms.StatusBar();
			this.mainMenu1 = new System.Windows.Forms.MainMenu();
			this.menuItem1 = new System.Windows.Forms.MenuItem();
			this.menuItem2 = new System.Windows.Forms.MenuItem();
			this.menuItem3 = new System.Windows.Forms.MenuItem();
			this.DBTreeView = new System.Windows.Forms.TreeView();
			this.richTextBox = new System.Windows.Forms.RichTextBox();
			this.contextMenu = new System.Windows.Forms.ContextMenu();
			this.cut = new System.Windows.Forms.MenuItem();
			this.Copy = new System.Windows.Forms.MenuItem();
			this.Paste = new System.Windows.Forms.MenuItem();
			this.Del = new System.Windows.Forms.MenuItem();
			this.label3 = new System.Windows.Forms.Label();
			this.txtNameSpace = new System.Windows.Forms.TextBox();
			this.SuspendLayout();
			// 
			// button_create
			// 
			this.button_create.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
			this.button_create.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
			this.button_create.Location = new System.Drawing.Point(512, 40);
			this.button_create.Name = "button_create";
			this.button_create.Size = new System.Drawing.Size(64, 23);
			this.button_create.TabIndex = 0;
			this.button_create.Text = "生  成";
			this.button_create.Click += new System.EventHandler(this.button_create_Click);
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(176, 40);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(56, 23);
			this.label1.TabIndex = 1;
			this.label1.Text = "表  名:";
			this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// txttabname
			// 
			this.txttabname.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right)));
			this.txttabname.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.txttabname.Location = new System.Drawing.Point(232, 40);
			this.txttabname.Name = "txttabname";
			this.txttabname.Size = new System.Drawing.Size(272, 21);
			this.txttabname.TabIndex = 2;
			this.txttabname.Text = "";
			// 
			// tabcolumns
			// 
			this.tabcolumns.DataGrid = null;
			this.tabcolumns.GridColumnStyles.AddRange(new System.Windows.Forms.DataGridColumnStyle[] {
																										 this.column_name,
																										 this.type_name,
																										 this.length});
			this.tabcolumns.HeaderForeColor = System.Drawing.SystemColors.ControlText;
			this.tabcolumns.MappingName = "";
			// 
			// column_name
			// 
			this.column_name.Format = "";
			this.column_name.FormatInfo = null;
			this.column_name.MappingName = "column_name";
			this.column_name.Width = 75;
			// 
			// type_name
			// 
			this.type_name.Format = "";
			this.type_name.FormatInfo = null;
			this.type_name.MappingName = "type_name";
			this.type_name.Width = 75;
			// 
			// length
			// 
			this.length.Format = "";
			this.length.FormatInfo = null;
			this.length.MappingName = "length";
			this.length.Width = 75;
			// 
			// label2
			// 
			this.label2.Location = new System.Drawing.Point(176, 8);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(56, 23);
			this.label2.TabIndex = 4;
			this.label2.Text = "用户名:";
			this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// textBox_Username
			// 
			this.textBox_Username.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right)));
			this.textBox_Username.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.textBox_Username.Location = new System.Drawing.Point(232, 8);
			this.textBox_Username.Name = "textBox_Username";
			this.textBox_Username.Size = new System.Drawing.Size(104, 21);
			this.textBox_Username.TabIndex = 5;
			this.textBox_Username.Text = "";
			// 
			// statusBar1
			// 
			this.statusBar1.Location = new System.Drawing.Point(0, 363);
			this.statusBar1.Name = "statusBar1";
			this.statusBar1.Size = new System.Drawing.Size(592, 22);
			this.statusBar1.TabIndex = 6;
			this.statusBar1.Text = "代码生成器";
			// 
			// mainMenu1
			// 
			this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					  this.menuItem1});
			// 
			// menuItem1
			// 
			this.menuItem1.Index = 0;
			this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					  this.menuItem2,
																					  this.menuItem3});
			this.menuItem1.Text = "系统设置";
			// 
			// menuItem2
			// 
			this.menuItem2.Index = 0;
			this.menuItem2.Text = "数据库连接";
			this.menuItem2.Click += new System.EventHandler(this.menuItem2_Click);
			// 
			// menuItem3
			// 
			this.menuItem3.Index = 1;
			this.menuItem3.Text = "连接数据库";
			this.menuItem3.Click += new System.EventHandler(this.menuItem3_Click);
			// 
			// DBTreeView
			// 
			this.DBTreeView.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
				| System.Windows.Forms.AnchorStyles.Left)));
			this.DBTreeView.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.DBTreeView.ImageIndex = -1;
			this.DBTreeView.Location = new System.Drawing.Point(0, 0);
			this.DBTreeView.Name = "DBTreeView";
			this.DBTreeView.SelectedImageIndex = -1;
			this.DBTreeView.Size = new System.Drawing.Size(168, 360);
			this.DBTreeView.TabIndex = 8;
			this.DBTreeView.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.DBTreeView_AfterSelect);
			// 
			// richTextBox
			// 
			this.richTextBox.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.richTextBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.richTextBox.ContextMenu = this.contextMenu;
			this.richTextBox.Location = new System.Drawing.Point(168, 72);
			this.richTextBox.Name = "richTextBox";
			this.richTextBox.Size = new System.Drawing.Size(416, 288);
			this.richTextBox.TabIndex = 9;
			this.richTextBox.Text = "";
			// 
			// contextMenu
			// 
			this.contextMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																						this.cut,
																						this.Copy,
																						this.Paste,
																						this.Del});
			// 
			// cut
			// 
			this.cut.Index = 0;
			this.cut.Text = "剪切(&T)";
			this.cut.Click += new System.EventHandler(this.cut_Click);
			// 
			// Copy
			// 
			this.Copy.Index = 1;
			this.Copy.Text = "复制(&C)";
			this.Copy.Click += new System.EventHandler(this.Copy_Click);
			// 
			// Paste
			// 
			this.Paste.Index = 2;
			this.Paste.Text = "粘贴(&P)";
			this.Paste.Click += new System.EventHandler(this.Paste_Click);
			// 
			// Del
			// 
			this.Del.Index = 3;
			this.Del.Text = "删除(&D)";
			this.Del.Click += new System.EventHandler(this.Del_Click);
			// 
			// label3
			// 
			this.label3.Location = new System.Drawing.Point(352, 8);
			this.label3.Name = "label3";
			this.label3.Size = new System.Drawing.Size(80, 23);
			this.label3.TabIndex = 10;
			this.label3.Text = "命名空间:";
			this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// txtNameSpace
			// 
			this.txtNameSpace.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right)));
			this.txtNameSpace.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.txtNameSpace.Location = new System.Drawing.Point(432, 8);
			this.txtNameSpace.Name = "txtNameSpace";
			this.txtNameSpace.Size = new System.Drawing.Size(104, 21);
			this.txtNameSpace.TabIndex = 11;
			this.txtNameSpace.Text = "NoahArk_Perform.CommonComponent";
			// 
			// AutoCreateCode
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(592, 385);
			this.Controls.Add(this.txtNameSpace);
			this.Controls.Add(this.label3);
			this.Controls.Add(this.richTextBox);
			this.Controls.Add(this.DBTreeView);
			this.Controls.Add(this.statusBar1);
			this.Controls.Add(this.textBox_Username);
			this.Controls.Add(this.label2);
			this.Controls.Add(this.txttabname);
			this.Controls.Add(this.label1);
			this.Controls.Add(this.button_create);
			this.Menu = this.mainMenu1;
			this.Name = "AutoCreateCode";
			this.Text = "自动生成类代码";
			this.ResumeLayout(false);

		}
		#endregion

		/// <summary>
		/// 应用程序的主入口点。
		/// </summary>
		[STAThread]
		static void Main() 
		{
			Application.Run(new AutoCreateCode());
		}

		private void LoadData()
		{
			DataTable dtDataBase	=	sqlconn.GetDataBaseName();
			
			if( dtDataBase != null )
			{
		
				for( int i = 0; i < dtDataBase.Rows.Count; i++ )
				{

⌨️ 快捷键说明

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