Пример #1
0
        public Przedmiot parsujStrPrzedmiot(string linia)
        {
            decimal cena = 0;
            int     podatek = 0;
            string  nazwa, cena_s, podatek_s;

            //MessageBox.Show(linia);

            nazwa = linia.Substring(0, linia.IndexOf(','));
            linia = linia.Substring((linia.IndexOf(',') + 1), linia.Length - (linia.IndexOf(',') + 1));

            cena_s = linia.Substring(0, linia.IndexOf(','));
            linia  = linia.Substring((linia.IndexOf(',') + 1), linia.Length - (linia.IndexOf(',') + 1));

            podatek_s = linia.Substring(0, (linia.Length - 1));

            cena_s = zamiana(cena_s, '.', ',');
            try
            {
                cena    = Convert.ToDecimal(cena_s);
                podatek = Int32.Parse(podatek_s);
            }
            catch (FormatException)
            {
                string msg;
                msg = "Blad parsowania stringow ";
                MessageBox.Show(msg);
                cena    = 0;
                podatek = 0;
            }
            Przedmiot temp = new Przedmiot(nazwa, cena, podatek);

            return(temp);
        }
Пример #2
0
        private void Add_Product(object sender, RoutedEventArgs e)
        {
            if (_nazwaPoprawna && _cenaPoprawna && _stawkaPoprawna)
            {
                Przedmiot _nowyPrzedmiot = new Przedmiot(_nazwa, _cena, _stawkaVat);

                int qounter = _controler.Asortyment.Count;

                _controler.Asortyment.Add(qounter, _nowyPrzedmiot);

                addLastElementToDataGrid();

                tb_nazwa.Text     = "";
                tb_cena.Text      = "0.0";
                tb_stawkaVAT.Text = "0";
            }
        }
Пример #3
0
        public void loadAsortyment(Controler controler)
        {
            try
            {
                if (controler.Asortyment.Count == 0)
                {
                    //string msg;
                    //msg = "Wczytywanie";
                    //MessageBox.Show(msg);
                    StreamReader se     = File.OpenText(asortymentFilePath);
                    int          l      = 0;
                    string       length = se.ReadLine();
                    length = length.Substring(0, length.IndexOf(';'));
                    Int32.TryParse(length, out l);

                    string linia;

                    for (int i = 0; i < l; i++)
                    {
                        linia = se.ReadLine();
                        Przedmiot temp = parsujStrPrzedmiot(linia);
                        int       nr   = controler.Asortyment.Count;
                        controler.Asortyment.Add(nr, temp);
                        controler.asortymentIndeks.Add(temp.nazwa, nr);
                    }

                    se.Close();
                    MessageBox.Show("Wczytano: " + l + " rekordow.");
                }
                else
                {
                    string msg;
                    msg = "Juz wczytano dane.";
                    MessageBox.Show(msg);
                }
            }
            catch (IOException e)
            {
                MessageBox.Show("Blad odczytu asortymentu " + e.ToString());
            }
        }