nHydrate.DslPackage.Forms.RegistrationForm.cmdLogin_Click C# (CSharp) Method

cmdLogin_Click() private method

private cmdLogin_Click ( object sender, System e ) : void
sender object
e System
return void
        private void cmdLogin_Click(object sender, System.EventArgs e)
        {
            try
            {
                nHydrate.Generator.Common.nhydrateservice.MainService service = null;
                service = new nHydrate.Generator.Common.nhydrateservice.MainService();
                service.Url = VersionHelper.SERVICE_URL;
                if (service.AuthenticateUser2(txtLoginEMail.Text, txtLoginPassword.Text, SecurityHelper.GetMachineID()))
                {
                    AddinAppData.Instance.PremiumValidated = false;
                    if (!string.IsNullOrEmpty(txtPremium.Text))
                    {
                        var result = service.VerifyPremiumKey(txtLoginEMail.Text, txtLoginPassword.Text, SecurityHelper.GetMachineID(), txtPremium.Text);
                        if (string.IsNullOrEmpty(result))
                        {
                            AddinAppData.Instance.PremiumValidated = true;
                            MessageBox.Show("The premium key has been verified and applied. All application features have been enabled.", "Success!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else
                        {
                            //Display the reason for the error
                            MessageBox.Show("An error has occurred while verifing your premium key. The failure reason is listed below.\n\n'" + result + "'", "Success!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }
                    }

                    MessageBox.Show("The login has been validated. Your machine has been verified.", "Success!", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    service.ResetStatistics(txtLoginEMail.Text, chkStat.Checked);
                    var key = service.GetKey(txtLoginEMail.Text);
                    AddinAppData.Instance.Key = key;
                    AddinAppData.Instance.PremiumKey = txtPremium.Text;
                    AddinAppData.Instance.AllowStats = chkStat.Checked;
                    AddinAppData.Instance.Save();

                    this.DialogResult = DialogResult.OK;
                    this.Close();
                }
                else
                {
                    MessageBox.Show("The login could not be validated.", "Invalid Login!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            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;
            }
        }