public ViewHistoryWindow(IncomeHistory incomeHistory) { InitializeComponent(); Uri iconUri = new Uri("pack://application:,,,/img/icon.ico", UriKind.RelativeOrAbsolute); this.Icon = BitmapFrame.Create(iconUri); historyArr = new List <Income>(); if (incomeHistory != null) { var ih = incomeHistory.incomeArr.OrderBy(t => t.date).ToList(); chart_history.DataSource = ih; for (var i = 0; i < ih.Count; i++) { try { var dtstr = ih[i].date; var dt = new DateTime(int.Parse(dtstr.Substring(0, 4)), int.Parse(dtstr.Substring(4, 2)), int.Parse(dtstr.Substring(6, 2))); var ic = new Income { date = dt.ToLongDateString(), num = ih[i].num }; historyArr.Add(ic); } catch (Exception ex) { Debug.WriteLine(ex.Message); } } } }
public async Task <IActionResult> Edit(Guid id, [Bind("IncomeCategoryID,AccountsID,Amount,Date,Remarks,ID")] IncomeHistory incomeHistory) { if (id != incomeHistory.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(incomeHistory); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!IncomeHistoryExists(incomeHistory.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["AccountsID"] = new SelectList(_context.Accounts.OrderBy(x => x.AccountName), "ID", "AccountName", incomeHistory.AccountsID); ViewData["IncomeCategoryID"] = new SelectList(_context.IncomeCategory.OrderBy(x => x.Name), "ID", "Name", incomeHistory.IncomeCategoryID); return(View(incomeHistory)); }
public async Task <IActionResult> Create([Bind("IncomeCategoryID,AccountsID,Amount,Date,Remarks,ID")] IncomeHistory incomeHistory) { if (ModelState.IsValid) { incomeHistory.ID = Guid.NewGuid(); _context.Add(incomeHistory); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["AccountsID"] = new SelectList(_context.Accounts.OrderBy(x => x.AccountName), "ID", "AccountName", incomeHistory.AccountsID); ViewData["IncomeCategoryID"] = new SelectList(_context.IncomeCategory.OrderBy(x => x.Name), "ID", "Name", incomeHistory.IncomeCategoryID); return(View(incomeHistory)); }