private void btn_Login_Click(object sender, EventArgs e)
        {
            if ("" == tb_Name.Text)
            {
                MessageBox.Show("名称不能为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                tb_Name.Focus();
                return;
            }

            ReaderCate cate = new ReaderCate();

            cate.Id = 0;
            cate.LimitBooksCount = Convert.ToInt32(n_BookCnt.Value);
            cate.LimitDays       = Convert.ToInt32(n_Bd.Value);
            cate.Name            = tb_Name.Text;
            cate.ReBorrowDays    = Convert.ToInt32(n_Rd.Value);
            cate.ReBorrowTimes   = Convert.ToInt32(n_Rt.Value);
            cate.Discount        = Convert.ToDouble(n_Discount.Value / 100);

            if (libraryManage.readerManage.addReaderCate(cate))
            {
                m_DialogResult = System.Windows.Forms.DialogResult.OK;
                MessageBox.Show("添加成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                if (true == cb_add.Checked)
                {
                    clear();
                }
                else
                {
                    this.DialogResult = m_DialogResult;
                }
            }
            else
            {
                m_DialogResult = System.Windows.Forms.DialogResult.No;
                String errorString = "";
                switch (libraryManage.conn.getErrorCode())
                {
                //字段信息重复
                case 19:
                    errorString = "角色重复,添加失败";
                    break;

                default:
                    errorString = "添加失败";
                    break;
                }
                MessageBox.Show(errorString, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                if (false == cb_add.Checked)
                {
                    this.DialogResult = m_DialogResult;
                }
            }
        }
Esempio n. 2
0
        private void toolStripButton4_Click(object sender, EventArgs e)
        {
            if (1 != listView1.SelectedItems.Count)
            {
                return;
            }

            int index = listView1.Items.IndexOf(listView1.FocusedItem);

            double     Price = 0;
            ReaderCate rc    = libraryManage.borrowManage.getReader(list[index].ReaderCode).Cate;

            if (list[index].ReturnDate >= DateTime.Now)
            {
                Price = libraryManage.getBorrowCost() * rc.Discount;
                if (DialogResult.Yes == MessageBox.Show("该借阅记录须缴纳:\n" +
                                                        Price.ToString() + "元" +
                                                        "\n才能归还!\n\n已缴纳,点\"是\"\n未缴纳,点\"否\"", "费用", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk))
                {
                    if (libraryManage.borrowManage.returnBook(list[index]))
                    {
                        Book book = libraryManage.borrowManage.getBook(list[index].ISBN);
                        libraryManage.borrowManage.addBookCount(book);
                        MessageBox.Show("还书成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                        UpdateView();
                    }
                    else
                    {
                        MessageBox.Show("还书失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
            }
            else
            {
                int days = new TimeSpan(DateTime.Now.Ticks - list[index].ReturnDate.Ticks).Days;
                Price = libraryManage.getBorrowCost() * rc.Discount + libraryManage.getLateFee() * days;
                if (DialogResult.Yes == MessageBox.Show("该借阅记录已超出规定还书日期!\n须缴纳:\n" +
                                                        Price.ToString() + "元" +
                                                        "\n才能归还!\n\n已缴纳,点\"是\"\n未缴纳,点\"否\"", "逾期", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk))
                {
                    if (libraryManage.borrowManage.returnBook(list[index]))
                    {
                        Book book = libraryManage.borrowManage.getBook(list[index].ISBN);
                        libraryManage.borrowManage.addBookCount(book);
                        MessageBox.Show("还书成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                        UpdateView();
                    }
                    else
                    {
                        MessageBox.Show("还书失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
            }
        }
 public ReaderCateEdit(ReaderCate c, LibraryManage lm)
 {
     InitializeComponent();
     cate          = c;
     libraryManage = lm;
 }