Esempio n. 1
0
        private async void DeleteProOD(int?obj)
        {
            try
            {
                dc = new DialogContent()
                {
                    Content = "Bạn muốn sản phẩm viên này ?", Tilte = "Thông Báo"
                };
                var dialogYS = new DialogYesNo()
                {
                    DataContext = dc
                };
                var result = (bool)await DialogHost.Show(dialogYS, DialogHostId);

                if (result)
                {
                    if (obj != null)
                    {
                        var item = ListOD.SingleOrDefault(t => t.ProductID == (int)obj);
                        ListOD.Remove(item);
                        Subtotal -= (double)item.UnitPrice * (int)item.OrderQty;
                    }
                }
            }
            catch
            {
                MessageBox.Show("Có Lỗi", "Thông Báo", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
Esempio n. 2
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);
     }
 }