WinFormsApp1/借书.cs

(开头部分) 3KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WinFormsApp1
{
    public partial class 借书 : Form
    {
        IQueryable<BookQueryRecord> Query;
        public 借书()
        {
            //if(Global.account == null || Global.)
            InitializeComponent();
            //RefreshQuery();
        }

        public void SearchQuery(string keyword)
        {
            Query = from b in LibraryDbContext.Shared.Books
                    join bi in LibraryDbContext.Shared.BookInfo on b.BookInfoId equals bi.Id
                    join c in LibraryDbContext.Shared.Categories on bi.CategoryID equals c.Id
                    join h in LibraryDbContext.Shared.BookWareHouses on b.Position equals h.Id
                    where bi.Name.ToLower().Contains(keyword) || bi.Author.ToLower().Contains(keyword) 
                    || bi.ISBN.Contains(keyword) || bi.Publisher.ToLower().Contains(keyword) || b.BookID.ToLower().Contains(keyword)
                    select new BookQueryRecord { book = b, wareHouse = h, bookInfo = bi, bookCategory = c };

            form_books.DataSource = Query.ToList();
        }

        private void button_search_Click(object sender, EventArgs e)
        {
            if (textbox_bookqueryword.Text == string.Empty)
                ShowAllBooks();
            else
                SearchQuery(textbox_bookqueryword.Text.ToLower());
        }

        private void button_borrow_Click(object sender, EventArgs e)
        {
            var book = ((BookQueryRecord)form_books.CurrentRow.DataBoundItem).book;

            if (book.OwnerID!=null)
            {
                MessageBox.Show("此书已被借出");
                return;
            }

            book.OwnerID = Global.account.AId;

            LibraryDbContext.Shared.BorrowLogs.Add(
            new BorrowLog
            {
                ActionType = BookActionType.Borrow,
                BookId = book.Id,
后面还有 45 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。