private void cmdOK_Click(object sender, System.EventArgs e)
        {
            txtFirstName.Text = txtFirstName.Text.Trim();
            txtLastName.Text = txtLastName.Text.Trim();
            txtEmail.Text = txtEmail.Text.Trim();
            txtPassword.Text = txtPassword.Text.Trim();

            if (txtFirstName.Text == string.Empty)
            {
                MessageBox.Show("The first name is required.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else if (txtLastName.Text == string.Empty)
            {
                MessageBox.Show("The last name is required.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else if (cboCountry.SelectedIndex == 0)
            {
                MessageBox.Show("The country is required.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else if (txtEmail.Text == string.Empty)
            {
                MessageBox.Show("The email is required.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else if (txtPassword.Text == string.Empty)
            {
                MessageBox.Show("The password is required.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else if (txtPassword.Text != txtVerify.Text)
            {
                MessageBox.Show("The password must be verified.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            var message = string.Empty;
            nhydrateservice.MainService service = null;
            try
            {
                service = new nhydrateservice.MainService();
                var document = new XmlDocument();
                document.LoadXml("<a></a>");
                XmlHelper.AddElement(document.DocumentElement, "firstname", txtFirstName.Text);
                XmlHelper.AddElement(document.DocumentElement, "lastname", txtLastName.Text);
                XmlHelper.AddElement(document.DocumentElement, "city", txtCity.Text);
                XmlHelper.AddElement(document.DocumentElement, "region", txtRegion.Text);
                XmlHelper.AddElement(document.DocumentElement, "postcode", txtPostalCode.Text);
                XmlHelper.AddElement(document.DocumentElement, "country", cboCountry.SelectedItem.ToString());
                XmlHelper.AddElement(document.DocumentElement, "email", txtEmail.Text);
                XmlHelper.AddElement(document.DocumentElement, "password", txtPassword.Text);
                XmlHelper.AddElement(document.DocumentElement, "machinekey", SecurityHelper.GetMachineID());
                XmlHelper.AddElement(document.DocumentElement, "version", VersionHelper.GetCurrentVersion());
                XmlHelper.AddElement(document.DocumentElement, "allowstats", chkStat.Checked.ToString().ToLower());
                message = service.RegisterUser2(document.OuterXml);
            }
            catch (Exception ex)
            {
                MessageBox.Show("There was an error trying to register. Please visit the main nHydrate site to register: http://www.nHydrate.org.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (!string.IsNullOrEmpty(message))
            {
                MessageBox.Show(message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            var key = string.Empty;
            try
            {
                key = service.GetKey(txtEmail.Text);
            }
            catch (Exception ex)
            {
                MessageBox.Show("There was an error trying to retrieve the key. Please visit the main nHydrate site to register: http://www.nHydrate.org.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            AddinAppData.Instance.Key = key;
            AddinAppData.Instance.AllowStats = chkStat.Checked;
            AddinAppData.Instance.Save();

            this.DialogResult = DialogResult.OK;
            this.Close();
        }
Exemple #2
0
        private void cmdOK_Click(object sender, System.EventArgs e)
        {
            txtFirstName.Text = txtFirstName.Text.Trim();
            txtLastName.Text  = txtLastName.Text.Trim();
            txtEmail.Text     = txtEmail.Text.Trim();
            txtPassword.Text  = txtPassword.Text.Trim();

            if (txtFirstName.Text == string.Empty)
            {
                MessageBox.Show("The first name is required.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else if (txtLastName.Text == string.Empty)
            {
                MessageBox.Show("The last name is required.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else if (cboCountry.SelectedIndex == 0)
            {
                MessageBox.Show("The country is required.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else if (txtEmail.Text == string.Empty)
            {
                MessageBox.Show("The email is required.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else if (txtPassword.Text == string.Empty)
            {
                MessageBox.Show("The password is required.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else if (txtPassword.Text != txtVerify.Text)
            {
                MessageBox.Show("The password must be verified.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            var message = string.Empty;

            nhydrateservice.MainService service = null;
            try
            {
                service = new nhydrateservice.MainService();
                var document = new XmlDocument();
                document.LoadXml("<a></a>");
                XmlHelper.AddElement(document.DocumentElement, "firstname", txtFirstName.Text);
                XmlHelper.AddElement(document.DocumentElement, "lastname", txtLastName.Text);
                XmlHelper.AddElement(document.DocumentElement, "city", txtCity.Text);
                XmlHelper.AddElement(document.DocumentElement, "region", txtRegion.Text);
                XmlHelper.AddElement(document.DocumentElement, "postcode", txtPostalCode.Text);
                XmlHelper.AddElement(document.DocumentElement, "country", cboCountry.SelectedItem.ToString());
                XmlHelper.AddElement(document.DocumentElement, "email", txtEmail.Text);
                XmlHelper.AddElement(document.DocumentElement, "password", txtPassword.Text);
                XmlHelper.AddElement(document.DocumentElement, "machinekey", SecurityHelper.GetMachineID());
                XmlHelper.AddElement(document.DocumentElement, "version", VersionHelper.GetCurrentVersion());
                XmlHelper.AddElement(document.DocumentElement, "allowstats", chkStat.Checked.ToString().ToLower());
                message = service.RegisterUser2(document.OuterXml);
            }
            catch (Exception ex)
            {
                MessageBox.Show("There was an error trying to register. Please visit the main nHydrate site to register: http://www.nHydrate.org.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (!string.IsNullOrEmpty(message))
            {
                MessageBox.Show(message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            var key = string.Empty;

            try
            {
                key = service.GetKey(txtEmail.Text);
            }
            catch (Exception ex)
            {
                MessageBox.Show("There was an error trying to retrieve the key. Please visit the main nHydrate site to register: http://www.nHydrate.org.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            AddinAppData.Instance.Key        = key;
            AddinAppData.Instance.AllowStats = chkStat.Checked;
            AddinAppData.Instance.Save();

            this.DialogResult = DialogResult.OK;
            this.Close();
        }