Пример #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (AddCart != null)        //등록된 이벤트 핸들러가 있으면
            {
                AddCartEventArgs args = new AddCartEventArgs();
                args.Bookid   = bookid;
                args.Bookname = Bookname;
                //  args.Bookprice = Bookprice;
                args.BookImage = Bookimage;

                AddCart(this, args);        //이벤트를 발생시킨다
            }
        }
Пример #2
0
 private void Ucon_AddCart(object sender, AddCartEventArgs e)
 {
     DataRow[] drrows = dtCart.Select("bookid=" + e.Bookid);
     if (drrows.Length > 0)
     { //이미 장바구니에 있는 경우
         drrows[0]["bookqty"] = Convert.ToInt32(drrows[0]["bookqty"]) + 1;
     }
     else
     //장바구니에 없는 경우
     {
         DataRow dr = dtCart.NewRow();
         dr["bookid"]   = e.Bookid;
         dr["bookname"] = e.Bookname;
         dr["bookqty"]  = 1;
         //  dr["bookprice"] = e.Bookprice;
         dtCart.Rows.Add(dr);
     }
     dtCart.AcceptChanges();
     dataGridView1.DataSource = dtCart;
 }