コード例 #1
0
        private void AddDebt(object sender, RoutedEventArgs e)
        {
            try
            {
                Dluh d = new Dluh();
                d.Castka = Int32.Parse(Castka.Text);

                d.Den   = Int32.Parse(Den.Text);
                d.Rok   = Int32.Parse(Rok.Text);
                d.Mesic = Int32.Parse(Mesic.Text);

                d.Sazba     = Int32.Parse(Sazba.Text);
                d.Zaplaceno = false;

                Osoba ii = (Osoba)CBP.SelectedItem;
                d.IDOsoby = ii.ID;
                App.Database.SaveItems <Dluh>(d);
                MessageBox.Show("Dluh byl přidán");
                var itemsFromDb = new ObservableCollection <Dluh>(App.Database.GetItems <Dluh>().Result);
                FillDebtList(itemsFromDb);
            }
            catch
            {
                MessageBox.Show("Něco se nepovedlo :( ");
            }
        }
コード例 #2
0
 private void DeleteDl_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         ListBoxItem uu       = (ListBoxItem)LBDluhy.SelectedItem;
         string      y        = uu.Content.ToString();
         string      v        = y.Split('.')[0];
         int         r        = Int32.Parse(v);
         Dluh        selected = App.Database.GetItemWhereID <Dluh>(r).Result;
         selected.Zaplaceno = true;
         App.Database.SaveItems <Dluh>(selected);
         MessageBox.Show("Dluh byl zplacen!");
         FillDebtList(GetDluhy());
     }catch {
     }
 }
コード例 #3
0
        public int NovaCena(Dluh d)
        {
            int puvodni = d.Castka;
            int sazba   = d.Sazba;

            DateTime DluhCas = new DateTime(d.Rok, d.Mesic, d.Den);
            DateTime TedCas  = DateTime.Now;

            TimeSpan Diff     = DluhCas.Subtract(TedCas);
            int      rozdilek = Diff.Days;
            int      tomonths = (int)(rozdilek / 30.436875);

            if (tomonths < 0)
            {
                tomonths = tomonths * -1;
            }

            int plusurok  = (puvodni * sazba) / 100;
            int finalcena = (tomonths * plusurok) + puvodni;

            return(finalcena);
        }