private void UpdateChargesList()
        {
            if (SellDate == null || SelectedApartmentName == null)
            {
                return;
            }

            using (var db = new DB.DomenaDBContext())
            {
                var ltDay = new DateTime(SellDate.Year, SellDate.Month, DateTime.DaysInMonth(SellDate.Year, SellDate.Month));
                var gtDay = new DateTime(SellDate.Year, SellDate.Month, 1);

                var q = db.Charges.Include(x => x.Components).Include(x => x.Components.Select(y => y.GroupName)).Where(x => x.ApartmentId == SelectedApartmentName.ApartmentId &&
                                                                                                                        x.ChargeDate >= gtDay &&
                                                                                                                        x.ChargeDate <= ltDay);

                ChargesCollection = new ObservableCollection <ApartmentSellChargeDG>();

                foreach (var ch in q)
                {
                    ChargesCollection.Add(
                        new ApartmentSellChargeDG()
                    {
                        Charge         = ch,
                        TotalCost      = ch.Components.Where(x => x.GroupName.BuildingChargeGroupNameId != BuildingChargeGroupName.RepairFundGroupId).Select(x => x.Sum).DefaultIfEmpty(0).Sum(),
                        SettlementType = ApartmentSellChargeSettlementType.SPLIT_BY_SELL_DATE,
                    }
                        );
                }
            }
        }
예제 #2
0
 private void InitializeCategoriesList()
 {
     using (var db = new DB.DomenaDBContext())
     {
         SettlementCategories = new ObservableCollection <BuildingChargeBasisCategory>(db.CostCategories.Where(x => !x.IsDeleted).ToList());
     }
 }
예제 #3
0
        private async void ExtendedClosingEditSettingsEventHandler(object sender, DialogClosingEventArgs eventArgs)
        {
            if ((bool)eventArgs.Parameter)
            {
                var dc = (eventArgs.Session.Content as Wizards.EditSettings);
                //Accept
                using (var db = new DB.DomenaDBContext())
                {
                    foreach (var s in dc.Settings)
                    {
                        var set = db.Settings.FirstOrDefault(x => x.Key == s.Key);
                        if (set != null)
                        {
                            set.Value = s.Value;
                        }
                    }
                    db.SaveChanges();
                }
            }
            else if (!(bool)eventArgs.Parameter)
            {
                bool ynResult = await Helpers.YNMsg.Show("Czy chcesz anulować?");

                if (!ynResult)
                {
                    var dc     = (eventArgs.Session.Content as Wizards.EditSettings);
                    var result = await DialogHost.Show(dc, "RootDialog", ExtendedOpenedEventHandler, ExtendedClosingEditSettingsEventHandler);
                }
            }
        }
예제 #4
0
 private void CanPerformCharge()
 {
     using (var db = new DB.DomenaDBContext())
     {
         var lastChargeDate = db.AutoCharges.OrderByDescending(x => x.AutoChargeDate).FirstOrDefault();
         if (lastChargeDate != null)
         {
             var currIterDate = new DateTime(lastChargeDate.AutoChargeDate.Year, lastChargeDate.AutoChargeDate.Month, 1).AddMonths(1);
             while (currIterDate <= new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1))
             {
                 //if (await YNMsg.Show("Wykryto nowy miesiąc. Czy utworzyć naliczenia zgodnie z aktualnymi danymi?"))
                 //{
                 PerformCharge(currIterDate);
                 currIterDate = currIterDate.AddMonths(1);
                 //}
             }
         }
         else
         {
             //if (await YNMsg.Show("Wykryto nowy miesiąc. Czy utworzyć naliczenia zgodnie z aktualnymi danymi?"))
             //{
             PerformCharge(new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1));
             //}
         }
     }
 }
예제 #5
0
 private void InitializeRepairFund()
 {
     using (var db = new DB.DomenaDBContext())
     {
         if (db.GroupName.FirstOrDefault(x => x.BuildingChargeGroupNameId == LibDataModel.BuildingChargeGroupName.RepairFundGroupId) == null)
         {
             db.GroupName.Add(new LibDataModel.BuildingChargeGroupName()
             {
                 BuildingChargeGroupNameId = LibDataModel.BuildingChargeGroupName.RepairFundGroupId,
                 GroupName = "Fundusz Remontowy",
                 IsDeleted = false,
             });
         }
         if (db.GroupName.FirstOrDefault(x => x.BuildingChargeGroupNameId == LibDataModel.BuildingChargeGroupName.ExploitationGroupId) == null)
         {
             db.GroupName.Add(new LibDataModel.BuildingChargeGroupName()
             {
                 BuildingChargeGroupNameId = LibDataModel.BuildingChargeGroupName.ExploitationGroupId,
                 GroupName = "Eksploatacja",
                 IsDeleted = false,
             });
         }
         if (db.InvoiceCategories.FirstOrDefault(x => x.CategoryId == LibDataModel.InvoiceCategory.RepairFundInvoiceCategoryId) == null)
         {
             db.InvoiceCategories.Add(new LibDataModel.InvoiceCategory()
             {
                 CategoryId   = LibDataModel.InvoiceCategory.RepairFundInvoiceCategoryId,
                 CategoryName = "Remonty",
                 IsDeleted    = false,
             });
         }
         db.SaveChanges();
     }
 }
예제 #6
0
        public InvoiceDataGrid(Invoice invoice)
        {
            this.BuildingId         = invoice.BuildingId;
            this.ContractorName     = invoice.ContractorName;
            this.CostAmount         = invoice.CostAmount;
            this.CreatedTime        = invoice.CreatedTime;
            this.InvoiceCategoryId  = invoice.InvoiceCategoryId;
            this.InvoiceDate        = invoice.InvoiceDate;
            this.InvoiceCreatedDate = invoice.InvoiceCreatedDate;
            this.InvoiceId          = invoice.InvoiceId;
            this.InvoiceNumber      = invoice.InvoiceNumber;
            this.IsDeleted          = invoice.IsDeleted;
            this.IsSettled          = invoice.IsSettled;
            this.Title                   = invoice.Title;
            this.CostAmountGross         = invoice.CostAmountGross;
            this.CostAmountConst         = invoice.CostAmountConst;
            this.CostAmountConstGross    = invoice.CostAmountConstGross;
            this.VariableVat             = invoice.VariableVat;
            this.CostAmountVariable      = invoice.CostAmountVariable;
            this.CostAmountVariableGross = invoice.CostAmountVariableGross;
            this.ConstVat                = invoice.ConstVat;

            using (var db = new DB.DomenaDBContext())
            {
                this.Building = db.Buildings.Where(x => x.BuildingId.Equals(invoice.BuildingId)).FirstOrDefault();
                this.Category = db.InvoiceCategories.Where(x => x.CategoryId.Equals(invoice.InvoiceCategoryId)).FirstOrDefault();
            }
        }
 private void InitializeContractorsList()
 {
     using (var db = new DB.DomenaDBContext())
     {
         ContractorsNames = new ObservableCollection <ContractorsName>(db.InvoiceContractors.ToList());
     }
 }
예제 #8
0
 private void InitializeCategories()
 {
     using (var db = new DB.DomenaDBContext())
     {
         Categories = new ObservableCollection <InvoiceCategory>(db.InvoiceCategories.ToList());
     }
 }
 private void InitializeOwnerList()
 {
     using (var db = new DB.DomenaDBContext())
     {
         OwnersNames = new ObservableCollection <Owner>(db.Owners.Where(x => x.IsDeleted == false).ToList());
     }
 }
예제 #10
0
 public void InitializeCollection()
 {
     BindingsList = new ObservableCollection <ApartmentBinding>();
     using (var db = new DB.DomenaDBContext())
     {
         Apartments = new ObservableCollection <Apartment>(db.Apartments.Where(x => !x.IsDeleted && x.SoldDate == null).ToList());
         foreach (var b in db.Bindings.Where(x => !x.IsDeleted))
         {
             var ab = new ApartmentBinding()
             {
                 BindingId = b.BindingId, Name = b.Name
             };
             ab.BoundApartments = new ObservableCollection <BindingDataGrid>();
             var apartments = db.Apartments.Where(x => x.BindingParent.Equals(b.BindingId) && !x.IsDeleted && x.SoldDate == null);
             foreach (var a in apartments)
             {
                 var bdg = new BindingDataGrid();
                 bdg.apartment = a;
                 bdg.building  = db.Buildings.FirstOrDefault(x => x.BuildingId.Equals(a.BuildingId));
                 bdg.owner     = db.Owners.FirstOrDefault(x => x.OwnerId.Equals(a.OwnerId));
                 ab.BoundApartments.Add(bdg);
             }
             BindingsList.Add(ab);
         }
     }
 }
예제 #11
0
        private void SaveDialog(object param)
        {
            if (!IsValid(this as DependencyObject))
            {
                return;
            }
            double amount;
            bool   isAmountValid = double.TryParse(this.PaymentAmount, out amount);

            //Accept

            if (!IsValid(this as DependencyObject) || (string.IsNullOrEmpty(this.SelectedBuildingValue) || string.IsNullOrEmpty(this.SelectedApartmentNumberValue) || !isAmountValid))
            {
                return;
            }
            //Add new payment
            using (var db = new DB.DomenaDBContext())
            {
                foreach (var p in PaymentsList)
                {
                    var newPayment = new Payment()
                    {
                        IsDeleted = false, ApartmentId = p.Apartment.ApartmentId, PaymentAddDate = p.PaymentAddDate, PaymentAmount = p.PaymentAmount, PaymentId = Guid.NewGuid(), PaymentRegistrationDate = p.PaymentRegistrationDate, ChargeGroup = p.ChargeGroup
                    };
                    db.Payments.Add(newPayment);
                    db.Entry(newPayment.ChargeGroup).State = EntityState.Unchanged;
                }
                db.SaveChanges();
            }
        }
예제 #12
0
        private void CreatePDF(object obj)
        {
            if (SelectedLetterValue == MonthlySummary)
            {
                List <ChargeDataGrid> selectedCharges = new List <ChargeDataGrid>();
                using (var db = new DB.DomenaDBContext())
                {
                    foreach (var c in db.Charges.Include(x => x.Components).Include(x => x.Components.Select(y => y.GroupName)))
                    {
                        if (!c.IsDeleted &&
                            c.ChargeDate.Month == SelectedDate.Month &&
                            c.ChargeDate.Year == SelectedDate.Year &&
                            SelectedApartments.Any(x => x.apartment.ApartmentId.Equals(c.ApartmentId)))
                        {
                            selectedCharges.Add(new ChargeDataGrid(c));
                        }
                    }
                }

                foreach (var s in selectedCharges)
                {
                    PDFOperations.PrepareSingleChargeReport(s, true);
                }
            }
            else if (SelectedLetterValue == YearSettlement)
            {
                foreach (var ap in SelectedApartments)
                {
                    PDFOperations.PrepareSingleYearSummary(SelectedDate.Year, ap.apartment, ap.owner, ap.building, true);
                }
            }
        }
예제 #13
0
        private void DeleteBinding(object param)
        {
            if (IsEditMode) // cancel
            {
                IsEditMode = false;
                InitializeCollection();
                InitializeAvailableApartmentsCollection();
            }
            else // delete
            {
                using (var db = new DB.DomenaDBContext())
                {
                    var bind = db.Bindings.FirstOrDefault(x => !x.IsDeleted && x.BindingId.Equals(SelectedBinding.BindingId));
                    if (bind != null) // delete
                    {
                        bind.IsDeleted = true;

                        var ap = db.Apartments.Where(x => x.BindingParent.Equals(SelectedBinding.BindingId));
                        foreach (var a in ap)
                        {
                            a.BindingParent = Guid.Empty;
                        }

                        BindingsList.Remove(SelectedBinding);
                    }
                    db.SaveChanges();
                }
            }
        }
예제 #14
0
        private void InitializeCollection()
        {
            Charges = new ObservableCollection <ChargeDataGrid>();
            using (var db = new DB.DomenaDBContext())
            {
                foreach (var apartment in db.Apartments.Where(x => !x.IsDeleted))
                {
                    var c   = Helpers.ChargesOperations.CreateMonthlyCharge(apartment);
                    var cdg = new ChargeDataGrid(c);
                    Charges.Add(cdg);
                }
            }

            ChargesCV = (CollectionView)CollectionViewSource.GetDefaultView(Charges);
            ChargesCV.SortDescriptions.Add(new SortDescription("Apartment.ApartmentNumber", ListSortDirection.Ascending));
            ChargesCV.Filter = FilterCollection;

            if (GroupByApartment)
            {
                ChargesCV.GroupDescriptions.Add(new PropertyGroupDescription("Apartment.ApartmentNumber"));
            }
            if (GroupByBuilding)
            {
                ChargesCV.GroupDescriptions.Add(new PropertyGroupDescription("Building.Name"));
            }
            ChargesCV.Refresh();
        }
예제 #15
0
        private void InitializeCollection()
        {
            Charges = new ObservableCollection<ChargeDataGrid>();
            using (var db = new DB.DomenaDBContext())
            {
                //var qa = db.Charges.Include(c => c.Components).Where(x => x.IsClosed).FirstOrDefault();
                var q = db.Charges.Include(x => x.Components).Include(x => x.Components.Select(y => y.GroupName)).Where(x => !x.IsDeleted);
                foreach (var ch in q)
                {
                    var cdg = new ChargeDataGrid(ch);
                    Charges.Add(cdg); 
                }
            }
            
            ChargesCV = (CollectionView)CollectionViewSource.GetDefaultView(Charges);
            ChargesCV.SortDescriptions.Add(new SortDescription("CreatedTime", ListSortDirection.Ascending)); 
            ChargesCV.Filter = FilterCollection;

            if (GroupByApartment)
            {
                ChargesCV.GroupDescriptions.Add(new PropertyGroupDescription("Apartment.ApartmentNumber"));
            }
            if (GroupByBuilding)
            {
                ChargesCV.GroupDescriptions.Add(new PropertyGroupDescription("Building.Name"));
            }
            ChargesCV.Refresh();
        }
예제 #16
0
 private void InitializeCategories()
 {            
     using (var db = new DB.DomenaDBContext())
     {
         Categories = new ObservableCollection<BuildingChargeBasisCategory>(db.CostCategories.ToList());
     }
 }
예제 #17
0
        public ChargesData(Building b)
        {
            ObservableCollection <BuildingChargeBasisCategory> CategoriesNames;
            ObservableCollection <BuildingChargeGroupName>     GroupNames;

            using (var db = new DB.DomenaDBContext())
            {
                GroupBankAccounts = b != null ? new ObservableCollection <BuildingChargeGroupBankAccount>(db.BuildingChargeGroupBankAccounts.Where(x => !x.IsDeleted && x.Building.BuildingId == b.BuildingId).ToList()) : new ObservableCollection <BuildingChargeGroupBankAccount>();
                CategoriesNames   = new ObservableCollection <BuildingChargeBasisCategory>(db.CostCategories.Where(x => !x.IsDeleted).ToList());
                GroupNames        = new ObservableCollection <BuildingChargeGroupName>(db.GroupName.Where(x => !x.IsDeleted).ToList());
            }

            var values     = (CostDistribution[])Enum.GetValues(typeof(CostDistribution));
            var UnitsNames = new ObservableCollection <Helpers.CostDistributionCollectionItem>();

            foreach (var v in values)
            {
                var cdci = new Helpers.CostDistributionCollectionItem(v);
                UnitsNames.Add(cdci);
            }

            CostCollection = new ObservableCollection <CostListView>();
            if (b != null)
            {
                foreach (var c in b.CostCollection)
                {
                    var clv = new Helpers.CostListView {
                        BegginingDate = c.BegginingDate.Date, EndingDate = c.EndingDate.Date, Cost = c.CostPerUnit, CostUnit = UnitsNames.Where(x => x.EnumValue == c.BuildingChargeBasisDistribution).FirstOrDefault(), CategoryName = CategoriesNames.Where(x => x.BuildingChargeBasisCategoryId.Equals(c.BuildingChargeBasisCategoryId)).FirstOrDefault().CategoryName, CostGroup = GroupNames.Where(x => x.BuildingChargeGroupNameId == c.BuildingChargeGroupNameId).FirstOrDefault()
                    };
                    CostCollection.Add(clv);
                }
            }
        }
 private void InitializeBuildingsList()
 {
     using (var db = new DB.DomenaDBContext())
     {
         BuildingsNames = new ObservableCollection <Building>(db.Buildings.Where(x => x.IsDeleted == false).ToList());
     }
 }
 private void InitializeLists()
 {
     using (var db = new DB.DomenaDBContext())
     {
         BuildingsNames = new ObservableCollection <Building>(db.Buildings.ToList());
     }
 }
예제 #20
0
        public static void GenerateCharges(DateTime chargeDate, Guid autoChargeId)
        {
            using (var db = new DB.DomenaDBContext())
            {
                var q = db.Buildings.Include(b => b.CostCollection);
                foreach (var a in db.Apartments.Where(x => !x.IsDeleted && x.SoldDate == null && q.Where(y => y.BuildingId.Equals(x.BuildingId)).FirstOrDefault().CostCollection.Count > 0))
                {
                    var c = new Charge()
                    {
                        ApartmentId = a.ApartmentId, ChargeId = Guid.NewGuid(), IsClosed = false, ChargeDate = chargeDate, CreatedDate = DateTime.Today, SettlementId = Guid.Empty, AutoChargeId = autoChargeId, OwnerId = a.OwnerId
                    };
                    c.Components = new List <ChargeComponent>();
                    foreach (var costCollection in db.Buildings.Include(b => b.CostCollection).Where(x => x.BuildingId.Equals(a.BuildingId)).FirstOrDefault().CostCollection)
                    {
                        if (costCollection.BegginingDate > chargeDate || (costCollection.EndingDate.Year > 1901 && costCollection.EndingDate < chargeDate))
                        {
                            continue;
                        }
                        var group = db.GroupName.FirstOrDefault(x => x.BuildingChargeGroupNameId == costCollection.BuildingChargeGroupNameId);
                        var cc    = new ChargeComponent()
                        {
                            ChargeComponentId = Guid.NewGuid(), CostCategoryId = costCollection.BuildingChargeBasisCategoryId, CostDistribution = costCollection.BuildingChargeBasisDistribution, CostPerUnit = costCollection.CostPerUnit, GroupName = group
                        };
                        double units;
                        switch ((CostDistribution)cc.CostDistribution)
                        {
                        case CostDistribution.PerApartment:
                            units = 1;
                            break;

                        case CostDistribution.PerApartmentTotalArea:
                            units = a.AdditionalArea + a.ApartmentArea;
                            break;

                        case CostDistribution.PerApartmentArea:
                            units = a.ApartmentArea;
                            break;

                        case CostDistribution.PerAdditionalArea:
                            units = a.AdditionalArea;
                            break;

                        case CostDistribution.PerLocators:
                            units = a.Locators;
                            break;

                        default:
                            units = 0;
                            break;
                        }
                        cc.Sum = Math.Round((Convert.ToDecimal(units) * cc.CostPerUnit), 2);
                        c.Components.Add(cc);
                        db.Entry(cc.GroupName).State = EntityState.Unchanged;
                    }
                    db.Charges.Add(c);
                }
                db.SaveChanges();
            }
        }
 private void InitializeBuildingList()
 {
     using (var db = new DB.DomenaDBContext())
     {
         BuildingsNames       = new ObservableCollection <Building>(db.Buildings.Include(x => x.MeterCollection).Where(x => x.IsDeleted == false).ToList());
         ApartmentsCollection = new ObservableCollection <Apartment>(db.Apartments.Include(x => x.MeterCollection).ToList());
     }
 }
 private void InitializeCategoriesList()
 {
     using (var db = new DB.DomenaDBContext())
     {
         CategoriesNames = new ObservableCollection <InvoiceCategory>(db.InvoiceCategories.Where(x => x.IsDeleted == false).ToList());
         VatCollection   = new ObservableCollection <InvoiceVatRate>(db.InvoiceVatRates.Where(x => !x.IsDeleted).ToList());
     }
 }
예제 #23
0
 public void InitializeView()
 {
     InitializeUnitDG();
     using (var db = new DB.DomenaDBContext())
     {
         Categories = new ObservableCollection <BuildingChargeBasisCategory>(db.CostCategories.Where(x => !x.IsDeleted).ToList());
     }
     OnPropertyChanged("");
 }
예제 #24
0
 private void PrepareData()
 {
     using (var db = new DB.DomenaDBContext())
     {
         Apartments = (db.Apartments.Include(x => x.MeterCollection.Select(y => y.MeterTypeParent)).Where(x => !x.IsDeleted && x.SoldDate == null).ToList());
         Charges    = (db.Charges.Include(x => x.Components).Where(x => !x.IsDeleted).ToList());
         Owners     = (db.Owners.Where(x => !x.IsDeleted).ToList());
     }
 }
        private async void ExtendedEOWClosingEventHandler(object sender, DialogClosingEventArgs eventArgs)
        {
            if ((bool)eventArgs.Parameter)
            {
                var dc = (eventArgs.Session.Content as Wizards.EditOwnerWizard);
                //Accept
                if (dc._ownerLocalCopy == null)
                {
                    if (!IsValid(dc as DependencyObject) || (string.IsNullOrEmpty(dc.OwnerFirstName) || string.IsNullOrEmpty(dc.OwnerSurname) || string.IsNullOrEmpty(dc.MailAddress)))
                    {
                        eventArgs.Cancel();
                        return;
                    }
                    //Add new owner
                    var newOwner = new LibDataModel.Owner {
                        OwnerId = Guid.NewGuid(), MailAddress = dc.MailAddress, OwnerFirstName = dc.OwnerFirstName, OwnerSurname = dc.OwnerSurname, IsDeleted = false
                    };
                    using (var db = new DB.DomenaDBContext())
                    {
                        db.Owners.Add(newOwner);
                        db.SaveChanges();
                    }
                    InitializeOwnerList();
                    SelectedOwnerName = OwnersNames.Where(x => x.OwnerId.Equals(newOwner.OwnerId)).FirstOrDefault();
                }
                else
                {
                    if (!IsValid(dc as DependencyObject) || (string.IsNullOrEmpty(dc.OwnerFirstName) || string.IsNullOrEmpty(dc.OwnerSurname) || string.IsNullOrEmpty(dc.MailAddress)))
                    {
                        eventArgs.Cancel();
                        return;
                    }
                    //Edit Owner
                    using (var db = new DB.DomenaDBContext())
                    {
                        var q = db.Owners.Where(x => x.OwnerId.Equals(dc._ownerLocalCopy.OwnerId)).FirstOrDefault();
                        q.OwnerFirstName = dc.OwnerFirstName;
                        q.OwnerSurname   = dc.OwnerSurname;
                        q.MailAddress    = dc.MailAddress;
                        db.SaveChanges();
                    }
                    InitializeOwnerList();
                    SelectedOwnerName = OwnersNames.Where(x => x.OwnerId.Equals(dc._ownerLocalCopy.OwnerId)).FirstOrDefault();
                }
            }
            else if (!(bool)eventArgs.Parameter)
            {
                bool ynResult = await Helpers.YNMsg.Show("Czy chcesz anulować?");

                if (!ynResult)
                {
                    //eventArgs.Cancel();
                    var dc     = (eventArgs.Session.Content as Wizards.EditOwnerWizard);
                    var result = await DialogHost.Show(dc, "HelperDialog", ExtendedEOWOpenedEventHandler, ExtendedEOWClosingEventHandler);
                }
            }
        }
예제 #26
0
 private void InitializeCategoriesList()
 {
     using (var db = new DB.DomenaDBContext())
     {
         CategoriesNames        = new ObservableCollection <BuildingChargeBasisCategory>(db.CostCategories.Where(x => !x.IsDeleted).ToList());
         GroupNames             = new ObservableCollection <BuildingChargeGroupName>(db.GroupName.Where(x => !x.IsDeleted).ToList());
         GroupBankAccountsTotal = new List <BuildingChargeGroupBankAccount>(db.BuildingChargeGroupBankAccounts.Include(x => x.GroupName).Include(x => x.Building).ToList());
     }
 }
예제 #27
0
        public static Charge CreateMonthlyCharge(Apartment apartment)
        {
            Charge c;

            using (var db = new DB.DomenaDBContext())
            {
                var building = db.Buildings.Include(b => b.CostCollection).Where(x => x.BuildingId == apartment.BuildingId).FirstOrDefault();

                c = new Charge()
                {
                    ApartmentId = apartment.ApartmentId, ChargeId = Guid.NewGuid(), IsClosed = false, ChargeDate = DateTime.Today, CreatedDate = DateTime.Today, SettlementId = Guid.Empty, AutoChargeId = Guid.Empty, OwnerId = apartment.OwnerId
                };
                c.Components = new List <ChargeComponent>();
                foreach (var costCollection in building.CostCollection)
                {
                    if (costCollection.BegginingDate > DateTime.Today || (costCollection.EndingDate.Year > 1901 && costCollection.EndingDate < DateTime.Today))
                    {
                        continue;
                    }
                    var group = db.GroupName.FirstOrDefault(x => x.BuildingChargeGroupNameId == costCollection.BuildingChargeGroupNameId);
                    var cc    = new ChargeComponent()
                    {
                        ChargeComponentId = Guid.NewGuid(), CostCategoryId = costCollection.BuildingChargeBasisCategoryId, CostDistribution = costCollection.BuildingChargeBasisDistribution, CostPerUnit = costCollection.CostPerUnit, GroupName = group
                    };
                    double units;
                    switch ((CostDistribution)cc.CostDistribution)
                    {
                    case CostDistribution.PerApartment:
                        units = 1;
                        break;

                    case CostDistribution.PerApartmentTotalArea:
                        units = apartment.AdditionalArea + apartment.ApartmentArea;
                        break;

                    case CostDistribution.PerApartmentArea:
                        units = apartment.ApartmentArea;
                        break;

                    case CostDistribution.PerAdditionalArea:
                        units = apartment.AdditionalArea;
                        break;

                    case CostDistribution.PerLocators:
                        units = apartment.Locators;
                        break;

                    default:
                        units = 0;
                        break;
                    }
                    cc.Sum = Math.Round((Convert.ToDecimal(units) * cc.CostPerUnit), 2);
                    c.Components.Add(cc);
                }
            }
            return(c);
        }
예제 #28
0
 private void ShowPayments(object param)
 {
     //var mw = (((((this.Parent as MahApps.Metro.Controls.TransitioningContentControl).Parent as Grid).Parent as DialogHost).Parent as DialogHost).Parent as DialogHost).Parent as Windows.MainWindow;
     using (var db = new DB.DomenaDBContext())
     {
         var CurrentPage = new PaymentsPage(db.Apartments.FirstOrDefault(x => x.ApartmentId.Equals(SelectedApartment.ApartmentId)));
         SwitchPage.SwitchMainPage(CurrentPage, this);
     }
 }
예제 #29
0
 private void InitializeLists()
 {
     using (var db = new DB.DomenaDBContext())
     {
         BuildingsNames = new ObservableCollection <Building>(db.Buildings.ToList());
         ApartmentsList = new ObservableCollection <Apartment>(db.Apartments.ToList());
         OwnersList     = new ObservableCollection <Owner>(db.Owners.ToList());
     }
 }
예제 #30
0
 public EditInvoiceCategories()
 {
     DataContext = this;
     InitializeComponent();
     commandBuffer = new List <Helpers.CategoryCommand <InvoiceCategory> >();
     using (var db = new DB.DomenaDBContext())
     {
         CategoryCollection = new ObservableCollection <InvoiceCategory>(db.InvoiceCategories.Where(x => !x.IsDeleted).ToList());
     }
 }