错误:“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; }
三层架构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; }
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货