public EditInvoiceWizard(Invoice invoice = null)
        {
            DataContext = this;
            InitializeComponent();
            InitializeBuildingsList();
            InitializeCategoriesList();
            InitializeContractorsList();

            if (invoice != null)
            {
                _lic = invoice;
                SelectedBuildingName    = BuildingsNames.Where(x => x.BuildingId.Equals(_lic.BuildingId)).FirstOrDefault();
                SelectedCategoryName    = CategoriesNames.Where(x => x.CategoryId.Equals(_lic.InvoiceCategoryId)).FirstOrDefault();
                InvoiceDate             = _lic.InvoiceDate.Date;
                InvoiceCreatedDate      = _lic.InvoiceCreatedDate.Date;
                InvoiceNumber           = _lic.InvoiceNumber;
                SelectedContractorsName = ContractorsNames.Where(x => x.Name.Equals(_lic.ContractorName)).FirstOrDefault();
                IsSettled               = _lic.IsSettled ? SettlementOptions.Where(x => x == "Tak").FirstOrDefault() : SettlementOptions.Where(x => x == "Nie").FirstOrDefault();
                Title                   = _lic.Title;
                CostAmountVariable      = _lic.CostAmountVariable.ToString();
                CostAmountVariableGross = _lic.CostAmountVariableGross.ToString();
                SelectedVariableVat     = VatCollection.FirstOrDefault(x => x.Rate == _lic.VariableVat);
                CostAmountConst         = _lic.CostAmountConst.ToString();
                CostAmountConstGross    = _lic.CostAmountConstGross.ToString();
                SelectedConstVat        = VatCollection.FirstOrDefault(x => x.Rate == _lic.ConstVat);
                return;
            }

            InvoiceDate        = DateTime.Today;
            InvoiceCreatedDate = DateTime.Today;
        }
Beispiel #2
0
        public EditLegacyBuildingWizard(Building SelectedBuilding = null)
        {
            InitializeComponent();
            DataContext = this;

            MetersCollection = new ObservableCollection <MeterType>();
            InitializeCategoriesList();
            InitializeUnitsList();
            InitializeCostCollection();
            CostBeggining = DateTime.Today;
            if (SelectedBuilding != null)
            {
                _buildingLocalCopy = new Building(SelectedBuilding);

                BuildingName       = SelectedBuilding.Name;
                BuildingCity       = SelectedBuilding.City;
                BuildingZipCode    = SelectedBuilding.ZipCode;
                BuildingRoadName   = SelectedBuilding.RoadName;
                BuildingRoadNumber = SelectedBuilding.BuildingNumber;

                foreach (var c in SelectedBuilding.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);
                }
                MetersCollection = new ObservableCollection <MeterType>(SelectedBuilding.MeterCollection);
            }
            if (_buildingLocalCopy != null)
            {
                GroupBankAccounts = new ObservableCollection <BuildingChargeGroupBankAccount>(GroupBankAccountsTotal.Where(x => !x.IsDeleted && x.Building.BuildingId == _buildingLocalCopy.BuildingId).ToList());
            }
            else
            {
                GroupBankAccounts = new ObservableCollection <BuildingChargeGroupBankAccount>();
            }
        }