Esempio n. 1
0
 private void dataGridViewCustomers_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     if (dataGridViewCustomers.Columns[e.ColumnIndex].Name == "Cart" && e.RowIndex >= 0)
     {
         string             CustomerId_Value = dataGridViewCustomers.Rows[e.RowIndex].Cells["Id"].Value.ToString();
         var                cart             = CartOfCustomerDataAccess.GetCart(CustomerId_Value);
         CartOfCustomerForm customerCartForm = new CartOfCustomerForm();
         SendCartInfoEvent += customerCartForm.ShowCart;
         SendCartInfoEvent.Invoke(cart);
         customerCartForm.ShowDialog();
     }
     else if (dataGridViewCustomers.Columns[e.ColumnIndex].Name == "Order" && e.RowIndex >= 0)
     {
         string CustomerId_Value = dataGridViewCustomers.Rows[e.RowIndex].Cells["Id"].Value.ToString();
         var    orders           = OrderOfCustomerDataAccess.GetAllOrders(CustomerId_Value);
         OrdersOfCustomerForm ordersOfCustomerForm = new OrdersOfCustomerForm();
         SendOrdersInfoEvent += ordersOfCustomerForm.ShowOrders;
         SendOrdersInfoEvent.Invoke(orders);
         ordersOfCustomerForm.ShowDialog();
     }
     else if (dataGridViewCustomers.Columns[e.ColumnIndex].Name == "Review" && e.RowIndex >= 0)
     {
         string CustomerId_Value = dataGridViewCustomers.Rows[e.RowIndex].Cells["Id"].Value.ToString();
         var    reviews          = ReviewOfCustomerDataAccess.GetReviews(CustomerId_Value);
         ReviewsOfCustomerForm ordersOfCustomerForm = new ReviewsOfCustomerForm();
         SendReviewsInfoEvent += ordersOfCustomerForm.ShowReviews;
         SendReviewsInfoEvent.Invoke(reviews);
         ordersOfCustomerForm.ShowDialog();
     }
 }
 private void dataGridViewBooks_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     if (dataGridViewBooks.Columns[e.ColumnIndex].Name == "Detail" && e.RowIndex >= 0)
     {
         string         ISBN_Value = dataGridViewBooks.Rows[e.RowIndex].Cells["ISBN"].Value.ToString();
         var            book       = BookDataAccess.GetFullBookByISBN(ISBN_Value);
         BookDetailForm detailForm = new BookDetailForm();
         SendBookInfoEvent += detailForm.ShowDetail;
         SendBookInfoEvent.Invoke(book);
         detailForm.ShowDialog();
     }
     else if (dataGridViewBooks.Columns[e.ColumnIndex].Name == "Edit" && e.RowIndex >= 0)
     {
         string         ISBN_Value   = dataGridViewBooks.Rows[e.RowIndex].Cells["ISBN"].Value.ToString();
         var            book         = BookDataAccess.GetFullBookByISBN(ISBN_Value);
         BookEditorForm editBookForm = new BookEditorForm();
         SendBookInfoEvent += editBookForm.GetValues;
         SendBookInfoEvent.Invoke(book);
         editBookForm.ShowDialog();
         ShowAllBasicBookData();
     }
     else if (dataGridViewBooks.Columns[e.ColumnIndex].Name == "Delete" && e.RowIndex >= 0)
     {
         if (MessageBox.Show("删除图书后可能会导致部分订单、购物车和评论数据失效\n确定删除图书?", "警告", MessageBoxButtons.OKCancel) == DialogResult.OK)
         {
             string ISBN_Value = dataGridViewBooks.Rows[e.RowIndex].Cells["ISBN"].Value.ToString();
             try
             {
                 BookDataAccess.DeleteBook(ISBN_Value);
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message);
             }
             ShowAllBasicBookData();
         }
     }
     else if (dataGridViewBooks.Columns[e.ColumnIndex].Name == "Review" && e.RowIndex >= 0)
     {
         string            ISBN_Value        = dataGridViewBooks.Rows[e.RowIndex].Cells["ISBN"].Value.ToString();
         var               reviews           = ReviewOfBookDataAccess.GetReviews(ISBN_Value);
         ReviewsOfBookForm reviewsOfBookForm = new ReviewsOfBookForm();
         SendReviewsInfoEvent += reviewsOfBookForm.ShowReviews;
         SendReviewsInfoEvent.Invoke(reviews);
         reviewsOfBookForm.ShowDialog();
     }
     else if (dataGridViewBooks.Columns[e.ColumnIndex].Name == "Order" && e.RowIndex >= 0)
     {
         string           ISBN_Value        = dataGridViewBooks.Rows[e.RowIndex].Cells["ISBN"].Value.ToString();
         var              orders            = OrderOfBookDataAccess.GetOrders(ISBN_Value);
         OrdersOfBookForm reviewsOfBookForm = new OrdersOfBookForm();
         SendOrdersInfoEvent += reviewsOfBookForm.ShowOrders;
         SendOrdersInfoEvent.Invoke(orders);
         reviewsOfBookForm.ShowDialog();
     }
 }
Esempio n. 3
0
 private void dataGridViewSuppliers_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     if (dataGridViewSuppliers.Columns[e.ColumnIndex].Name == "Order" && e.RowIndex >= 0)
     {
         string SupplierId_Value = dataGridViewSuppliers.Rows[e.RowIndex].Cells["Id"].Value.ToString();
         var    orders           = OrderOfSupplierDataAccess.GetOrders(SupplierId_Value);
         OrdersOfSupplierForm ordersOfCustomerForm = new OrdersOfSupplierForm();
         SendOrdersInfoEvent += ordersOfCustomerForm.ShowOrders;
         SendOrdersInfoEvent.Invoke(orders);
         ordersOfCustomerForm.ShowDialog();
     }
 }