Beispiel #1
0
        private void button_leases_add_Click(object sender, RoutedEventArgs e)
        {
            BoolHelper bh = new BoolHelper();
            LeaseAdd   la = new LeaseAdd(Flats.ToList(), Users.ToList(), bh);
            Lease      l  = new Lease();

            la.DataContext = l;
            la.ShowDialog();

            if (bh.BoolHelp)
            {
                try
                {
                    dbContext.Leases.Add(l);
                    dbContext.SaveChanges();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            Leases = new ObservableCollection <Lease>(dbContext.Leases.ToList());
            dataGrid_leases.ItemsSource = null;
            dataGrid_leases.ItemsSource = Leases;
        }
Beispiel #2
0
        private void button_constFees_add_Click(object sender, RoutedEventArgs e)
        {
            BoolHelper   bh  = new BoolHelper();
            ConstFeesAdd cfa = new ConstFeesAdd(Flats.ToList(), bh);
            ConstFees    cf  = new ConstFees();

            cfa.DataContext = cf;
            cfa.ShowDialog();

            if (bh.BoolHelp)
            {
                try
                {
                    dbContext.ConstFees.Add(cf);
                    dbContext.SaveChanges();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }

            ConstFees = new ObservableCollection <ConstFees>(dbContext.ConstFees.ToList());
            dataGrid_constFees.ItemsSource = null;
            dataGrid_constFees.ItemsSource = ConstFees;
        }
Beispiel #3
0
        private void button_leases_modify_Click(object sender, RoutedEventArgs e)
        {
            if (dataGrid_leases.SelectedIndex == -1)
            {
                return;
            }

            BoolHelper bh  = new BoolHelper();
            LeaseAdd   la  = new LeaseAdd(Flats.ToList(), Users.ToList(), bh);
            Lease      l   = Leases[dataGrid_leases.SelectedIndex];
            Lease      lcf = l.ShallowCopy();

            la.DataContext = l;

            la.ShowDialog();

            if (bh.BoolHelp)
            {
                try
                {
                    dbContext.SaveChanges();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            else
            {
                l = lcf.ShallowCopy();
                dbContext.Leases.AddOrUpdate(l);
                dbContext.SaveChanges();
            }

            dataGrid_leases.ItemsSource = null;
            dataGrid_leases.ItemsSource = Leases;
        }
Beispiel #4
0
        private void button_constFees_modify_Click(object sender, RoutedEventArgs e)
        {
            if (dataGrid_constFees.SelectedIndex == -1)
            {
                return;
            }

            BoolHelper   bh  = new BoolHelper();
            ConstFeesAdd cfa = new ConstFeesAdd(Flats.ToList(), bh);
            ConstFees    cf  = ConstFees[dataGrid_constFees.SelectedIndex];
            ConstFees    cfc = cf.ShallowCopy();

            cfa.DataContext = cf;

            cfa.ShowDialog();

            if (bh.BoolHelp)
            {
                try
                {
                    dbContext.SaveChanges();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            else
            {
                cf = cfc.ShallowCopy();
                dbContext.ConstFees.AddOrUpdate(cf);
                dbContext.SaveChanges();
            }

            dataGrid_constFees.ItemsSource = null;
            dataGrid_constFees.ItemsSource = ConstFees;
        }