Ejemplo 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);
            }
        }
Ejemplo 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);
     }
 }
Ejemplo n.º 3
0
        private async void CreateOrder()
        {
            try
            {
                if (ListOD.Count() > 0)
                {
                    var newOrder = new OrderHeader();

                    if (SelectedCus != null)
                    {
                        newOrder.CusID = SelectedCus.CusID;
                    }

                    newOrder.Discount = SelectedDis;

                    if (SelectedLog != null)
                    {
                        newOrder.LogId = SelectedLog.LogID;
                    }

                    newOrder.OrderDate = DateTime.Now;

                    foreach (var i in ListOD)
                    {
                        newOrder.OrderDetails.Add(new OrderDetail()
                        {
                            ProductId = i.ProductID,
                            OrderQty  = i.OrderQty,
                            UnitPrice = (decimal)i.UnitPrice,
                            StoreID   = i.StoreID
                        });
                    }

                    var result = await oh_repo.Add(newOrder);

                    MessengerInstance.Send <OrderHeader>(result);
                }
            }
            catch
            {
                MessageBox.Show("Có Lỗi");
            }
        }