Example #1
0
        public void ShowIncome(Income income)
        {
            CreateView();

            view.Presenter.Income = income;
            view.Show();
        }
Example #2
0
 private static void SetItems(Income i, ListViewItem li)
 {
     li.SubItems.Clear();
     li.SubItems.Add(i.Amount.ToString());
     li.SubItems.Add(i.Period2.Format);
     li.SubItems.Add(i.Account.Name);
     li.Text = i.Name;
 }
Example #3
0
 private void AddIncome(Income i)
 {
     ListViewItem li = new ListViewItem();
     SetItems(i, li);
     li.Tag = i;
     listView1.Items.Add(li);
     items[i] = li;
     i.PropertyChanged += new PropertyChangedEventHandler(Income_PropertyChanged);
 }
Example #4
0
        public void Start(DateTime now)
        {
            nextEvent = DateTime.MaxValue;
            foreach (Income i in db.Container.IncomeSet)
            {
                if ((nextEvents[i] = i.Period2.GetNearestEvent(now)) < nextEvent)
                {
                    nextEvent = nextEvents[i];
                    nextEventIncome = i;
                }
            }

            //System.Windows.Forms.MessageBox.Show(nextEvent.ToString());
            SetupTimer();
        }
Example #5
0
        void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            if (DateTime.Now < nextEvent)
            {
                SetupTimer();
                return;
            }

            db.CreateIncomeTx(nextEventIncome, nextEvent);

            nextEvents[nextEventIncome] = nextEventIncome.Period2.GetNearestEvent(nextEvent);

            nextEvent = DateTime.MaxValue;
            foreach (Income i in nextEvents.Keys)
                if (nextEvents[i] < nextEvent)
                {
                    nextEvent = nextEvents[i];
                    nextEventIncome = i;
                }

            SetupTimer();
        }
Example #6
0
        public void CreateIncome()
        {
            CreateView();
            Account a = null;

            try
            {
                a = view.Presenter.Accounts.First();
            }
            catch (Exception e)
            {
                Error.Show(e);
                return;
            }

            Income i = new Income();
            i.Account = a;
            i.StartDate = DateTime.Now;
            i.EndDate = DateTime.Now.AddYears(1);
            i.Period = "";
            i.Name = "";

            ShowIncome(i);
        }
Example #7
0
        private void UpdateNextEvent(Income income)
        {
            nextEvents[income] = income.Period2.GetNearestEvent(DateTime.Now);
            if (nextEvents[income] >= nextEvent)
                return;

            nextEvent = nextEvents[income];
            nextEventIncome = income;

            timer.Stop();
            SetupTimer();
        }
Example #8
0
 public void OnIncomeChanged(Income income)
 {
     UpdateNextEvent(income);
 }
Example #9
0
 public void OnIcomeAdded(Income income)
 {
     UpdateNextEvent(income);
 }
Example #10
0
File: Db.cs Project: qwer/budget
        public void CreateIncomeTx(Income income, DateTime datetime)
        {
            History h = new History();

            h.AccountDest = income.Account;
            h.AccountSrc = null;
            h.Amount = income.Amount;
            h.Date = datetime;
            h.Description = "";
            h.Income = income;

            AddHistory(h);
        }
Example #11
0
File: Db.cs Project: qwer/budget
        public void AddIncome(Income income)
        {
            bool added = income.EntityState == EntityState.Added;
            if (added)
                Container.IncomeSet.AddObject(income);

            try
            {
                Container.SaveChanges();
            }
            catch (Exception e)
            {
                Error.Show(e);
                if (added)
                    Container.Detach(income);
                return;
            }

            if (player != null)
            {
                if (added)
                    player.OnIcomeAdded(income);
                else
                    player.OnIncomeChanged(income);
            }

            if (added && IncomeAdded != null)
                IncomeAdded(income, null);
        }
Example #12
0
 /// <summary>
 /// Create a new Income object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="amount">Initial value of the Amount property.</param>
 /// <param name="period">Initial value of the Period property.</param>
 /// <param name="startDate">Initial value of the StartDate property.</param>
 /// <param name="endDate">Initial value of the EndDate property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 public static Income CreateIncome(global::System.Int32 id, global::System.Decimal amount, global::System.String period, global::System.DateTime startDate, global::System.DateTime endDate, global::System.String name)
 {
     Income income = new Income();
     income.Id = id;
     income.Amount = amount;
     income.Period = period;
     income.StartDate = startDate;
     income.EndDate = endDate;
     income.Name = name;
     return income;
 }
Example #13
0
 /// <summary>
 /// Deprecated Method for adding a new object to the IncomeSet EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToIncomeSet(Income income)
 {
     base.AddObject("IncomeSet", income);
 }