private void Clear_Click(object sender, RoutedEventArgs e) { Isbn.Clear(); isbnmsg.Visibility = Visibility.Visible; Name.Content = ""; fkTypeCode.Content = ""; fkTypeName.Content = ""; fkPressName.Content = ""; Author.Content = ""; unifyNum.Content = ""; parallelTitle.Content = ""; postIssueNumber.Content = ""; openBook.Content = ""; issnPrice.Content = ""; releaseCycle.Content = ""; remark.Content = ""; periodicalInfo = new PeriodicalInfo(); EPC.Clear(); BookCode.Clear(); info = new CallNumberInfo(); CallNumberTxt.Clear(); callNumbermsg.Visibility = Visibility.Visible; PeriodicalCode.Clear(); PeriodicalMsg.Visibility = Visibility.Visible; sNumber.Content = ""; page.Content = ""; publicationDateStr.Content = ""; remarks.Content = ""; price.Content = ""; }
public ActionResult BorrowBook(int userId, int bookId) { Book book = new Book(); book = db.Books.Where(a => a.BookId == bookId).Single(); User user = new User(); user = db.Users.Where(a => a.UserId == userId).Single(); Booking booking = new Booking(); BookCode bookCode = new BookCode(); bookCode = db.BookCodes.Where(a => a.BookId == bookId && a.IsInLibrary == true).First(); booking.Book = book; booking.BookId = bookId; booking.User = user; booking.DateCreated = DateTime.Now; booking.DateReturned = null; booking.BookCodeId = bookCode.BookCodeId; bookCode.IsInLibrary = false; db.Bookings.Add(booking); db.BookCodes.AddOrUpdate(bookCode); db.SaveChanges(); return(View(booking)); }
public ActionResult DetailsUser(int userId) { User user = new User(); BookCode bookCode = new BookCode(); user = db.Users.Where(a => a.UserId == userId).Single(); List <BookReserve> bookReserves = db.BookReserves.Where(a => a.UserId == userId).ToList(); List <Booking> bookingList = db.Bookings.Where(a => a.UserId == userId).ToList(); // List<PaymentLibrary> paymentLibrary = db.Payments.Where(a => a.UserId == userId).ToList(); string bookName; List <string> bookNameList = new List <string>(); foreach (var booking in bookingList) { bookCode = db.BookCodes.Where(a => a.BookCodeId == booking.BookCodeId).Single(); bookName = db.Books.Where(a => a.BookId == bookCode.BookId).Single().Name; bookNameList.Add(bookName); } ViewBag.BookNames = bookNameList; user.ListOfReserves = bookReserves; user.ListOfReserves = db.BookReserves.Where(a => a.UserId == userId).ToList(); user.Bookings = bookingList; user.ListOfPayment = db.Payments.Where(a => a.UserId == userId).ToList(); return(View(user)); }
public ActionResult ListOfLoans() { BookCode bookCode = new BookCode(); List <Booking> listOfBookings = db.Bookings.ToList(); List <string> listOfSerialNumbers = new List <string>(); List <bool> listOfIsInLibrary = new List <bool>(); List <String> listOfNames = new List <string>(); List <String> listOfFirstNames = new List <string>(); List <String> listOfSurNames = new List <string>(); List <string> userNames = new List <string>(); List <User> listofUsers = db.Users.ToList(); string bookName; foreach (var booking in listOfBookings) { bookCode = db.BookCodes.Where(a => a.BookCodeId == booking.BookCodeId).Single(); bookName = db.Books.Where(a => a.BookId == bookCode.BookId).Single().Name; listOfNames.Add(bookName); listOfSerialNumbers.Add(bookCode.BookSerialNumber); listOfIsInLibrary.Add(bookCode.IsInLibrary); userNames.Add(db.Users.Where(a => a.UserId == booking.UserId).Single().Name + " " + db.Users.Where(a => a.UserId == booking.UserId).Single().Surname); } ViewBag.UserNames = userNames; ViewBag.BookSerialNumber = listOfSerialNumbers; ViewBag.ListOfNames = listOfNames; ViewBag.ListOfFirstNames = listOfFirstNames; ViewBag.ListOfSurNames = listOfSurNames; ViewBag.IsInLibrary = listOfIsInLibrary; return(View(listOfBookings)); }
public override Task <Book> BookByCode(BookCode request, ServerCallContext context) { var query = from book in books where book.Code == request.Code select book; return(Task.FromResult(query.FirstOrDefault())); }
public ActionResult FinalizeReservation(int reservationId) { BookReserve bookReserve = db.BookReserves.Where(a => a.BookReserveId == reservationId).Single(); User user = db.Users.Where(a => a.UserId == bookReserve.UserId).Single(); BookCode bookCode = new BookCode(); bookCode = db.BookCodes.Where(a => a.BookCodeId == bookReserve.BookCodeId && a.IsInLibrary == true).First(); bookCode.IsInLibrary = false; Booking booking = new Booking(); booking.BookId = bookCode.BookId; booking.User = user; booking.DateCreated = DateTime.Now; booking.DateReturned = null; booking.BookCodeId = bookCode.BookCodeId; booking.Book = db.Books.Where(a => a.BookCode.FirstOrDefault().BookCodeId == bookCode.BookCodeId).Single(); user.Bookings.Add(booking); if (ModelState.IsValid) { db.BookReserves.Remove(bookReserve); db.Bookings.AddOrUpdate(booking); db.BookCodes.AddOrUpdate(bookCode); db.SaveChanges(); return(RedirectToAction("ListOfReservations")); } return(View("Error")); }
public void IsInLibraryPropertyOk() { //create an instance of the class we want to create BookCode bookCode = new BookCode(); //create some test data to assign to the property bool TestData = true; //assign the data to the property bookCode.IsInLibrary = TestData; //test to see that the two values are the same Assert.AreEqual(bookCode.IsInLibrary, TestData); }
public void BookSerialNumberPropertyOk() { //create an instance of the class we want to create BookCode bookCode = new BookCode(); //create some test data to assign to the property string TestData = "33353"; //assign the data to the property bookCode.BookSerialNumber = TestData; //test to see that the two values are the same Assert.AreEqual(bookCode.BookSerialNumber, TestData); }
public void BookIdPropertyOk() { //create an instance of the class we want to create BookCode bookCode = new BookCode(); //create some test data to assign to the property Int32 TestData = 1; //assign the data to the property bookCode.BookId = TestData; //test to see that the two values are the same Assert.AreEqual(bookCode.BookId, TestData); }
public ActionResult CreateCopy(BookCode bookCode) { if (!db.BookCodes.Select(a => a.BookSerialNumber).Contains(bookCode.BookSerialNumber)) { db.BookCodes.Add(bookCode); db.SaveChanges(); } PrintLabel(bookCode.BookSerialNumber); return(Redirect("/Admin/DisplayCopies/" + bookCode.BookId)); }
public ActionResult ListOfReservations(int userId) { BookCode bookCode = new BookCode(); List <BookReserve> listOfBookReserves = db.BookReserves.Where(a => a.UserId == userId).ToList(); Book book = new Book(); foreach (var bookReserve in listOfBookReserves) { bookCode = db.BookCodes.Where(a => a.BookCodeId == bookReserve.BookCodeId).Single(); ViewBag.BookSerialNumber = bookCode.BookSerialNumber; ViewBag.IsInLibrary = bookCode.IsInLibrary; book = db.Books.Where(a => a.BookId == bookCode.BookId).Single(); ViewBag.TitleBook = book.Name; } return(View(listOfBookReserves)); }
public ActionResult ReturnBook(string bookSerialNumber) { // bookSerialNumber = RouteData.Values["SerialNumber"] + Request.Url.Query; LibraryRegulations libraryRegulations = new LibraryRegulations(); List <BookCode> bookCode = db.BookCodes.ToList(); List <Booking> bookings = db.Bookings.ToList(); BookCode bookCode1 = bookCode.Where(a => a.BookSerialNumber == bookSerialNumber).Single(); if (db.Bookings.Where(a => a.BookCodeId == bookCode1.BookCodeId && a.DateReturned == null).Count() > 0) { int bookingId = Int32.Parse(db.Bookings.Where(a => a.BookCodeId == bookCode1.BookCodeId && a.DateReturned == null).Single().BookingId.ToString()); Booking booking = db.Bookings.Where(a => a.BookingId == bookingId).Single(); User user = db.Users.Where(a => a.UserId == booking.UserId).Single(); foreach (var book in bookCode) { if (book.BookSerialNumber == bookSerialNumber) { booking.DateReturned = DateTime.Today; book.IsInLibrary = true; if ((DateTime.Today - booking.DateCreated).TotalDays > libraryRegulations.BorrowTime) { //create a fee for user for being late PaymentLibrary payment = new PaymentLibrary() { UserId = user.UserId, Amount = libraryRegulations.Fine, BookingId = booking.BookingId, Status = "Unpaid", DatePaid = null }; db.Payments.Add(payment); } } db.BookCodes.AddOrUpdate(book); } db.SaveChanges(); return(Redirect("/Admin/BookDatabase")); } else { return(View("Error")); } }
private void Clear_Click(object sender, RoutedEventArgs e) { EPC.Clear(); BookCode.Clear(); CallNumberTxt.Clear(); Isbn.Clear(); isbnmsg.Visibility = Visibility.Visible; BookName.Content = ""; Price.Content = ""; Author.Content = ""; Press.Content = ""; PressDate.Content = ""; CallNumber.Content = ""; PageNumber.Content = ""; Classification.Content = ""; info = new CallNumberInfo(); }
public PeriodicalControl(MainControl mainControl) { InitializeComponent(); DataContext = null; DataContext = new PeriodicalViewModel(this); this.mainControl = mainControl; mainControl.thread = new Thread(new ThreadStart(() => { while (true) { if (ServerSetting.rfid.IsOpen()) { ServerSetting.rfid.Start(); } this.Dispatcher.BeginInvoke((Action) delegate { lock (ServerSetting.EPClist) { if (ServerSetting.EPClist.Count == 0 && string.IsNullOrEmpty(EPC.Text)) { BookCode.Text = "请先扫描RFID"; BookCode.IsReadOnly = true; EPC.Clear(); } else { if (BookCode.IsReadOnly) { BookCode.IsReadOnly = false; BookCode.Text = ""; BookCode.Focus(); lock (ServerSetting.EPClist) { string epc = ServerSetting.EPClist.Dequeue(); ServerSetting.EPClist.Enqueue(epc); EPC.Text = epc; } } } } }); Thread.Sleep(500); } })); mainControl.thread.IsBackground = true; }
public ActionResult DeleteSerialNumber(string SerialNumber) { BookCode bookCode = db.BookCodes.Where(a => a.BookSerialNumber == SerialNumber).Single(); if (bookCode.IsInLibrary == true) { if (ModelState.IsValid) { db.BookCodes.Remove(bookCode); db.SaveChanges(); } } else { return(View("Error")); } return(Redirect("Stocks?userId" + Session["UserId"])); }
public ActionResult ListOfReservations() { BookCode bookCode = new BookCode(); string bookName; List <BookReserve> listOfBookReserves = db.BookReserves.ToList(); List <string> listOfSerialNumbers = new List <string>(); List <bool> listOfIsInLibrary = new List <bool>(); List <String> listOfNames = new List <string>(); foreach (var bookReserve in listOfBookReserves) { bookCode = db.BookCodes.Where(a => a.BookCodeId == bookReserve.BookCodeId).Single(); bookName = db.Books.Where(a => a.BookId == bookCode.BookId).Single().Name; listOfNames.Add(bookName); listOfSerialNumbers.Add(bookCode.BookSerialNumber); listOfIsInLibrary.Add(bookCode.IsInLibrary); } ViewBag.BookSerialNumber = listOfSerialNumbers; ViewBag.ListOfNames = listOfNames; ViewBag.IsInLibrary = listOfIsInLibrary; return(View(listOfBookReserves)); }
{ //DropCreateDatabaseAlways<LibraryContext> protected override void Seed(LibraryContext context) { LibraryRegulations libraryRegulations = new LibraryRegulations() { Fine = 3, BorrowTime = 7 }; //------------------------------------- PEOPLE Author author = new Author() { Id = 1, Name = "Joanne", Surname = "Rowling", }; context.Authors.Add(author); Author author1 = new Author() { Id = 2, Name = "Kremi", Surname = "Super", }; context.Authors.Add(author1); Author author2 = new Author() { Id = 3, Name = "Guten", Surname = "Yers", }; context.Authors.Add(author2); Author author3 = new Author() { Id = 4, Name = "Awel", Surname = "Rona", }; context.Authors.Add(author3); Book book = new Book() { DateOfPublication = DateTime.Now, Genre = Genre.Action, Name = "Harry Potter", Overview = "good book", Publisher = "JKR", BookId = 1, Rating = 5, //BookImage = "~/Images/BookImageTest.png", }; context.Books.Add(book); Book book2 = new Book() { DateOfPublication = DateTime.Now, Genre = Genre.Horror, Name = "Lord of The Rings", Overview = "Fantasy book", Publisher = "Tolkien", BookId = 2, Rating = 5, //BookImage = "~/Images/BookImageTest.png", Link = "http://www.china.doingbusinessguide.co.uk/media/880543/Doing_Business_in_China_Guide_PDF.pdf", }; context.Books.Add(book2); Book book3 = new Book() { DateOfPublication = DateTime.Now, Genre = Genre.Horror, Name = "James Bond", Overview = "Spy book", Publisher = "007", BookId = 3, Rating = 5, //BookImage = "~/Images/BookImageTest.png", }; context.Books.Add(book3); Book book4 = new Book() { DateOfPublication = DateTime.Now, Genre = Genre.Horror, Name = "Doom", Overview = "Slayer book", Publisher = "Bethesda", // BookImage = "~/Images/BookImageTest.png", BookId = 6, Rating = 5, }; context.Books.Add(book4); BookCode bookCode = new BookCode() { BookCodeId = 1, BookId = 1, BookSerialNumber = "33233", IsInLibrary = true }; context.BookCodes.Add(bookCode); BookCode bookCode1 = new BookCode() { BookCodeId = 2, BookId = 1, BookSerialNumber = "33234", IsInLibrary = true }; context.BookCodes.Add(bookCode1); BookCode bookCode2 = new BookCode() { BookCodeId = 3, BookId = 1, BookSerialNumber = "33235", IsInLibrary = false }; context.BookCodes.Add(bookCode2); BookCode bookCode3 = new BookCode() { BookCodeId = 4, BookId = 2, BookSerialNumber = "33236", IsInLibrary = true }; context.BookCodes.Add(bookCode3); BookCode bookCode4 = new BookCode() { BookCodeId = 5, BookId = 2, BookSerialNumber = "33237", IsInLibrary = false }; context.BookCodes.Add(bookCode4); BookCode bookCode5 = new BookCode() { BookCodeId = 4, BookId = 3, BookSerialNumber = "33238", IsInLibrary = false }; context.BookCodes.Add(bookCode5); BookCode bookCode6 = new BookCode() { BookCodeId = 5, BookId = 3, BookSerialNumber = "33239", IsInLibrary = false }; context.BookCodes.Add(bookCode6); //=------------------ User var hash = SecurePasswordHasher.Hash("abcdef!"); User user = new User(); { user.Name = "Matt"; user.Surname = "Sean"; user.DateOfBirth = new DateTime(2020, 10, 10); user.Email = "*****@*****.**"; user.HouseNo = "35"; user.Password = hash; user.UserRole = "User"; user.ZipCode = "Le27dp"; user.UserId = 1; // user.ConfirmPassword = hash; } context.Users.Add((user)); User user2 = new User(); { user2.Name = "Ethan"; user2.Surname = "Jason"; user2.DateOfBirth = new DateTime(2000, 10, 10); user2.Email = "*****@*****.**"; user2.HouseNo = "35"; user2.Password = hash; user2.UserRole = "Admin"; user2.ZipCode = "Le2 7dp"; user2.UserId = 2; } context.Users.Add((user2)); User user3 = new User(); { user3.Name = "John"; user3.Surname = "Smith"; user3.DateOfBirth = new DateTime(2020, 10, 10); user3.Email = "*****@*****.**"; user3.HouseNo = "22"; user3.Password = hash; user3.UserRole = "User"; user3.ZipCode = "Le2 7dp"; user3.UserId = 3; } context.Users.Add((user3)); ////============ Payment BookReserve bookReserve = new BookReserve() { BookReserveId = 1, BookCodeId = 1, UserId = 1, ReservationRequestTime = DateTime.Now, }; context.BookReserves.Add(bookReserve); //=============Reviews BookReview bookReview = new BookReview(); { bookReview.BookId = 1; bookReview.BookReviewId = 1; bookReview.Content = "Harry Potter is the most miserable, lonely boy you can imagine. He’s shunned by his relatives, the Dursley’s, that have raised him since he was an infant. He’s forced to live in the cupboard under the stairs, forced to wear his cousin Dudley’s hand-me-down clothes, and forced to go to his neighbour’s house when the rest of the family is doing something fun. Yes, he’s just about as miserable as you can get."; bookReview.UserId = 1; bookReview.DatePosted = DateTime.Now; } context.BookReviews.Add(bookReview); BookReview bookReview1 = new BookReview(); { bookReview1.BookId = 2; bookReview1.BookReviewId = 2; bookReview1.Content = "content testing"; bookReview1.UserId = 1; bookReview1.DatePosted = DateTime.Now; } context.BookReviews.Add(bookReview1); //------------------------------------------------ Booking booking = new Booking(); { booking.BookCodeId = 1; booking.UserId = 1; booking.BookId = 1; booking.DateCreated = new DateTime(2019, 12, 05); booking.DateReturned = new DateTime(2019, 12, 12); } context.Bookings.Add(booking); Booking booking1 = new Booking(); { booking1.BookCodeId = 1; booking1.UserId = 1; booking1.BookId = 2; booking1.DateCreated = new DateTime(2021, 12, 05); booking1.DateReturned = new DateTime(2020, 01, 02); } context.Bookings.Add(booking1); Booking booking2 = new Booking(); { booking2.BookCodeId = 1; booking2.UserId = 2; booking2.BookId = 2; booking2.DateCreated = new DateTime(2021, 12, 05); booking2.DateReturned = null; } context.Bookings.Add(booking2); Booking booking3 = new Booking(); { booking3.BookCodeId = 3; booking3.UserId = 2; booking3.BookId = 1; booking3.DateCreated = new DateTime(2019, 12, 05); booking3.DateReturned = new DateTime(2020, 04, 01); } context.Bookings.Add(booking3); //--------------------------Payment // LibraryRegulations libraryRegulations = new LibraryRegulations(); PaymentLibrary payment = new PaymentLibrary(); { // Booking bookingPayment1 = context.Bookings.Where(a => a.BookingId == 1).Single(); payment.UserId = 1; payment.Amount = libraryRegulations.Fine; payment.DatePaid = null; payment.PaymentLibraryId = 1; payment.Status = "Unpaid"; payment.BookingId = 2; // payment.Booking = bookingPayment1; } context.Payments.Add(payment); PaymentLibrary payment1 = new PaymentLibrary(); { //Booking bookingPayment2 = context.Bookings.Where(a => a.BookingId == 2).Single(); payment1.UserId = 1; payment1.Amount = libraryRegulations.Fine; payment1.DatePaid = DateTime.Now; payment1.PaymentLibraryId = 2; payment1.Status = "Paid"; payment.BookingId = 1; // payment.Booking = bookingPayment2; } context.Payments.Add(payment1); //Payment payment2 = new Payment(); //{ // payment2.UserId = 1; // payment2.Amount = 5; // payment2.DatePaid = null; // payment2.PaymentLibraryId = 3; // payment2.Status = "Unpaid"; // payment.BookingId = 3; //} //context.Payments.Add(payment2); //------------------------------------------------------ COMMENTS Comment com2 = new Comment(); com2.CommentId = 4; com2.AuthorId = "1"; com2.Content = " Great book! "; com2.PersonId = 3; com2.BookId = 1; com2.PostId = 1; com2.IsBlocked = false; com2.UserRating = 6f; context.Comment.Add(com2); Comment com3 = new Comment(); com3.CommentId = 1; com3.AuthorId = "1"; com3.Content = " Great book! "; com3.PersonId = 1; com3.BookId = 2; com3.PostId = 1; com3.IsBlocked = false; com3.UserRating = 6f; context.Comment.Add(com3); Comment com4 = new Comment(); com4.CommentId = 4; com4.AuthorId = "1"; com4.Content = " Great book! "; com4.PersonId = 1; com4.BookId = 3; com4.PostId = 1; com4.IsBlocked = false; com4.UserRating = 6f; context.Comment.Add(com4); Comment com5 = new Comment(); com5.CommentId = 5; com5.AuthorId = "3"; com5.Content = " Great book! "; com5.PersonId = 3; com5.BookId = 4; com5.PostId = 1; com5.IsBlocked = false; com5.UserRating = 5f; context.Comment.Add(com5); //------------------------------------------------------ //-------------------------------------------------------------CommentReply //CommentReply comReply3 = new CommentReply() { CommentId = 2, CommentReplyID = 4, AuthorId = "1", PersonId = 1, BookId = 1, PostId = 1, Content = "this is a reply" }; //context.CommentReply.Add(comReply3); //CommentReply comReply4 = new CommentReply() { CommentId = 4, CommentReplyID = 5, AuthorId = "1", PersonId = 1, BookId = 1, PostId = 1, Content = "reply1-2" }; //context.CommentReply.Add(comReply4); //CommentReply comReply5 = new CommentReply() { CommentId = 2, CommentReplyID = 6, AuthorId = "1", PersonId = 1, BookId = 1, PostId = 1, Content = "this is a reply1-3" }; //context.CommentReply.Add(comReply5); //base.Seed(context); //--------------------------------------------------------------Loan info }
private void Button_Click_1(object sender, RoutedEventArgs e) { lock (BookCode.Text) { if (place.SelectedIndex < 0) { error.Content = "未选择馆藏地"; Success.Visibility = Visibility.Hidden; False.Visibility = Visibility.Visible; return; } if (periodicalInfo == null || string.IsNullOrEmpty(periodicalInfo.fkCataPeriodicalId)) { error.Content = "未选中需要绑定的期刊"; Success.Visibility = Visibility.Hidden; False.Visibility = Visibility.Visible; return; } if (string.IsNullOrEmpty(CallNumberTxt.Text)) { error.Content = "索取号不能为空"; Success.Visibility = Visibility.Hidden; False.Visibility = Visibility.Visible; return; } if (string.IsNullOrEmpty(periodicalInfo.pNumberId)) { error.Content = "未选定子刊"; Success.Visibility = Visibility.Hidden; False.Visibility = Visibility.Visible; return; } if (string.IsNullOrEmpty(BookCode.Text)) { error.Content = "书籍编码不能为空"; Success.Visibility = Visibility.Hidden; False.Visibility = Visibility.Visible; return; } if (string.IsNullOrEmpty(EPC.Text)) { error.Content = "书籍编码不能为空"; Success.Visibility = Visibility.Hidden; False.Visibility = Visibility.Visible; return; } if (periodicalInfo == null) { return; } if (lendingPermission.IsChecked.Value == true) { periodicalInfo.lendingPermission = "1"; } else { periodicalInfo.lendingPermission = "0"; } if (available.IsChecked.Value == true) { periodicalInfo.available = "1"; } else { periodicalInfo.available = "0"; } periodicalInfo.callNumber = CallNumberTxt.Text; periodicalInfo.code = BookCode.Text; string epc = ServerSetting.EPClist.Dequeue(); periodicalInfo.rfid = epc; if (ServerSetting.OldEPClist.Contains(epc)) { error.Content = "RFID重复"; Success.Visibility = Visibility.Hidden; False.Visibility = Visibility.Visible; EPC.Clear(); return; } PlaceInfo placeInfo = place.SelectedItem as PlaceInfo; periodicalInfo.placeId = placeInfo.id; PeriodicalAddDAL periodicalAddDAL = new PeriodicalAddDAL(); object errorMsg = periodicalInfo; if (periodicalAddDAL.PeriodicalAdd(ref errorMsg)) { RetrunInfo retrunInfo = errorMsg as RetrunInfo; if (!retrunInfo.TrueOrFalse) { Success.Visibility = Visibility.Hidden; False.Visibility = Visibility.Visible; if (retrunInfo.result.Equals("RFID重复")) { ServerSetting.OldEPClist.Enqueue(epc); } if (ServerSetting.IsOverDue) { ErrorPage errorPage = new ErrorPage(error.Content.ToString(), mainControl.mainWindow); DialogHelper.ShowDialog(errorPage); } error.Content = retrunInfo.result.ToString(); BookCode.IsReadOnly = true; } else { Success.Visibility = Visibility.Visible; False.Visibility = Visibility.Hidden; EPC.Clear(); ///成功列入已处理列 ServerSetting.OldEPClist.Enqueue(epc); BookCode.IsReadOnly = true; ///增加图片 List <MarCodeInfo> infos = MarCodeList.ItemsSource as List <MarCodeInfo>; AddCell(infos, CallNumberTxt.Text); int index = CallNumberTxt.Text.IndexOf("/"); string str1 = ""; string str = CallNumberTxt.Text.Substring(0, index + 1); if (CallNumberTxt.Text.Length > index + 1) { str1 = CallNumberTxt.Text.Substring(index + 1, CallNumberTxt.Text.Length - index - 1); } CallNumberTxt.Text = str + (str1.ToInt() + 1).ToString(); error.Content = ""; if (!string.IsNullOrEmpty(infos[infos.Count - 1].MarCode3)) { MessageBox.Show("单次操作最多可打印40张书标,后续绑定将不再生成"); } } } else { Success.Visibility = Visibility.Hidden; False.Visibility = Visibility.Visible; EPC.Clear(); } BookCode.Clear(); } EPC.Clear(); }
private void Button_Click_2(object sender, RoutedEventArgs e) { lock (BookCode.Text) { if (mainControl.info == null) { return; } if (string.IsNullOrEmpty(mainControl.info.id)) { error.Content = "未选中需要绑定的书籍"; Success.Visibility = Visibility.Hidden; False.Visibility = Visibility.Visible; return; } if (string.IsNullOrEmpty(EPC.Text)) { error.Content = "未扫描到可用RFID"; Success.Visibility = Visibility.Hidden; False.Visibility = Visibility.Visible; return; } if (string.IsNullOrEmpty(CallNumberTxt.Text)) { error.Content = "索取号不能为空"; Success.Visibility = Visibility.Hidden; False.Visibility = Visibility.Visible; return; } if (string.IsNullOrEmpty(BookCode.Text)) { error.Content = "书籍编码不能为空"; Success.Visibility = Visibility.Hidden; False.Visibility = Visibility.Visible; return; } mainControl.info.CallNumber = CallNumberTxt.Text; mainControl.info.EPC = ServerSetting.EPClist.Dequeue(); if (ServerSetting.OldEPClist.Contains(mainControl.info.EPC)) { error.Content = "RFID重复"; Success.Visibility = Visibility.Hidden; False.Visibility = Visibility.Visible; EPC.Clear(); return; } mainControl.info.BookCdoe = BookCode.Text; AddRfidDAL addRfidDAL = new AddRfidDAL(); object errorMsg = mainControl.info; if (addRfidDAL.AddRfid(ref errorMsg)) { Success.Visibility = Visibility.Visible; False.Visibility = Visibility.Hidden; EPC.Clear(); ///成功列入已处理列 ServerSetting.OldEPClist.Enqueue(mainControl.info.EPC); BookCode.IsReadOnly = true; ///增加图片 List <MarCodeInfo> infos = MarCodeList.ItemsSource as List <MarCodeInfo>; AddCell(infos, mainControl.info.CallNumber); int index = CallNumberTxt.Text.IndexOf("/"); string str1 = ""; string str = CallNumberTxt.Text.Substring(0, index + 1); if (CallNumberTxt.Text.Length > index + 1) { str1 = CallNumberTxt.Text.Substring(index + 1, CallNumberTxt.Text.Length - index - 1); } CallNumberTxt.Text = str + (str1.ToInt() + 1).ToString(); mainControl.info.CallNumber = CallNumberTxt.Text; error.Content = ""; if (!string.IsNullOrEmpty(infos[infos.Count - 1].MarCode3)) { MessageBox.Show("单次操作最多可打印40张书标,后续绑定将不再生成"); } } else { try { RetrunInfo retrunInfo = errorMsg as RetrunInfo; if (retrunInfo.result.Equals("RFID重复")) { ServerSetting.OldEPClist.Enqueue(mainControl.info.EPC); } error.Content = retrunInfo.result.ToString(); } catch { } Success.Visibility = Visibility.Hidden; False.Visibility = Visibility.Visible; EPC.Clear(); if (ServerSetting.IsOverDue) { ErrorPage errorPage = new ErrorPage(error.Content.ToString(), mainControl.mainWindow); DialogHelper.ShowDialog(errorPage); } } BookCode.Clear(); } BookCode.IsReadOnly = true; }