private void FrmDetailTransaksi_Load(object sender, EventArgs e) { this.listAwal = new List <Transaction>(); try { using (var transdao = new TransactionDAO()) { ListTransaction = transdao.GetAllTransactionDataByID(user.ID.ToString()); } foreach (var item in ListTransaction) { if (item.Date == DateTime.Parse(Date)) { listAwal.Add(item); } } dgvData.DataSource = listAwal; this.dgvData.Columns[0].DataPropertyName = "Category"; this.dgvData.Columns[1].DataPropertyName = "SubCategory"; this.dgvData.Columns[2].DataPropertyName = "Amount"; this.dgvData.Columns[3].DataPropertyName = "Note"; lblResult.Text = "Results : " + dgvData.Rows.Count.ToString() + " Row(s)"; } catch (Exception ex) { throw ex; } }
private void coBoxMonth_SelectedIndexChanged(object sender, EventArgs e) { listfilter = new List <Transaction>(); using (var transdao = new TransactionDAO()) { listTransaksi = transdao.GetAllTransactionDataByID(user.ID.ToString()); } foreach (var item in listTransaksi) { if (coBoxMonth.SelectedIndex == 0 && item.Date.Month == DateTime.Today.Month) { listfilter.Add(item); } else if (coBoxMonth.SelectedIndex == 1 && item.Date.Month == DateTime.Today.Month - 1) { listfilter.Add(item); } else if (coBoxMonth.SelectedIndex == 2 && item.Date.Month == DateTime.Today.Month - 2) { listfilter.Add(item); } } fillChart(listfilter); }
private void FrmMainMenu_Load(object sender, EventArgs e) { double totalIncome = 0, totalExpense = 0; double thisMonthIncome = 0, thisMonthExpense = 0; try { using (var transdao = new TransactionDAO()) { TransactionList = transdao.GetAllTransactionDataByID(user.ID.ToString()); listNonDetail = transdao.GetAllTransactionHeaderByID(user.ID.ToString()); } foreach (var item in listNonDetail) { if (item.Date.Month == DateTime.Today.Month) { thisMonthIncome += item.Income; thisMonthExpense += item.Expense; } totalIncome += item.Income; totalExpense += item.Expense; } lblIncome.Text = "Income : Rp. " + thisMonthIncome.ToString("n0") + ",00-"; lblExpense.Text = "Expense : Rp. " + thisMonthExpense.ToString("n0") + ",00-"; lblTotal.Text = "Account Balance : Rp. " + (totalIncome - totalExpense).ToString("n0") + ",00-"; coBoxMonth.SelectedIndex = 1; coBoxMonth.SelectedIndex = 0; this.dgvData.Columns[0].DataPropertyName = "Date"; this.dgvData.Columns[1].DataPropertyName = "Income"; this.dgvData.Columns[2].DataPropertyName = "Expense"; } catch (Exception ex) { throw ex; } }
private void fillChart() { incomeChart.Series["Income"].Points.Clear(); expenseChart.Series["Expense"].Points.Clear(); incomeChart.Titles.Clear(); expenseChart.Titles.Clear(); List <Transaction> listTransaksi = null; double[] arrayInAmount = new double[listInSubCategory.Count]; double[] arrayExAmount = new double[listExSubCategory.Count]; try { using (var transdao = new TransactionDAO()) { listTransaksi = transdao.GetAllTransactionDataByID(user.ID.ToString()); } foreach (var item in listTransaksi) { if (item.Category == "Income") { for (int i = 0; i < listInSubCategory.Count; i++) { if (item.SubCategory == listInSubCategory.ElementAt(i)) { arrayInAmount[i] += item.Amount; } } } else if (item.Category == "Expense") { for (int i = 0; i < listExSubCategory.Count; i++) { if (item.SubCategory == listExSubCategory.ElementAt(i)) { arrayExAmount[i] += item.Amount; } } } } } catch (Exception ex) { throw ex; } // For Income Chart for (int i = 0; i < listInSubCategory.Count; i++) { if (arrayInAmount[i] != 0) { incomeChart.Series["Income"].Points.AddXY(listInSubCategory.ElementAt(i), arrayInAmount[i]); } } incomeChart.Titles.Add("Income"); // For Expense Chart for (int i = 0; i < listExSubCategory.Count; i++) { if (arrayExAmount[i] != 0) { expenseChart.Series["Expense"].Points.AddXY(listExSubCategory.ElementAt(i), arrayExAmount[i]); } } expenseChart.Titles.Add("Expense"); }