示例#1
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            int rowIndex = dataGridView1.CurrentRow.Index;

            Book bk;

            bk.BookID    = Convert.ToInt32(dataGridView1.CurrentRow.Cells[0].Value);
            bk.BookName  = dataGridView1[1, rowIndex].Value.ToString(); //위와 같지만 다른 방법
            bk.Author    = dataGridView1[2, rowIndex].Value.ToString();
            bk.Publisher = dataGridView1[3, rowIndex].Value.ToString();
            bk.BookImage = null;

            frmBookInsUp frm = new frmBookInsUp(frmBookInsUp.OpenMode.Update);

            frm.bookInfo = bk;
            if (frm.ShowDialog() == DialogResult.OK)
            {
                Book   book   = frm.bookInfo;
                BookDB bookdb = new BookDB();
                bool   result = bookdb.Update(book);
                bookdb.Dispose();
                if (result)
                {
                    MessageBox.Show("추가되었습니다.");
                    LoadData();
                }
                else
                {
                    MessageBox.Show("다시 시도하여 주십시오.");
                }
            }
        }
示例#2
0
        private void button2_Click(object sender, EventArgs e)
        {
            frmBookInsUp frm = new frmBookInsUp(frmBookInsUp.OpenMode.Insert);

            if (frm.ShowDialog() == DialogResult.OK)
            {
                Book   book   = frm.bookInfo;
                BookDB bookdb = new BookDB();
                bool   result = bookdb.Insert(book);
                bookdb.Dispose();
                if (result)
                {
                    MessageBox.Show("추가 되었습니다.");
                    LoadData();
                }
                else
                {
                    MessageBox.Show("다시 시도하여 주십시오.");
                }
            }
        }