private void txtReadingCard_KeyDown(object sender, KeyEventArgs e) { if (this.txtReadingCard.Text.Length != 0 && e.KeyValue == 13) { objReader = readerService.GetReaderByReadingCard(this.txtReadingCard.Text.Trim()); if (objReader != null) { if (objReader.StatusId == 1) { //显示读者信息 this.lblReaderName.Text = objReader.ReaderName; this.lblRoleName.Text = objReader.RoleName; this.lblAllowCounts.Text = objReader.AllowCounts.ToString(); this.pbReaderImage.Image = objReader.ReaderImage != "" ? (Image) new Common.SerializeObjectToString().DeserializeObject(this.objReader.ReaderImage) : null; //开启图书条码扫描文本框已经还书按钮 this.txtBarCode.Enabled = true; this.btnConfirmReturn.Enabled = true; //显示读者未归还的图书 nonReturnList = borrowService.GetBorrowDetailByReadingCard(this.txtReadingCard.Text.Trim()); this.dgvNonReturnList.DataSource = null; this.dgvNonReturnList.DataSource = nonReturnList; //显示已借阅图书总数和剩余可借图书总数 /* int borrowCount = borrowService.GetBorrowCount(this.txtReadingCard.Text.Trim()); * this.lblBorrowCount.Text = borrowCount.ToString(); * this.lbl_Remainder.Text = (objReader.AllowCounts - borrowCount).ToString();*/ //基于linq实现 int borrowCount = (from n in nonReturnList select n).Sum(u => u.NonReturnCount); int remainder = objReader.AllowCounts - borrowCount; this.lblBorrowCount.Text = borrowCount.ToString(); this.lbl_Remainder.Text = remainder.ToString(); } else { MessageBox.Show("当前借阅证已经被挂失,目前不能拿继续使用!", "还书提示"); } } else { MessageBox.Show("当前借阅证号不存在!!!", "查询提示"); this.txtReadingCard.SelectAll(); } } }
/// <summary> /// 提交查询 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnQuery_Click(object sender, EventArgs e) { //验证 if (this.txt_IDCard.Text.Trim().Length == 0 && this.txt_ReadingCard.Text.Trim().Length == 0) { MessageBox.Show("请选择一个查询内容并输入查询条件", "查询提示"); return; } if (this.rdoIDCard.Checked && this.txt_IDCard.Text.Trim().Length != 0) { this.objCurrentReader = readerService.GetReaderByIDCard(this.txt_IDCard.Text.Trim()); } else { this.objCurrentReader = readerService.GetReaderByReadingCard(this.txt_ReadingCard.Text.Trim()); } //判读是否查询到信息 if (objCurrentReader != null) { if (objCurrentReader.StatusId != 0) { this.btnEnable.Enabled = true; } this.btnEdit.Enabled = true; //显示读者信息 this.lblAddress.Text = objCurrentReader.ReaderAddress; this.lblPhone.Text = objCurrentReader.PhoneNumber; this.lblPostCode.Text = objCurrentReader.PostCode; this.lblReaderName.Text = objCurrentReader.ReaderName; this.lblRoleName.Text = objCurrentReader.RoleName; this.lblReadingCard.Text = objCurrentReader.ReadingCard; this.lblGender.Text = objCurrentReader.Gender; this.pbReaderImg.Image = objCurrentReader.ReaderImage != "" ? (Image) new Common.SerializeObjectToString().DeserializeObject(objCurrentReader.ReaderImage) : null; } else { MessageBox.Show("当前读者不存在", "提示"); this.btnEnable.Enabled = false; this.btnEnable.Enabled = false; return; } }
/// <summary> /// 键盘事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void txtReadingCard_KeyDown(object sender, KeyEventArgs e) { if (this.txtReadingCard.Text.Length != 0 && e.KeyValue == 13) { objReader = readerService.GetReaderByReadingCard(this.txtReadingCard.Text.Trim()); if (objReader != null) { if (objReader.StatusId == 1) { //显示读者信息 this.lblReaderName.Text = objReader.ReaderName; this.lblRoleName.Text = objReader.RoleName; this.lblAllowCounts.Text = objReader.AllowCounts.ToString(); this.pbReaderImage.Image = objReader.ReaderImage != "" ? (Image) new Common.SerializeObjectToString().DeserializeObject(this.objReader.ReaderImage) : null; //显示已借阅图书总数和剩余可借图书总数 int borrowCount = borrowService.GetBorrowCount(this.txtReadingCard.Text.Trim()); this.lblBorrowCount.Text = borrowCount.ToString(); this.lbl_Remainder.Text = (objReader.AllowCounts - borrowCount).ToString(); //开启图书条码扫描文本框 if (objReader.AllowCounts > borrowCount) { this.txtBarCode.Enabled = true; this.txtBarCode.Focus(); } else { MessageBox.Show("当前读者借书总数已经达到上限!", "借书提示"); } } else { MessageBox.Show("当前借阅证已经被挂失,不能继续借书!", "借书提示"); } } else { MessageBox.Show("当前借阅证号不存在!!!", "查询提示"); this.txtReadingCard.SelectAll(); } } }
//根据借阅证编号查询会员信息 public Reader GetReaderByReadingCard(string ReadingCard) { return(objReaderService.GetReaderByReadingCard(ReadingCard)); }