Ejemplo n.º 1
0
 private void dataGridViewMyCart_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     if (dataGridViewMyCart.Columns[e.ColumnIndex].Name == "Detail" && e.RowIndex >= 0)
     {
         string ISBN_Value = dataGridViewMyCart.Rows[e.RowIndex].Cells["ISBN"].Value.ToString();
         if (!BookDataAccess.IsBookExisted(ISBN_Value))
         {
             MessageBox.Show("错误:图书不存在");
             return;
         }
         var            book           = BookDataAccess.GetFullBookByISBN(ISBN_Value);
         BookDetailForm bookDetailForm = new BookDetailForm();
         SendBookInfoEvent += bookDetailForm.ShowBookDetail;
         SendBookInfoEvent.Invoke(book);
         bookDetailForm.ShowDialog();
     }
     else if (dataGridViewMyCart.Columns[e.ColumnIndex].Name == "Edit" && e.RowIndex >= 0)
     {
         string ISBN_Value = dataGridViewMyCart.Rows[e.RowIndex].Cells["ISBN"].Value.ToString();
         if (!BookDataAccess.IsBookExisted(ISBN_Value))
         {
             MessageBox.Show("错误:图书不存在");
             return;
         }
         var book = BookDataAccess.GetFullBookByISBN(ISBN_Value);
         CartItemAmountForm cartItemAmountForm = new CartItemAmountForm();
         SendCartInfoEvent += cartItemAmountForm.GetInfo;
         SendCartInfoEvent.Invoke(book, false);
         cartItemAmountForm.ShowDialog();
         ShowAllCartData();
     }
     else if (dataGridViewMyCart.Columns[e.ColumnIndex].Name == "CheckOut" && e.RowIndex >= 0)
     {
         string          ISBN_Value      = dataGridViewMyCart.Rows[e.RowIndex].Cells["ISBN"].Value.ToString();
         var             book            = BookDataAccess.GetFullBookByISBN(ISBN_Value);
         int             amount          = CartDataAccess.SelectAmount(CustomerInfo.customer.Id, ISBN_Value);
         SubmitOrderForm submitOrderForm = new SubmitOrderForm();
         SendOrderInfoEvent += submitOrderForm.GetOrderInfo;
         SendOrderInfoEvent.Invoke(book, amount);
         submitOrderForm.ShowDialog();
         ShowAllCartData();
     }
     else if (dataGridViewMyCart.Columns[e.ColumnIndex].Name == "Delete" && e.RowIndex >= 0)
     {
         string ISBN_Value = dataGridViewMyCart.Rows[e.RowIndex].Cells["ISBN"].Value.ToString();
         try
         {
             CartDataAccess.DeleteCartItem(CustomerInfo.customer.Id, ISBN_Value);
             MessageBox.Show("删除成功");
         }
         catch (Exception ex)
         {
             MessageBox.Show("删除失败\r\n" + ex.Message);
         }
         ShowAllCartData();
     }
 }
Ejemplo n.º 2
0
 private void iconButtonSupply_Click(object sender, EventArgs e)
 {
     if (textBoxISBN.Text.Length == 0)
     {
         MessageBox.Show("ISBN不能为空");
         return;
     }
     if (BookDataAccess.IsBookExisted(textBoxISBN.Text))
     {
         SupplierOrderDataAccess.InsertSupplierOrderOfExistentBook(SupplierInfo.supplier.Id, DateTime.Now, (int)numericUpDownAmount.Value, textBoxISBN.Text);
         MessageBox.Show("发货成功");
     }
     else
     {
         MessageBox.Show("您供应的图书ISBN在书库中未被检索到,\r\n您需要录入关于新书的信息");
         NewBookForm newBookForm = new NewBookForm();
         SendOrderInfoEvent += newBookForm.GetInfo;
         SendOrderInfoEvent.Invoke(textBoxISBN.Text, (int)numericUpDownAmount.Value);
         newBookForm.ShowDialog();
     }
 }