Exemplo n.º 1
0
 private void btnDel_Click(object sender, RoutedEventArgs e)
 {
     if (MessageBox.Show("Удалить строку?", "Подтверждение действия", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes)
     {
         if (Olines != null && Olines.Count > 0)
         {
             Olines.Remove(this.dgridOrderlines.SelectedItem as OrderLine);
         }
         var sumS = Olines.Sum(o => Convert.ToDouble(o.Total));
         lblTotalS.Content = String.Format("Итого: {0:0.00}", sumS);
     }
     else
     {
         return;
     }
 }
Exemplo n.º 2
0
 private void dgridOrderlines_MouseDoubleClick(object sender, MouseButtonEventArgs e)
 {
     try
     {
         OrderLine       ol  = (OrderLine)dgridOrderlines.SelectedItem;
         EditOrderWindow eow = new EditOrderWindow(ol);
         Effect = new System.Windows.Media.Effects.BlurEffect();
         eow.ShowDialog();
         Effect = null;
         if (eow.DialogResult == true)
         {
             var sumS = Olines.Sum(o => Convert.ToDouble(o.Total));
             lblTotalS.Content = String.Format("Итого: {0:0.00}", sumS);
         }
     }
     catch { return; }
 }
Exemplo n.º 3
0
        private void AddOrderLine()
        {
            cboxClients.IsEnabled = false;
            dtPicker.IsEnabled    = false;

            if (txtQuantity.Text != String.Empty && txtPrice.Text != String.Empty)
            {
                OrderLine ol = new OrderLine();
                ol.ProductId = Product.Id;
                ol.Products  = Product;
                ol.Quantity  = (Convert.ToDouble(txtQuantity.Text)).ToString();
                ol.Price     = txtPrice.Text;
                ol.Total     = String.Format("{0:0.00}", (Convert.ToDouble(ol.Quantity) * Convert.ToDouble(ol.Price)));
                ol.Orders    = Order;


                if (Olines.Where(o => o.Products.Name == ol.Products.Name).Count() == 0)
                {
                    Olines.Add(ol);
                }
                else if (Olines.Where(o => o.Products.Name == ol.Products.Name).Count() > 0)
                {
                    MessageBox.Show("Товар уже добавлен в список.\nДля редактирования строки заказа,\nкликните два раза по ней.", "Добавление товара", MessageBoxButton.OK, MessageBoxImage.Error);
                }

                double sumS = Olines.Sum(o => Convert.ToDouble(o.Total)) * (-1);
                lblTotalS.Content          = String.Format("Итого: {0:0.00}", sumS);
                cboxProducts.SelectedIndex = -1;
                txtQuantity.Text           = String.Empty;
                txtPrice.Text = String.Empty;
            }
            else
            {
                MessageBox.Show("Поля 'Количество' и 'Цена'\nдолжны содержать значения", "Ошибка формирования возврата", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }