Beispiel #1
0
 private void btnRegister_Click(object sender, EventArgs e)
 {
     try
     {
         if (txtName.Text == string.Empty)
         {
             MyMessageBox.ShowBox("Name is required!", "Alert!");
             return;
         }
         else if (txtUsername.Text == string.Empty)
         {
             MyMessageBox.ShowBox("UserName is required!", "Alert!");
             return;
         }
         else if (txtPassword.Text == string.Empty)
         {
             MyMessageBox.ShowBox("Password is required!", "Alert!");
             return;
         }
         else
         {
             string Name      = txtName.Text;
             string UserName  = txtUsername.Text;
             string Password  = _crypt.Encrypt(txtPassword.Text);
             int    UserType  = Convert.ToInt32(cmbUserType.SelectedValue);
             string ContactNo = txtContact_no.Text;
             string Email     = txtEmail_Address.Text;
             int    i         = _repoLogin.RegisterUser(UserName, Password, UserType, Name, ContactNo, Email);
             if (i > 0)
             {
                 MyMessageBox.ShowBox("User Created!", "Success!");
                 txtName.Clear();
                 txtUsername.Clear();
                 txtPassword.Clear();
                 txtContact_no.Clear();
                 txtEmail_Address.Clear();
             }
             else
             {
                 MyMessageBox.ShowBox("UserName already Exists!", "Failed!");
             }
         }
     }
     catch (Exception ex)
     {
         _errorLogs.LogErrors("frmRegistration", "btnRegister_Click", ex.Message);
     }
 }