错误:“MyBookShopBLL.UserManager”并不包含“AddUsers”的定义
三层架构MyBookShopBLL.UserManager中有个方法添加到WEB页面的时候
提示不包含这个定义!
详细代码如下:
using System;
using System.Collections.Generic;
using System.Text;
using MyBookShopModels;
using MyBookShopDAL;namespace MyBookShopBLL
{
  public  class UserManager
    {
           public static int AddUsers(User user)
      {
          return UserService.AddUser(user);
      }
     
    }
}
-----页面代码----
using MyBookShopBLL;
using MyBookShopModels;public partial class Membership_UserRegister : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {    }
    protected void imgBtnOK_Click(object sender, ImageClickEventArgs e)
    {
        string Users = txtUser.Text.Trim();
        string Name = txtName.Text.Trim();
        string pwd = txtPwd.Text.Trim();
        string address = txtAdd.Text.Trim();
        string Email = txtEmail.Text.Trim();
        string Phone = txtPhone.Text.Trim();
        User u = new User();
        u.Loginid = Users;
        u.Loginpwd = pwd;
        u.Name = Name;
        u.Address = address;
        u.Mail = Email;
        u.Phone = Phone;
        int result = UserManager.AddUsers(u);
        if(result>0)
        {
            this.ClientScript.RegisterStartupScript(this.GetType(),"alert","<script>alert('恭喜你注册成功!');</script>");
        
        
        }
       
    }
}-----DAL中的方法----------
       public static int AddUser(User user)
        {
            //获取最新添加用户的ID
            string sql = "insert into users (LoginId,LoginPwd,Name,Address,Phone,Mail,UserRoleId,UserStateId)" +
                "values (@LoginId,@LoginPwd,@Name,@Address,@Phone,@Mail,@UserRoleId,@UserStateId)";
            sql += " ; select @@IDENTITY";
            //SqlParameter的书写方式
            //SqlParameter para=new SqlParameter[]{获取属性},后面是”,“,不是”;“
            SqlParameter para = new SqlParameter[]
            {   
                    new SqlParameter("@UserStateId",user.UserState.Id),
                    new SqlParameter("@UserRoleId",user.UserRole.Id),
                    new SqlParameter("@LoginId",user.Loginid),
                    new SqlParameter("@LoginPwd",user.Loginpwd),
                    new SqlParameter("@Name",user.Name),
                    new SqlParameter("@Address",user.Address),
                    new SqlParameter("@Phone",user.Phone),
                    new SqlParameter("@Mail",user.Mail)
            };
            int result = DBHelper.ExecuteCommand(sql);
            return result;        }

解决方案 »

  1.   

    先分别编译一下你的DAL,BLL,看能不能编译成功。
      

  2.   

    从你贴出来的代码看,没有什么问题。不过,在 UserManager 类中叫 AddUsers(),在 UserService 类中叫 AddUser(),同一个东西,一会用复数,一会用单数,似乎有些不够严谨。
      

  3.   

    看看你的引用对不对,还有就是using,还有就是你的namespace对不对
      

  4.   

    MyBookShopBLL重新生成dll文件,添加项目引用