コード例 #1
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;
                    }
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// 查询
        /// </summary>
        private void btSearch_Click(object sender, EventArgs e)
        {
            if (cbGReaderID.Text != "" && cbGBookID.Text != "")
            {
                CtbLend    cLend    = new CtbLend();
                CtbLendBLL cLendBll = new CtbLendBLL();
                int        readerID = int.Parse(cbGReaderID.Text);
                int        bookID   = int.Parse(cbGBookID.Text);
                string     sql      = "bookID=" + bookID + " and readerID=" + readerID + " and lendNum>0";
                if (cLendBll.GetModelList(sql).Count > 0)//如果存在借阅信息,将信息赋值到相应控件
                {
                    cLend              = cLendBll.GetModelList(sql)[0];
                    tbGLendNum.Text    = cLend.lendNum.ToString();
                    dtkGLendDate.Value = cLend.lendDate;
                    dtkGYreturn.Value  = cLend.lendYDate;
                    dtkSreturn.Value   = DateTime.Now;
                    //计算罚金

                    if (DateTime.Compare(dtkSreturn.Value, dtkGYreturn.Value) > 0)
                    {
                        TimeSpan ts = dtkSreturn.Value - dtkGYreturn.Value;

                        Double unit = 0.50;//超过应归还日期一天罚0.50元

                        tbFmoney.Text = (ts.Days * unit).ToString();
                    }
                    else
                    {
                        tbFmoney.Text = "0";
                    }


                    IsExistLendInfo = true;
                }
                else
                {
                    MessageBox.Show("没有此借阅信息!", "操作提示");
                    IsExistLendInfo = false;
                }
            }
        }
コード例 #3
0
        //归还图书
        private void btGEnter_Click(object sender, EventArgs e)
        {
            if (IsExistLendInfo)
            {
                int    readerID = int.Parse(cbGReaderID.Text);
                int    bookID   = int.Parse(cbGBookID.Text);
                string sql      = "bookID=" + bookID + " and readerID=" + readerID + " and lendNum>0";


                CtbLendBLL cLendBll = new CtbLendBLL();
                CtbLend    cLend    = cLendBll.GetModelList(sql)[0];


                cLend.lendNum   = 0;//将借出的书数量置为0
                cLend.lendSDate = dtkSreturn.Value.ToString();
                cLend.lendYDate = dtkGYreturn.Value;

                cLendBll.Update(cLend);
                MessageBox.Show("操作成功!", "操作提示");
            }
        }
コード例 #4
0
        //借阅信息查询
        private void btLend_Click(object sender, EventArgs e)
        {
            List <CtbLend> cLends  = new List <CtbLend>();
            CtbLendBLL     lendBll = new CtbLendBLL();

            string StrSQL = "";

            if (cbLBookID.Checked)
            {
                if (tbLBookID.Text != "")
                {
                    StrSQL = StrSQL + "and bookID=" + tbLBookID.Text + " ";
                }
            }
            if (cbLReaderID.Checked)
            {
                if (tbLReaderID.Text != "")
                {
                    StrSQL = StrSQL + "and readerID=" + tbLReaderID.Text + " ";
                }
            }
            if (cbLlendNum.Checked)
            {
                if (tbLlendNum.Text != "")
                {
                    StrSQL = StrSQL + "and lendNum" + numFlag.Text + tbLlendNum.Text + " ";
                }
            }
            if (cbLlenddate.Checked)
            {
                StrSQL = StrSQL + "and lendDate between '" + dtpStartTime.Value.ToString() + "' and '" + dtpEndTime.Value.ToString() + "' ";
            }


            if (StrSQL != "")
            {
                StrSQL = StrSQL.Remove(0, 4);
                cLends = lendBll.GetModelList(StrSQL);
                if (cLends.Count > 0)
                {
                    this.dgvSearchResult.Columns.Clear();
                    this.dgvSearchResult.DataSource = cLends;
                    this.dgvSearchResult.Columns["bookID"].HeaderText    = "图书编号";
                    this.dgvSearchResult.Columns["readerID"].HeaderText  = "读者编号";
                    this.dgvSearchResult.Columns["lendNum"].HeaderText   = "借阅数量";
                    this.dgvSearchResult.Columns["lendDate"].HeaderText  = "借阅日期";
                    this.dgvSearchResult.Columns["lendYDate"].HeaderText = "应归还日期";
                    this.dgvSearchResult.Columns["lendSDate"].HeaderText = "实归还日期";
                    this.dgvSearchResult.Columns["lendMulct"].HeaderText = "罚款金额";
                }
                else
                {
                    MessageBox.Show("未查到相关信息!", "操作提示");
                }
            }
            else
            {
                StrSQL = "readerID>0";
                cLends = lendBll.GetModelList(StrSQL);
                if (cLends.Count > 0)
                {
                    this.dgvSearchResult.Columns.Clear();
                    this.dgvSearchResult.DataSource = cLends;
                    this.dgvSearchResult.Columns["bookID"].HeaderText    = "图书编号";
                    this.dgvSearchResult.Columns["readerID"].HeaderText  = "读者编号";
                    this.dgvSearchResult.Columns["lendNum"].HeaderText   = "借阅数量";
                    this.dgvSearchResult.Columns["lendDate"].HeaderText  = "借阅日期";
                    this.dgvSearchResult.Columns["lendYDate"].HeaderText = "应归还日期";
                    this.dgvSearchResult.Columns["lendSDate"].HeaderText = "实归还日期";
                    this.dgvSearchResult.Columns["lendMulct"].HeaderText = "罚款金额";
                }
                else
                {
                    MessageBox.Show("未查到相关信息!", "操作提示");
                }
            }
        }