private void tspSaveAndNew_Click(object sender, EventArgs e) { this.isSaveAndNew = true; SaveReminder(); frmMain.LoadReminderByStatus(frmMain.CboFilterText); frmMain.DisableEditDelete(); }
private void tspSaveAndNew_Click(object sender, EventArgs e) { this.isSaveAndNew = true; SaveAccount(); frmMain.LoadAccountByType(frmMain.CboFilterText); frmMain.DisableEditDelete(); frmMain.DrawChart(frmMain.CboChart); }
private void tspSaveAndClose_Click(object sender, EventArgs e) { if (cboAccount.Text == "") { MessageBox.Show("Pilih rekening terlebih dahulu", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (txtAmount.Text == "") { MessageBox.Show("Jumlah tidak boleh kosong", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); txtAmount.Focus(); } else if (decimal.Parse(txtAmount.Text.Replace(".", string.Empty)) > forBalance) { MessageBox.Show("Pembayaran tidak mencukupi. " + lblForBalance.Text, "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); txtAmount.Focus(); } else { Model.Transaction transaction = new Model.Transaction(); transaction.Type = TransactionType.Payment.ToString(); transaction.Date = dtpDate.Value; transaction.Amount = decimal.Parse(txtAmount.Text.Replace(".", string.Empty)); transaction.Description = "Bayar " + this.accountName + " dengan " + cboAccount.Text; transaction.CategoryId = new Guid(lblCategoryId.Text); transaction.AccountId = new Guid(lblAccountId.Text); transaction.Notes = txtNotes.Text; transactionRepository.Save(transaction); frmMain.LoadAccountByType(frmMain.CboFilterText); frmMain.DisableEditDelete(); frmMain.DisableAction(); frmMain.DrawChart(frmMain.CboChart); this.Close(); } }
private void btnFilter_Click(object sender, EventArgs e) { int month = frmMain.CurrentMonth; int year = frmMain.CurrentYear; StringBuilder clause = new StringBuilder(); if (cboFilter.Text == "Pendapatan") { clause.Append("t.Type ='Income' AND "); } else if (cboFilter.Text == "Pengeluaran") { clause.Append("t.Type IN ('Expense','Payment') AND "); } else if (cboFilter.Text == "Transfer Bank") { clause.Append("t.Type='Transfer' AND "); } else if (cboFilter.Text == "Penarikan Tunai") { clause.Append("t.Type='Withdrawl' AND "); } else if (cboFilter.Text == "Setor Tunai") { clause.Append("t.Type='Deposit' AND "); } if (chkDate.Checked) { clause.Append("Date BETWEEN '" + dtpFrom.Value.ToString("MM/dd/yyyy") + "' AND '" + dtpTo.Value.ToString("MM/dd/yyyy") + "'"); } else { clause.Append("DATEPART(month,Date)=" + month + " AND DATEPART(year,Date)=" + year); } if (chkCategory.Checked) { clause.Append(" AND c.Name='" + cboCategory.Text.TrimStart() + "'"); } if (chkAccount.Checked) { clause.Append(" AND a.Name='" + cboAccount.Text + "'"); } if (chkDescription.Checked) { clause.Append(" AND Description LIKE '%" + txtDescription.Text.Replace("'", string.Empty) + "%'"); } if (chkNotes.Checked) { clause.Append(" AND Notes LIKE '%" + txtNotes.Text.Replace("'", string.Empty) + "%'"); } List <Model.Transaction> transactions = transactionRepository.GetByFilter(clause.ToString()); frmMain.FilterTransaction(transactions); frmMain.DisableEditDelete(); }
private void SaveCategory() { if (ValidateEntry()) { string errMsg = string.Empty; try { if (formMode == FormMode.AddNew) { errMsg = "Gagal menyimpan kategori!"; categoryRepository.Save(AssignCategory(this.type, Guid.Empty)); DoubleEntryForIncomeExpense(); if (this.isSaveAndNew) { ClearForm(); } else { this.Close(); } } else if (formMode == FormMode.Edit) { errMsg = "Gagal mengubah kategori!"; if (cboGroup.Text == "Hutang" || cboGroup.Text == "Piutang") { categoryRepository.Update(AssignCategory(this.type, new Guid(lblID.Text))); Category category2 = null; if (this.type == "Income") { category2 = categoryRepository.GetByNameAndType(lblCategory.Text, "Expense"); category2.Type = "Expense"; } else if (this.type == "Expense") { category2 = categoryRepository.GetByNameAndType(lblCategory.Text, "Income"); category2.Type = "Income"; } category2.Name = txtName.Text; categoryRepository.Update(category2); } else { categoryRepository.Update(AssignCategory(this.type, new Guid(lblID.Text))); } this.Close(); } } catch (Exception ex) { MessageBox.Show(errMsg, "Info", MessageBoxButtons.OK, MessageBoxIcon.Error); } frmMain.LoadCategoryByType(frmMain.CboFilterText); frmMain.DisableEditDelete(); } }
private void SaveTransaction() { if (ValidateEntry()) { Model.Transaction transaction = new Model.Transaction(); transaction.Date = dtpDate.Value; transaction.Type = transactionType.ToString(); transaction.CategoryId = new Guid(lblCategoryId.Text); transaction.AccountId = new Guid(lblAccountId.Text); transaction.Amount = decimal.Parse(txtAmount.Text.Replace(".", string.Empty)); transaction.Notes = txtNotes.Text; string errMsg = string.Empty; try { if (formMode == FormMode.AddNew) { errMsg = "Gagal menyimpan transaksi!"; if (transactionType == TransactionType.Income.ToString()) { transaction.Description = "Pendapatan dari " + cboCategory.Text + " disimpan di " + cboAccount.Text; } else if (transactionType == TransactionType.Expense.ToString()) { transaction.Description = "Pengeluaran untuk " + cboCategory.Text + " dibayar dengan " + cboAccount.Text; } if (transactionRepository.IsTransactionExist(dtpDate.Value, this.transactionType, new Guid(lblCategoryId.Text), new Guid(lblAccountId.Text))) { MessageBox.Show("Transaksi sudah ada", "Perhatian", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { transactionRepository.Save(transaction); if (this.isSaveAndNew) { ClearForm(); } else { this.Close(); } } } else if (formMode == FormMode.Edit) { errMsg = "Gagal mengubah transaksi!"; transaction.ID = new Guid(lblID.Text); transactionRepository.Update(transaction); this.Close(); } frmMain.LoadTransactionByType(frmMain.CboFilterText); frmMain.DisableEditDelete(); frmMain.DrawChart(frmMain.CboChart); } catch (Exception ex) { MessageBox.Show(errMsg, "Info", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }