private void loadExpenseList() { double totalAmount = 0; expenseID = -1; datePicker.Text = DateTime.Today.ToString(); txtName.Text = ""; txtAmount.Text = ""; expenses = SQLiteDataAccess.loadExpenses(); wireExpenseList(); foreach (DataGridViewRow item in listBox.Rows) { totalAmount += Convert.ToDouble(item.Cells[2].Value.ToString()); } txtTotalAmount.Text = totalAmount.ToString(); }
private void expenseButton_Click(object sender, EventArgs e) { try { expenseModel em = new expenseModel(); double tempAmount = Convert.ToDouble(txtAmount.Text); double finalAmount = 0; if (tempAmount > 0) { finalAmount = tempAmount * -1; } else { finalAmount = tempAmount; } em.Name = txtName.Text; em.Amount = finalAmount; em.Date = datePicker.Value.ToString("MM/dd/yyy"); if (expenseID == -1) { SQLiteDataAccess.saveExpenses(em); } else { SQLiteDataAccess.editExpenses(em, expenseID); } loadExpenseList(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }