Ejemplo n.º 1
0
        // TODO: use database ID for edit
        public EditUniqueItemVM(bool _IsAdd, int _ItemId)   // _RegularItemId could be NEW_REGULAR_ITEM_ID
        {
            m_ShowAddButton = _IsAdd;

            if (_ItemId != NEW_REGULAR_ITEM_ID)
            {
                UniqueExpenseItemId = _ItemId;

                UniqueExpensesStorage db = App.GlobalPersistanceService.GetUniqueExpensesStorage();
                UniqueExpenseItem     ri = db.GetUniqueExpense(_ItemId);

                this.Date = ri.Date.ToLocalTime();
                this.Name = ri.Name;
                int am = ri.Amount;
                m_IsIncome  = am > 0;                                                         // save "income" or "expense"
                this.Amount = DataConversion.ConvertCentsToCurrency(Math.Abs(am)).ToString(); // display abs amount
            }
            else
            {
                UniqueExpenseItemId = NEW_REGULAR_ITEM_ID;

                Name   = "";
                Amount = "";
                Date   = DateTimeOffset.Now.Date;
            }

            UpdateButtonColor = m_IsIncome ? "ForestGreen" : "DarkRed";

            UpdateButtonText = m_IsIncome ? "Update Income" : "Update Expense";
        }
Ejemplo n.º 2
0
 private void InitializeRegularItem(int _Id, string _Name, int _Amount, REGULARS_PERIOD _Period)
 {
     this.Id     = _Id;
     this.Name   = _Name;
     this.Amount = DataConversion.ConvertCentsToCurrency(_Amount);
     InitializePeriod(_Period);
 }
Ejemplo n.º 3
0
        // TODO: use database ID for edit
        public EditRegularItemVM(bool _IsIncome, bool _IsAdd, int _RegularItemId)   // _RegularItemId could be NEW_REGULAR_ITEM_ID
        {
            m_IsIncome = _IsIncome;

            string action    = _IsAdd ? "Add" : "Update";
            string direction = _IsIncome ? "Income" : "Expense";

            Header      = string.Format("{0} {1}", action, direction);
            HeaderColor = _IsIncome ? "ForestGreen" : "DarkRed";

            EditButtonText = string.Format("{0} {1}", action, direction);

            if (_RegularItemId != RegularItemVM.NEW_REGULAR_ITEM_ID)
            {
                RegularItemId = _RegularItemId;

                RegularStorage db = new RegularStorage();
                RegularItem    ri = db.GetRegular(_RegularItemId);

                this.Name   = ri.Name;
                this.Amount = DataConversion.ConvertCentsToCurrency(Math.Abs(ri.Amount)).ToString();
                SetPeriod(ri.Period);
            }
            else
            {
                RegularItemId = RegularItemVM.NEW_REGULAR_ITEM_ID;

                Name   = "";
                Amount = "";
                SetPeriod(REGULARS_PERIOD.YEARLY);
            }
        }
Ejemplo n.º 4
0
 public UniqueExpenseVM(int _Id, DateTime _Date, int _Amount, string _Name)
 {
     this.Id           = _Id;
     this.Date         = _Date;
     this.Amount       = DataConversion.ConvertCentsToCurrency(Math.Abs(_Amount));
     this.SignedAmount = DataConversion.ConvertCentsToCurrency(_Amount);
     this.AmountColor  = ViewHelpers.GetColorByAmount(_Amount);
     this.Name         = _Name;
 }
Ejemplo n.º 5
0
        public ExpenseVM(int _Id, DateTime _Date, int _Amount)
        {
            m_Date = _Date;

            this.Id = _Id;
            SetDate(_Date);
            this.Amount      = DataConversion.ConvertCentsToCurrency(_Amount);
            this.AmountColor = GetColorByAmount(_Amount);
        }