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
        void SaveFlat(object param)
        {
            try
            {
                ErrorVisibility = "Collapsed";

                if (ValidateFlat())
                {
                    if (Flats == null)
                    {
                        Flats = new ObservableCollection <FlatModel>();
                    }
                    Flats.Add(new FlatModel
                    {
                        Number               = FlatNumber,
                        ProjectId            = SelectedProject.ID,
                        Project              = SelectedProject,
                        EstimatedAmount      = EstimatedAmount,
                        AggregateAmountTotal = AggregateAmountTotal,
                        EMI  = EMI,
                        Days = Days
                    });
                    ClearFlatFields();
                }
            }
            catch (Exception ex)
            {
                ErrorMessage    = $"Error: {ex.Message}";
                ErrorVisibility = "Visible";
            }
        }
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Flats = await _context.Flats.FirstOrDefaultAsync(m => m.ProductID == id);

            if (Flats == null)
            {
                return(NotFound());
            }
            return(Page());
        }
Beispiel #5
0
        private void button_flats_save_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                dbContext.Flats.AddOrUpdate(Flats.ToArray());
                dbContext.SaveChanges();

                dataGrid_flats.ItemsSource = null;
                dataGrid_flats.ItemsSource = Flats;
            }
            catch (Exception ex)
            {
                //TODO: obsługa błedu
                MessageBox.Show(ex.Message);
            }
        }
        public void LoadData()
        {
            var res = doc.Element("root").Elements("flat").ToList();

            foreach (var x in res)
            {
                Flat c = new Flat()
                {
                    Region = x.Attribute("region").Value,
                    Price  = x.Attribute("price").Value,
                    Adress = x.Attribute("adress").Value,
                    Owner  = x.Attribute("owner").Value,
                    Phone  = x.Attribute("phone").Value
                };
                Flats.Add(c);
            }
        }
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Flats = await _context.Flats.FindAsync(id);

            if (Flats != null)
            {
                _context.Flats.Remove(Flats);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
Beispiel #8
0
 void DeleteFlat(object param)
 {
     try
     {
         ErrorVisibility = "Collapsed";
         if (SelectedFlat != null)
         {
             Flats.Remove(SelectedFlat);
         }
         else
         {
             ErrorMessage    = "Please select a flat to be deleted";
             ErrorVisibility = "Visible";
         }
     }
     catch (Exception ex)
     {
         ErrorMessage    = $"Error: {ex.Message}";
         ErrorVisibility = "Visible";
     }
 }
Beispiel #9
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 #10
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;
        }
Beispiel #11
0
 public bool AddFlat(Flats f)
 {
     return(admin.AddFlat(f));
 }
Beispiel #12
0
 public bool UpdateFlat(Flats f)
 {
     return(admin.UpdateFlat(f));
 }
Beispiel #13
0
 /// <summary>
 /// Finds the specified id.
 /// </summary>
 /// <param name="id">The id.</param>
 /// <returns></returns>
 public Flat Find(string id)
 {
     return(Flats.FirstOrDefault(e => e.Id == id));
 }
Beispiel #14
0
        public ActionResult EditRegion(Flats.Views.Manage.Region model)
        {
            dbDataContext db = new dbDataContext();
            Flats.Views.Manage.Region ft = db.Region.SingleOrDefault(c => c.ID == model.ID);
            if (ft == null)
            {
                return RedirectToAction("RegionList");
            }

            ft.Naim = model.Naim;

            db.SubmitChanges();
            return RedirectToAction("RegionList");
        }
Beispiel #15
0
        public ActionResult CreateRegion(Flats.Views.Manage.Region model)
        {
            dbDataContext db = new dbDataContext();

            db.Region.InsertOnSubmit(model);
            db.SubmitChanges();

            return RedirectToAction("RegionList");
        }
Beispiel #16
0
 public void AddFlat(Flat flat)
 {
     Flats.Add(flat);
     IsDirty = false;
 }