public object Convert(object value, Type targetType, object parameter, string language) { decimal summeCosts, summeIncomes; var homeWithDaten = new MonatYearDaten(); summeCosts = homeWithDaten.GetWertAusgabe(); summeIncomes = homeWithDaten.GetWertEinnahme(); var uNFI = new UserNumberFormat(); Balance balance = value as Balance; ObservableCollection <Balance> data = new ObservableCollection <Balance>(); { Balance einnahmen = new Balance() { Name = EinnahmenAusgaben.Einnahmen.ToString(), Price = summeIncomes, Percentage = homeWithDaten.GetPercentageEinnahme().ToString("P", uNFI.GetNFI()) }; data.Add(einnahmen); Balance ausgaben = new Balance() { Name = EinnahmenAusgaben.Ausgaben.ToString(), Price = summeCosts, Percentage = homeWithDaten.GetPercentageAusgabe().ToString("P", uNFI.GetNFI()) }; data.Add(ausgaben); } return(data); }
private void HomePage_Loaded(object sender, RoutedEventArgs e) { var btn = new AppShellToggleButton(); btn.SetShellButton(true); var loader = new Windows.ApplicationModel.Resources.ResourceLoader(); BtnTxtAusgbe.Text = loader.GetString("BtnCostsHome"); BtnTxtEinnahme.Text = loader.GetString("BtnIncomesHome"); txtBalanceText.Text = loader.GetString("TxtBalanceHome"); txtIncomeText.Text = loader.GetString("TxtIncomesHome"); txtCostText.Text = loader.GetString("TxtCostsHome"); var datum = new MonatYearDaten(); if (datum.Monat > 0 || datum.Year > 0) { BtnMonatAuswahl.Content = datum.GetMonatYearString(); } txtAusgabe.Text = datum.GetWertAusgabe().ToString("C", uNFI.GetNFI()); txtEinnahme.Text = datum.GetWertEinnahme().ToString("C", uNFI.GetNFI()); txtBalance.Text = datum.GetWertBalance().ToString("C", uNFI.GetNFI()); if (datum.GetWertBalance() < 0) { txtBalance.Foreground = new SolidColorBrush(Color.FromArgb(255, 204, 51, 51)); } }
internal string GetPercentage() { UserNumberFormat uNFI = new UserNumberFormat(); if (_summeItem == 0) { return((_summeItem * -1).ToString("P", uNFI.GetNFI())); } else { return((_summeItem / _summeItems).ToString("P", uNFI.GetNFI())); } }
public object Convert(object value, Type targetType, object parameter, string language) { if (value == null) return null; string wert = value.ToString(); var uNFI = new UserNumberFormat(); decimal item; Decimal.TryParse(wert, NumberStyles.Number | NumberStyles.AllowCurrencySymbol, uNFI.GetNFI(), out item); return item.ToString("C", uNFI.GetNFI()); }
//Berechnet for ganze Jahr public async Task BalanceForYearAsync() { var uNFI = new UserNumberFormat(); decimal?summeCostsTemp, summeIncomesTemp; using (var dataBase = new Store.DataBase.DataBaseEF.DataBaseFile()) { summeIncomesTemp = await dataBase.Incomes.AsNoTracking() .Select(c => new { price = (decimal?)Decimal.Parse(c.PreisOfIncome, NumberStyles.Number | NumberStyles.AllowCurrencySymbol, uNFI.GetNFI()), datum = c.DateOfIncome }) .Where(a => a.datum.Year == _year) .Select(a => a.price).SumAsync(); } using (var dataBase = new Store.DataBase.DataBaseEF.DataBaseFile()) { summeCostsTemp = await dataBase.Costs.AsNoTracking() .Select(c => new { price = (decimal?)Decimal.Parse(c.PreisOfCost, NumberStyles.Number | NumberStyles.AllowCurrencySymbol, uNFI.GetNFI()), datum = c.DateOfCost }) .Where(a => a.datum.Year == _year) .Select(a => a.price).SumAsync(); } _ausgabeForYear = (decimal)summeCostsTemp; _einnahmeForYear = (decimal)summeIncomesTemp; BalanceForYearProperty = _einnahmeForYear + _ausgabeForYear; }
public async Task CostIncomeSummeAsync() { var uNFI = new UserNumberFormat(); decimal?summeCostsTemp, summeIncomesTemp; using (var dataBase = new Store.DataBase.DataBaseEF.DataBaseFile()) { summeIncomesTemp = await dataBase.Incomes.AsNoTracking() .Select(c => new { price = (decimal?)Decimal.Parse(c.PreisOfIncome, NumberStyles.Number | NumberStyles.AllowCurrencySymbol, uNFI.GetNFI()), datum = c.DateOfIncome }) .Where(a => a.datum.Month == _monat & a.datum.Year == _year) .Select(a => a.price).SumAsync(); } using (var dataBase = new Store.DataBase.DataBaseEF.DataBaseFile()) { summeCostsTemp = await dataBase.Costs.AsNoTracking() .Select(c => new { price = (decimal?)Decimal.Parse(c.PreisOfCost, NumberStyles.Number | NumberStyles.AllowCurrencySymbol, uNFI.GetNFI()), datum = c.DateOfCost }) .Where(a => a.datum.Month == _monat & a.datum.Year == _year) .Select(a => a.price).SumAsync(); } _ausgabe = (decimal)summeCostsTemp; _einnahme = (decimal)summeIncomesTemp; _balanceEinnahmeAusgabe = _einnahme + _ausgabe; if (_ausgabe == 0 | _einnahme == 0) { if (_ausgabe == 0) { _percentAusgabe = 0; } else { _percentAusgabe = (_ausgabe * -1) / (_einnahme - _ausgabe); } if (_einnahme == 0) { _percentEinnahme = 0; } else { _percentEinnahme = _einnahme / (_einnahme - _ausgabe); } } else { _percentEinnahme = _einnahme / (_einnahme - _ausgabe); _percentAusgabe = (_ausgabe * -1) / (_einnahme - _ausgabe); } }
private async Task <decimal> SummeRechnenAsync(string category, int monat, int year) { var uNFI = new UserNumberFormat(); decimal?summeTemp; if (category == CategoryNamenIncomen.Salary.ToString() || category == CategoryNamenIncomen.OtherIncomes.ToString()) { using (var dataBase = new Store.DataBase.DataBaseEF.DataBaseFile()) { summeTemp = await dataBase.Incomes.AsNoTracking() .Select(c => new { nameCategory = c.CategoryOfIncome, price = (decimal?)Decimal.Parse(c.PreisOfIncome, NumberStyles.Number | NumberStyles.AllowCurrencySymbol, uNFI.GetNFI()), datum = c.DateOfIncome }) .Where(a => a.datum.Month == monat & a.datum.Year == year && a.nameCategory == category) .Select(a => a.price).SumAsync(); } } else { using (var dataBase = new Store.DataBase.DataBaseEF.DataBaseFile()) { summeTemp = await dataBase.Costs.AsNoTracking() .Select(c => new { nameCategory = c.CategoryOfCost, price = (decimal?)Decimal.Parse(c.PreisOfCost, NumberStyles.Number | NumberStyles.AllowCurrencySymbol, uNFI.GetNFI()), datum = c.DateOfCost }) .Where(a => a.datum.Month == monat & a.datum.Year == year && a.nameCategory == category) .Select(a => a.price).SumAsync(); } } _summeItem = (decimal)summeTemp; return(_summeItem); }
/// <summary> /// Get summe one item undercategory /// </summary> /// <param name="category"></param> /// <param name="nameUnderCategory"></param> /// <param name="monat"></param> /// <param name="year"></param> /// <returns></returns> internal async Task <decimal> GetSummeAsync(string category, string nameUnderCategory, int monat, int year) { var uNFI = new UserNumberFormat(); decimal?summeTemp; //decimal summe; using (var dataBase = new Store.DataBase.DataBaseEF.DataBaseFile()) { summeTemp = await dataBase.Costs.AsNoTracking() .Select(c => new { nameCategory = c.CategoryOfCost, nameUnderCategory = c.CategoryUnderOfCost, price = (decimal?)Decimal.Parse(c.PreisOfCost, NumberStyles.Number | NumberStyles.AllowCurrencySymbol, uNFI.GetNFI()), datum = c.DateOfCost }) .Where(a => a.datum.Month == monat & a.datum.Year == year && a.nameCategory == category && a.nameUnderCategory == nameUnderCategory) .Select(a => a.price).SumAsync(); } _summeItem = (decimal)summeTemp; //summe = (decimal)summeTemp; return(_summeItem); }