/// <summary>
/// 添加
/// </summary>
/// <param name="name">用户名</param>
/// <param name="pwd">密码</param>
/// <returns></returns>
[WebMethod]
public int Add(string name,string pwd)
{
SqlConnection conn = new SqlConnection("连接字符串")
conn.Open()
string sql = "intsert into User (UserName,UsersPwd) values(@UserName,@UsersPwd)"
SqlCommand cmd = new SqlCommand(sql, conn)
SqlParameter parn = new SqlParameter("@UserName", name)
cmd.Parameters.Add(parn)
SqlParameter parp = new SqlParameter("@UsersPwd", pwd)
cmd.Parameters.Add(parp)
int result = cmd.ExecuteNonQuery()
conn.Close()
cmd.Dispose()
return result
}
/// <summary>
/// 修改
/// </summary>
/// <param name="name">用户名</param>
/// <param name="pwd">密码</param>
/// <param name="id">编号</param>
/// <returns></returns>
[WebMethod]
public int Update(string name, string pwd, int id)
{
SqlConnection conn = new SqlConnection("连接字符串")
conn.Open()
string sql = "update User set UserName=@UserName,UsersPwd=@UsersPwd where id=@id"
SqlCommand cmd = new SqlCommand(sql, conn)
SqlParameter parn = new SqlParameter("@UserName", name)
cmd.Parameters.Add(parn)
SqlParameter parp = new SqlParameter("@UsersPwd", pwd)
cmd.Parameters.Add(parp)
SqlParameter pari = new SqlParameter("@id", id)
cmd.Parameters.Add(pari)
int result = cmd.ExecuteNonQuery()
conn.Close()
cmd.Dispose()
return result
}
/// <summary>
/// 删除
/// </summary>
/// <param name="id">编号</param>
/// <returns></returns>
[WebMethod]
public int Delete(int id)
{
SqlConnection conn = new SqlConnection("连接字符串")
conn.Open()
string sql = "delete from User where id=@id"
SqlCommand cmd = new SqlCommand(sql, conn)
SqlParameter pari = new SqlParameter("@id", id)
cmd.Parameters.Add(pari)
int result = cmd.ExecuteNonQuery()
conn.Close()
cmd.Dispose()
return result
}
方法为:
在数据库中增加一个标志字段
在页面中如果满足条件那么让空上标志字段为真
那么就可以在页面显示上即不显示该标志字段为真的内容,否则就显示
说明:具体实现要以具体业务逻辑为准,以上为解决思想,理解便可解决该问题。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)