HELP!!!! SQLEXPRESS and Connection Issue


Author
Message
Ross L. Rooker, Sr.
Ross L. Rooker, Sr.
StrataFrame User (189 reputation)StrataFrame User (189 reputation)StrataFrame User (189 reputation)StrataFrame User (189 reputation)StrataFrame User (189 reputation)StrataFrame User (189 reputation)StrataFrame User (189 reputation)StrataFrame User (189 reputation)StrataFrame User (189 reputation)
Group: Forum Members
Posts: 153, Visits: 462
I was using the 6 month trial on SQL 2008 and had to create the same database in SQL Express 2008. Both are identical with the same user ID and password to get into that database for both. When I set the default connection to SQL 2008 and start my application the log in appears instantly. When I set the default connection to SQL Express when I start the app there is a 60 second delay and then the Connect Manager appears. I simply SELECT the default connect of SQL Express and the login instantly appears. What can be going on? It is almost as though the delay is some kind of a timeout in relation to SQL EXpress that then causes the Connect Manager to appear. I am running the latest version of StrataFrame
Edhy Rijo
E
StrataFrame VIP (3.7K reputation)StrataFrame VIP (3.7K reputation)StrataFrame VIP (3.7K reputation)StrataFrame VIP (3.7K reputation)StrataFrame VIP (3.7K reputation)StrataFrame VIP (3.7K reputation)StrataFrame VIP (3.7K reputation)StrataFrame VIP (3.7K reputation)StrataFrame VIP (3.7K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi Ross,
Check your connection string which may be pointing to the SQL Sever trial and not the Express edition.  Also If you don't need the trial of SQL Sever, then uninstall it. 

Edhy Rijo

Keith Chisarik
Keith Chisarik
StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)
Group: StrataFrame Users
Posts: 939, Visits: 40K
Yup... sounds like it is trying to use your old connection string. Search this forum for connections.dat and delete that file to reset it, or add a call to the connection manager in AppMain .

Keith Chisarik
Ross L. Rooker, Sr.
Ross L. Rooker, Sr.
StrataFrame User (189 reputation)StrataFrame User (189 reputation)StrataFrame User (189 reputation)StrataFrame User (189 reputation)StrataFrame User (189 reputation)StrataFrame User (189 reputation)StrataFrame User (189 reputation)StrataFrame User (189 reputation)StrataFrame User (189 reputation)
Group: Forum Members
Posts: 153, Visits: 462
I already tried deleting the connection.dat files and the first time in, then connection manager appeared. I pointed to the SQL Express. Then my login instantly appeared. I logged in and created a menu option to display the connection string. It is pointed to SQLEXPRESS. Then I log out of the app, click the icon to restart the app.  For about 10 seconds I see the cursor as a waitcursor, then it is the default cursor for 20 seconds, then before the login screen appears, then connection manager appears displaying the default connection. I click on it. then click SELECT, then the login screen immediately appears and everything works fast at this point.

I also stopped the trial version of SQL Server to make sure that wasn't even running.

This app does have security with RBS as a part of the app. I am not certain what the framework may be waiting for when it is trying to open the default connection, then displaying the connection manager when it is okay.


Ivan George Borges
Ivan George Borges
Strategic Support Team Member (2.8K reputation)Strategic Support Team Member (2.8K reputation)Strategic Support Team Member (2.8K reputation)Strategic Support Team Member (2.8K reputation)Strategic Support Team Member (2.8K reputation)Strategic Support Team Member (2.8K reputation)Strategic Support Team Member (2.8K reputation)Strategic Support Team Member (2.8K reputation)Strategic Support Team Member (2.8K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
Ross L. Rooker, Sr. (2/5/2012)
... then before the login screen appears, then connection manager appears displaying the default connection. I click on it. then click SELECT, then the login screen immediately appears and everything works fast at this point.

Are you calling ConnectionManager.ShowAvailableConnectionStrings() somewhere for some reason?
Ross L. Rooker, Sr.
Ross L. Rooker, Sr.
StrataFrame User (189 reputation)StrataFrame User (189 reputation)StrataFrame User (189 reputation)StrataFrame User (189 reputation)StrataFrame User (189 reputation)StrataFrame User (189 reputation)StrataFrame User (189 reputation)StrataFrame User (189 reputation)StrataFrame User (189 reputation)
Group: Forum Members
Posts: 153, Visits: 462
Yes in the programs.cs there is this code: So it appears as though after I saved the database for my application from SQL 2008 Trial Edition and then restored to SQL Express 2008 that the RBS files are not being found on startup and that is why connection manager is displaying. The RBS files are located in the database with the user tables.

               //-- ToDo:  Configure the security settings
                //--------------------------------------------
                //-- Retrieve the global preferences
                try
                {
                    SFSPreferencesBO.RetrieveSecurityPreferences();
                }
                catch
                {
                        if (ConnectionManager.ShowAvailableConnectionStrings())
                        {
                            // Set the connections
                            ConnectionManager.SetConnections();


                            SFSPreferencesBO.RetrieveSecurityPreferences();
                        }
                }


Here is the entire programs.cs:

using MicroFour.StrataFrame.Application;
using MicroFour.StrataFrame.Data;
using MicroFour.StrataFrame.Security;
using MicroFour.StrataFrame.Security.BusinessObjects;
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Configuration;
using System.IO;

namespace visualOfficeNet
{
    static class Program
    {
        static Boolean gotConnection = true;
       

         /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {

           
            //-- Enable visual styles on the application
            Application.EnableVisualStyles();

            //-- Add event handlers for the application events
            StrataFrameApplication.ShowGateway +=
                new StrataFrameApplication.ShowGatewayEventHandler(
                ShowGateway);
            StrataFrameApplication.InitializingApplication +=
                new StrataFrameApplication.InitializingApplicationEventHandler(
                InitApplication);
            StrataFrameApplication.SetDataSources +=
                new StrataFrameApplication.SetDataSourcesEventHandler(
                SetDataSources);
            StrataFrameApplication.UnhandledExceptionFound +=
                new StrataFrameApplication.UnhandledExceptionFoundEventHandler(
                UnhandledExceptionFound);
            StrataFrameApplication.ShowLoginAndInitializeForm +=
                new StrataFrameApplication.ShowLoginAndInitializeFormEventHandler(
                ShowLoginAndInitMainForm);

           
                //-- Run the application
                StrataFrameApplication.RunApplication();

 
                //-- Stop the session monitoring before the application exits to remove the low-level event handlers
                SessionLock.StopSessionMonitoring();

                //-- Forcibly close the application to stop message pumps from looping and preventing the application
                //   from closing
                System.Environment.Exit(1);

        }


        /// <summary>
        /// Gets the connection string if the application will use a custom method to aquire the connection
        /// string rather than the StrataFrame Connection String Manager (optional)
        /// </summary>
        /// <remarks></remarks>
        ///
        private static void SetDataSources()
        {
            
                ConnectionManager.ApplicationKey = "visualOfficeNet";
                ConnectionManager.ApplicationDefaultTitle = "visualOfficeNet";
                ConnectionManager.ApplicationDefaultDescription = "This application connection is used by visualOfficeNet";

                //-- Set the required data source information so that the ConnectionManager can gather it
                //      SQL Connection
                ConnectionManager.AddRequiredDataSourceItem("", "SQL Connection",
                    DataSourceTypeOptions.SqlServer, "visualOfficeNet_Data", "This connection is used by visualOfficeNet for the data.");

                ConnectionManager.SetConnections();
 
         }

        /// <summary>
        /// Shows the "Gateway" form (a custom form that gives the user a choice to launch different components
        /// within the application) (optional)
        /// </summary>
        /// <param name="e"></param>
        /// <remarks></remarks>
        private static void ShowGateway(ShowGatewayEventArgs e)
        {
            if (gotConnection)
            {
                //-- Inform the application to not show the "Gateway" form again after the main form has closed
                e.ShowGatewayAfterMainFormClose = false;
            }
        }

        /// <summary>
        /// Shows a login form before a main form is shown and allows security to be checked before the application
        /// launches the main form (optional)
        /// </summary>
        /// <param name="e"></param>
        /// <remarks></remarks>
        private static void ShowLoginAndInitMainForm(ShowLoginAndInitFormEventArgs e)
        {
                      //-- Set the login form to your custom login form (optional)
                    Login.LoginFormType = typeof(CustomLogin);


                    //-- Show the login form and authenticate the user

                    e.ShowMainForm = Login.ShowLoginAndAuthUser(true);
 
        }

        /// <summary>
        /// Provides a centralized location to add any initialization parameters that need to be set before
        /// the application is loaded and defines the form types used as main forms by the application
        /// </summary>
        /// <param name="e"></param>
        /// <remarks></remarks>
        private static void InitApplication(InitializingApplicationEventArgs e)
        {
            if (MicroFour.StrataFrame.Data.DataBasics.DataSources.Count < 1)
            {
                e.Forms.Clear();
                e.Forms.Add(typeof(visualOfficeNet.frmConnectionError));
                return;
            }


            //-- Add the main form type
            //-- If more than one form is added to the collection, they can be chosen by showing a "Gateway" form
            //   and supplying the index of the form to show (At least 1 form type must be added to the collection
            e.Forms.Add(typeof(visualOfficeNet.frmMain));

            //-- ToDo:  Add any extra application initialization
            MicroFour.StrataFrame.UI.Localization.MessageKeyType = MicroFour.StrataFrame.Messaging.MessageKeyDataType.XML;
            MicroFour.StrataFrame.UI.Localization.MessageLocaleID = MicroFour.StrataFrame.UI.Localization.GetActiveLanguage("visualOfficeNet", "", false); ;


 
                //-- ToDo:  Configure the security settings
                //--------------------------------------------
                //-- Retrieve the global preferences
                try
                {
                    SFSPreferencesBO.RetrieveSecurityPreferences();
                }
                catch
                {
                        if (ConnectionManager.ShowAvailableConnectionStrings())
                        {
                            // Set the connections
                            ConnectionManager.SetConnections();

                            SFSPreferencesBO.RetrieveSecurityPreferences();
                        }
                }

                //-- Set the encryption key and vector for the user data
                SecurityBasics.SetSecurityKeyAndVectorForUserAuthentication("visualOfficeNetSFSecurity");

                //-- Start the session locking monitor & set the quick key to lock the application
                SessionLock.StartSessionMonitoring();
                SessionLock.SessionLockKey = Keys.F11;

                //-- Set the administrative and security maintenance usernames and passwords
                //SecurityBasics.AdministratorUserName = "Administrator";
                //SecurityBasics.AdministratorPassword = "admin" + DateTime.Now.Day.ToString(); //-- set the admin password so that it changes from day to day
                SecurityBasics.AdministratorUserName = "rrooker";
                SecurityBasics.AdministratorPassword = "maggie5626"; //-- set the admin password so that it changes from day to day


                SecurityBasics.AdministratorUserPk = -1;

                //SecurityBasics.SecurityMaintenanceUserName = "SecurityUser";
                //SecurityBasics.SecurityMaintenancePassword = "mySecurityUserPass1";
                SecurityBasics.SecurityMaintenanceUserName = "xxxxxx";
                SecurityBasics.SecurityMaintenancePassword = "xxxxxxxxxx";

                SecurityBasics.SecurityMaintenanceUserPk = -2;

                //-- Set the default actions for security enabled objects within the application
                SecurityBasics.DefaultPermissionInfo = new PermissionInfo(PermissionAction.Deny,
                    "Access Denied.", DeniedActions.Message);
                SecurityBasics.DefaultPermissionAction = PermissionAction.Deny;
                SecurityBasics.DefaultBlockedMsg = "Access Denied.";
                //SecurityBasics.DefaultBlockedMsgKey = "AccessDeniedKey";
                SecurityBasics.BlockedReplacementCharacter = '*';
                SecurityBasics.BlockedReplacementRegex = @"[A-Za-z0-9@]";

                //-- Determine whether to allow Windows authentication
                SecurityBasics.AllowWindowsAuth = false;
            }
 

        /// <summary>
        /// Catches any unhandled exception within the application and provides a place to log the information
        /// </summary>
        /// <param name="e"></param>
        /// <remarks></remarks>
        private static void UnhandledExceptionFound(UnhandledExceptionFoundEventArgs e)
        {

        }
    }
}
Ross L. Rooker, Sr.
Ross L. Rooker, Sr.
StrataFrame User (189 reputation)StrataFrame User (189 reputation)StrataFrame User (189 reputation)StrataFrame User (189 reputation)StrataFrame User (189 reputation)StrataFrame User (189 reputation)StrataFrame User (189 reputation)StrataFrame User (189 reputation)StrataFrame User (189 reputation)
Group: Forum Members
Posts: 153, Visits: 462
Also, I did not delete the localization file from the Documents and Settings area which I don't believe is the issue.
Ross L. Rooker, Sr.
Ross L. Rooker, Sr.
StrataFrame User (189 reputation)StrataFrame User (189 reputation)StrataFrame User (189 reputation)StrataFrame User (189 reputation)StrataFrame User (189 reputation)StrataFrame User (189 reputation)StrataFrame User (189 reputation)StrataFrame User (189 reputation)StrataFrame User (189 reputation)
Group: Forum Members
Posts: 153, Visits: 462
I basically just commented out this section of code which was written a couple years ago. At this point I can't remember why it was put there.

              //-- ToDo: Configure the security settings
//--------------------------------------------
//-- Retrieve the global preferences
try
{
SFSPreferencesBO.RetrieveSecurityPreferences();
}
catch
{
if (ConnectionManager.ShowAvailableConnectionStrings())
{
// Set the connections
ConnectionManager.SetConnections();

SFSPreferencesBO.RetrieveSecurityPreferences();
}
}

Ross L. Rooker, Sr.
Ross L. Rooker, Sr.
StrataFrame User (189 reputation)StrataFrame User (189 reputation)StrataFrame User (189 reputation)StrataFrame User (189 reputation)StrataFrame User (189 reputation)StrataFrame User (189 reputation)StrataFrame User (189 reputation)StrataFrame User (189 reputation)StrataFrame User (189 reputation)
Group: Forum Members
Posts: 153, Visits: 462
After I commented out the code above, the login screen instantly appears, but then when the main form displays I get this error after about 20 seconds so it seems as though the framework is waiting for something as startup but this may give you a bit more info. If the user CANCELS the error screen, everything works but I need to get this resolved. It only happens with SQL Express.

SqlException
  Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.

Source     : .Net SqlClient Data Provider

Stack Trace:
   at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
   at System.Data.SqlClient.TdsParserStateObject.ReadSniSyncOverAsync()
   at System.Data.SqlClient.TdsParserStateObject.ReadNetworkPacket()
   at System.Data.SqlClient.TdsParserStateObject.ReadBuffer()
   at System.Data.SqlClient.TdsParserStateObject.ReadByte()
   at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
   at System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK)
   at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject)
   at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String host, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, Int64 timerStart)
   at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance)
   at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance)
   at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection)
   at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options)
   at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject)
   at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject)
   at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)
   at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
   at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
   at System.Data.SqlClient.SqlConnection.Open()
   at System.Data.Common.DbDataAdapter.QuietOpen(IDbConnection connection, ConnectionState& originalState)
   at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
   at System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior)
   at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable)
   at MicroFour.StrataFrame.Data.DbDataSourceItem.GetDataTable(DbCommand Command, OnChangeEventHandler CallBack)
   at MicroFour.StrataFrame.Data.SqlDataSourceItem.GetDataTable(DbCommand Command, OnChangeEventHandler CallBack)
   at MicroFour.StrataFrame.Data.DbDataSourceItem.GetDataTable(String Statement, OnChangeEventHandler CallBack)
   at MicroFour.StrataFrame.Data.DataLayer.GetDataTable(String Statement, Boolean RegisterNotification)
   at MicroFour.StrataFrame.Business.BusinessLayer.FillDataTable(String SelectStatement)
   at visualOfficeNetBO.tblUCompany.Get_UCompany() in C:\VisualOfficeNetBO\visualOfficeNetBO\visualOfficeNetBO\tblUCompany.cs:line 57
   at visualOfficeNet.frmMain.tblUCompany_ParentFormLoading() in C:\visualOfficeNet\visualOfficeNet\frmMain.cs:line 525
   at MicroFour.StrataFrame.Business.BusinessLayer.raise_ParentFormLoading()
   at MicroFour.StrataFrame.Business.BusinessLayer.OnParentFormLoading()
   at MicroFour.StrataFrame.Business.BusinessLayer.RaiseParentFormLoadingEvent()
   at MicroFour.StrataFrame.UI.Windows.Forms.BaseForm.InitializeFormLoadObjects()
   at MicroFour.StrataFrame.UI.Windows.Forms.BaseForm.OnLoad(EventArgs e)
   at System.Windows.Forms.Form.OnCreateControl()
   at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
   at System.Windows.Forms.Control.CreateControl()
   at System.Windows.Forms.Control.WmShowWindow(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   at System.Windows.Forms.ContainerControl.WndProc(Message& m)
   at System.Windows.Forms.Form.WmShowWindow(Message& m)
   at System.Windows.Forms.Form.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativewindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativewindow.WndProc(Message& m)
   at System.Windows.Forms.Nativewindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
Ross L. Rooker, Sr.
Ross L. Rooker, Sr.
StrataFrame User (189 reputation)StrataFrame User (189 reputation)StrataFrame User (189 reputation)StrataFrame User (189 reputation)StrataFrame User (189 reputation)StrataFrame User (189 reputation)StrataFrame User (189 reputation)StrataFrame User (189 reputation)StrataFrame User (189 reputation)
Group: Forum Members
Posts: 153, Visits: 462
On the post above when commenting out those lines, it seems that the only person that can log in and get the error is me and I am set up as the default admin. Anyone else that tries to sign on after they enter their login, there is a 20 second delay and a messagebox indicating "Connection Failed, please contact your administrator" in my CustomLogin at the AttempLogin. Again it works in the regular SQL Server 2008 Standard Edition but when I saved that DB and restored it to SQL Express this started. I detached the origin db. I deleted the connection files for strataframe and re-established the connect successfully but this still is not working. Is there anything else in the RBS or RBS database files that could be looking for the old database?

using System;
using System.Windows.Forms;

using MicroFour.StrataFrame.Messaging;
using MicroFour.StrataFrame.Security;

namespace visualOfficeNet
{
 public partial class CustomLogin : ILoginForm
 {

 #region  Private Fields

  private const string DomainValueName = "DomainValue";
  private static string _HeaderTitle = "User Authentication";
  private static string _HeaderDesc = "Please enter user credentials below.";

 #endregion

 #region  Events

  /// <summary>
  /// Occurs when the end-user attempts to authenticate.
  /// </summary>
  /// <param name="sender"></param>
  /// <param name="e"></param>
  /// <remarks></remarks>
  public event EventHandler AttemptLogin;

  /// <summary>
  /// Raises the AttemptLogin event.
  /// </summary>
  /// <remarks></remarks>
  protected virtual void OnAttemptLogin()
  {
   if (AttemptLogin != null)
                try
                {
                    AttemptLogin(this, EventArgs.Empty);
                }
                catch
                {
                    MessageBox.Show("Connection Failed, please contact your administrator");
                    this.DialogResult = System.Windows.Forms.DialogResult.Cancel;

                }

  }

 #endregion

 #region  Public Properties

  /// <summary>
  /// Gets or sets a value that determines whether this form allows the application to be closed
  /// from within it.
  /// </summary>
  /// <value></value>
  /// <returns></returns>
  /// <remarks></remarks>
  public bool AllowAppExit
  {
   get
   {
    return this.cmdExit.Enabled;
   }
   set
   {
    //this.cmdExit.Enabled = value;
                this.cmdExit.Enabled = true;
   }
  }

  /// <summary>
  /// Gets or sets the domain name the end-user has entered.
  /// </summary>
  /// <value></value>
  /// <returns></returns>
  /// <remarks></remarks>
  public string DomainName
  {
   get
   {
    return this.cboDomain.Text;
   }
   set
   {
    this.cboDomain.Text = value;
   }
  }

  /// <summary>
  /// Gets or sets the gradient form header title.
  /// </summary>
  /// <value></value>
  /// <returns></returns>
  /// <remarks></remarks>
  public static string HeaderTitle
  {
   get
   {
    return _HeaderTitle;
   }
   set
   {
    _HeaderTitle = value;
   }
  }

  /// <summary>
  /// Gets or set the gradient form header description
  /// </summary>
  /// <value></value>
  /// <returns></returns>
  /// <remarks></remarks>
  public static string HeaderDesc
  {
   get
   {
    return _HeaderDesc;
   }
   set
   {
    _HeaderDesc = value;
   }
  }

  /// <summary>
  /// Gets or sets the password entered by the end-user.
  /// </summary>
  /// <value></value>
  /// <returns></returns>
  /// <remarks></remarks>
  public string Password
  {
   get
   {
    return this.txtPassword.Text;
   }
   set
   {
    this.txtPassword.Text = value;
   }
  }

  /// <summary>
  /// Gets or sets a value that indicates whether the domain combo box is shown.
  /// </summary>
  /// <value></value>
  /// <returns></returns>
  /// <remarks></remarks>
  public bool ShowDomainBox
  {
   get
   {
    return this.cboDomain.Visible;
   }
   set
   {
    this.lblDomain.Visible = value;
    this.cboDomain.Visible = value;
    //'-- Set the height of the form
    //If value Then
    //    Me.Height = 231
    //Else
    //    Me.Height = 205
    //End If
   }
  }

  /// <summary>
  /// Gets or sets the username entered by the end-user.
  /// </summary>
  /// <value></value>
  /// <returns></returns>
  /// <remarks></remarks>
  public string Username
  {
   get
   {
    return this.txtUsername.Text;
   }
   set
   {
    this.txtUsername.Text = value;
   }
  }

 #endregion

 #region  Protected Methods

  /// <summary>
  /// Overrides the OnLoad method of the base class.
  /// </summary>
  /// <param name="e"></param>
  /// <remarks></remarks>
  protected override void OnLoad(System.EventArgs e)
  {
   //-- Activate and show the form
   this.Activate();
   this.WindowState = FormWindowState.Normal;

   //-- Set the gradient form header
   this.GradientFormHeader1.Title = _HeaderTitle;
   this.GradientFormHeader1.DetailText = _HeaderDesc;

   //-- Base call
   base.OnLoad(e);
  }

 #endregion

 #region  Public Methods

  /// <summary>
  /// Sets the DialogResult of the form to DialogResult.OK.
  /// </summary>
  /// <remarks></remarks>
  public void SetDialogResultToOK()
  {
   this.DialogResult = System.Windows.Forms.DialogResult.OK;
  }

  /// <summary>
  /// Sets the delay seconds on the form.
  /// </summary>
  /// <param name="Value"></param>
  /// <remarks></remarks>
  public void SetDelaySeconds(int Value)
  {
   if (Value == 0)
   {
    grpLogin.Title = "Login Details";
   }
   else
   {
    grpLogin.Title = "Retry Delay: " + Value.ToString() + " seconds";
   }
  
        }

  /// <summary>
  /// Sets the domain names within the domain combo box to the given values.
  /// </summary>
  /// <param name="DomainNames"></param>
  /// <remarks></remarks>
  public void SetDomainNames(string[] DomainNames)
  {
   this.cboDomain.Items.Clear();
   this.cboDomain.Items.AddRange(DomainNames);

   //-- Set the text on the domain names to the old value
   this.cboDomain.Text = this.Registry.ReadString(DomainValueName, string.Empty);
  }

  /// <summary>
  /// Disable form and its controls
  /// </summary>
  /// <remarks></remarks>
  public void SetFormDisabled()
  {
   this.txtPassword.Enabled = false;
   this.txtUsername.Enabled = false;
   this.cboDomain.Enabled = false;
   this.cmdOk.Enabled = false;
  }

  /// <summary>
  /// Enable form and its controls
  /// </summary>
  /// <remarks></remarks>
  public void SetFormEnabled()
  {
   this.txtPassword.Enabled = true;
   this.txtUsername.Enabled = true;
   this.cboDomain.Enabled = true;
   this.cmdOk.Enabled = true;
  }

  /// <summary>
  /// Show the user account is deactivated.
  /// </summary>
  /// <remarks></remarks>
  public void ShowAccountDeactivated()
  {
   MessageForm.ShowMessageByKey("SFSM_UserDeactivated");
  }

  /// <summary>
  /// Shows an authentication failed message to the end-user.
  /// </summary>
  /// <remarks></remarks>
  public void ShowAuthFailedMessage()
  {
   MessageForm.ShowMessageByKey("SFSM_PasswordAuthenticationFailed");
  }

  /// <summary>
  /// Shows login attempts exceeded message.
  /// </summary>
  /// <remarks></remarks>
  public void ShowLoginAttemptsExceeded()
  {
   MessageForm.ShowMessageByKey("SFSM_LoginAttemptsExceeded");
  }

  /// <summary>
  /// Shows a message to the end-user informing them that they do not have the required permission
  /// necessary to login to the system.
  /// </summary>
  /// <remarks></remarks>
  public void ShowLoginPermissionDenied()
  {
   MessageForm.ShowMessageByKey("SFSM_LoginPermissionDenied");
  }

 #endregion

 #region  Event handlers

  /// <summary>
  /// Handles the cmdOk.Click event.
  /// </summary>
  /// <param name="sender"></param>
  /// <param name="e"></param>
  /// <remarks></remarks>
  private void cmdOk_Click(object sender, System.EventArgs e)
  {
   //-- Save off the selected domain text
   if (this.cboDomain.Text.Length > 0)
   {
    this.Registry.WriteValue(DomainValueName, this.cboDomain.Text);
   }

   //-- Raise the attempt login event
   this.OnAttemptLogin();
  }

  /// <summary>
  /// Handles the cmdExit.Click event.
  /// </summary>
  /// <param name="sender"></param>
  /// <param name="e"></param>
  /// <remarks></remarks>
  private void cmdExit_Click(object sender, System.EventArgs e)
  {
   //this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
            //try
            //{
            //Application.Exit();
            Application.ExitThread();
               
            //}
            //catch
            //{

            //}

  }

 #endregion

        private void txtUsername_TextChanged(object sender, EventArgs e)
        {

        }

        private void CustomLogin_Load(object sender, EventArgs e)
        {

        }

 }
} //end of root namespace
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search