Ejemplo n.º 1
0
        private void MyProducts_Button_Click(object sender, RoutedEventArgs e)
        {
            MyProducts myProducts = new MyProducts();

            myProducts.Show();
            Close();
        }
Ejemplo n.º 2
0
        private void MP_Button_Click(object sender, RoutedEventArgs e)
        {
            MyProducts objMPWindow = new MyProducts();

            Close();
            objMPWindow.Top  = 0;
            objMPWindow.Left = 300;
            objMPWindow.Show();
        }
Ejemplo n.º 3
0
        private void MP_Button_Click(object sender, RoutedEventArgs e)
        {
            MyProducts objMyProductsWindow = new MyProducts();

            if (!CloseDiary())
            {
                return;
            }
            objMyProductsWindow.Top  = 0;
            objMyProductsWindow.Left = 300;
            objMyProductsWindow.Show();
        }
Ejemplo n.º 4
0
        private void Save_Button_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                // Get informations about product.
                string name        = NameInput.Text;
                string description = DescriptionInput.Text;
                string unit;
                double weight;

                if (UnitInput.SelectedIndex == 0)
                {
                    unit   = "g";
                    weight = GetParsedDouble(WeightInput.Text.ToString());
                }
                else
                {
                    unit   = "ml";
                    weight = GetParsedDouble(CapacityInput.Text.ToString());
                }

                double calories = GetParsedDouble(CaloriesInput.Text.ToString());
                double carbs    = GetParsedDouble(CarbsInput.Text.ToString());
                double proteins = GetParsedDouble(ProteinsInput.Text.ToString());
                double fat      = GetParsedDouble(FatInput.Text.ToString());

                Product product = new Product(name, description, unit, weight, calories, fat, carbs, proteins);

                IProductsProvider provider = new XMLProductsParser();
                provider.AddProduct(product);

                MyProducts myProducts = new MyProducts();
                myProducts.Show();
                this.Close();
            }
            catch (NullReferenceException)
            {
                MessageBox.Show("You have to fill every field!");
            }
            catch (FormatException)
            {
                MessageBox.Show("Cannot save new product! Invalid data!");
            }
            catch (ArgumentOutOfRangeException ex)
            {
                MessageBox.Show(ex.Message);
            }
            catch (Exception)
            {
                MessageBox.Show("Something went wrong! :(");
            }
        }