private void item_double_click(object sender, EventArgs e) { book_item item = ((book_item)sender); if (Int32.Parse(item.lbl_amount_data.Text) == 0) { MessageBox.Show("재고가 없습니다.", "주의!"); return; } sum += item.book_info.price; lbl_price_sum.Text = string.Format("{0:#,###}", sum) + "\\"; for (int i = 0; i < grid_sell.Rows.Count; ++i) { if (grid_sell.Rows[i].Cells[0].Value == null) { continue; } if (Int32.Parse((string)grid_sell.Rows[i].Cells[0].Value) == item.book_info.ISBN) { int amount = Int32.Parse((string)grid_sell.Rows[i].Cells[1].Value); if (Int32.Parse(item.lbl_amount_data.Text) == amount) { MessageBox.Show("재고가 부족합니다.", "주의!"); return; } amount++; grid_sell.Rows[i].Cells[1].Value = amount.ToString(); return; } } grid_sell.Rows.Add( new object[] { item.lbl_isbn_data.Text, "1", item.lbl_title_data.Text, item.lbl_price_data.Text }); }
private void FillList(string category, string search) { list_book.Controls.Clear(); List <Book> bookList; if (category == "" || search == "") { bookList = DBC.GetInstance().SelectRecord <Book>("book", ""); } else { bookList = DBC.GetInstance().SelectRecord <Book>("book", category + " Like " + "'%" + search + "%'"); } foreach (Book b in bookList) { book_item item = new book_item(b); item.Click += new System.EventHandler(this.item_click); item.DoubleClick += new System.EventHandler(this.item_double_click); list_book.Controls.Add(item); } }