public AccountWindow(Konto konto) : this()
 {
     DataContext = konto;
     if (konto is Sparkonto)
     {
         cmbokontotyp.Text = "Sparkonto";
         sparkonto         = konto as Sparkonto;
     }
     if (konto is Girokonto)
     {
         cmbokontotyp.Text = "Girokonto";
         girokonto         = konto as Girokonto;
     }
 }
Example #2
0
        /// <summary>
        /// button adds new account info. to grid
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ButAdd_Click(object sender, RoutedEventArgs e)
        {
            AccountWindow w = new AccountWindow();

            w.Owner = this;
            w.ShowDialog();

            if (w.DialogResult == true)
            {
                if (w.kontotyp == -1)
                {
                    sparkonto = w.sparkonto;
                    Kontos.Add(sparkonto);
                }
                else if (w.kontotyp == 1)
                {
                    girokonto = w.girokonto;
                    Kontos.Add(girokonto);
                }
                DataContext = null;
                DataContext = this;
            }
        }
Example #3
0
        private void Butchange_Click(object sender, RoutedEventArgs e)
        {
            int indexval = Gridbank.SelectedIndex;

            sparkonto = Gridbank.SelectedItem as Sparkonto;
            girokonto = Gridbank.SelectedItem as Girokonto;
            AccountWindow w = new AccountWindow(sparkonto);

            w.Owner = this;
            if (sparkonto != null)
            {
                w.ShowDialog();
            }
            else if (girokonto != null)
            {
                w = new AccountWindow(girokonto);
                w.ShowDialog();
            }

            if (w.DialogResult == true)
            {
                if (w.kontotyp == -1)
                {
                    Kontos.Remove(sparkonto);
                    sparkonto = w.sparkonto;
                    Kontos.Insert(indexval, sparkonto);
                }
                else if (w.kontotyp == 1)
                {
                    Kontos.Remove(girokonto);
                    girokonto = w.girokonto;
                    Kontos.Insert(indexval, girokonto);
                }
                DataContext = null;
                DataContext = this;
            }
        }
Example #4
0
        private void Butauzahlen_Click(object sender, RoutedEventArgs e)
        {
            int indexval = Gridbank.SelectedIndex;

            sparkonto = Gridbank.SelectedItem as Sparkonto;
            girokonto = Gridbank.SelectedItem as Girokonto;
            PayWindow p = new PayWindow(sparkonto, -1);

            p.Owner = this;
            if (sparkonto != null)
            {
                p.ShowDialog();
            }
            else if (girokonto != null)
            {
                p = new PayWindow(girokonto, -1);
                p.ShowDialog();
            }
            if (p.DialogResult == true)
            {
                if (p.kontotyp == -1)
                {
                    Kontos.Remove(sparkonto);
                    sparkonto = p.skonto;
                    Kontos.Insert(indexval, sparkonto);
                }
                else if (p.kontotyp == 1)
                {
                    Kontos.Remove(girokonto);
                    girokonto = p.gkonto;
                    Kontos.Insert(indexval, girokonto);
                }
                DataContext = null;
                DataContext = this;
            }
        }
Example #5
0
        private void Butconfirm_Click(object sender, RoutedEventArgs e)
        {
            double amount = 0.0;

            try
            {
                amount = Convert.ToDouble(TBbetrag.Text);
            }
            catch (FormatException)
            {
                MessageBox.Show("Bitte füllen Sie den Betragfeld richtig ein", "Alert", MessageBoxButton.OK, MessageBoxImage.Asterisk);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }


            if (Transtyp == 1 && amount != 0.0)
            {
                if (mainkonto is Girokonto)
                {
                    gkonto = mainkonto as Girokonto;
                    try
                    {
                        gkonto.PayIn(amount);
                        kontotyp = 1;
                    }
                    catch (KtoException ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
                else
                {
                    skonto = mainkonto as Sparkonto;
                    try
                    {
                        skonto.PayIn(amount);
                        kontotyp = -1;
                    }
                    catch (KtoException ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
            }
            if (Transtyp == -1 && amount != 0.0)
            {
                if (mainkonto is Girokonto)
                {
                    gkonto = mainkonto as Girokonto;
                    try
                    {
                        gkonto.PayOut(amount);
                        kontotyp = 1;
                    }
                    catch (KtoException ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
                else
                {
                    skonto = mainkonto as Sparkonto;
                    try
                    {
                        skonto.PayOut(amount);
                        kontotyp = -1;
                    }
                    catch (KtoException ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
            }
            DialogResult = true;
            this.Close();
        }