Exemple #1
0
        private bool FormValidated()
        {
            bool ret = true;

            ResetErrors();

            if (scd.ConnectionStringBuilder == null ||
                !SqlConnectionDialog.ValidConnection(scd.ConnectionStringBuilder))
            {
                ret = false;
                MessageBox.Show("Unable to connect to SQL Server. Invalid credentials or none proviced.", "Connection Failure", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else if (string.IsNullOrEmpty(txtXEventSession.Text))
            {
                ret = false;
                errProvider.SetError(btnPickSession, "Choose an XEvent session.");
            }
            else
            {
                //TODO: validate appropriate form data is entered.
                if (clbEvents.CheckedIndices.Count == 0)
                {
                    ret = false;
                    errProvider.SetError(grpEventsHandled, "Choose at least one event to handle.");
                }

                if (!ckPlaySysSound.Checked && !ckSendEmail.Checked)
                {
                    ret = false;
                    errProvider.SetError(grpEventResponses, "Choose at least one response for events.");
                }

                if (ckPlaySysSound.Checked && cboSounds.SelectedIndex == -1)
                {
                    ret = false;
                    errProvider.SetError(cboSounds, "Choose the sound to play.");
                }

                if (ckSendEmail.Checked && string.IsNullOrEmpty(txtEmail.Text))
                {
                    ret = false;
                    errProvider.SetError(txtEmail, "Enter a valid email address.");
                }
            }

            return(ret);
        }
Exemple #2
0
        private void LoadAppConfigItems()
        {
            bool   minToSysTray    = false;
            string emailRecipients = "";
            string defConn         = "";

            try
            {
                minToSysTray = Convert.ToBoolean(ConfigurationManager.AppSettings["MinimizeToSystemTray"]);
            }
            catch { }

            try
            {
                emailRecipients = ConfigurationManager.AppSettings["EmailRecipients"];
            }
            catch { }

            try
            {
                defConn = ConfigurationManager.AppSettings["DefaultConnectionString"];
            }
            catch { }

            minimizeToSystemTrayToolStripMenuItem.Checked = minToSysTray;
            txtEmail.Text = emailRecipients;

            System.Data.SqlClient.SqlConnectionStringBuilder csb =
                new System.Data.SqlClient.SqlConnectionStringBuilder(defConn);

            if (string.IsNullOrEmpty(defConn) ||
                !SqlConnectionDialog.ValidConnection(csb))
            {
                tsslLogin.Text   = "";
                tsslSqlHost.Text = "";
                tsslPipe.Text    = "";
            }
            else
            {
                scd.ConnectionStringBuilder = csb;
                SetToolStrip();
            }
        }