private void dataGridViewMyOrders_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     if (dataGridViewMyOrders.Columns[e.ColumnIndex].Name == "Detail" && e.RowIndex >= 0)
     {
         string OrderId_Value = dataGridViewMyOrders.Rows[e.RowIndex].Cells["OrderId"].Value?.ToString();
         bool   IsNewBook;
         try
         {
             IsNewBook = SupplierOrderDataAccess.GetIsNewBook(OrderId_Value);
         }
         catch (MyException ex)
         {
             MessageBox.Show(ex.Message);
             return;
         }
         if (!IsNewBook)
         {
             var book = BookDataAccess.GetFullBookBySupplierExistentBookOrderId(OrderId_Value);
             if (book == null)
             {
                 MessageBox.Show("图书不存在");
                 return;
             }
             BookDetailForm detailForm = new BookDetailForm();
             SendBookInfoEvent += detailForm.ShowBookDetail;
             SendBookInfoEvent.Invoke(book);
             detailForm.ShowDialog();
         }
         else
         {
             var new_book  = NewBookInfoOfSupplierOrderDataAccess.GetNewBookInfoBySupplierOrderId(OrderId_Value);
             int status_id = new_book.Supplier_Order.Status.Id;
             if (status_id == 1) // 未入库
             {
                 BookUnstockedDetailForm detailForm = new BookUnstockedDetailForm();
                 SendNewBookInfoEvent += detailForm.ShowNewBookDetail;
                 SendNewBookInfoEvent.Invoke(new_book);
                 detailForm.ShowDialog();
             }
             else // 已入库
             {
                 var book = BookDataAccess.GetFullBookByISBN(new_book.Book_ISBN);
                 if (book == null)
                 {
                     MessageBox.Show("图书不存在");
                     return;
                 }
                 BookDetailForm detailForm = new BookDetailForm();
                 SendBookInfoEvent += detailForm.ShowBookDetail;
                 SendBookInfoEvent.Invoke(book);
                 detailForm.ShowDialog();
             }
         }
     }
     else if (dataGridViewMyOrders.Columns[e.ColumnIndex].Name == "Cancel" && e.RowIndex >= 0)
     {
         string OrderId_Value  = dataGridViewMyOrders.Rows[e.RowIndex].Cells["OrderId"].Value.ToString();
         int    StatusId_Value = SupplierOrderDataAccess.GetStatusIdValue(OrderId_Value);
         if (StatusId_Value == 1)
         {
             try
             {
                 SupplierOrderDataAccess.CancelOrder(OrderId_Value);
             }
             catch (Exception ex)
             {
                 MessageBox.Show("取消订单失败\n" + ex.Message);
             }
         }
         ShowMyOrders();
     }
     else if (dataGridViewMyOrders.Columns[e.ColumnIndex].Name == "Delete" && e.RowIndex >= 0)
     {
         string OrderId_Value = dataGridViewMyOrders.Rows[e.RowIndex].Cells["OrderId"].Value.ToString();
         try
         {
             SupplierOrderDataAccess.DeleteOrder(OrderId_Value);
         }
         catch (Exception ex)
         {
             MessageBox.Show("删除订单失败\n" + ex.Message);
         }
         ShowMyOrders();
     }
 }
 private void dataGridViewOrders_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     if (dataGridViewOrders.Columns[e.ColumnIndex].Name == "SupplierDetail" && e.RowIndex >= 0)
     {
         string             Username_Value     = dataGridViewOrders.Rows[e.RowIndex].Cells["SupplierId"].Value.ToString();
         var                supplier           = SupplierDataAccess.GetSupplierById(Username_Value);
         SupplierDetailForm supplierDetailForm = new SupplierDetailForm();
         SendSupplierInfoEvent += supplierDetailForm.ShowDetail;
         SendSupplierInfoEvent.Invoke(supplier);
         supplierDetailForm.ShowDialog();
     }
     else if (dataGridViewOrders.Columns[e.ColumnIndex].Name == "BookDetail" && e.RowIndex >= 0)
     {
         string OrderId_Value = dataGridViewOrders.Rows[e.RowIndex].Cells["OrderId"].Value?.ToString();
         bool   IsNewBook;
         try
         {
             IsNewBook = SupplierOrderDataAccess.GetIsNewBook(OrderId_Value);
         }
         catch (MyException ex)
         {
             MessageBox.Show(ex.Message);
             return;
         }
         if (!IsNewBook)
         {
             var book = BookDataAccess.GetFullBookBySupplierExistentBookOrderId(OrderId_Value);
             if (book == null)
             {
                 MessageBox.Show("图书不存在");
                 return;
             }
             BookDetailForm detailForm = new BookDetailForm();
             SendBookInfoEvent += detailForm.ShowDetail;
             SendBookInfoEvent.Invoke(book);
             detailForm.ShowDialog();
         }
         else
         {
             var new_book  = NewBookInfoOfSupplierOrderDataAccess.GetNewBookInfoBySupplierOrderId(OrderId_Value);
             int status_id = new_book.Supplier_Order.Status.Id;
             if (status_id == 1) // 未入库
             {
                 BookUnstockedDetailForm detailForm = new BookUnstockedDetailForm();
                 SendNewBookInfoEvent += detailForm.ShowNewBookDetail;
                 SendNewBookInfoEvent.Invoke(new_book);
                 detailForm.ShowDialog();
             }
             else // 已入库
             {
                 var book = BookDataAccess.GetFullBookByISBN(new_book.Book_ISBN);
                 if (book == null)
                 {
                     MessageBox.Show("图书不存在");
                     return;
                 }
                 BookDetailForm detailForm = new BookDetailForm();
                 SendBookInfoEvent += detailForm.ShowDetail;
                 SendBookInfoEvent.Invoke(book);
                 detailForm.ShowDialog();
             }
         }
     }
     else if (dataGridViewOrders.Columns[e.ColumnIndex].Name == "Warehouse" && e.RowIndex >= 0)
     {
         string OrderId_Value  = dataGridViewOrders.Rows[e.RowIndex].Cells["OrderId"].Value.ToString();
         int    StatusId_Value = SupplierOrderDataAccess.GetStatusIdValue(OrderId_Value);
         if (StatusId_Value == 1)
         {
             bool IsNewBook;
             try
             {
                 IsNewBook = SupplierOrderDataAccess.GetIsNewBook(OrderId_Value);
             }
             catch (MyException ex)
             {
                 MessageBox.Show(ex.Message);
                 return;
             }
             if (IsNewBook)
             {
                 bool is_on_sale = MessageBox.Show("是否立即上架该图书?", "上架", MessageBoxButtons.OKCancel) == DialogResult.OK;
                 try
                 {
                     SupplierOrderDataAccess.WarehouseNewBook(OrderId_Value, is_on_sale);
                 }
                 catch (MyException ex)
                 {
                     MessageBox.Show(ex.Message);
                 }
             }
             else
             {
                 try
                 {
                     SupplierOrderDataAccess.WarehouseExistentBook(OrderId_Value);
                 }
                 catch (MyException ex)
                 {
                     MessageBox.Show(ex.Message);
                 }
             }
         }
         ShowAllSupplierOrderData();
     }
     else if (dataGridViewOrders.Columns[e.ColumnIndex].Name == "Cancel" && e.RowIndex >= 0)
     {
         string OrderId_Value = dataGridViewOrders.Rows[e.RowIndex].Cells["OrderId"].Value.ToString();
         try
         {
             SupplierOrderDataAccess.CancelOrder(OrderId_Value);
         }
         catch (Exception ex)
         {
             MessageBox.Show("取消订单失败\n" + ex.Message);
         }
         ShowAllSupplierOrderData();
     }
     else if (dataGridViewOrders.Columns[e.ColumnIndex].Name == "Delete" && e.RowIndex >= 0)
     {
         string OrderId_Value = dataGridViewOrders.Rows[e.RowIndex].Cells["OrderId"].Value.ToString();
         try
         {
             SupplierOrderDataAccess.DeleteOrder(OrderId_Value);
         }
         catch (Exception ex)
         {
             MessageBox.Show("删除订单失败\n" + ex.Message);
         }
         ShowAllSupplierOrderData();
     }
 }