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

📄 frmmain.cs

📁 LLBLGen 1.21 Sourcecode
💻 CS
📖 第 1 页 / 共 3 页
字号:
//////////////////////////////////////////////////////////////////////
// Part of LLBLGen sourcecode. See version information
//////////////////////////////////////////////////////////////////////
// COPYRIGHTS:
// Copyright (c)2002 Solutions Design. All rights reserved.
// 
// Released under the following license: (BSD2)
// -------------------------------------------
// Redistribution and use in source and binary forms, with or without modification, 
// are permitted provided that the following conditions are met: 
//
// 1) Redistributions of source code must retain the above copyright notice, this list of 
//    conditions and the following disclaimer. 
// 2) Redistributions in binary form must reproduce the above copyright notice, this list of 
//    conditions and the following disclaimer in the documentation and/or other materials 
//    provided with the distribution. 
// 
// THIS SOFTWARE IS PROVIDED BY SOLUTIONS DESIGN ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, 
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 
// PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SOLUTIONS DESIGN OR CONTRIBUTORS BE LIABLE FOR 
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 
// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 
// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
//
// The views and conclusions contained in the software and documentation are those of the authors 
// and should not be interpreted as representing official policies, either expressed or implied, 
// of Solutions Design. 
//
//////////////////////////////////////////////////////////////////////
// Contributers to the code:
//		- Frans Bouma [FB]
//////////////////////////////////////////////////////////////////////
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;
using System.Text;
using System.Reflection;

namespace LLBLGen
{

	public enum eConnectionStringRetrieval:int
	{
		AppConfig,
		Property,
		ConstructionString		// COM+ Services only
	}
	
	public enum eDotNetLanguages:int
	{
		CSharp,
		VBDotNet
	}
	
	public enum eSQLObjectType:int
	{
		Table,
		View
	}


	/// <summary>
	/// Purpose: The main gui
	/// </summary>
	public class frmMain : System.Windows.Forms.Form
	{
		#region Class Constant Declarations
			public const string sBUILDTYPE = "Final";
			public const string sRELEASEDATE = "08212002";
		#endregion

		#region Class Member Declarations
		private short					m_siProgressPct;
		private clsLLBLGenerator		m_lgGenerator;
		private clsApplicationParams	m_apApplicationParams;
		private string					m_sAppVersion;
		private System.ComponentModel.Container components = null;
		private System.Windows.Forms.StatusBar sbMain;
		private System.Windows.Forms.StatusBarPanel sbpServer;
		private System.Windows.Forms.StatusBarPanel sbpCatalog;
		private System.Windows.Forms.StatusBarPanel sbpCopyright;
		private System.Windows.Forms.TabControl tclMain;
		private System.Windows.Forms.TabPage tbpConnection;
		private System.Windows.Forms.TabPage tbpTables;
		private System.Windows.Forms.TabPage tbpSPParams;
		private System.Windows.Forms.TabPage tbpGenerator;
		private System.Windows.Forms.Button btnC_Connect;
		private System.Windows.Forms.Label label11;
		private System.Windows.Forms.TextBox tbxC_Catalog;
		private System.Windows.Forms.GroupBox grpC_SQLServerCredentials;
		private System.Windows.Forms.TextBox tbxC_Password;
		private System.Windows.Forms.TextBox tbxC_LoginID;
		private System.Windows.Forms.Label label12;
		private System.Windows.Forms.Label label13;
		private System.Windows.Forms.RadioButton rbtC_SQLAuthentication;
		private System.Windows.Forms.RadioButton rbtC_WindowsAuthentication;
		private System.Windows.Forms.Label label14;
		private System.Windows.Forms.TextBox tbxC_Server;
		private System.Windows.Forms.Button btnT_ToggleSelected;
		private System.Windows.Forms.Label label15;
		private System.Windows.Forms.ListView lvT_Tables;
		private System.Windows.Forms.Label label9;
		private System.Windows.Forms.GroupBox groupBox1;
		private System.Windows.Forms.Label label5;
		private System.Windows.Forms.CheckBox chkSP_GenerateSelectAllSPs;
		private System.Windows.Forms.CheckBox chkSP_PrefixParams;
		private System.Windows.Forms.CheckBox chkSP_GenerateDeleteSPs;
		private System.Windows.Forms.CheckBox chkSP_GenerateInsertSPs;
		private System.Windows.Forms.CheckBox chkSP_GenerateUpdateSPs;
		private System.Windows.Forms.CheckBox chkSP_GenerateSelectSPs;
		private System.Windows.Forms.CheckBox chkSP_IncludeSPComments;
		private System.Windows.Forms.CheckBox chkSP_IncludeDrops;
		private System.Windows.Forms.Label label6;
		private System.Windows.Forms.TextBox tbxSP_SPPrefix;
		private System.Windows.Forms.Button btnG_Start;
		private System.Windows.Forms.TextBox tbxG_SPOutputPath;
		private System.Windows.Forms.Label label8;
		private System.Windows.Forms.Label label7;
		private System.Windows.Forms.Button btnG_BrowseForSPPath;
		private System.Windows.Forms.Label label4;
		private System.Windows.Forms.Label label3;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.CheckBox chkSP_IncludeErrorCodeSupport;
		private System.Windows.Forms.GroupBox groupBox3;
		private System.Windows.Forms.RadioButton rbtSP_UseFieldListSelectClause;
		private System.Windows.Forms.RadioButton rbtSP_UseAsterixSelectClause;
		private System.Windows.Forms.Button btnC_Disconnect;
		private System.Windows.Forms.Button btnG_About;
		private System.Windows.Forms.Button btnG_Close;
		private System.Windows.Forms.TextBox tbxG_Feedback;
		private System.Windows.Forms.ProgressBar pbG_Main;
		private System.Windows.Forms.ColumnHeader lvcT_TableHeader;
		private System.Windows.Forms.Label label16;
		private System.Windows.Forms.GroupBox groupBox4;
		private System.Windows.Forms.TabPage tbpNETParams;
		private System.Windows.Forms.Label label17;
		private System.Windows.Forms.ComboBox cbxNET_OutputLanguage;
		private System.Windows.Forms.RadioButton rbtNET_ConnectionStringRetrieval_COMPlus;
		private System.Windows.Forms.RadioButton rbtNET_ConnectionStringRetrieval_Property;
		private System.Windows.Forms.RadioButton rbtNET_ConnectionStringRetrieval_AppConfig;
		private System.Windows.Forms.CheckBox chkNET_IncludeCOMPlusSupport;
		private System.Windows.Forms.CheckBox chkNET_IncludeNullValueSupport;
		private System.Windows.Forms.CheckBox chkNET_IncludeTransactionSupport;
		private System.Windows.Forms.CheckBox chkNET_IncludeObjectPoolingSupport;
		private System.Windows.Forms.CheckBox chkNET_IncludeLoadBalancingSupport;
		private System.Windows.Forms.CheckBox chkNET_IncludeJITSupport;
		private System.Windows.Forms.CheckBox chkNET_IncludeAutoComplete;
		private System.Windows.Forms.TextBox tbxNET_ClassPrefix;
		private System.Windows.Forms.CheckBox chkNET_PrefixProperties;
		private System.Windows.Forms.RadioButton rbtNET_StyleHungarian;
		private System.Windows.Forms.RadioButton rbtNET_StyleMicrosoft;
		private System.Windows.Forms.CheckBox chkNET_IncludeCSComments;
		private System.Windows.Forms.TextBox tbxNET_Namespace;
		private System.Windows.Forms.GroupBox grpNET_COMPlusOptions;
		private System.Windows.Forms.TextBox tbxG_NETOutputPath;
		private System.Windows.Forms.Button btnG_BrowseForNETPath;
		private System.Windows.Forms.CheckBox chkNET_IncludeConnectionProviderSupport;
		private System.Windows.Forms.ColumnHeader lvcT_TableTypeHeader;
		private System.Windows.Forms.GroupBox groupBox9;
		private System.Windows.Forms.Button btnSP_RefreshExcludedFieldsList;
		private System.Windows.Forms.Button btnSP_ToggleSelected;
		private System.Windows.Forms.Label label10;
		private System.Windows.Forms.ListView lvSP_ExcludedFields;
		private System.Windows.Forms.ColumnHeader lvcSP_FieldName;
		private System.Windows.Forms.ColumnHeader lvcSP_FieldType;
		private System.Windows.Forms.TextBox tbxG_CurrentTable;
		private System.Windows.Forms.TextBox tbxG_OverallPct;
		private System.Windows.Forms.GroupBox grpConnection;
		private System.Windows.Forms.GroupBox grpTablesViews;
		private System.Windows.Forms.GroupBox grpNETCode;
		private System.Windows.Forms.GroupBox grpTSQLCode;
		private System.Windows.Forms.GroupBox grpGenerator_Progress;
		private System.Windows.Forms.GroupBox grpGenerator_Params;
		private System.Windows.Forms.CheckBox chkSP_IncludeNoCountStatements;
		#endregion

		/// <summary>
		/// Purpose: Constructor.
		/// </summary>
		public frmMain()
		{
			m_lgGenerator = new clsLLBLGenerator();

			InitializeComponent();

			// Initialize application
			InitializeApplication();
			
			this.MinimumSize = this.Size;

			Assembly asmThis = Assembly.GetExecutingAssembly();
			Version verThis = asmThis.GetName().Version;
			
			this.Text += " version: " + verThis.Major + "." + verThis.Minor + " " + sBUILDTYPE;
			m_sAppVersion = verThis.Major + "." + verThis.Minor + "." + verThis.Build + "." + verThis.Revision + " " + sBUILDTYPE;
		}


		/// <summary>
		/// Purpose: reads, if available, a serialized clsApplicationParams object from disk and
		/// initializes the gui with these settings.
		/// </summary>
		private void InitializeApplication()
		{
			m_siProgressPct=0;

			try
			{
				// read back a serialized instance. If it's not available, a new instance is returned.
				m_apApplicationParams = clsApplicationParams.RetrieveSerialized();
				
				// reflect the settings in m_apApplicationParams in the gui
				ApplyApplicationParamsToGui();
			}
			catch(Exception ex)
			{
				// an exception is caught. View it.
				frmException wExceptionViewer = new frmException(ex);
				wExceptionViewer.ShowDialog();
			}
		}

		
		/// <summary>
		/// Purpose: resets the gui and applies all settings currently in m_apApplicationParams
		/// to the gui controls
		/// </summary>
		private void ApplyApplicationParamsToGui()
		{
			// stop gui processing until all controls are reset.
			this.SuspendLayout();

		 	btnC_Connect.Enabled=true;
		 	btnC_Disconnect.Enabled=false;
		 	tbxC_Catalog.Enabled=true;
		 	tbxC_Server.Enabled=true;
		 	rbtC_WindowsAuthentication.Enabled=true;
		 	rbtC_SQLAuthentication.Enabled=true;
		 	grpC_SQLServerCredentials.Enabled=false;
		 	rbtC_WindowsAuthentication.Checked=true;
		 	sbpServer.Text = "Not connected";
		 	sbpCatalog.Text = "Not connected";
		 	lvT_Tables.Items.Clear();
			lvSP_ExcludedFields.Items.Clear();
		 	tbxG_CurrentTable.Text="";
		 	pbG_Main.Minimum=0;
		 	pbG_Main.Maximum=100;
		 	pbG_Main.Value=0;
		 	tbxG_OverallPct.Text="0 %";
		 	tbxC_Password.Text = "";			// always clear password. This field is not serialized.
		 	chkNET_PrefixProperties.Enabled=false;
			rbtNET_ConnectionStringRetrieval_AppConfig.Checked = true;
			
			// Apply all settings to the gui controls.
			chkNET_IncludeAutoComplete.Checked = m_apApplicationParams.bNETIncludeAutoComplete;
			chkNET_IncludeCSComments.Checked = m_apApplicationParams.bNETIncludeComments;
			chkNET_IncludeJITSupport.Checked = m_apApplicationParams.bNETIncludeJITSupport;
			chkNET_IncludeLoadBalancingSupport.Checked = m_apApplicationParams.bNETIncludeLoadBalancingSupport;
			chkNET_IncludeObjectPoolingSupport.Checked = m_apApplicationParams.bNETIncludeObjectPoolingSupport;
			chkNET_IncludeConnectionProviderSupport.Checked = m_apApplicationParams.bNETIncludeConnectionProviderSupport;
			rbtNET_StyleHungarian.Checked = m_apApplicationParams.bNETStyleHungarian;
			rbtNET_StyleMicrosoft.Checked = !m_apApplicationParams.bNETStyleHungarian;
			chkNET_PrefixProperties.Checked = m_apApplicationParams.bNETPrefixProperties;
			chkNET_PrefixProperties.Enabled = rbtNET_StyleHungarian.Checked;
			chkSP_GenerateDeleteSPs.Checked = m_apApplicationParams.bSPGenerateDeleteSPs;
			chkSP_GenerateInsertSPs.Checked = m_apApplicationParams.bSPGenerateInsertSPs;
			chkSP_GenerateUpdateSPs.Checked = m_apApplicationParams.bSPGenerateUpdateSPs;
			chkSP_GenerateSelectSPs.Checked = m_apApplicationParams.bSPGenerateSelectSPs;
			chkSP_GenerateSelectAllSPs.Checked = m_apApplicationParams.bSPGenerateSelectAllSPs;
			chkSP_IncludeSPComments.Checked = m_apApplicationParams.bSPIncludeComments;
			chkNET_IncludeCOMPlusSupport.Checked = m_apApplicationParams.bNETIncludeCOMPlusSupport;
			grpNET_COMPlusOptions.Enabled = m_apApplicationParams.bNETIncludeCOMPlusSupport;
			chkSP_IncludeDrops.Checked = m_apApplicationParams.bSPIncludeDrops;
			chkSP_IncludeErrorCodeSupport.Checked = m_apApplicationParams.bSPIncludeErrorCodeSupport;
			chkNET_IncludeNullValueSupport.Checked = m_apApplicationParams.bNETIncludeNullValueSupport;
			chkSP_IncludeNoCountStatements.Checked = m_apApplicationParams.bSPIncludeNoCountStatements;
			chkNET_IncludeTransactionSupport.Checked = m_apApplicationParams.bNETIncludeTransactionSupport;
			chkSP_PrefixParams.Checked = m_apApplicationParams.bSPPrefixParams;
			rbtSP_UseFieldListSelectClause.Checked = m_apApplicationParams.bSPUseFieldListSelectClause;
			rbtSP_UseAsterixSelectClause.Checked = !m_apApplicationParams.bSPUseFieldListSelectClause;
			rbtC_SQLAuthentication.Checked = !m_apApplicationParams.bSQLWindowsAuthentication;
			rbtC_WindowsAuthentication.Checked = m_apApplicationParams.bSQLWindowsAuthentication;
			tbxC_Catalog.Text = m_apApplicationParams.sSQLCatalog;
			tbxC_Server.Text = m_apApplicationParams.sSQLServer;
			tbxNET_Namespace.Text = m_apApplicationParams.sNETNamespace;
			tbxNET_ClassPrefix.Text = m_apApplicationParams.sNETClassPrefix;
			tbxG_NETOutputPath.Text = m_apApplicationParams.sNETOutputPath;
			tbxSP_SPPrefix.Text = m_apApplicationParams.sSPNamePrefix;
			tbxG_SPOutputPath.Text = m_apApplicationParams.sSPOutputPath;
			tbxC_LoginID.Text = m_apApplicationParams.sSQLUID;
			switch(m_apApplicationParams.iNETConnectionStringRetrieval)
			{
				case (int)eConnectionStringRetrieval.AppConfig:
					rbtNET_ConnectionStringRetrieval_AppConfig.Checked = true;
					break;
				case (int)eConnectionStringRetrieval.ConstructionString:
					rbtNET_ConnectionStringRetrieval_COMPlus.Checked = true;
					break;
				case (int)eConnectionStringRetrieval.Property:
					rbtNET_ConnectionStringRetrieval_Property.Checked = true;
					break;
			}

⌨️ 快捷键说明

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