public EditIn_Cats(IncomeCategories incomeCategories)
 {
     InitializeComponent();
     In_CategoryController = new In_CategoryController();
     BindingContext        = incomeCategories;
     IncomeCategories      = incomeCategories;
 }
示例#2
0
 public In_Cat_List()
 {
     InitializeComponent();
     In_Cat_database = new In_CategoryController();
     if (In_Cat_database.GetCategories() != null)
     {
         incomeCategories = new ObservableCollection <IncomeCategories>(In_Cat_database.GetCategories());
     }
     else
     {
         //Insert primary data
         IncomeCategories _incomeCategories = new IncomeCategories()
         {
             Name = "Salary"
         };
         IncomeCategories _incomeCategories1 = new IncomeCategories()
         {
             Name = "Business"
         };
         incomeCategories = new ObservableCollection <IncomeCategories>();
         incomeCategories.Add(_incomeCategories);
         incomeCategories.Add(_incomeCategories1);
     }
     _Inc_Cats.ItemsSource = incomeCategories;
 }
        public ActionResult DeleteConfirmed(int id)
        {
            IncomeCategories incomeCategories = db.IncomeCategories.Find(id);

            db.IncomeCategories.Remove(incomeCategories);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
示例#4
0
        /// <summary>
        /// Clears data from the SubCategories.
        /// </summary>
        public void ClearData()
        {
            IncomeCategories.Clear();
            ExpenseCategories.Clear();

            SelectedIncomeCategory  = new Category();
            SelectedExpenseCategory = new Category();
        }
示例#5
0
 public void GetFromCSV(string path)
 {
     //Чита податоци од csv фајл и запишува во овој објект.
     using (StreamReader file = new StreamReader(path))
     {
         string type = "";
         string line;
         line = file.ReadLine();
         if (line == null)
         {
             return;
         }
         string[] parts = line.Split(',');
         Income   = Convert.ToDecimal(parts[0]);
         Expenses = Convert.ToDecimal(parts[1]);
         Total    = Convert.ToDecimal(parts[2]);
         while ((line = file.ReadLine()) != null)
         {
             if (line.Equals("Categories:"))
             {
                 type = line;
                 continue;
             }
             else if (line.Equals("Accounts:"))
             {
                 type = line;
                 continue;
             }
             else if (line.Equals("Transactions:"))
             {
                 type = line;
                 continue;
             }
             if (type.Equals("Categories:"))
             {
                 if (line[0] == '1')
                 {
                     IncomeCategories.Add(line.Substring(2), new IncomeCategory(line.Substring(2)));
                 }
                 else
                 {
                     ExpensesCategories.Add(line.Substring(2), new ExpensesCategory(line.Substring(2)));
                 }
             }
             else if (type.Equals("Accounts:"))
             {
                 Account a = MakeAccount(line);
                 Accounts.Add(a.Name, a);
             }
             else if (type.Equals("Transactions:"))
             {
                 Transactions.Add(MakeTransaction(line));
             }
         }
         file.Close();
     }
 }
 public ActionResult Edit([Bind(Include = "Id,IncomeCategoryName")] IncomeCategories incomeCategories)
 {
     if (ModelState.IsValid)
     {
         db.Entry(incomeCategories).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(incomeCategories));
 }
        public ActionResult Create([Bind(Include = "Id,IncomeCategoryName")] IncomeCategories incomeCategories)
        {
            if (ModelState.IsValid)
            {
                db.IncomeCategories.Add(incomeCategories);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(incomeCategories));
        }
示例#8
0
 /// <summary>
 /// Adds a new Income SubCategory with the name in the NewIncomeName TextBox.
 /// </summary>
 public void AddIncomeCategory()
 {
     if (NewIncomeName == String.Empty)
     {
         IncomeCategories.Add(new Category("Default"));
     }
     else
     {
         IncomeCategories.Add(new Category(NewIncomeName));
         NewIncomeName = String.Empty;
     }
 }
        // GET: IncomeCategories/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            IncomeCategories incomeCategories = db.IncomeCategories.Find(id);

            if (incomeCategories == null)
            {
                return(HttpNotFound());
            }
            return(View(incomeCategories));
        }
示例#10
0
 public int SaveCategory(IncomeCategories cat)
 {
     lock (Locker)
     {
         if (cat.Id != 0)
         {
             database.Update(cat);
             return(cat.Id);
         }
         else
         {
             return(database.Insert(cat));
         }
     }
 }
示例#11
0
        /// <summary>
        /// Base Constructor, Subscribes to the SendEnter Event.
        /// </summary>
        public SubCategoryViewModel()
        {
            #region Test Data. Should get replaced on startup.
            IncomeCategories.Add(new Category("Temp Income Category 1"));
            IncomeCategories.Add(new Category("Temp Income Category 2"));
            IncomeCategories.Add(new Category("Temp Income Category 3"));
            IncomeCategories.Add(new Category("Should not be shown."));

            ExpenseCategories.Add(new Category("Temp Expense Category 1"));
            ExpenseCategories.Add(new Category("Temp Expense Category 2"));
            ExpenseCategories.Add(new Category("Temp Expense Category 3"));
            ExpenseCategories.Add(new Category("Should not be shown."));
            #endregion

            SubCategoryView.SendEnter += this.SubCategoryView_SendKeyPress;
        }
示例#12
0
        public Transaction MakeTransaction(string csvLine)
        {
            Transaction t;

            if (csvLine[0] == '1')
            {
                t = new IncomeTransaction();
            }
            else
            {
                t = new ExpenseTransaction();
            }
            csvLine = csvLine.Substring(2);
            string[] parts = csvLine.Split(',');
            if (Accounts.ContainsKey(parts[1]) && (IncomeCategories.ContainsKey(parts[2]) || ExpensesCategories.ContainsKey(parts[2])))
            {
                t.Date    = DateTime.Parse(parts[0]);
                t.Account = Accounts[parts[1]];
                if (IncomeCategories.ContainsKey(parts[2]))
                {
                    t.Category = IncomeCategories[parts[2]];
                }
                else
                {
                    t.Category = ExpensesCategories[parts[2]];
                }
                t.Amount   = Convert.ToDecimal(parts[3]);
                t.Contents = "";
                for (int i = 4; i < parts.Length; i++)
                {
                    if (i == parts.Length - 1)
                    {
                        t.Contents += string.Format("{0}", parts[i]);
                    }
                    else
                    {
                        t.Contents += string.Format("{0},", parts[i]);
                    }
                }
            }
            return(t);
        }
示例#13
0
 private void BtnSave_Clicked(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(In_Cat_Name.Text))
     {
         IncomeCategories incomeCategories = new IncomeCategories
         {
             Name = In_Cat_Name.Text
         };
         if (In_CategoryController.SaveCategory(incomeCategories) != 0)
         {
             _IncomeCats.Add(incomeCategories);
             DisplayAlert("Hey", "Category successfully saved", "great");
         }
     }
     else
     {
         DisplayAlert("Hey", "Please enter a category", "Ok");
     }
     Clear();
 }
示例#14
0
 public IEnumerable <IncomeCategories> GetCategories()
 {
     lock (Locker)
     {
         var incomes = from c in database.Table <IncomeCategories>()
                       select c;
         if (incomes.Count() == 0)
         {
             IncomeCategories inc1 = new IncomeCategories
             {
                 Name = "Salary"
             };
             IncomeCategories inc2 = new IncomeCategories
             {
                 Name = "Stock Options"
             };
             SaveCategory(inc1);
             SaveCategory(inc2);
             incomes = from c in database.Table <IncomeCategories>()
                       select c;
         }
         return(incomes);
     }
 }
示例#15
0
 protected override void OnAttached(BudgetModel model)
 {
     base.OnAttached(model);
     IncomeCategories.AttachToModel(model);
 }
 public ActionResult AddCategory(IncomeCategories incomeCategories)
 {
     incomeRepository.AddIncomeCategory(incomeCategories);
     return(RedirectToAction("AddIncome"));
 }
示例#17
0
 public void Handle(UpdateDataListEvent message)
 {
     Income.AllIncomeCategories   = IncomeCategories.ToList();
     Expense.AllExpenseCategories = ExpenseCategories.ToList();
 }
示例#18
0
 /// <summary>
 /// Sends all edits to the Income & Expense SubCategory Lists.
 /// </summary>
 public void FinishCategories()
 {
     Income.AllIncomeCategories   = IncomeCategories.ToList();
     Expense.AllExpenseCategories = ExpenseCategories.ToList();
 }
示例#19
0
 /// <summary>
 /// Removes the selected Income SubCategory from the SubCategory List.
 /// </summary>
 public void RemoveIncomeCategory()
 {
     IncomeCategories.Remove(SelectedIncomeCategory);
 }
 public void AddIncomeCategory(IncomeCategories incomeCategories)
 {
     context.IncomeCategories.Add(incomeCategories);
     context.SaveChanges();
 }