Ejemplo n.º 1
0
 private void AddItem_Click(object sender, RoutedEventArgs e)//button add
 {
     if (!string.IsNullOrEmpty(fooditem.SelectedValue.ToString()) ||
         !string.IsNullOrEmpty(tableitem.SelectedValue.ToString()) || !string.IsNullOrEmpty(Quantitytxt.Text))
     {
         _vOrderItems          = new ViewOrderItems();
         _oVM                  = new OrderingViewModel();
         fooditemdata          = _oVM.getFoodDetail(Convert.ToInt32(fooditem.SelectedValue));
         _vOrderItems.Quantity = Convert.ToInt32(Quantitytxt.Text);
         _vOrderItems.Price    = fooditemdata.fPrice * _vOrderItems.Quantity;
         _vOrderItems.FoodID   = fooditemdata.FoodID;
         _vOrderItems.FoodName = fooditemdata.FoodName;
         _vOrderItems.TableID  = Convert.ToInt32(tableitem.SelectedValue);
         var createdOrder = _oVM.PlaceOrder(_vOrderItems);
         if (createdOrder != null)
         {
             mycart.Add(_vOrderItems);
             fooditemsgrid.ItemsSource = mycart;
             fooditemsgrid.Items.Refresh();
             status.Content = "Додано до списку замовлених страв";
         }
     }
     else
     {
         status.Foreground = Brushes.Red;
         status.Content    = "Всі поля обов'язкові для заповнення";
         status.Foreground = Brushes.Green;
     }
 }
 private void AddItem_Click(object sender, RoutedEventArgs e)
 {
     if (fooditem.SelectedValue != null || tableitem.SelectedValue != null || Quantitytxt.Text != null)
     {
         _vOrderItems          = new ViewOrderItems();
         _oVM                  = new OrderingViewModel();
         fooditemdata          = _oVM.getFoodDetail(Convert.ToInt32(fooditem.SelectedValue));
         _vOrderItems.Quantity = Convert.ToInt32(Quantitytxt.Text);
         _vOrderItems.Price    = fooditemdata.fPrice * _vOrderItems.Quantity;
         _vOrderItems.FoodID   = fooditemdata.FoodID;
         _vOrderItems.FoodName = fooditemdata.FoodName;
         _vOrderItems.TableID  = Convert.ToInt32(tableitem.SelectedValue);
         mycart.Add(_vOrderItems);
         fooditemsgrid.ItemsSource = mycart;
         fooditemsgrid.Items.Refresh();
         status.Content = "Ürün listeye eklendi";
     }
     else
     {
         status.Foreground = Brushes.Red;
         status.Content    = "Tüm alanlar zorunludur";
         status.Foreground = Brushes.Green;
     }
 }