Exemplo n.º 1
0
        //修改卡片信息
        private void tsbUpdateInfo_Click(object sender, EventArgs e)
        {
            CtbBookInformation      updateBook = new CtbBookInformation();
            _delegateRefreshAllInfo dlg        = new _delegateRefreshAllInfo(RefreshAllInfo);

            if (dgvAllBookInfo.CurrentRow != null)
            {
                updateBook.bookID      = int.Parse(dgvAllBookInfo.CurrentRow.Cells["bookID"].Value.ToString());
                updateBook.bookSortID  = int.Parse(dgvAllBookInfo.CurrentRow.Cells["bookSortID"].Value.ToString());
                updateBook.bookName    = dgvAllBookInfo.CurrentRow.Cells["bookName"].Value.ToString();
                updateBook.bookAutor   = dgvAllBookInfo.CurrentRow.Cells["bookAutor"].Value.ToString();
                updateBook.bookPublish = dgvAllBookInfo.CurrentRow.Cells["bookPublish"].Value.ToString();
                updateBook.bookPubDate = DateTime.Parse(dgvAllBookInfo.CurrentRow.Cells["bookPubDate"].Value.ToString());
                updateBook.bookPrice   = Decimal.Parse(dgvAllBookInfo.CurrentRow.Cells["bookPrice"].Value.ToString());
                updateBook.bookSummary = dgvAllBookInfo.CurrentRow.Cells["bookSummary"].Value.ToString();
                updateBook.bookRealNum = int.Parse(dgvAllBookInfo.CurrentRow.Cells["bookRealNum"].Value.ToString());
                updateBook.bookLendNum = int.Parse(dgvAllBookInfo.CurrentRow.Cells["bookLendNum"].Value.ToString());
                updateBook.bookResDate = DateTime.Parse(dgvAllBookInfo.CurrentRow.Cells["bookResDate"].Value.ToString());

                frmBookInfoAddOrUpdate frmUpdate = new frmBookInfoAddOrUpdate(updateBook, dlg);//打开修改窗体
                frmUpdate.Show();
            }
            else
            {
                MessageBox.Show("请选中你要修改的信息再执行修改!", "操作提示");
            }
        }
Exemplo n.º 2
0
        public frmBookInfoAddOrUpdate(CtbBookInformation bookInfoModel, frmBookInfoManage._delegateRefreshAllInfo _dlg)
        {
            InitializeComponent();
            //此构造函数用于创建修改图书卡片信息的窗体
            dlg = _dlg;

            //然后修改窗体标题显示的信息以及按钮显示的信息
            this.Text    = "修改卡片信息";
            btEnter.Text = "保存";

            //将传过来的待修改的信息进行窗体赋值
            tbBookID.Text        = bookInfoModel.bookID.ToString();
            cbBookSortID.Text    = bookInfoModel.bookSortID.ToString();
            tbBookName.Text      = bookInfoModel.bookName;
            tbBookAutor.Text     = bookInfoModel.bookAutor;
            tbBookPublish.Text   = bookInfoModel.bookPublish;
            dtpPublishDate.Value = bookInfoModel.bookPubDate;
            tbBookPrice.Text     = bookInfoModel.bookPrice.ToString();
            tbBookRealNum.Text   = bookInfoModel.bookRealNum.ToString();
            tbLendNum.Text       = bookInfoModel.bookLendNum.ToString();
            rtbBookSummary.Text  = bookInfoModel.bookSummary;
            dtpBookResDate.Value = bookInfoModel.bookResDate;

            //图书编号在修改过程不能更改
            tbBookID.ReadOnly = true;
        }
Exemplo n.º 3
0
        //借阅按钮事件
        private void btEnter_Click(object sender, EventArgs e)
        {
            //首先判断是否存在已经借阅了此本书的情况
            if (cbReader.Text != "" && cbBook.Text != "")
            {
                CtbLend    cLend    = new CtbLend();
                CtbLendBLL cLendBll = new CtbLendBLL();
                int        readerID = int.Parse(cbReader.Text);
                int        bookID   = int.Parse(cbBook.Text);
                string     sql      = "bookID=" + bookID + " and readerID=" + readerID + " and lendNum>0";
                if (cLendBll.GetModelList(sql).Count > 0)
                {
                    MessageBox.Show("该读者已经借阅了此本书.请先归还现有数目!", "操作提示");
                    return;
                }
                else
                {
                    if (tbLendNum.Text != "")
                    {
                        int lendNum = 0;
                        try
                        {
                            lendNum = int.Parse(tbLendNum.Text);
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show("输入的数量不正确,请确定格式正确。详细异常信息:\n" + ex.Message, "出现异常");
                            return;
                        }
                        if (lendNum > int.Parse(lbTrueName1.Text))
                        {
                            MessageBox.Show("借出数量不应该大于实际存书数量", "出现异常");
                            return;
                        }
                        CtbLendBLL lendBll = new CtbLendBLL();
                        CtbLend    lend    = new CtbLend();
                        lend.readerID  = int.Parse(cbReader.Text);
                        lend.bookID    = int.Parse(cbBook.Text);
                        lend.lendDate  = dtkBorrowDate.Value;
                        lend.lendYDate = dtkYReturnDate.Value;
                        lend.lendSDate = null;
                        lend.lendNum   = int.Parse(tbLendNum.Text);

                        CtbBookInformation    cBook    = new CtbBookInformation();
                        CtbBookInformationBLL cBookBll = new CtbBookInformationBLL();
                        cBook             = cBookBll.GetModel(lend.bookID);
                        cBook.bookLendNum = cBook.bookLendNum + lend.lendNum;
                        cBookBll.Update(cBook);

                        lendBll.Add(lend);
                        MessageBox.Show("添加借阅信息成功!", "操作提示");
                    }
                    else
                    {
                        MessageBox.Show("借出数量不能为空", "出现异常");
                        return;
                    }
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <CtbBookInformation> GetModelList(string strWhere)
        {
            DataSet ds = dal.GetList(strWhere);
            List <CtbBookInformation> modelList = new List <CtbBookInformation>();
            int rowsCount = ds.Tables[0].Rows.Count;

            if (rowsCount > 0)
            {
                CtbBookInformation model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new CtbBookInformation();
                    if (ds.Tables[0].Rows[n]["bookID"].ToString() != "")
                    {
                        model.bookID = int.Parse(ds.Tables[0].Rows[n]["bookID"].ToString());
                    }
                    if (ds.Tables[0].Rows[n]["bookSortID"].ToString() != "")
                    {
                        model.bookSortID = int.Parse(ds.Tables[0].Rows[n]["bookSortID"].ToString());
                    }
                    model.bookName    = ds.Tables[0].Rows[n]["bookName"].ToString();
                    model.bookAutor   = ds.Tables[0].Rows[n]["bookAutor"].ToString();
                    model.bookPublish = ds.Tables[0].Rows[n]["bookPublish"].ToString();
                    if (ds.Tables[0].Rows[n]["bookPubDate"].ToString() != "")
                    {
                        model.bookPubDate = DateTime.Parse(ds.Tables[0].Rows[n]["bookPubDate"].ToString());
                    }
                    if (ds.Tables[0].Rows[n]["bookPrice"].ToString() != "")
                    {
                        model.bookPrice = decimal.Parse(ds.Tables[0].Rows[n]["bookPrice"].ToString());
                    }
                    model.bookSummary = ds.Tables[0].Rows[n]["bookSummary"].ToString();
                    if (ds.Tables[0].Rows[n]["bookRealNum"].ToString() != "")
                    {
                        model.bookRealNum = int.Parse(ds.Tables[0].Rows[n]["bookRealNum"].ToString());
                    }
                    if (ds.Tables[0].Rows[n]["bookLendNum"].ToString() != "")
                    {
                        model.bookLendNum = int.Parse(ds.Tables[0].Rows[n]["bookLendNum"].ToString());
                    }
                    if (ds.Tables[0].Rows[n]["bookResDate"].ToString() != "")
                    {
                        model.bookResDate = DateTime.Parse(ds.Tables[0].Rows[n]["bookResDate"].ToString());
                    }
                    modelList.Add(model);
                }
            }
            return(modelList);
        }
Exemplo n.º 5
0
        private void cbBook_TextChanged(object sender, EventArgs e)
        {
            CtbBookInformationBLL cBookBll = new CtbBookInformationBLL();
            CtbBookInformation    cBook    = cBookBll.GetModel(int.Parse(cbBook.Text));

            if (cBook != null)
            {
                lbBname.Visible  = true;
                lbBname1.Visible = true;
                lbBname1.Text    = cBook.bookName;

                //同时显示图书实际存货
                lbTrueNum.Visible   = true;
                lbTrueName1.Visible = true;
                lbTrueName1.Text    = cBook.bookRealNum.ToString();
            }
        }
Exemplo n.º 6
0
 private void btEnter_Click(object sender, EventArgs e)
 {
     //在这里我们要进行判断我们进行的是添加还是修改
     //判断的方法我们这里只介绍针对我们现在这种情况的方法
     //方法就是判断按钮的TEXT是"添加"还是"保存"
     #region 添加事件代码
     if (btEnter.Text == "添加")
     {
         //任何时候不要忘记做程序异常检查
         //这是个良好的习惯,便于检查程序运行过程出现的容易忽略的错误
         try
         {
             //这里做添加事件的代码
             //先判断输入的数据是否为空
             //我们进行进行整体判断
             if (tbBookID.Text != "")
             {
                 if (cbBookSortID.Text != "")
                 {
                     if (tbBookName.Text != "")
                     {
                         if (tbBookAutor.Text != "")
                         {
                             if (tbBookPublish.Text != "")
                             {
                                 if (tbBookPrice.Text != "")
                                 {
                                     if (tbBookRealNum.Text != "")
                                     {
                                         if (tbLendNum.Text != "")
                                         {
                                             if (rtbBookSummary.Text != "")
                                             {
                                                 //添加图书卡片信息的代码
                                                 CtbBookInformation    newBook    = new CtbBookInformation();
                                                 CtbBookInformationBLL newBookBll = new CtbBookInformationBLL();
                                                 newBook.bookID      = int.Parse(tbBookID.Text);
                                                 newBook.bookSortID  = int.Parse(cbBookSortID.Text);
                                                 newBook.bookName    = tbBookName.Text;
                                                 newBook.bookAutor   = tbBookAutor.Text;
                                                 newBook.bookPublish = tbBookPublish.Text;
                                                 newBook.bookPubDate = dtpPublishDate.Value;
                                                 newBook.bookPrice   = decimal.Parse(tbBookPrice.Text);
                                                 newBook.bookRealNum = int.Parse(tbBookRealNum.Text);
                                                 newBook.bookLendNum = int.Parse(tbLendNum.Text);
                                                 newBook.bookSummary = rtbBookSummary.Text;
                                                 newBook.bookResDate = dtpBookResDate.Value;
                                                 newBookBll.Add(newBook);
                                                 if (MessageBox.Show("添加成功!是否继续添加?", "操作提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
                                                 {
                                                     ClearControlValue();//清除控件中的现有值
                                                 }
                                                 else
                                                 {
                                                     dlg();//同步更新
                                                     this.Close();
                                                 }
                                             }
                                             else
                                             {
                                                 MessageBox.Show("图书摘要不能为空!", "操作提示");
                                             }
                                         }
                                         else
                                         {
                                             MessageBox.Show("借出数量不能为空!", "操作提示");
                                         }
                                     }
                                     else
                                     {
                                         MessageBox.Show("实际数量不能为空!", "操作提示");
                                     }
                                 }
                                 else
                                 {
                                     MessageBox.Show("定价不能为空!", "操作提示");
                                 }
                             }
                             else
                             {
                                 MessageBox.Show("出版社不能为空!", "操作提示");
                             }
                         }
                         else
                         {
                             MessageBox.Show("作者不能为空!", "操作提示");
                         }
                     }
                     else
                     {
                         MessageBox.Show("图书名称不能为空!", "操作提示");
                     }
                 }
                 else
                 {
                     MessageBox.Show("图书类别不能为空!", "操作提示");
                 }
             }
             else
             {
                 MessageBox.Show("图书编号不能为空!", "操作提示");
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, "程序异常提示");
         }
     }
     #endregion
     #region 修改事件代码
     else if (btEnter.Text == "保存")
     {
         //这里做修改事件的代码
         try
         {
             //这里我们也应该判断修改后的数据有没有空值
             if (cbBookSortID.Text != "")
             {
                 if (tbBookName.Text != "")
                 {
                     if (tbBookAutor.Text != "")
                     {
                         if (tbBookPublish.Text != "")
                         {
                             if (tbBookPrice.Text != "")
                             {
                                 if (tbBookRealNum.Text != "")
                                 {
                                     if (tbLendNum.Text != "")
                                     {
                                         if (rtbBookSummary.Text != "")
                                         {
                                             //修改图书卡片信息的代码
                                             CtbBookInformation    newBook    = new CtbBookInformation();
                                             CtbBookInformationBLL newBookBll = new CtbBookInformationBLL();
                                             newBook.bookID      = int.Parse(tbBookID.Text);
                                             newBook.bookSortID  = int.Parse(cbBookSortID.Text);
                                             newBook.bookName    = tbBookName.Text;
                                             newBook.bookAutor   = tbBookAutor.Text;
                                             newBook.bookPublish = tbBookPublish.Text;
                                             newBook.bookPubDate = dtpPublishDate.Value;
                                             newBook.bookPrice   = decimal.Parse(tbBookPrice.Text);
                                             newBook.bookRealNum = int.Parse(tbBookRealNum.Text);
                                             newBook.bookLendNum = int.Parse(tbLendNum.Text);
                                             newBook.bookSummary = rtbBookSummary.Text;
                                             newBook.bookResDate = dtpBookResDate.Value;
                                             newBookBll.Update(newBook);
                                             MessageBox.Show("修改成功!", "操作提示");
                                             dlg();    //同步更新
                                             this.Close();
                                         }
                                         else
                                         {
                                             MessageBox.Show("图书摘要不能为空!", "操作提示");
                                         }
                                     }
                                     else
                                     {
                                         MessageBox.Show("借出数量不能为空!", "操作提示");
                                     }
                                 }
                                 else
                                 {
                                     MessageBox.Show("实际数量不能为空!", "操作提示");
                                 }
                             }
                             else
                             {
                                 MessageBox.Show("定价不能为空!", "操作提示");
                             }
                         }
                         else
                         {
                             MessageBox.Show("出版社不能为空!", "操作提示");
                         }
                     }
                     else
                     {
                         MessageBox.Show("作者不能为空!", "操作提示");
                     }
                 }
                 else
                 {
                     MessageBox.Show("图书名称不能为空!", "操作提示");
                 }
             }
             else
             {
                 MessageBox.Show("图书类别不能为空!", "操作提示");
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, "程序异常提示");
         }
     }
     #endregion
 }