public List <CustomerOrderStatusModel> getCustomerOrderStatus(long customerId)
        {
            CustomerOrderStatusModel        customerOrderStatus2    = new CustomerOrderStatusModel();
            List <CustomerOrderStatusModel> listCustomerOrderStatus = new List <CustomerOrderStatusModel>();
            List <OrderStatus>      orderStatusModels     = _orderStatusRepository.getOrderDetailsByCustomerID(customerId);
            List <OrderStatusModel> listorderStatusModels = Mapper.Map <List <OrderStatus>, List <OrderStatusModel> >(orderStatusModels);

            foreach (OrderStatusModel data in listorderStatusModels)
            {
                CustomerOrderStatusModel customerOrderStatus = new CustomerOrderStatusModel();
                customerOrderStatus.OrderID          = data.Id;
                customerOrderStatus.CustomerFullName = data.CustomerFullName;
                customerOrderStatus.CurrentStatus    = data.CurrentStatus;
                customerOrderStatus.InventoryName    = data.InventoryName;
                customerOrderStatus.OrderedDate      = data.CreationDate.Date;
                customerOrderStatus.PurchaseAmount   = data.PurchaseAmount;
                customerOrderStatus.UnitOrder        = data.UnitOrder;
                customerOrderStatus.Weight           = data.Weight;
                customerOrderStatus.Height           = data.Height;
                customerOrderStatus.Status           = data.CurrentStatus;
                customerOrderStatus.SaleManFullName  = data.SalesManFullName;
                listCustomerOrderStatus.Add(customerOrderStatus);
            }
            return(listCustomerOrderStatus);
        }
Esempio n. 2
0
 private void dataGridViewOrders_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     if (dataGridViewOrders.Columns[e.ColumnIndex].Name == "CustomerDetail" && e.RowIndex >= 0)
     {
         string             Username_Value     = dataGridViewOrders.Rows[e.RowIndex].Cells["CustomerId"].Value.ToString();
         var                customer           = CustomerDataAccess.GetCustomerById(Username_Value);
         CustomerDetailForm customerDetailForm = new CustomerDetailForm();
         SendCustomerInfoEvent += customerDetailForm.ShowDetail;
         SendCustomerInfoEvent.Invoke(customer);
         customerDetailForm.ShowDialog();
     }
     else if (dataGridViewOrders.Columns[e.ColumnIndex].Name == "BookDetail" && e.RowIndex >= 0)
     {
         string OrderId_Value  = dataGridViewOrders.Rows[e.RowIndex].Cells["OrderId"].Value.ToString();
         string BookISBN_Value = CustomerOrderDataAccess.GetBookISBNById(OrderId_Value);
         //string BookISBN_Value = dataGridViewOrders.Rows[e.RowIndex].Cells["BookISBN"].Value?.ToString();
         if (BookISBN_Value == null)
         {
             MessageBox.Show("图书不存在");
             return;
         }
         var            book           = BookDataAccess.GetFullBookByISBN(BookISBN_Value);
         BookDetailForm bookDetailForm = new BookDetailForm();
         SendBookInfoEvent += bookDetailForm.ShowDetail;
         SendBookInfoEvent.Invoke(book);
         bookDetailForm.ShowDialog();
     }
     else if (dataGridViewOrders.Columns[e.ColumnIndex].Name == "Ship" && e.RowIndex >= 0)
     {
         string OrderId_Value  = dataGridViewOrders.Rows[e.RowIndex].Cells["OrderId"].Value.ToString();
         string BookISBN_Value = CustomerOrderDataAccess.GetBookISBNById(OrderId_Value);
         if (BookISBN_Value == null)
         {
             MessageBox.Show("图书不存在");
             return;
         }
         CustomerOrderStatusModel Status_Value = (CustomerOrderStatusModel)dataGridViewOrders.Rows[e.RowIndex].Cells["Status"].Value;
         if (Status_Value.Id == 2)
         {
             int quantity = BookDataAccess.GetBookQuantityByISBN(BookISBN_Value);
             int amount   = CustomerOrderDataAccess.GetAmountById(OrderId_Value);
             if (quantity >= amount)
             {
                 CustomerOrderDataAccess.ShipOrder(OrderId_Value);
                 BookDataAccess.UpdateBookQuantity(BookISBN_Value, quantity - amount);
             }
             else
             {
                 MessageBox.Show("库存不足");
                 return;
             }
         }
         ShowAllCustomerOrderData();
     }
     else if (dataGridViewOrders.Columns[e.ColumnIndex].Name == "Cancel" && e.RowIndex >= 0)
     {
         string OrderId_Value = dataGridViewOrders.Rows[e.RowIndex].Cells["OrderId"].Value.ToString();
         CustomerOrderDataAccess.CancelOrder(OrderId_Value);
         ShowAllCustomerOrderData();
     }
     else if (dataGridViewOrders.Columns[e.ColumnIndex].Name == "Delete" && e.RowIndex >= 0)
     {
         string OrderId_Value = dataGridViewOrders.Rows[e.RowIndex].Cells["OrderId"].Value.ToString();
         CustomerOrderDataAccess.DeleteOrder(OrderId_Value);
         ShowAllCustomerOrderData();
     }
 }