Exemplo n.º 1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void btnRegistration_Click(object sender, EventArgs e)
 {
     try
     {
         if (IsPostBack)
         {
             Page.Validate();
             if (Page.IsValid)
             {
                 objUser.FirstName             = txtFirstName.Text.Trim();
                 objUser.LastName              = txtLastName.Text.Trim();
                 objUser.Mobile                = txtMobile.Text.Trim();
                 objUser.Email                 = txtEmail.Text.Trim();
                 objUser.Gender                = Convert.ToInt32(rbnLstSex.SelectedValue.Trim());
                 objUser.Address               = txtAddress.Text.Trim();
                 objUser.CountryId             = Convert.ToInt32(ddlCountry.SelectedValue.Trim());
                 objUser.City                  = Convert.ToString(txtCity.Text.Trim());
                 objUser.ZipCode               = Convert.ToString(txtZipCode.Text.Trim());
                 objUser.CreatedBy             = Convert.ToInt32(Session["UserId"]);
                 objUser.CreatedOn             = DateTime.Now;
                 objUser.UpdatedBy             = Convert.ToInt32(Session["UserId"]);
                 objUser.UpdatedOn             = DateTime.Now;
                 objUser.IsEmailVerified       = false;
                 objUserLogin.UserName         = txtUserName.Text.Trim();
                 objUserLogin.Password         = CommonUtils.Encrypt(txtPassword.Text.Trim());
                 objUserLogin.SecurityQuestion = Convert.ToInt32(ddlSecurityQuestion.SelectedValue.Trim());
                 objUserLogin.Answer           = txtAnswer.Text.Trim();
                 objUserLogin.RoleId           = Convert.ToInt32(ddlRole.SelectedValue.Trim());
                 objUserLogin.IsActive         = false;
                 objUserLogin.AccountLocked    = false;
                 objUser.UserLogin             = objUserLogin;
                 userId = objUserBLL.AddUserDetails(objUser);
                 if (userId != 0)
                 {
                     SendVerficationEmail(userId);
                     lblMsg.Text      = "User registered sucessfully. Check your registered email for confirmation email.";
                     lblMsg.ForeColor = Color.Green;
                     lblMsg.Font.Bold = true;
                     ClearAllFields(this);
                 }
             }
         }
     }
     catch (Exception ex)
     {
         log.Error("btnRegistration_Click \n Message: " + ex.Message + "\n Source: " + ex.Source + "\n StackTrace: " + ex.StackTrace);
         ExceptionLog.WriteLog(PageName + " @ btnRegistration_Click ", ex.Message + " \n " + ex.StackTrace);
     }
 }