示例#1
0
        private void borrow_btn_Click(object sender, EventArgs e)
        {
            fill_borrow();
            if (rb_borrow_bk.Checked == false)
            {
                rb_borrow_bk.Checked = true;
                MessageBox.Show("请重新选择读者和书本", "qoq", MessageBoxButtons.OK);
            }
            DialogResult br_power = DialogResult.Cancel;

            if (rd.rdStatus.Equals("有效") && bk.bkStatus.Equals("在馆"))
            {
                br_power = MessageBox.Show("可以借书,确定借阅?(Y?N)", "lol", MessageBoxButtons.OKCancel);
            }
            else if (rd.rdStatus.Equals("有效"))
            {
                MessageBox.Show("很抱歉书本不在馆,不能借阅", "qoq", MessageBoxButtons.OK);
            }
            else if (bk.bkStatus.Equals("在馆"))
            {
                MessageBox.Show("很抱歉读者证已失效,不能借阅", "qoq", MessageBoxButtons.OK);
            }


            if (br_power == DialogResult.OK)
            {
                string sql_canlendbk = string.Format("select dbo.ReaderType.CanLendQty from dbo.ReaderType where ReaderType.rdType = (select rdType from dbo.Reader where rdID = '{0}')", rd.rdID);
                int    rd_canlendbk  = Convert.ToInt32(Reader_ad.rd_sel(sql_canlendbk));
                string sql_allendbk  = string.Format("select rdBorrowQty from dbo.reader where rdID = '{0}'", rd.rdID);
                int    rd_allendbk   = Convert.ToInt32(Reader_ad.rd_sel(sql_allendbk));

                if (rd_allendbk < rd_canlendbk)
                {
                    bk.bkStatus    = "借出";                                //Book对象状态
                    rd.rdBorrowQty = string.Format("{0}", ++rd_allendbk); //Reader对象更改后书籍数量
                    if (Borrow_ad.run_insql(br, 0))
                    {
                        Reader_ad.run_insql(rd, 2); //更新读者已借书本数
                        Book_ad.run_insql(bk, 1);   //更新Reader rd书本状态
                        MessageBox.Show(string.Format("\"{0}\"借阅\"{1}\"成功!", rd.rdName, bk.bkName), "lol", MessageBoxButtons.OK);
                    }
                    rd_refresh_Click(null, null);
                    bk_refresh_Click(null, null);
                }
                else
                {
                    MessageBox.Show(string.Format("\"{0}\"借阅\"{1}\"失败!", rd.rdName, bk.bkName), "lol", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            br = new Borrow();// 清空borrow对象数据
        }
示例#2
0
 private void return_btn_Click(object sender, EventArgs e)
 {
     if (rb_return_bk.Checked == false)
     {
         rb_return_bk.Checked = true;
         MessageBox.Show("请重新选择读者和书本", "qoq", MessageBoxButtons.OK);
     }
     else
     {
         fill_borrow_b();
         if (br.BorrowID.Equals("") || br.bkID.Equals("") || br.rdID.Equals(""))
         {
             MessageBox.Show("请输入(借阅号 或 书本号 或 读者号)", "qoq", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
             return;
         }
         DialogResult rt_power = DialogResult.Cancel;
         rt_power = MessageBox.Show("可以还书,确定退还?(Y?N)", "lol", MessageBoxButtons.OKCancel);
         if (rt_power == DialogResult.OK)
         {
             if (Borrow_ad.run_insql(br, 1))
             {
                 bk.bkStatus = "在馆";
                 string sql_allendbk = string.Format("select rdBorrowQty from dbo.reader where rdID = '{0}'", rd.rdID);
                 int    rd_allendbk  = Convert.ToInt32(Reader_ad.rd_sel(sql_allendbk));
                 rd.rdBorrowQty = string.Format("{0}", --rd_allendbk);
                 Console.WriteLine(string.Format("{0}", --rd_allendbk));
                 Book_ad.run_insql(bk, 1);   //更新Reader rd书本状态
                 Reader_ad.run_insql(rd, 2); //更新读者已借书本数
                 MessageBox.Show(string.Format("\"{0}\"退还\"{1}\"成功!", rd.rdName, bk.bkName), "lol", MessageBoxButtons.OK);
                 rd_refresh_Click(null, null);
                 bk_refresh_Click(null, null);
             }
             else
             {
                 MessageBox.Show(string.Format("\"{0}\"退还\"{1}\"失败!", rd.rdName, bk.bkName), "lol", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
         br = new Borrow();// 清空borrow对象数据
     }
 }
示例#3
0
 //数据框内容转Reader对象
 private void tbox2rd()
 {
     try
     {
         rd.rdID         = tb_rdID.Text;
         rd.rdPwd        = tb_rdPwd.Text;
         rd.rdType       = tb_rdType.Text;
         rd.rdName       = tb_rdName.Text;
         rd.rdSex        = tb_rdSex.Text;
         rd.rdDept       = tb_rdDept.Text;
         rd.rdStatus     = tb_rdStatus.Text;
         rd.rdPhoto      = tb_rdPhoto.Text;
         rd.rdDateReg    = tb_rdDateReg.Text;
         rd.rdEmail      = tb_rdEmail.Text;
         rd.rdPhone      = tb_rdPhone.Text;
         rd.rdQQ         = tb_rdQQ.Text;
         rd.rdBorrowQty  = Reader_ad.rd_sel("select CanLendQty from dbo.ReaderType where rdType = '" + rd.rdType + "'");
         rd.rdAdminRoles = tb_rdAdminRoles.Text;
     }catch
     {
         MessageBox.Show("fail", "qoq", MessageBoxButtons.OK);
     }
 }