/// <summary>
        /// 确认添加
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnAdd_Click(object sender, EventArgs e)
        {
            Reader reader = new Reader
            {
                ReadingCard   = this.txtReadingCard.Text.Trim(),
                ReaderName    = this.txtReaderName.Text.Trim(),
                Gender        = rdoMale.Checked?"男":"女",
                IDCard        = this.txtIdCard.Text.Trim(),
                ReaderAddress = this.txtAddress.Text.Trim(),
                PostCode      = this.txtPostcode.Text.Trim(),
                PhoneNumber   = this.txtPhone.Text.Trim(),
                RoleId        = Convert.ToInt32(this.cboReaderRole.SelectedValue),
                ReaderImage   = this.pbReaderPhoto.Image == null?"": SerializeObjectToString.SerializeObject(this.pbReaderPhoto.Image),
                ReaderPwd     = "123456",
                AdminId       = Program.CurrentAdmin.AdminId
            };

            try
            {
                readerManager.AddNewReader(reader);
                MessageBox.Show("办证成功", "新增提示");
                //清除信息
            }
            catch (Exception ex)
            {
                MessageBox.Show("操作异常:" + ex.Message, "异常提示");
            }
        }
        /// <summary>
        /// 提交修改
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnSave_Click(object sender, EventArgs e)
        {
            //数据校验
            Reader reader = new Reader
            {
                ReaderId      = roleId,
                ReadingCard   = this.txtReadingCard.Text.Trim(),
                ReaderName    = this.txtReaderName.Text.Trim(),
                Gender        = rdoMale.Checked ? "男" : "女",
                ReaderAddress = this.txtAddress.Text.Trim(),
                PostCode      = this.txtPostcode.Text.Trim(),
                PhoneNumber   = this.txtPhone.Text.Trim(),
                RoleId        = Convert.ToInt32(this.cboReaderRole.SelectedValue),
                ReaderImage   = this.pbReaderPhoto.Image == null ? "" : SerializeObjectToString.SerializeObject(this.pbReaderPhoto.Image),
            };

            try
            {
                readerManager.EditReader(reader);
                MessageBox.Show("修改成功!:", "修改提示");
            }
            catch (Exception ex)
            {
                MessageBox.Show("操作异常:" + ex.Message, "异常提示");
            }
        }
        public void CustomSerializerWillSerializeJson()
        {
            var testPerson = new Person
            {
                DateOfBirth = new DateTime(1978, 12, 5, 0, 0, 0, DateTimeKind.Utc),
                Email = "*****@*****.**",
                Name = new Name
                {
                    FirstName = "OJ",
                    Surname = "Reeves"
                },
                PhoneNumbers = new List<PhoneNumber>
                {
                    new PhoneNumber
                    {
                        Number = "12345678",
                        NumberType = PhoneNumberType.Home
                    }
                }
            };

            var sots = new SerializeObjectToString<Person>(JsonConvert.SerializeObject);

            var obj = new RiakObject("bucket", "key");
            obj.SetObject(testPerson, RiakConstants.ContentTypes.ApplicationJson, sots);
            obj.Value.ShouldNotBeNull();
            obj.ContentType.ShouldEqual(RiakConstants.ContentTypes.ApplicationJson);

            var json = obj.Value.FromRiakString();
            json.ShouldEqual("{\"Name\":{\"FirstName\":\"OJ\",\"Surname\":\"Reeves\"},\"PhoneNumbers\":[{\"Number\":\"12345678\",\"NumberType\":1}],\"DateOfBirth\":\"\\/Date(281664000000)\\/\",\"Email\":\"[email protected]\"}");

            var deserialisedPerson = obj.GetObject<Person>();
            deserialisedPerson.ShouldEqual(testPerson);
        }
 public FrmEidtReader(Reader reader, DataTable dt)
 {
     InitializeComponent();
     #region 数据初始化
     this.txtAddress.Text     = reader.ReaderAddress;
     this.txtPhone.Text       = reader.PhoneNumber;
     this.txtPostcode.Text    = reader.PostCode;
     this.txtReaderName.Text  = reader.ReaderName;
     this.txtReadingCard.Text = reader.ReadingCard;
     this.pbReaderPhoto.Image = reader.ReaderImage == "" ? null : (Image)SerializeObjectToString.DeserializeObject(reader.ReaderImage);
     if (reader.Gender == "男")
     {
         this.rdoMale.Checked = true;
     }
     else
     {
         this.rdoFemale.Checked = true;
     }
     this.cboReaderRole.DataSource    = dt;
     this.cboReaderRole.DisplayMember = "RoleName";
     this.cboReaderRole.ValueMember   = "RoleId";
     this.cboReaderRole.SelectedValue = reader.RoleId;
     roleId = reader.RoleId;
     #endregion
 }
Example #5
0
        /// <summary>
        /// Set the object's value, after serializing it.
        /// </summary>
        /// <typeparam name="T">The type of the value.</typeparam>
        /// <param name="value">The unserialized value.</param>
        /// <param name="contentType">The content type of the object.</param>
        /// <remarks>
        /// This overload will choose its serializer based on the <paramref name="contentType"/>.
        /// Supported types for this overload are: <see cref="RiakConstants.ContentTypes.ApplicationJson"/>,
        /// <see cref="RiakConstants.ContentTypes.ProtocolBuffers"/>
        /// <see cref="RiakConstants.ContentTypes.Xml"/>
        /// and text.
        /// </remarks>
        public void SetObject <T>(T value, string contentType = null)
            where T : class
        {
            if (!string.IsNullOrEmpty(contentType))
            {
                ContentType = contentType;
            }

            // check content type
            // save based on content type's deserialization method
            if (ContentType == RiakConstants.ContentTypes.ApplicationJson)
            {
                var sots = new SerializeObjectToString <T>(theObject => theObject.Serialize());
                SetObject(value, ContentType, sots);
                return;
            }

            if (ContentType == RiakConstants.ContentTypes.ProtocolBuffers)
            {
                var objectToByteArrayFunc = new SerializeObjectToByteArray <T>(theObject =>
                {
                    using (var ms = new MemoryStream())
                    {
                        Serializer.Serialize(ms, value);
                        return(ms.ToArray());
                    }
                });

                SetObject(value, ContentType, objectToByteArrayFunc);

                return;
            }

            if (ContentType == RiakConstants.ContentTypes.Xml)
            {
                var objectToByteArrayFunc = new SerializeObjectToByteArray <T>(theObject =>
                {
                    var ms    = new MemoryStream();
                    var serde = new XmlSerializer(typeof(T));
                    serde.Serialize(ms, value);
                    return(ms.ToArray());
                });

                SetObject(value, ContentType, objectToByteArrayFunc);

                return;
            }

            if (ContentType.StartsWith("text"))
            {
                Value = value.ToString().ToRiakString();
                return;
            }

            throw new NotSupportedException(string.Format("Your current ContentType ({0}), is not supported.", ContentType));
        }
        //确认添加
        private void BtnAdd_Click(object sender, EventArgs e)
        {
            #region 数据校验
            //基础数据校验
            #endregion

            #region 对象封装
            Book book = new Book
            {
                BarCode     = this.txtBarCode.Text.Trim(),
                BookName    = this.txtBookName.Text.Trim(),
                Author      = this.txtAuthor.Text.Trim(),
                PublisherId = Convert.ToInt32(this.cboPublisher.SelectedValue),
                PublishDate = this.dtpPublishDate.Value,
//                PublishDate = Convert.ToDateTime(this.dtpPublishDate.Text),
                BookCategoryId = Convert.ToInt32(this.cboBookCategory.SelectedValue),
                UnitPrice      = Convert.ToDouble(this.txtUnitPrice.Text.Trim()),
                BookCount      = Convert.ToInt32(this.txtBookCount.Text.Trim()),
                Remainder      = Convert.ToInt32(this.txtBookCount.Text.Trim()),
                BookPosition   = this.txtBookPosition.Text.Trim(),
                BookImage      = SerializeObjectToString.SerializeObject(this.pbCurrentImage.Image),
                PublisherName  = this.cboPublisher.Text
            };
            #endregion
            #region 调用后台
            try
            {
                bookManager.AddNewBook(book);
                books.Add(book);
                this.dgvBookList.DataSource = null;
                this.dgvBookList.DataSource = books;
                DialogResult dialogResult = MessageBox.Show("添加成功,是否继续添加?", "提示信息", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
                if (dialogResult == DialogResult.OK)
                {
                    //清空数据
                    this.pbImage.Image = null;
                    foreach (Control item in this.gbBook.Controls)
                    {
                        if (item is TextBox)
                        {
                            item.Text = String.Empty;
                        }
                        else if (item is ComboBox)
                        {
                            ((ComboBox)item).SelectedIndex = -1;
                        }
                    }
                    this.txtBookName.Focus();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("数据库异常:" + ex.Message, "错误提示");
            }
            #endregion
        }
Example #7
0
        public static void ExecutePrint(StudentExt studentExt)
        {
            // 定义Excel 工作簿
            Microsoft.Office.Interop.Excel.Application excelApp = new Application();

            // 获取已创建的工作路径
            string pathOfExcel = Environment.CurrentDirectory + "\\studentInfo.xls";

            // 将现有工作簿加入已定义的工作簿集合中
            excelApp.Workbooks.Add(pathOfExcel);

            // 获取第一个工作表
            Worksheet workSheet = (Worksheet)excelApp.Worksheets[1];

            /**
             * 写入数据
             */
            // 文字设置
            workSheet.Cells[4, 6]  = studentExt.studentName;
            workSheet.Cells[6, 6]  = studentExt.sex;
            workSheet.Cells[8, 6]  = studentExt.className;
            workSheet.Cells[10, 6] = studentExt.birthday;
            // 图片设置
            if (studentExt.img.Length != 0)
            {
                // 获取图片信息
                Image img = (Image)SerializeObjectToString.DeserializeObject(studentExt.img);
                // 在默认文件路径里存储图片
                // 如果根目录路径已经有图片存在,则删除它
                if (File.Exists(Environment.CurrentDirectory + "\\studentInfo.jpg"))
                {
                    File.Delete(Environment.CurrentDirectory + "\\studentInfo.jpg");
                }
                // 保存到根目录路径
                img.Save(Environment.CurrentDirectory + "\\studentInfo.jpg");
                // 将图片插入到 Excel 中
                // 接受第一个参数为文件路径,最后的是坐标
                workSheet.Shapes.AddPicture(
                    Environment.CurrentDirectory + "\\studentInfo.jpg",
                    MsoTriState.msoFalse,
                    MsoTriState.msoCTrue,
                    10, 10, 140, 130
                    );
                // 导入成功之后,删除图片
                File.Delete(Environment.CurrentDirectory + "\\studentInfo.jpg");
            }

            // 打印预览
            excelApp.Visible = true;
            excelApp.Sheets.PrintPreview();

            // 释放对象
            excelApp.Quit();
            System.Runtime.InteropServices.Marshal.ReleaseComObject(excelApp);
            excelApp = null;
        }
Example #8
0
        /// <summary>
        /// Set the object's value, after serializing it with the provided serializer.
        /// </summary>
        /// <typeparam name="T">The type of the value.</typeparam>
        /// <param name="value">The unserialized value.</param>
        /// <param name="serializeObject">A delegate to handle serialization of an object to a string.</param>
        public void SetObject <T>(T value, SerializeObjectToString <T> serializeObject)
            where T : class
        {
            if (serializeObject == null)
            {
                throw new ArgumentException("serializeObject cannot be null");
            }

            Value = serializeObject(value).ToRiakString();
        }
Example #9
0
        /// <summary>
        /// Set the object's value, after serializing it with the provided serializer.
        /// </summary>
        /// <typeparam name="T">The type of the value.</typeparam>
        /// <param name="value">The unserialized value.</param>
        /// <param name="contentType">The content type of the object.</param>
        /// <param name="serializeObject">A delegate to handle serialization of an object to a string.</param>
        public void SetObject <T>(T value, string contentType, SerializeObjectToString <T> serializeObject)
            where T : class
        {
            if (string.IsNullOrEmpty(contentType))
            {
                throw new ArgumentException("contentType must be a valid MIME type");
            }

            ContentType = contentType;

            SetObject(value, serializeObject);
        }
Example #10
0
        public void SetObject <T>(T value, string contentType, SerializeObjectToString <T> serializeObject)
            where T : class
        {
            if (string.IsNullOrEmpty(contentType))
            {
                throw new ArgumentException("contentType must be a valid MIME type");
            }

            if (serializeObject == null)
            {
                throw new ArgumentException("serializeObject cannot be null");
            }

            ContentType = contentType;

            Value = serializeObject(value).ToRiakString();
        }
        //保存修改
        private void BtnSave_Click(object sender, EventArgs e)
        {
            #region 数据校验
            #endregion
            #region 对象封装
            Book book = new Book
            {
                BookId      = Convert.ToInt32(this.lbl_BookId.Text.Trim()),
                BookName    = this.txt_BookName.Text.Trim(),
                Author      = this.txt_Author.Text.Trim(),
                PublisherId = Convert.ToInt32(this.cbo_Publisher.SelectedValue.ToString()),
                PublishDate = this.dtp_PublishDate.Value,
                //                PublishDate = Convert.ToDateTime(this.dtpPublishDate.Text),
                BookCategoryId = Convert.ToInt32(this.cbo_BookCategory.SelectedValue.ToString()),
                UnitPrice      = Convert.ToDouble(this.txt_UnitPrice.Text.Trim()),
                BookPosition   = this.txt_BookPosition.Text.Trim(),
                BookImage      = SerializeObjectToString.SerializeObject(this.pbCurrentImage.Image),
            };
            #endregion

            //调用后台
            try
            {
                bookManager.UpdateBookInfoByBarCode(book);
                MessageBox.Show("修改成功", "修改提示");
                Book currentBook = books.Where(o => o.BookId == book.BookId).First();
                currentBook.BookName       = book.BookName;
                currentBook.Author         = book.Author;
                currentBook.PublisherId    = book.PublisherId;
                currentBook.PublishDate    = book.PublishDate;
                currentBook.BookCategoryId = book.BookCategoryId;
                currentBook.UnitPrice      = book.UnitPrice;
                currentBook.BookPosition   = book.BookPosition;
                currentBook.BookImage      = book.BookImage;
                this.dgvBookList.Refresh();
            }
            catch (Exception ex)
            {
                MessageBox.Show("操作异常:" + ex.Message, "异常提示");
            }
        }
Example #12
0
 //TxtBarCode失去焦点
 private void TxtBarCode_Leave(object sender, EventArgs e)
 {
     if (this.txtBarCode.Text.Trim().Length != 0)
     {
         try
         {
             var bookInfo = bookManager.GetBookInfoByBarCode(this.txtBarCode.Text.Trim());
             if (bookInfo == null)
             {
                 MessageBox.Show("未查询到该图书信息", "查询信息");
                 this.txtBarCode.SelectAll();
                 this.txtBarCode.Focus();
             }
             else
             {
                 this.lblBookName.Text     = bookInfo.BookName;
                 this.lblCategory.Text     = bookInfo.CategoryName;
                 this.lblBookPosition.Text = bookInfo.BookPosition;
                 this.lblBookId.Text       = bookInfo.BookId.ToString();
                 this.lblBookCount.Text    = bookInfo.BookCount.ToString();
                 this.pbImage.Image        = (Image)SerializeObjectToString.DeserializeObject(bookInfo.BookImage);
                 this.txtAddCount.Enabled  = true;
                 this.btnSave.Enabled      = true;
                 this.txtAddCount.Focus();
                 var isExists = books.Where(o => o.BarCode == bookInfo.BarCode).Count();
                 if (isExists == 0)
                 {
                     books.Add(bookInfo);
                     this.dgvBookList.DataSource = null;
                     this.dgvBookList.DataSource = books;
                 }
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show("查询图书信息异常:" + ex.Message, "异常提示");
         }
     }
 }
Example #13
0
        private void Editbkfrm()
        {
            lblTiele.Text = "【修改图书】";
            BookExtModel bkinfo = bkbll.GetBookModelById(bookid);

            if (bkinfo != null)
            {
                //页面控件赋值
                txtBookId.Text        = bkinfo.BookId;
                txtBookId.ReadOnly    = true;
                txtBookISBN.Text      = bkinfo.ISBN;
                txtBookName.Text      = bkinfo.BookName;
                txtBookAuthor.Text    = bkinfo.BookAuthor;
                txtBookPrice.Text     = bkinfo.BookPrice.ToString();
                cboBookPress.Text     = bkinfo.BookPress.ToString();
                dtpPublishDate.Text   = bkinfo.BookPublishDate.ToString();
                lblStorageInDate.Text = bkinfo.StorageInDate.ToString();
                txtStorageInNum.Value = bkinfo.StorageInNum;
                lblInventoryNum.Value = bkinfo.InventoryNum;
                lblBorrowedNum.Value  = bkinfo.BorrowedNum;
                //把文本转成图片
                if (string.IsNullOrWhiteSpace(bkinfo.BookImage))
                {
                    pbCurrentImage.Image = null;
                }
                else
                {
                    pbCurrentImage.Image = (Image)SerializeObjectToString.DeserializeObject(bkinfo.BookImage);
                }
                //处理下拉框
                cboBookPress.SelectedItem = presslist.Find(x => x.PressId == bkinfo.BookPress);
                //得到当前书类别信息
                BookTypeExtModel currenttype = btbll.GetBookTypeId(bkinfo.BookType);
                BookTypeModel    typeone     = typelist.Find(x => x.TypeId == currenttype.ParentTypeId);
                cboBookTypeOne.SelectedItem = typeone;
            }
        }
Example #14
0
        public void CustomSerializerWillSerializeJson()
        {
            var testPerson = new Person
            {
                DateOfBirth = new DateTime(1978, 12, 5, 0, 0, 0, DateTimeKind.Utc),
                Email       = "*****@*****.**",
                Name        = new Name
                {
                    FirstName = "OJ",
                    Surname   = "Reeves"
                },
                PhoneNumbers = new List <PhoneNumber>
                {
                    new PhoneNumber
                    {
                        Number     = "12345678",
                        NumberType = PhoneNumberType.Home
                    }
                }
            };

            var sots = new SerializeObjectToString <Person>(JsonConvert.SerializeObject);

            var obj = new RiakObject("bucket", "key");

            obj.SetObject(testPerson, RiakConstants.ContentTypes.ApplicationJson, sots);
            obj.Value.ShouldNotBeNull();
            obj.ContentType.ShouldEqual(RiakConstants.ContentTypes.ApplicationJson);

            var json = obj.Value.FromRiakString();

            json.ShouldEqual("{\"Name\":{\"FirstName\":\"OJ\",\"Surname\":\"Reeves\"},\"PhoneNumbers\":[{\"Number\":\"12345678\",\"NumberType\":1}],\"DateOfBirth\":\"\\/Date(281664000000)\\/\",\"Email\":\"[email protected]\"}");

            var deserialisedPerson = obj.GetObject <Person>();

            deserialisedPerson.ShouldEqual(testPerson);
        }
 private void DataDisplay(Reader reader)
 {
     if (reader != null)
     {
         if (reader.StatusId != 0)
         {
             this.btnEnable.Enabled = true;
             this.btnEdit.Enabled   = true;
         }
         this.lblReaderName.Text  = reader.ReaderName;
         this.lblReadingCard.Text = reader.ReadingCard;
         this.lblGender.Text      = reader.Gender;
         this.lblRoleName.Text    = reader.RoleName;
         this.lblPostCode.Text    = reader.PostCode;
         this.lblPhone.Text       = reader.PhoneNumber;
         this.lblAddress.Text     = reader.ReaderAddress;
         this.pbReaderImg.Image   = reader.ReaderImage == ""?null:(Image)SerializeObjectToString.DeserializeObject(reader.ReaderImage);
     }
     else
     {
         MessageBox.Show("未查询到会员信息,请核查询条件!", "查询提示");
         Clear();
     }
 }
Example #16
0
        /// <summary>
        /// 提交
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnCommit_Click(object sender, EventArgs e)
        {
            //输入验证
            //图书类别验证
            if (cboBookTypeOne.SelectedItem == null)
            {
                MessageBox.Show("请选择图书一级类别");
                return;
            }
            if (cboBookTypeTwo.SelectedItem == null)
            {
                MessageBox.Show("请选择图书二级类别");
                return;
            }
            //isban长度必须是纯数字且13位
            if (!ValidateInput.IsInteger(txtBookISBN.Text.Trim()))
            {
                MessageBox.Show("图书的ISBN编号必须是纯数字");
                return;
            }
            if (txtBookISBN.Text.Trim().Length != 13)
            {
                MessageBox.Show("图书的ISBN编号长度必须是13位");
                return;
            }
            //名称和作者不能为空
            if (string.IsNullOrWhiteSpace(txtBookAuthor.Text.Trim()))
            {
                MessageBox.Show("图书作者不能为空");
                return;
            }
            BookModel bkmodel = new BookModel();

            bkmodel.BookId          = txtBookId.Text.Trim();
            bkmodel.BookName        = txtBookName.Text.Trim();
            bkmodel.BookType        = Convert.ToInt32(cboBookTypeTwo.SelectedValue);
            bkmodel.BookAuthor      = txtBookAuthor.Text.Trim();
            bkmodel.BookPrice       = Convert.ToDecimal(txtBookPrice.Text.Trim());
            bkmodel.ISBN            = txtBookISBN.Text.Trim();
            bkmodel.BookPress       = Convert.ToInt32(cboBookPress.SelectedValue);
            bkmodel.BookPublishDate = dtpPublishDate.Value;
            bkmodel.StorageInNum    = Convert.ToInt32(txtStorageInNum.Value);
            bkmodel.StorageInDate   = lblStorageInDate.Value;
            bkmodel.InventoryNum    = Convert.ToInt32(lblInventoryNum.Value);
            bkmodel.BorrowedNum     = Convert.ToInt32(lblBorrowedNum.Value);
            if (pbCurrentImage.Image != null)
            {
                bkmodel.BookImage = SerializeObjectToString.SerializeObject(pbCurrentImage.Image);
            }
            switch (actionflag)
            {
            case 1:
                int result2 = bkbll.InsertBook(bkmodel);
                if (result2 == 1)
                {
                    MessageBox.Show("图书添加成功");
                    this.DialogResult = DialogResult.OK;
                    this.Close();
                }
                break;

            case 2:
                int result = bkbll.UpdateBook(bkmodel);
                if (result == 1)
                {
                    MessageBox.Show("图书修改成功");
                    this.DialogResult = DialogResult.OK;
                    this.Close();
                }
                else
                {
                    MessageBox.Show("图书修改失败");
                    return;
                }
                break;
            }
        }
 private void TxtReadingCard_Leave(object sender, EventArgs e)
 {
     if (this.txtReadingCard.Text.Trim().Length != 0)
     {
         //查询读者信息
         reader     = readerManager.QueryReaderInfoByReadingCard(this.txtReadingCard.Text.Trim());
         borrowList = borrowManager.QueryBorrowInfoByReadingCard(this.txtReadingCard.Text.Trim());
         this.dgvNonReturnList.DataSource = null;
         this.dgvNonReturnList.DataSource = borrowList;
         if (reader != null)
         {
             if (reader.StatusId == 1)
             {
                 this.lblReaderName.Text  = reader.ReaderName;
                 this.lblRoleName.Text    = reader.RoleName;
                 this.lblAllowCounts.Text = reader.AllowCounts.ToString();
                 var borrowCount = borrowManager.GetBorrowCount(this.txtReadingCard.Text.Trim());
                 this.lblBorrowCount.Text = borrowCount.ToString();
                 this.lbl_Remainder.Text  = (reader.AllowCounts - borrowCount).ToString();
                 this.pbReaderImage.Image = reader.ReaderImage == "" ? null : (Image)SerializeObjectToString.DeserializeObject(reader.ReaderImage);
             }
             else
             {
                 MessageBox.Show("当前借阅证号已被挂失,请联系管理员!", "查询提示");
                 Clear();
             }
         }
         else
         {
             MessageBox.Show("借阅证号错误,请核对借阅证号码是否正确!", "查询提示");
             Clear();
         }
     }
 }
Example #18
0
        /// <summary>
        /// 查询借阅信息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void TxtReadingCard_Leave(object sender, EventArgs e)
        {
            if (this.txtReadingCard.Text.Trim().Length != 0)
            {
                //查询读者信息
                try
                {
                    reader = readerManager.QueryReaderInfoByReadingCard(this.txtReadingCard.Text.Trim());
                }
                catch (Exception ex)
                {
                }

                if (reader != null)
                {
                    if (reader.StatusId == 1)
                    {
                        this.lblReaderName.Text  = reader.ReaderName;
                        this.lblRoleName.Text    = reader.RoleName;
                        this.lblAllowCounts.Text = reader.AllowCounts.ToString();
                        var borrowCount = borrowManager.GetBorrowCount(this.txtReadingCard.Text.Trim());
                        this.lblBorrowCount.Text = borrowCount.ToString();
                        this.lbl_Remainder.Text  = (reader.AllowCounts - borrowCount).ToString();
                        this.pbReaderImage.Image = reader.ReaderImage == "" ? null : (Image)SerializeObjectToString.DeserializeObject(reader.ReaderImage);
                        if (borrowCount < reader.AllowCounts)
                        {
                            this.txtBarCode.Enabled = true;
                            this.txtBarCode.Focus();
                        }
                        else
                        {
                            MessageBox.Show("当前读者借书已达到上限,请归还后继续借书!", "查询提示");
                        }
                    }
                    else
                    {
                        MessageBox.Show("当前借阅证号已被挂失,请联系管理员!", "查询提示");
                        Clear();
                    }
                }
                else
                {
                    MessageBox.Show("借阅证号错误,请核对借阅证号码是否正确!", "查询提示");
                    Clear();
                }
            }
        }
        //dgv选择的行变化时触发同步展示图书信息
        private void DgvBookList_SelectionChanged(object sender, EventArgs e)
        {
            if (this.dgvBookList.RowCount == 0)
            {
                return;
            }
            //展示信息
            var barCode = this.dgvBookList.CurrentRow.Cells["BarCode"].Value.ToString();
            var book    = books.Where(o => o.BarCode == barCode).FirstOrDefault();

            this.txt_BookName.Text              = book.BookName;
            this.txt_UnitPrice.Text             = book.UnitPrice.ToString();
            this.txt_Author.Text                = book.Author;
            this.txt_BookPosition.Text          = book.BookPosition;
            this.lbl_BarCode.Text               = book.BarCode;
            this.dtp_PublishDate.Value          = book.PublishDate;
            this.lbl_BookCount.Text             = book.BookCount.ToString();
            this.lbl_BookId.Text                = book.BookId.ToString();
            this.cbo_BookCategory.SelectedValue = book.BookCategoryId;
            this.cbo_Publisher.SelectedValue    = book.PublisherId;
            this.pbCurrentImage.Image           = book.BookImage.Length == 0?null:(Image)SerializeObjectToString.DeserializeObject(book.BookImage);
        }