private void button1_Click(object sender, EventArgs e) { if (AddCart != null) { AddShoppingListEventArgs args = new AddShoppingListEventArgs(); args.BookID = BookID; args.BookName = BookName; args.Author = Author; args.Publisher = Publisher; AddCart(this, args); } }
private void Book_AddShoppingList(object sender, AddShoppingListEventArgs e) { DataRow[] drRows = dtShopping.Select("BookID=" + e.BookID); if (drRows.Length > 0) // 리스트에 이미 있는 경우 { drRows[0]["BookQty"] = Convert.ToInt32(drRows[0]["bookQty"]) + 1; } else { DataRow dr = dtShopping.NewRow(); dr["BookID"] = e.BookID; dr["BookName"] = e.BookName; dr["Author"] = e.Author; dr["Publisher"] = e.Publisher; dr["BookQty"] = 1; dtShopping.Rows.Add(dr); } dtShopping.AcceptChanges(); dataGridView1.DataSource = dtShopping; }