Пример #1
0
        private void UpdateSummary()
        {
            var amount = 0m;

            if (decimal.TryParse(TbAmount.Text, out var a))
            {
                amount = a;
            }

            LblTotalAmount.Text      = $"{(string.IsNullOrWhiteSpace(TbAmount.Text) ? "0" : TbAmount.Text)} {_currencyPickerModel.SelectedItem}";
            LblAmountNormalized.Text = $" = {amount / CurrencyRates.Convert("USD", _currencyPickerModel.SelectedItem):F2} USD";
            LblConversion.Text       = $"1 USD = {CurrencyRates.Convert("USD", _currencyPickerModel.SelectedItem)} {_currencyPickerModel.SelectedItem}";
            LblDescription.Text      = TbDescription.Text;
        }
Пример #2
0
        public void SaveExpense(string amount, string currency, string category, string description)
        {
            var valuesArr = new List <string>
            {
                DateTime.Now.Date.ToString("yyyy-M-dd"),
                amount,
                currency,
                CurrencyRates.Convert("USD", currency).ToString(CultureInfo.InvariantCulture)
            };

            // TODO: move to constant and then to settings.
            var last = _googleSheetsClient.GetFirstEmptyCell("Transactions!B4:B500");

            var firstPart  = last;
            var secondPart = new GSheetRange(last.TableName, "G" + last.RangeStart.YNumber, null);

            _googleSheetsClient.WriteRows(firstPart.ToString(), valuesArr);
            valuesArr.Clear();

            valuesArr.Add(description);
            valuesArr.Add(category);

            _googleSheetsClient.WriteRows(secondPart.ToString(), valuesArr);
        }