private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            var bookid   = dataGridView1.Rows[e.RowIndex].Cells[1].Value;
            var infoForm = new BookInfo(db, Convert.ToInt32(bookid));

            infoForm.ShowDialog();
        }
Esempio n. 2
0
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            var firstrow = dataGridView1.Columns[0].Name.ToString();

            if (firstrow == "bk_id")
            {
                var bookid   = dataGridView1.Rows[e.RowIndex].Cells[0].Value;
                var infoForm = new BookInfo(db, Convert.ToInt32(bookid));
                infoForm.ShowDialog();
            }
            else if (firstrow == "r_id")
            {
                var bookid   = dataGridView1.Rows[e.RowIndex].Cells[1].Value;
                var infoForm = new BookInfo(db, Convert.ToInt32(bookid));
                infoForm.ShowDialog();
            }
        }
 private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     Console.WriteLine(e.ColumnIndex);
     if (e.ColumnIndex == 11)
     {
         var bookid   = dataGridView1.Rows[e.RowIndex].Cells[0].Value;
         var modiForm = new BookModificationForm(db, Convert.ToInt32(bookid));
         modiForm.ShowDialog();
     }
     else if (e.ColumnIndex == 12)
     {
         var bookname = dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString();
         var ok       = MessageBox.Show("确定删除" + bookname + "?", "确认删除", MessageBoxButtons.OKCancel);
         if (ok == DialogResult.OK)
         {
             var bookid    = Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells[0].Value);
             var deletesql = "DELETE FROM book WHERE bk_id=" + bookid.ToString() + ";";
             try
             {
                 db.Execute(deletesql);
                 MessageBox.Show("删除成功,刷新看到结果", "删除成功");
             }
             catch (Exception exception)
             {
                 Console.WriteLine(exception);
                 MessageBox.Show("删除失败,有可能是数据库出错", "删除失败");
             }
         }
     }
     else
     {
         var bookid   = dataGridView1.Rows[e.RowIndex].Cells[0].Value;
         var infoForm = new BookInfo(db, Convert.ToInt32(bookid));
         infoForm.ShowDialog();
     }
 }