private void 借书ToolStripMenuItem_Click(object sender, EventArgs e) { if (!check_is_binded(username)) { MessageBox.Show("您还未绑定身份,不能使用该功能!"); } else { if (get_user_borrowed_num(username) == "5") { MessageBox.Show("您已经借了5本书,达到上限"); } else if (dataGridView1.SelectedRows.Count > 0) { MessageBoxButtons messButton = MessageBoxButtons.OKCancel; DialogResult dr = MessageBox.Show("确定要借这本书吗?", "确定", messButton); if (dr == DialogResult.OK) { if (!check_book_user_exist(username, dataGridView1.SelectedRows[0].Cells["BookNum"].Value.ToString())) { string sql = "insert into ordertable(UserName,OrderNum,OrderBookName)values( "; sql += "'" + username + "',"; sql += "'" + dataGridView1.SelectedRows[0].Cells["BookNum"].Value.ToString() + "',"; sql += "'" + dataGridView1.SelectedRows[0].Cells["BookName"].Value.ToString() + "')"; string sql2 = "update [User] set Number = Number +1 where UserName = "******"'" + username + "'"; try { SQLServer.ExecuteNonQuery(sql); MessageBox.Show("借书成功!"); load_data(); SQLServer.ExecuteNonQuery(sql2); FormUserBorrowedBooks formBorrowedBooks = new FormUserBorrowedBooks(username); Visible = false; formBorrowedBooks.ShowDialog(); Visible = true; } catch (Exception ex) { MessageBox.Show("借书失败"); Console.WriteLine(ex); } } else { MessageBox.Show("您已经借过这本书"); } } } } }
private void 已借书目ToolStripMenuItem_Click(object sender, EventArgs e) { if (!check_is_binded(username)) { MessageBox.Show("您还未绑定身份,不能使用该功能!"); } else { FormUserBorrowedBooks formUserBorrowedBooks = new FormUserBorrowedBooks(username); Visible = false; formUserBorrowedBooks.ShowDialog(); Visible = true; } }