Beispiel #1
0
        private void SearchMethod(string url, string keyword, string method)
        {
            string SearchResult = SearchData.Post(url, keyword);
            var    ResultList   = JsonConvert.DeserializeObject <List <BookClass> >(SearchResult);

            if (method == "MyBook")
            {
                foreach (BookClass b in ResultList)
                {
                    if (b.ReturnFlag == 0)
                    {
                        BookInfo.Add(new MyBookListViewInfo {
                            Title = b.BookName, Image = b.ImageUrl, Author = b.BookAuthor, BookClassId = b.BookClassId, ReturnFlag = b.ReturnFlag, BookId = b.BookId, BorrowDate = b.BorrowDate
                        });
                    }
                }
                BookList.Adapter = new MyBookListViewAdapter(this, BookInfo, BookList, "MyBook");
            }
            else if (method == "MyBookAll")
            {
                ReturnAll.Visibility = ViewStates.Invisible;
                foreach (BookClass b in ResultList)
                {
                    BookInfo.Add(new MyBookListViewInfo {
                        Title = b.BookName, Image = b.ImageUrl, Author = b.BookAuthor, BookClassId = b.BookClassId, ReturnFlag = b.ReturnFlag, BookId = b.BookId, BorrowDate = b.BorrowDate
                    });
                }
                BookList.Adapter = new MyBookListViewAdapter(this, BookInfo, BookList, "MyBookAll");
            }

            BookList.ItemClick += BookList_ItemClick;
        }
        private void SearchMethod(string url, string keyword)
        {
            string SearchResult = SearchData.Post(url, keyword);
            var    ResultList   = JsonConvert.DeserializeObject <List <BookClass> >(SearchResult);

            foreach (BookClass b in ResultList)
            {
                string Count = BorrowData.Post("http://115.159.145.115/BookBasketBorrowCheck.php/", b.BookClassId);
                BookInfo.Add(new BookListViewInfo {
                    Title = b.BookName, Image = b.ImageUrl, Author = b.BookAuthor, BookClassId = b.BookClassId, count = Count
                });
            }
            BookList.Adapter = new BookListViewAdapter(this, BookInfo);
        }
        private void SearchMethod(string url, string keyword, string type)
        {
            string SearchResult = SearchData.Post(url, keyword, type);
            var    ResultList   = JsonConvert.DeserializeObject <List <BookClass> >(SearchResult);

            foreach (BookClass b in ResultList)
            {
                BookInfo.Add(new BookListViewInfo {
                    Title = b.BookName, Image = b.ImageUrl, Author = b.BookAuthor, BookClassId = b.BookClassId
                });
            }
            BookList.Adapter    = new BookListViewAdapter(this, BookInfo);
            BookList.ItemClick += BookList_ItemClick;
        }
Beispiel #4
0
        private void TabBookBasket()
        {
            BookList  = FindViewById <ListView>(Resource.Id.TabBookBasketList);
            BorrowAll = FindViewById <Button>(Resource.Id.BorrowAll);

            BookInfo = new List <BookBasketListInfo>();
            ISharedPreferences LoginSP      = GetSharedPreferences("LoginData", FileCreationMode.Private);
            string             SearchResult = SearchData.Post("http://115.159.145.115/BookBasket.php", LoginSP.GetString("PhoneNum", ""));
            var ResultList = JsonConvert.DeserializeObject <List <BookClass> >(SearchResult);

            foreach (BookClass b in ResultList)
            {
                BookInfo.Add(new BookBasketListInfo {
                    Title = b.BookName, Image = b.ImageUrl, BookAuthor = b.BookAuthor, BookClassId = b.BookClassId, PhoneNum = LoginSP.GetString("PhoneNum", "")
                });
            }
            BookList.Adapter = new BookBasketListAdapter(this, BookInfo);

            BookList.ItemClick += BookList_ItemClick;

            BorrowAll.Click += delegate {
                string res  = BorrowData.Post("http://115.159.145.115/BorrowCheck.php", LoginSP.GetString("PhoneNum", ""), BookInfo.Count);
                string days = SearchData.Post("http://115.159.145.115/NotRenewDays.php", LoginSP.GetString("PhoneNum", ""));
                if (int.Parse(days) < 10)
                {
                    if (res == "Success")
                    {
                        List <BorrowList> borrowList = new List <BorrowList>();
                        foreach (BookBasketListInfo b in BookInfo)
                        {
                            string AllocResult     = BorrowData.Post("http://115.159.145.115/AllocateBookId.php/", b.BookClassId);
                            var    AllocResultList = JsonConvert.DeserializeObject <List <Book> >(AllocResult);
                            foreach (Book c in AllocResultList)
                            {
                                if (c.ReturnFlag == null || c.ReturnFlag == "1")
                                {
                                    borrowList.Add(new BorrowList {
                                        BookId = c.BookId, PhoneNum = LoginSP.GetString("PhoneNum", "")
                                    });
                                    break;
                                }
                            }
                        }

                        if (borrowList.Count != 0)
                        {
                            var    BorrowJson      = JsonConvert.SerializeObject(borrowList);
                            Intent ActBorrowReader = new Intent(this, typeof(BorrowReader));
                            ActBorrowReader.PutExtra("BorrowInfo", BorrowJson);
                            StartActivity(ActBorrowReader);
                        }
                    }
                    else if (res == "Fail")
                    {
                        Toast.MakeText(this, "一个人最多借十本书哦!", ToastLength.Short).Show();
                    }
                }
                else
                {
                    Toast.MakeText(this, "您有图书超过十天没有归还,请续借或者归还后再借书!", ToastLength.Long).Show();
                }
            };
        }