示例#1
0
        private void btnAddProfile_Click(object sender, EventArgs e)
        {
            // Make sure the email is valid
            if (SGGlobals.IsEmailValid(txtDefaultAddress.Text) == false)
            {
                MessageBox.Show("Email address does not appear to be valid!", "Error creating profile", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            // Make sure the profile doesn't exist
            try
            {
                UserProfiles.GetProfileByName(txtProfileName.Text);

                // Profile exists!
                MessageBox.Show("Profile name already exists!", "Error creating profile", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            catch (ProfileNotFoundException)
            {
                // Profile does not exist, create it
                Profile objNewProfile = new Profile();
                objNewProfile.Name = txtProfileName.Text;
                objNewProfile.ToAddresses.Add(txtDefaultAddress.Text);
                objNewProfile.Save();
                this._objDialogStatus = DialogResult.OK;
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("An unknown error occured creating the new profile:"
                    + Environment.NewLine + ex.Message, "Error creating profile", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#2
0
        /// <summary>
        /// Populates the selected profile and closes the form
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnOK_Click(object sender, EventArgs e)
        {
            // Make sure they have selected a profile
            if (cboProfile.Text.Equals(""))
            {
                MessageBox.Show("Please select a valid profile", "Select Profile", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            // Set the selected profile
            this._objSelectedProfile = UserProfiles.GetProfileByName(cboProfile.Text);

            // Set the reporting action
            if (radSpam.Checked == true)
            {
                this._enumAction = SGGlobals.ReportAction.ReportSpam;
            }
            else
            {
                this._enumAction = SGGlobals.ReportAction.ReportHam;
            }

            // Set dialog result
            this.DialogResult = DialogResult.OK;

            // Close the form
            this.Close();
        }