示例#1
0
 private async void InsertIntoCart(int?obj)
 {
     try
     {
         if (obj != null)
         {
             var item = ListPro.SingleOrDefault(t => t.ProductID == (int)obj);
             if (item != null)
             {
                 if (!string.IsNullOrEmpty(Qty) && Qty.IsNum())
                 {
                     if (ListOD.SingleOrDefault(t => t.ProductID == (int)obj) == null)
                     {
                         if (Convert.ToInt32(Qty) <= RestQty && RestQty >= 0)
                         {
                             var ProOD = new ProductODModel()
                             {
                                 ProductID = _selectedPro.ProductID,
                                 Name      = _selectedPro.Name,
                             };
                             ProOD.OrderQty  = Convert.ToInt32(Qty);
                             ProOD.UnitPrice = (double)_selectedPro.UnitOnOrder;
                             ProOD.StoreID   = SelectedSto.StoreID;
                             Subtotal       += (double)_selectedPro.UnitOnOrder * Convert.ToInt32(Qty);
                             ListOD.Add(ProOD);
                         }
                         else
                         {
                             MessageBox.Show("số lượng phải nhỏ hơn hoặc bằng số lượng hiện tại", "Thông Báo", MessageBoxButton.OK, MessageBoxImage.Warning);
                         }
                     }
                     else
                     {
                         MessageBox.Show("Đã Tồn Tại Trong Giỏ Hàng", "Thông Báo", MessageBoxButton.OK, MessageBoxImage.Warning);
                     }
                 }
                 else
                 {
                     MessageBox.Show("Có Lỗi - Số Lượng Phải Là Số", "Thông Báo", MessageBoxButton.OK, MessageBoxImage.Warning);
                 }
             }
         }
     }
     catch
     {
         MessageBox.Show("Có Lỗi", "Thông Báo", MessageBoxButton.OK, MessageBoxImage.Warning);
     }
 }