public static bool ChangePrivillege(MyMySql sql, string userid, string privillege) { string SQLstr = $@" UPDATE users SET userprivillege = {privillege} WHERE userid = {userid}"; return(sql.executeNonQuery(SQLstr) == 1); }
public static bool AddBook(MyMySql sql, string bookname, string bookauthor, string bookcount) { string SQLstr = $@" INSERT INTO books (bookname, bookauthor, bookcount) VALUES ('{bookname.Trim()}','{bookauthor.Trim()}',{bookcount})"; return(sql.executeNonQuery(SQLstr) == 1); }
public static bool RemoveTag(MyMySql sql, string bookid, string tagid) { string sqlstr = $@" DELETE FROM book_tag WHERE bookid = {bookid} AND tagid = {tagid}"; return(sql.executeNonQuery(sqlstr) != 0); }
public static bool AddTag(MyMySql sql, string bookid, string tagid) { string sqlstr = $@" INSERT INTO book_tag(bookid, tagid) VALUES ({bookid}, {tagid})"; return(sql.executeNonQuery(sqlstr) == 1); }
public static bool EditBook(MyMySql sql, string bookid, string bookname, string bookauthor, string bookcount) { string SQLstr = $@" UPDATE books SET bookname = '{bookname}', bookauthor = '{bookauthor}', bookcount = {bookcount} WHERE bookid = {bookid}"; return(sql.executeNonQuery(SQLstr) == 1); }
public static bool Leave(MyMySql sql, string roomid, string deskid, string seatid) { string sqlstr = $@" UPDATE seats SET backdatetime = NOW() WHERE roomid = {roomid} AND deskid = {deskid} AND seatid = {seatid}"; return(sql.executeNonQuery(sqlstr) == 1); }
static public int BorrowBooks(MyMySql sql, string userid, List <string> bookids) { int result = 0; string booklist = ""; foreach (var bookid in bookids) { booklist += $"\n({userid}, {bookid}, NOW()),"; } booklist = booklist.Substring(0, booklist.Length - 1); string SQLstr = "INSERT INTO borrowlog(`userid`, `bookid`, `borrowdatetime`) VALUES" + booklist; result = sql.executeNonQuery(SQLstr); return(result); }
static public bool changeUserInfo(MyMySql mysql, string userid, string contact, int sex, string username = "", string password = "") { string passwd = EncryptionUtils.getMD5(password).ToUpper(); string SQLstr = "UPDATE users SET " + (username.Equals("") ? "" : $"username = '******',") + (password.Equals("") ? "" : $"password = '******',") + $"contact = '{contact}', " + $"sex = {sex} " + $"WHERE userid = {userid}"; int result = mysql.executeNonQuery(SQLstr); if (result != 1) { return(false); } return(true); }
static public void ReturnBook(MyMySql sql, string logid) { string SQLstr = $"UPDATE borrowlog SET returndatetime = NOW() WHERE logid = {logid}"; sql.executeNonQuery(SQLstr); }
public static bool Order(MyMySql sql, string roomid, string deskid, string seatid, string userid) { string sqlstr = $"INSERT INTO seats (roomid, userid, deskid, seatid, orderdatetime) VALUES ({roomid},{userid}, {deskid},{seatid}, NOW())"; return(sql.executeNonQuery(sqlstr) == 1); }