📄 usercontrol.cs
字号:
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;
/// <summary>
/// UserControl 的摘要说明
/// </summary>
public class UserControl
{
public UserControl()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
/********************************************************************
* 验证登陆
* ******************************************************************/
public string LoginCheck(string userNo, string userPwd, ref string UserID)
{
string result = "";
string sRet = "";
dataOperate dbop = new dataOperate();
string sql = "select count(*) from UserList where UserNo = '" + userNo + "' and UserPwd = '" + userPwd + "'";
sRet = dbop.ExecuteScalar(sql, ref result);
if (sRet == "" && Convert.ToInt32(result) > 0)
{
sql = "select UserID from UserList where UserNo = '" + userNo + "' and UserPwd = '" + userPwd + "'";
sRet = dbop.ExecuteScalar(sql, ref UserID);
if (sRet == "")
{
return "";
}
else
{
return "登陆出错,请重新尝试!";
}
}
else
{
return "用户名或密码错误!";
}
}
/********************************************************************
* 验证密码
* ******************************************************************/
public static bool PasswordCheck(string userID, string userPwd)
{
string result = "";
string sRet = "";
dataOperate dbop = new dataOperate();
string sql = "select count(*) from UserList where UserID = '" + userID + "' and UserPwd = '" + userPwd + "'";
sRet = dbop.ExecuteScalar(sql, ref result);
if (sRet == "" && result=="1")
{
return true;
}
else
{
return false;
}
}
/********************************************************************
* 获取用户个人资料
* ******************************************************************/
public string GetUserDetail(string userid, ref DataSet ds, string dsName)
{
dataOperate dbop = new dataOperate();
string sql = "select * from UserList, UserInfo where UserList.UserID = UserInfo.UserID and UserList.UserID = " + userid;
string sRet = dbop.GetDataSet(sql, ref ds, dsName);
return sRet;
}
/********************************************************************
* 获取个人借阅信息
* 1表示已借,2表示续借,0表示已还
* ******************************************************************/
public string GetMyBook(string userid, ref DataSet ds, string dsName, string state)
{
dataOperate dbop = new dataOperate();
string sql = "select * from BookState inner join BookPer on BookPer.BPID = BookState.BPID inner join BookList on BookPer.BLID = BookList.BLID inner join BookKind on BookKind.BKID = BookList.BKID where BookState.UserID = " + userid;
if(state == "all")
{
}
else if(state == "borrow")
{
sql += " and BookState.BSFlag = 1 or BookState.BSFlag = 2";
}
else if(state == "reBorrow")
{
sql += " and BookState.BSFlag = 2";
}
else if(state == "returned")
{
sql += " and BookState.BSFlag = 0";
}
else if (state == "loss")
{
sql += " and BookState.BSLose = 1";
}
sql += " order by BookState.BSID desc";
string sRet = dbop.GetDataSet(sql, ref ds, dsName);
return sRet;
}
/********************************************************************
* 获取预约信息
* ******************************************************************/
public string GetBookingList(string userid, ref DataSet ds, string dsName, string state)
{
dataOperate dbop = new dataOperate();
string sql = "select * from Booking inner join BookList on Booking.BLID = BookList.BLID inner join BookKind on BookKind.BKID = BookList.BKID where Booking.UserID = " + userid;
//if (state == "all")
//{
//}
//else if (state == "finish")
//{
// sql += " and Booking.BingFlag = 2";
//}
//else if (state == "arrive")
//{
// sql += " and Booking.BingFlag = 1";
//}
//else if (state == "notarrive")
//{
// sql += " and Booking.BingFlag = 0";
//}
sql += " order by Booking.BingID desc";
string sRet = dbop.GetDataSet(sql, ref ds, dsName);
return sRet;
}
/********************************************************************
* 获取违章信息
* ******************************************************************/
public string GetArrearsInfo(string userid, ref DataSet ds, string dsName, string state, ref int count)
{
dataOperate dbop = new dataOperate();
string sql = "select * from PayList inner join BookList on PayList.BLID = BookList.BLID inner join BookKind on BookKind.BKID = BookList.BKID where PayList.UserID = " + userid;
//if (state == "all")
//{
//}
//else if (state == "finish")
//{
// sql += " and Booking.BingFlag = 2";
//}
//else if (state == "arrive")
//{
// sql += " and Booking.BingFlag = 1";
//}
//else if (state == "notarrive")
//{
// sql += " and Booking.BingFlag = 0";
//}
sql += " order by PayList.PLID desc";
string sRet = dbop.GetDataSet(sql, ref ds, dsName);
if (sRet == "")
{
count = Convert.ToInt32(ds.Tables[dsName].Rows.Count);
}
return sRet;
}
/********************************************************************
*读者挂失处理
* ******************************************************************/
public string setReaderLoss(string UserID)
{
string sql = "update userlist set userlose = 1 where userid = " + UserID;
dataOperate dbop = new dataOperate();
string sRet = "";
sRet = dbop.ExecuteNonQuery(sql);
return sRet;
}
/********************************************************************
* 确认挂失
* ******************************************************************/
public static bool ReaderLossCheck(string UserID)
{
string result = "";
dataOperate dbop = new dataOperate();
string sql = "select userlose from userlist where userid = " + UserID;
string sRet = dbop.ExecuteScalar(sql, ref result);
if (sRet == "")
{
if (result == "1")
{
return true;
}
else
{
return false;
}
}
else
{
return false;
}
}
/********************************************************************
*归还图书
* ******************************************************************/
public string returnBook(string BSID)
{
dataOperate dbop = new dataOperate();
string sql = "update BookState set BSFlag=0 where BSID = " + BSID;
string sRet = dbop.ExecuteNonQuery(sql);
return sRet;
}
/********************************************************************
* 修改密码
* ******************************************************************/
public string modifyPwd(string userid, string oldpwd, string newpwd)
{
dataOperate dbop = new dataOperate();
string sql = "select count(*) from userlist where userid = " + userid + " and userpwd = '" + oldpwd + "'";
string ret = "";
string sRet = dbop.ExecuteScalar(sql, ref ret);
if(sRet == "")
{
if(Convert.ToInt32(ret) > 0)
{
sql = "update userlist set userpwd = '" + newpwd + "' where userid = " + userid;
sRet = dbop.ExecuteNonQuery(sql);
}
else
{
sRet = "原密码错误!";
}
}
return sRet;
}
/********************************************************************
* 更新头像
* ******************************************************************/
public string renewImage(string userid, string imgurl)
{
dataOperate dbop = new dataOperate();
string sql = "update userinfo set userimage = '" + imgurl + "' where userid=" + userid;
string sRet = dbop.ExecuteNonQuery(sql);
return sRet;
}
/********************************************************************
*更新个人信息
* ******************************************************************/
public string updateInfo(string userid, string userNo, string userName, string userSex, string userBirth, string userAddress, string userPhone,
string email, string userPerID)
{
dataOperate dbop = new dataOperate();
string sql = "select userno from userlist where userid=" + userid;
string result = "";
string sRet = dbop.ExecuteScalar(sql, ref result);
if (sRet == "")
{
if (result != userNo)
{
sql = "select count(*) from userlist where userno='" + userNo + "'";
sRet = dbop.ExecuteScalar(sql, ref result);
if (sRet == "" && Convert.ToInt32(result) > 0)
{
sRet = "该证件号已经存在!";
}
else
{
sql = "update userlist set userNo = '" + userNo + "', userName = '" + userName + "', useremail = '" + email + "' where userid = " + userid;
sRet = dbop.ExecuteNonQuery(sql);
if (sRet == "")
{
sql = "update userinfo set usersex='" + userSex + "', userbirth='" + userBirth + "', userAddress='" + userAddress + "', userphone='" + userPhone + "', userperid='" + userPerID + "' where userid = " + userid;
sRet = dbop.ExecuteNonQuery(sql);
}
}
}
if (result == userNo)
{
sql = "update userlist set userName = '" + userName + "', useremail = '" + email + "' where userid = " + userid;
sRet = dbop.ExecuteNonQuery(sql);
if (sRet == "")
{
sql = "update userinfo set usersex='" + userSex + "', userbirth='" + userBirth + "', userAddress='" + userAddress + "', userphone='" + userPhone + "', userperid='" + userPerID + "' where userid = " + userid;
sRet = dbop.ExecuteNonQuery(sql);
}
}
}
return sRet;
}
/********************************************************************
* 图书借阅/预约
* ******************************************************************/
public string bookOP(string userid, string blid, string op)
{
dataOperate dbop = new dataOperate();
string sRet = "";
string sql = "";
if (op == "booking")
{
sql = "insert into booking(UserID, BLID) values(" + userid + "," + blid + ")";
sRet = dbop.ExecuteNonQuery(sql);
}
else
{
sql = "select count(*) from bookper where blid=" + blid + " and BPInLib='是'";
string ret = "";
sRet = dbop.ExecuteScalar(sql,ref ret);
if(sRet == "" && Convert.ToInt32(ret) > 0)
{
sql = "select top 1 BPID from bookper where blid=" + blid + " and BPInLib='是'";
dbop.ExecuteScalar(sql,ref ret);
sql = "insert into BookState(UserID, BPID) values(" + userid + "," + ret + ")";
sRet = dbop.ExecuteNonQuery(sql);
if (sRet == "")
{
sql = "update BookPer set BPInLib = '借出', UserID = " + userid + " where BPID = " + ret;
dbop.ExecuteNonQuery(sql);
}
}
}
return sRet;
}
/********************************************************************
*
* ******************************************************************/
/********************************************************************
*
* ******************************************************************/
/********************************************************************
*
* ******************************************************************/
/********************************************************************
*
* ******************************************************************/
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -