Exemplo n.º 1
0
 public static void UpdateInfo()
 {
     if (supplier != null)
     {
         supplier = SupplierDataAccess.GetSupplierById(supplier.Id.ToString());
     }
 }
Exemplo n.º 2
0
 private void ViewEditData()
 {
     supplier = SupplierDataAccess.GetSupplierById(supplierId);
     if (supplier != null)
     {
         txtName.Text      = supplier.Name;
         txtEmail.Text     = supplier.Email;
         txtMobile.Text    = supplier.Mobile;
         chkActive.Checked = supplier.IsActive;
     }
 }
 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();
     }
 }