Esempio n. 1
0
        private void MagazineBtn_Click(object sender, RoutedEventArgs e)
        {
            ProductListWindow plw = new ProductListWindow();

            plw.Show();
            this.Close();
        }
        private void IncrementBtn_Click(object sender, RoutedEventArgs e)
        {
            int  countToIncrement = 0;
            bool validation       = true;

            if (!Int32.TryParse(CountTextBox.Text, out countToIncrement))
            {
                validation = false;
                MessageBox.Show("Ilość musi być liczbą całkowitą", "Alert", MessageBoxButton.OK, MessageBoxImage.Information);
            }
            else
            {
                if (countToIncrement < 1)
                {
                    validation = false;
                    MessageBox.Show("Ilość musi być większa od 0", "Alert", MessageBoxButton.OK, MessageBoxImage.Information);
                }
            }

            if (validation == true)
            {
                if (id == -1)
                {
                    return;
                }
                data.incrementCountProduct(id, countToIncrement);
                ProductListWindow mw = (ProductListWindow)Application.Current.MainWindow;
                mw.refreshList();
                this.Close();
            }
        }
Esempio n. 3
0
        private void backToMenuBtn_Click(object sender, RoutedEventArgs e)
        {
            ProductListWindow m  = (ProductListWindow)Application.Current.MainWindow;
            MainWindow        mw = new MainWindow();

            mw.Show();
            m.Close();
        }
Esempio n. 4
0
        private void addProductBtn_Click(object sender, RoutedEventArgs e)
        {
            string name  = nameTextBox.Text;
            string count = nameTextBox.Text;
            string price = nameTextBox.Text;
            string vat   = nameTextBox.Text;

            int   countNumber = 0;
            float priceNumber = 0;
            int   vatNumber   = 0;

            bool validation = true;

            // name validation
            if (name.Length < 1)
            {
                validation = false;
                MessageBox.Show("Nazwa nie może być pusta", "Alert", MessageBoxButton.OK, MessageBoxImage.Information);
            }

            // count validation
            if (!Int32.TryParse(countTextBox.Text, out countNumber))
            {
                validation = false;
                MessageBox.Show("Ilość jest nieprawidłowa (musi być liczba całkowita)", "Alert", MessageBoxButton.OK, MessageBoxImage.Information);
            }

            // price validation
            if (priceTextBox.Text.Contains(","))
            {
                validation = false;
                MessageBox.Show("Cena jest nieprawidłowa (zamiast , użyj .)", "Alert", MessageBoxButton.OK, MessageBoxImage.Information);
            }
            else
            {
                try
                {
                    priceNumber = float.Parse(priceTextBox.Text, CultureInfo.InvariantCulture.NumberFormat);
                    Console.WriteLine(priceNumber);
                }
                catch
                {
                    validation = false;
                    MessageBox.Show("Cena jest nieprawidłowa", "Alert", MessageBoxButton.OK, MessageBoxImage.Information);
                }
            }
            if (priceNumber < 0)
            {
                validation = false;
                MessageBox.Show("Cena musi być liczbą dodatnią", "Alert", MessageBoxButton.OK, MessageBoxImage.Information);
            }

            // vat validation
            if (!Int32.TryParse(vatTextBox.Text, out vatNumber))
            {
                validation = false;
                MessageBox.Show("VAT musi być liczbą całkowitą", "Alert", MessageBoxButton.OK, MessageBoxImage.Information);
            }

            if (vatNumber < 0 || vatNumber > 100)
            {
                validation = false;
                MessageBox.Show("VAT musi być z zakresu 0-100", "Alert", MessageBoxButton.OK, MessageBoxImage.Information);
            }



            if (validation == true)
            {
                data.addProduct(name, countNumber, priceNumber, vatNumber);
                ProductListWindow mw = (ProductListWindow)Application.Current.MainWindow;
                mw.refreshList();
                this.Close();
            }
        }