private void btnSave_Click(object sender, EventArgs e) { //数据验证 //封装对象【主表】 BorrowInfo main = new BorrowInfo() { ReaderId = this.objReader.ReaderId, BorrowId = DateTime.Now.ToString("yyyyMMddhhmmssms"), AdminName_B = Program.admin.AdminName, }; //封装明细对象(将当前明细对象未封装的属性) for (int i = 0; i < detailList.Count; i++) { detailList[i].BorrowId = main.BorrowId; detailList[i].Expire = DateTime.Now.AddDays(objReader.AllowDay); detailList[i].NonReturnCount = detailList[i].BorrowCount; } try { borrowService.BorrowBook(main, detailList);//将封装的对象传递对象给业务逻辑完成数据保存 //各种数据复位 this.txtBarCode.Clear(); this.txtBarCode.Enabled = false; this.btnDel.Enabled = false; this.btnSave.Enabled = false; this.txtReadingCard.Clear(); this.lblReaderName.Text = ""; this.lblRoleName.Text = ""; this.lblAllowCounts.Text = "0"; this.lbl_Remainder.Text = "0"; this.lblBorrowCount.Text = "0"; dgvBookList.DataSource = null; this.objReader = null; MessageBox.Show("借书成功", "借书提示"); this.txtReadingCard.Focus(); } catch (Exception ex) { MessageBox.Show(ex.Message, "借书提示"); throw; } }