/// <summary> /// 确认还书 /// </summary> /// <param name="returnList">还书对象集合</param> /// <param name="nonReturnList">为还书对象集合</param> /// <param name="adminName_R">当前管理员</param> /// <returns></returns> public bool ReturnBook(List <BorrowDetail> returnList, List <BorrowDetail> nonReturnList, string adminName_R) { List <ReturnBook> list = new List <ReturnBook>(); foreach (BorrowDetail returnBook in returnList) { int returnCount = returnBook.ReturnCount; var borrowDetails = nonReturnList.Where(o => o.BarCode == returnBook.BarCode).ToList(); foreach (BorrowDetail borrowDetail in borrowDetails) { if (returnCount <= borrowDetail.NonReturnCount) { list.Add(new ReturnBook { BorrowDetailId = borrowDetail.BorrowDetailId, ReturnCount = returnCount, AdminName_R = adminName_R, }); break; } else { list.Add(new ReturnBook { BorrowDetailId = borrowDetail.BorrowDetailId, ReturnCount = borrowDetail.NonReturnCount, AdminName_R = adminName_R, }); returnCount -= borrowDetail.NonReturnCount; } } } return(borrowService.ReturnBook(list)); }
/// <summary> /// 图书归还 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnConfirmReturn_Click(object sender, EventArgs e) { try { //【1】调用业务逻辑操作后台 borrowService.ReturnBook(this.returnList, this.nonReturnList, Program.admin.AdminName); //【2】清除数据 this.groupBox1.Text = ""; this.pbReaderImage.Image = null; this.dgvNonReturnList.DataSource = null; this.dgvReturnList.DataSource = null; this.btnConfirmReturn.Enabled = false; this.txtBarCode.Clear(); this.txtBarCode.Enabled = false; this.txtReadingCard.Text = ""; this.lblReaderName.Text = ""; this.lblRoleName.Text = ""; this.lblAllowCounts.Text = "0"; this.lbl_Remainder.Text = "0"; this.lblBorrowCount.Text = "0"; this.txtReadingCard.Focus(); MessageBox.Show("还书成功", "还书提示"); } catch (Exception) { throw; } }
public ActionResult ReturnBook(int borrowId) { BorrowService borrowService = new BorrowService(); borrowService.ReturnBook(borrowId); return(View("Index")); }
public ActionResult ReturnBorrow(int id) { borrowService.ReturnBook(id); return(Json(new { success = true }, JsonRequestBehavior.AllowGet)); }