sqlhelper怎么用 50
2015-10-20 · 知道合伙人软件行家
关注
展开全部
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using SQLHelper;
using System.Text;
using System.Data.SqlClient;
/// <summary>
/// UserInfo 的摘要说明
/// </summary>
namespace BLL
{
public class UserInfo
{
#region增
///<summary>
///创建一个新用户
///</summary>
///<param name="username">用户名称</param>
///<param name="password">用户密码</param>
///<param name="email">电子邮件</param>
///<param name="question">密码问题</param>
///<param name="answer">问题答案</param>
///<returns></returns>
public int createUser(string username, string password, int power, string email, string question, string answer)
{
StringBuilder sb= new StringBuilder();
sb.Append("insert into UserInfo ([UserName],[Password],[Power],[Email],[Question],[Answer]) values");
sb.Append("(@UserName,@Password,@Power,@Email,@Question,@Answer)");
SqlParameter[] param=
{
DBHelper.GetParameter("@UserName",SqlDbType.NVarChar,50,"[UserName]",username),
DBHelper.GetParameter("@Password",SqlDbType.NVarChar,50,"[Password]",password),
DBHelper.GetParameter("@Power",SqlDbType.Int,4,"[Power]",power),
DBHelper.GetParameter("@Email",SqlDbType.NVarChar,50,"[Email]",email),
DBHelper.GetParameter("@Question",SqlDbType.NVarChar,50,"[Question]",question),
DBHelper.GetParameter("@Answer",SqlDbType.NVarChar,50,"[Answer]",answer)
};
return DBHelper.ExecuteSql(sb.ToString(), param);
}
#endregion
#region删
///<summary>
///删除一个用户
///</summary>
///<param name="userid">用户编号</param>
///<returns></returns>
public int deleteUser(int userid)
{
StringBuilder sb= new StringBuilder();
sb.Append("delete from UserInfo where [UserID]=@UserID");
SqlParameter[] param= { DBHelper.GetParameter("@UserID", SqlDbType.Int,4, "[UserID]", userid) };
return DBHelper.ExecuteSql(sb.ToString(), param);
}
#endregion
#region改
///<summary>
///修改密码
///</summary>
///<param name="userid">用户编号</param>
///<param name="newpassword">新密码</param>
///<returns></returns>
public int updateUserPassword(int userid, string newpassword)
{
StringBuilder sb= new StringBuilder();
sb.Append("update UserInfo set [Password]=@newpassword where [UserID]=@UserID");
SqlParameter[] param=
{
DBHelper.GetParameter("@UserID", SqlDbType.Int, 4,"[UserID]", userid) ,
DBHelper.GetParameter("@newpassword",SqlDbType.NVarChar,50,"[Password]",newpassword)
};
return DBHelper.ExecuteSql(sb.ToString(), param);
}
///<summary>
///修改用户资料
///</summary>
///<param name="userid">用户编号</param>
///<param name="password">用户密码</param>
///<param name="email">电子邮件</param>
///<param name="question">密码问题</param>
///<param name="answer">问题答案</param>
///<returns></returns>
public int updateUser(int userid, string password, string email, string question, string answer)
{
StringBuilder sb= new StringBuilder();
sb.Append("update UserInfo set [Password]=@Password,[Email]=@Email,[Question]=@Question,");
sb.Append("[Answer]=@Answer where [UserID]=@UserID");
SqlParameter[] param=
{
DBHelper.GetParameter("@UserID",SqlDbType.Int,4,"[UserID]",userid),
DBHelper.GetParameter("@Password",SqlDbType.NVarChar,50,"[Password]",password),
DBHelper.GetParameter("@Email",SqlDbType.NVarChar,50,"[Email]",email),
DBHelper.GetParameter("@Question",SqlDbType.NVarChar,50,"[Question]",question),
DBHelper.GetParameter("@Answer",SqlDbType.NVarChar,50,"[Answer]",answer)
};
return DBHelper.ExecuteSql(sb.ToString(), param);
}
#endregion
#region查
///<summary>
///找回用户密码
///</summary>
///<param name="username">用户名</param>
///<param name="question">密码问题</param>
///<param name="answer">问题答案</param>
///<returns></returns>
public stringresearchPassword(stringusername, stringquestion, stringanswer)
{
StringBuilder sb= new StringBuilder();
sb.Append("select [Password] from UserInfo where [UserName]=@UserName");
sb.Append("and [Question]=@Question and [Answer]=@Answer");
SqlParameter[] param=
{
DBHelper.GetParameter("@UserName",SqlDbType.NVarChar,50,"[UserName]",username),
DBHelper.GetParameter("@Question",SqlDbType.NVarChar,50,"[Question]",question),
DBHelper.GetParameter("@Answer",SqlDbType.NVarChar,50,"[Answer]",answer)
};
DataTable table= DBHelper.ExecuteDt(sb.ToString(), param);
if (table.Rows.Count > 0)
{
return table.Rows[0]["Password"].ToString();
}
else
{
return "";
}
}
///<summary>
///获得一个用户资料
///</summary>
///<param name="userid"></param>
///<returns></returns>
public DataTable getUser(intuserid)
{
StringBuilder sb= new StringBuilder();
sb.Append("select [UserID],[UserName],[Password],[Power],[Email],[Question],[Answer]");
sb.Append("from UserInfo where [UserID]=@UserID");
SqlParameter[] param= { DBHelper.GetParameter("@UserID", SqlDbType.Int,4, "[UserID]", userid) };
return DBHelper.ExecuteDt(sb.ToString(), param);
}
#endregion
publicUserInfo()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
}
}
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using SQLHelper;
using System.Text;
using System.Data.SqlClient;
/// <summary>
/// UserInfo 的摘要说明
/// </summary>
namespace BLL
{
public class UserInfo
{
#region增
///<summary>
///创建一个新用户
///</summary>
///<param name="username">用户名称</param>
///<param name="password">用户密码</param>
///<param name="email">电子邮件</param>
///<param name="question">密码问题</param>
///<param name="answer">问题答案</param>
///<returns></returns>
public int createUser(string username, string password, int power, string email, string question, string answer)
{
StringBuilder sb= new StringBuilder();
sb.Append("insert into UserInfo ([UserName],[Password],[Power],[Email],[Question],[Answer]) values");
sb.Append("(@UserName,@Password,@Power,@Email,@Question,@Answer)");
SqlParameter[] param=
{
DBHelper.GetParameter("@UserName",SqlDbType.NVarChar,50,"[UserName]",username),
DBHelper.GetParameter("@Password",SqlDbType.NVarChar,50,"[Password]",password),
DBHelper.GetParameter("@Power",SqlDbType.Int,4,"[Power]",power),
DBHelper.GetParameter("@Email",SqlDbType.NVarChar,50,"[Email]",email),
DBHelper.GetParameter("@Question",SqlDbType.NVarChar,50,"[Question]",question),
DBHelper.GetParameter("@Answer",SqlDbType.NVarChar,50,"[Answer]",answer)
};
return DBHelper.ExecuteSql(sb.ToString(), param);
}
#endregion
#region删
///<summary>
///删除一个用户
///</summary>
///<param name="userid">用户编号</param>
///<returns></returns>
public int deleteUser(int userid)
{
StringBuilder sb= new StringBuilder();
sb.Append("delete from UserInfo where [UserID]=@UserID");
SqlParameter[] param= { DBHelper.GetParameter("@UserID", SqlDbType.Int,4, "[UserID]", userid) };
return DBHelper.ExecuteSql(sb.ToString(), param);
}
#endregion
#region改
///<summary>
///修改密码
///</summary>
///<param name="userid">用户编号</param>
///<param name="newpassword">新密码</param>
///<returns></returns>
public int updateUserPassword(int userid, string newpassword)
{
StringBuilder sb= new StringBuilder();
sb.Append("update UserInfo set [Password]=@newpassword where [UserID]=@UserID");
SqlParameter[] param=
{
DBHelper.GetParameter("@UserID", SqlDbType.Int, 4,"[UserID]", userid) ,
DBHelper.GetParameter("@newpassword",SqlDbType.NVarChar,50,"[Password]",newpassword)
};
return DBHelper.ExecuteSql(sb.ToString(), param);
}
///<summary>
///修改用户资料
///</summary>
///<param name="userid">用户编号</param>
///<param name="password">用户密码</param>
///<param name="email">电子邮件</param>
///<param name="question">密码问题</param>
///<param name="answer">问题答案</param>
///<returns></returns>
public int updateUser(int userid, string password, string email, string question, string answer)
{
StringBuilder sb= new StringBuilder();
sb.Append("update UserInfo set [Password]=@Password,[Email]=@Email,[Question]=@Question,");
sb.Append("[Answer]=@Answer where [UserID]=@UserID");
SqlParameter[] param=
{
DBHelper.GetParameter("@UserID",SqlDbType.Int,4,"[UserID]",userid),
DBHelper.GetParameter("@Password",SqlDbType.NVarChar,50,"[Password]",password),
DBHelper.GetParameter("@Email",SqlDbType.NVarChar,50,"[Email]",email),
DBHelper.GetParameter("@Question",SqlDbType.NVarChar,50,"[Question]",question),
DBHelper.GetParameter("@Answer",SqlDbType.NVarChar,50,"[Answer]",answer)
};
return DBHelper.ExecuteSql(sb.ToString(), param);
}
#endregion
#region查
///<summary>
///找回用户密码
///</summary>
///<param name="username">用户名</param>
///<param name="question">密码问题</param>
///<param name="answer">问题答案</param>
///<returns></returns>
public stringresearchPassword(stringusername, stringquestion, stringanswer)
{
StringBuilder sb= new StringBuilder();
sb.Append("select [Password] from UserInfo where [UserName]=@UserName");
sb.Append("and [Question]=@Question and [Answer]=@Answer");
SqlParameter[] param=
{
DBHelper.GetParameter("@UserName",SqlDbType.NVarChar,50,"[UserName]",username),
DBHelper.GetParameter("@Question",SqlDbType.NVarChar,50,"[Question]",question),
DBHelper.GetParameter("@Answer",SqlDbType.NVarChar,50,"[Answer]",answer)
};
DataTable table= DBHelper.ExecuteDt(sb.ToString(), param);
if (table.Rows.Count > 0)
{
return table.Rows[0]["Password"].ToString();
}
else
{
return "";
}
}
///<summary>
///获得一个用户资料
///</summary>
///<param name="userid"></param>
///<returns></returns>
public DataTable getUser(intuserid)
{
StringBuilder sb= new StringBuilder();
sb.Append("select [UserID],[UserName],[Password],[Power],[Email],[Question],[Answer]");
sb.Append("from UserInfo where [UserID]=@UserID");
SqlParameter[] param= { DBHelper.GetParameter("@UserID", SqlDbType.Int,4, "[UserID]", userid) };
return DBHelper.ExecuteDt(sb.ToString(), param);
}
#endregion
publicUserInfo()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
}
}
ZESTRON
2024-09-04 广告
2024-09-04 广告
在Dr. O.K. Wack Chemie GmbH,我们高度重视ZESTRON的表界面分析技术。该技术通过深入研究材料表面与界面的性质,为提升产品质量与可靠性提供了有力支持。ZESTRON的表界面分析不仅涵盖了相变化、化学反应、吸附与解吸...
点击进入详情页
本回答由ZESTRON提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询