Beispiel #1
0
    protected void SaveClick(object sender, EventArgs e)
    {
        lblError.Text = ""; lbloutput.Text = "";
        UserContent   uContent = new UserContent();
        UserInterface user     = new UserInterface();
        alamaat_User  _user    = uContent.GetbyUsername(UserName.Text);

        if (null != _user)
        {
            lblError.Text = "Username is not available.";
            UserName.Focus();
            return;
        }
        alamaat_User useremail = uContent.GetuserByEmail(Email.Text);

        if (null != useremail)
        {
            lblError.Text = "A user is already registered with this email address. Please try another email address.";
            Email.Focus();
            return;
        }
        user.ID          = Guid.NewGuid();
        user.FirstName   = tbfirstname.Text;
        user.MiddleName  = tbmiddlename.Text;
        user.LastName    = tblastname.Text;
        user.UserName    = UserName.Text;
        user.Password    = Password.Text;
        user.Email       = Email.Text;
        user.Address     = tbaddress.Text;
        user.City        = tbcity.Text;
        user.Province    = tbprovince.Text;
        user.Country     = tbcountry.Text;
        user.PCode       = tbpCode.Text;
        user.Phone       = tbphone.Text;
        user.MobilePhone = tbMobilephone.Text;
        user.Fax         = tbfax.Text;
        user.BirthDate   = tbbirth.Text;
        if (uContent.InsertUser(user))
        {
            regpanel.Visible  = false;
            lbloutput.Visible = true;
            string emailcontent = "Hello " + user.UserName + ","
                                  + "<br/><br/><b>Username:</b>&nbsp;&nbsp;&nbsp;" + user.UserName
                                  + "<br/><br/>Thank you for registering at Alamaat. Your account is created and must be activated before you can use it."
                                  + "<br/>To activate the account click on the following link or copy-paste it in your browser:"
                                  + "<br/>www.alamaat.biz/activation.aspx?id=" + user.ID
                                  + "<br/>After activation you may login to http://www.alamaat.biz/ using the following username and the password you entered during registration:";
            if (SendEmail(user.Email, "Alamaat Account Details for " + user.UserName, emailcontent))
            {
                lbloutput.Text = "An email has been sent to you to activate your account.";
                return;
            }
            else
            {
                lbloutput.Text = "Failed to send activation email. please contact admin at [email protected] or (+92)-333-5113213211.";
                return;
            }
        }
    }