示例#1
0
        /// <summary>
        ///     Load event handler of Main Form.
        /// </summary>
        /// <param name="sender">Sender.</param>
        /// <param name="e">Event Argument.</param>
        private void MainForm_Load(object sender, EventArgs e)
        {
            try
            {
                if (AppStatic.DbConnectionString.Length == 0)
                {
                    var sqlConnForm = new SqlConnectionForm();

                    if (sqlConnForm.ShowDialog(this) == DialogResult.OK && sqlConnForm.ConnectionSuccess)
                    {
                        AppStatic.DbConnectionString = sqlConnForm.ConnReq.SqlConn.ConnectionString;
                        AppStatic.Database           = sqlConnForm.ConnReq.SqlConn.Database;
                        AppStatic.Server             = sqlConnForm.ConnReq.SqlConn.DataSource;

                        FormLoad();
                    }
                    else
                    {
                        Close();
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorViewerForm.ShowError(ex, this);
            }
        }
示例#2
0
        /// <summary>
        ///     Database change menu-item click event handler.
        /// </summary>
        /// <param name="sender">Sender.</param>
        /// <param name="e">Event Argument.</param>
        private void DbConnectionStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                var sqlConnForm = new SqlConnectionForm();

                if (sqlConnForm.ShowDialog(this) == DialogResult.OK && sqlConnForm.ConnectionSuccess)
                {
                    AppStatic.DbConnectionString = sqlConnForm.ConnReq.SqlConn.ConnectionString;
                    AppStatic.Database           = sqlConnForm.ConnReq.SqlConn.Database;
                    AppStatic.Server             = sqlConnForm.ConnReq.SqlConn.DataSource;

                    FormLoad();
                }
            }
            catch (Exception ex)
            {
                ErrorViewerForm.ShowError(ex, this);
            }
        }