コード例 #1
0
    protected Boolean check_login(string key, string password)
    {
        useradmin = new UserAdminBLL();
        List <UserAdmin> lst  = useradmin.login_Adminform(key, password);
        UserAdmin        user = lst.FirstOrDefault();

        if (user != null)
        {
            Session.SetCurrentUser(user);
            return(true);
        }
        return(false);
    }
コード例 #2
0
    protected void btnNewUser_Click(object sender, EventArgs e)
    {
        try
        {
            useradmin        = new UserAdminBLL();
            useradminprofile = new UserAdminProfileBLL();
            string Uname     = txtUsername.Text;
            string Uemail    = txtEmail.Text;
            string Fname     = txtFirstname.Text;
            string Lname     = txtLastname.Text;
            string Upassword = txtPrePassword.Text;

            List <UserAdmin> lst1 = useradmin.ListUserWithName(Uname);
            UserAdmin        ad1  = lst1.FirstOrDefault();
            List <UserAdmin> lst2 = useradmin.ListUserWithEmail(Uemail);
            UserAdmin        ad2  = lst2.FirstOrDefault();

            if (ad1 != null)
            {
                this.AlertPageValid(true, "The username already exists !", alertPageValid, lblPageValid);
            }
            else
            {
                if (ad2 != null)
                {
                    this.AlertPageValid(true, "The E-mail already exists !", alertPageValid, lblPageValid);
                }
                else
                {
                    bool bol1 = this.useradmin.NewUserAdmin(Uname, Uemail, CreateSHAHash(Upassword, SaltPassword()));
                    bool bol2 = this.useradminprofile.CreateUserAdminProfile(Fname, Lname, useradmin.GetUserIDWithName(Uname));

                    if (bol1 || bol2)
                    {
                        Response.Write("<script>alert('Thêm người dùng thành công !')</script>");
                    }
                    else
                    {
                        this.AlertPageValid(true, "Thêm người dùng thất bại. Lỗi kết nối CSDL !", alertPageValid, lblPageValid);
                    }
                }
            }
        }
        catch (Exception ex)
        {
            this.AlertPageValid(true, ex.ToString(), alertPageValid, lblPageValid);
        }
    }