コード例 #1
0
        protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
        {
            // Determine the currently logged on user's UserId
            //MembershipUser currentUser = Membership.GetUser();
            //Guid currentUserId = (Guid)currentUser.ProviderUserKey;

            //Create user in Account table
            DAO_Account_Interface acc_ctx = new AccountDAO();
            AccountDTO newAccount = new AccountDTO();

            newAccount.userName = CreateUserWizard1.UserName.ToLower();
            newAccount.password = "******";
            newAccount.status = "active";
            newAccount.accountType = "user";
            acc_ctx.presist(newAccount);

            //Add User Email to COntact Info
            DAO_ContactInfo_Interface info_ctx = new ContactInfoDAO();
            ContactInfoDTO mail_info = new ContactInfoDTO();
            mail_info.userName = newAccount.userName;
            mail_info.contactType = "e-mail";
            mail_info.data = CreateUserWizard1.Email;
            info_ctx.presist(mail_info);

            //Add User information to User Table
            DAO_User_Interface user_ctx = new UserDAO();
            UserDTO user_info = new UserDTO();
            user_info.userName = newAccount.userName;
            user_info.id = txtID.Text;
            user_info.fullName = txtName.Text;
            user_info.surname = txtSurname.Text;
            user_info.nickName = txtNickname.Text;
            user_info.idType = RadioIdType.SelectedValue;
            user_info.race = RadioRace.SelectedValue;
            user_info.gender = RadioGender.SelectedValue;
            user_ctx.presist(user_info);

            Roles.AddUserToRole(newAccount.userName, "User");
        }