Example #1
0
        /*
         * 借阅信息的删除
         */
        private void btn_DelBorr_Click(object sender, EventArgs e)
        {
            string bkNum   = null;
            string usrName = null;

            for (int i = 0; i < dataGridView1.Rows.Count; i++)
            {
                if (dataGridView1.Rows[i].Selected == true)
                {
                    bkNum   = dataGridView1.Rows[i].Cells[1].Value.ToString();
                    usrName = dataGridView1.Rows[i].Cells[2].Value.ToString();
                }
            }
            Opertion bean = new Opertion();
            Boolean  ok   = bean.BorrowDelete(bkNum, usrName);

            if (ok)
            {
                MessageBox.Show("dalete success!");
                SqlConnection conn = new SqlConnection(constr);
                conn.Open();
                string         sqlstr = "select * from Borrow";
                SqlDataAdapter da     = new SqlDataAdapter(sqlstr, conn);
                DataSet        ds     = new DataSet();
                da.Fill(ds);
                dataGridView1.DataSource = ds.Tables[0];
                conn.Close();
            }
            else
            {
                MessageBox.Show("error!");
            }
            //this.dataGridView1.Update();
            //this.btn_ReadAllBorrow_Click(this.SendToBack, this.Events);
        }
Example #2
0
        /*
         * 首先获取图书的信息,然后还书就是删除借书表的记录(这里需要书号,借阅人),然后改变图书的借出状态(书号)
         */
        private void btn_backBook_Click(object sender, EventArgs e)
        {
            int    flag    = 0;
            string bkNum   = null;
            string usrName = null;

            //获取图书的信息
            for (int i = 0; i < dataGridView1.Rows.Count; i++)
            {
                if (dataGridView1.Rows[i].Selected == true)
                {
                    bkNum   = dataGridView1.Rows[i].Cells[1].Value.ToString();
                    usrName = dataGridView1.Rows[i].Cells[2].Value.ToString();
                }
            }

            Opertion bean = new Opertion();
            Boolean  ok1  = bean.BorrowDelete(bkNum, usrName);

            if (ok1)//如果记录删除成功
            {
                flag = 1;
                //MessageBox.Show("delete success !");
                Boolean ok2 = bean.BkBuffUpdate(bkNum);
                if (ok2)
                {
                    flag = 1;
                }
                else
                {
                    flag = 0;
                }
            }
            else
            {
                flag = 0;
            }
            if (1 == flag)
            {
                MessageBox.Show("还书成功");
            }
            else
            {
                MessageBox.Show("failed!");
            }

            SqlConnection conn = new SqlConnection(constr);

            conn.Open();
            string         sqlstr = "select * from Borrow";
            SqlDataAdapter da     = new SqlDataAdapter(sqlstr, conn);
            DataSet        ds     = new DataSet();

            da.Fill(ds);
            dataGridView1.DataSource = ds.Tables[0];
            conn.Close();
        }