예제 #1
0
        private void NovyMesic(List <Ucet> lUcty, int pocetMesicu)
        {
            foreach (var ucet in lUcty)
            {
                ucet.Dokumentace_Cas(datum);

                if (ucet is Uverovy)
                {
                    Uverovy u = ucet as Uverovy;
                    ucet.Zustatek = Uverovy.Mesic(ucet as Uverovy, pocetMesicu);
                    if (u.ZbyvaSplatit >= 0)
                    {
                        ucet.Dokumentace += $"-{ucet.Anuita}, zbývá {u.ZbyvaSplatit} měsíců->";
                    }


                    ucet.Dokumentace += $"Zůstatek = {Math.Round(u.Zustatek, 2)}";
                }
                else
                {
                    for (int i = 1; i <= pocetMesicu; i++)
                    {
                        double u = (double)Sporici.Sazba * ucet.Zustatek;
                        ucet.Zustatek    += Math.Round(u, 2);
                        ucet.Dokumentace += $"+{Sporici.Sazba * 100}% za měsíc -> Zůstatek = {Math.Round(ucet.Zustatek, 2)}";
                    }
                }



                if (lbUcty.SelectedItem != null)
                {
                    if (lbUcty.SelectedItem.ToString() == ucet.Jmeno)
                    {
                        lZustatek.Content = "Zůstatek: " + ucet.Zustatek.ToString();
                        docBar.Content    = ucet.Dokumentace;
                    }
                }
            }
        }
예제 #2
0
        public static double Mesic(Uverovy ucet, int pocetMesicu)
        {
            double d = 0;

            if (ucet.ZbyvaSplatit <= 0)
            {
                ucet.ZbyvaSplatit -= pocetMesicu;
                return(Math.Round(ucet.Zustatek, 2));
            }
            if (pocetMesicu <= ucet.ZbyvaSplatit)
            {
                d = ucet.Zustatek - ucet.Anuita * pocetMesicu;
                ucet.ZbyvaSplatit -= pocetMesicu;
                return(Math.Round(d, 2));
            }
            else
            {
                d = ucet.Zustatek - ucet.Anuita * (ucet.ZbyvaSplatit);
                ucet.ZbyvaSplatit = 0;
                return(Math.Round(d, 2));
            }
        }
예제 #3
0
        public MainWindow()
        {
            InitializeComponent();

            List <string> Data = new List <string>();

            try
            {
                string[] f = File.ReadAllLines("ucty.txt");
                foreach (var item in f)
                {
                    Data.Add(item);
                }
            }
            catch (FileNotFoundException)
            {
                MessageBox.Show("Databáze účtů nenalezena");
            }

            foreach (var item in Data)
            {
                string[] s = item.Split('-');
                switch (s[0])
                {
                case "Spořící":
                    Ucty.Add(new Sporici(s[1],
                                         int.Parse(s[2])));
                    break;

                case "Úvěrový":
                    Ucty.Add(new Uverovy(s[1],
                                         int.Parse(s[2]),
                                         int.Parse(s[3])));
                    break;

                case "Studentský":
                    Ucty.Add(new Studentsky(s[1],
                                            int.Parse(s[2])));
                    break;

                default:
                    break;
                }
            }

            Studentsky stud1 = new Studentsky("Honza", 100);
            Uverovy    s2    = new Uverovy("Petr", 500, 4);
            Sporici    s1    = new Sporici("Jachym", 400);

            Ucty.Add(s1);
            Ucty.Add(s2);
            Ucty.Add(stud1);

            lDatum.Content = $"Aktuální datum: {datum.ToString("dd. MMMM yyyy")}";

            for (int i = 1; i <= 31; i++)
            {
                cbDny.Items.Add(i);
                if (i <= 12)
                {
                    cbMesic.Items.Add(i);
                }
            }

            foreach (var inst in Ucty)
            {
                lbUcty.Items.Add(inst.Jmeno);
            }

            try
            {
                vyber          = lbUcty.SelectedItem.ToString();
                lNazev.Content = $"Název účtu: {vyber}";
            }
            catch (Exception)
            {
                vyber = "";
            }
        }