private void showGrid() { dgList.Rows.Clear(); foreach (PaymentForm x in PaymentFormDAO.ListAll()) { dgList.Rows.Add(x.Id, x.Name, PaymentFormU.ArrayType[x.Type], Util.moneyFormat_ptBR(x.InitialBalance)); } }
private void dgList_DoubleClick(object sender, EventArgs e) { PaymentForm paymentFormVO = new PaymentForm(); paymentFormVO.Id = int.Parse(dgList.CurrentRow.Cells["clId"].Value.ToString()); paymentFormVO = PaymentFormDAO.GetByID(paymentFormVO); txtName.Text = paymentFormVO.Name; cmbType.SelectedIndex = paymentFormVO.Type; txtInitialBalance.Text = paymentFormVO.InitialBalance.ToString(); txtId.Text = paymentFormVO.Id.ToString(); btnExcluir.Enabled = true; }
private void cmbPaymentForm_Start() { PaymentForm pf = new PaymentForm(); cmbPaymentForm.Items.Add(pf); foreach (PaymentForm x in PaymentFormDAO.ListAll()) { cmbPaymentForm.Items.Add(x); } cmbPaymentForm.ValueMember = "Id"; cmbPaymentForm.DisplayMember = "Name"; }
private void showGrid() { DateTime dateIn = DateTime.Parse(dtDateIn.Text); DateTime dateEnd = DateTime.Parse(dtDateEnd.Text); Finance finance; double ganhos, gastos, totalGanhos = 0, totalGastos = 0, saldo; dgList.Rows.Clear(); foreach (PaymentForm p in PaymentFormDAO.ListAll()) { finance = new Finance(); finance.FinanceCategorySub = new FinanceCategorySub(); finance.FinanceCategorySub.FinanceCategory = new FinanceCategory(); finance.FinanceCategorySub.FinanceCategory.Type = FinanceCategoryU.TYPE_GANHO; finance.PaymentForm = p; ganhos = 0; foreach (Finance f in FinanceDAO.ListByFilter(finance, dateIn, dateEnd)) { ganhos += f.Value; } finance.FinanceCategorySub.FinanceCategory.Type = FinanceCategoryU.TYPE_GASTO; gastos = 0; foreach (Finance f in FinanceDAO.ListByFilter(finance, dateIn, dateEnd)) { gastos += f.Value; } dgList.Rows.Add(p.Name, Util.moneyFormat_ptBR(ganhos), Util.moneyFormat_ptBR(gastos), Util.moneyFormat_ptBR(FinanceBO.CalcSaldo(ganhos, gastos))); totalGanhos += ganhos; totalGastos += gastos; } txtGanhos.Text = Util.moneyFormat_ptBR(totalGanhos); txtGastos.Text = Util.moneyFormat_ptBR(totalGastos); saldo = FinanceBO.CalcSaldo(totalGanhos, totalGastos); txtMeuSaldo.Text = Util.moneyFormat_ptBR(saldo); if (saldo > 0) { txtMeuSaldo.ForeColor = System.Drawing.Color.Green; } else { txtMeuSaldo.ForeColor = System.Drawing.Color.Red; } }
private bool validateForm(PaymentForm paymentFormVO) { paymentFormVO.Name = txtName.Text.Trim(); if (paymentFormVO.Name.Equals("")) { lblErrorName.Text = "Campo obrigatório."; txtName.Focus(); return(false); } if (PaymentFormDAO.CountByName(paymentFormVO) > 0) { lblErrorName.Text = "Já consta cadastrado."; return(false); } lblErrorName.Text = ""; paymentFormVO.Type = cmbType.SelectedIndex; if (paymentFormVO.Type.Equals(0) || cmbType.Text.Trim().Equals("")) { lblErrorType.Text = "Campo obrigatório"; cmbType.Focus(); return(false); } lblErrorType.Text = ""; if (txtInitialBalance.Text.Trim().Equals("")) { lblErrorInitialBalance.Text = "Campo obrigatório."; txtInitialBalance.Focus(); return(false); } double initialBalance; if (!double.TryParse(txtInitialBalance.Text, out initialBalance)) { lblErrorInitialBalance.Text = "Preencha um número válido."; return(false); } lblErrorInitialBalance.Text = ""; paymentFormVO.InitialBalance = initialBalance; return(true); }
private void btnExcluir_Click(object sender, EventArgs e) { if (MessageBox.Show("Deseja mesmo este registro?", "Forma de Pagamento", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { PaymentForm paymentFormVO = new PaymentForm(); paymentFormVO.Id = int.Parse(txtId.Text); paymentFormVO = PaymentFormDAO.GetByID(paymentFormVO); if (!PaymentFormDAO.UpdateDisable(paymentFormVO)) { MessageBox.Show("Erro: Ocorreu um erro inesperado excluir."); } else { MessageBox.Show("Excluído com sucesso."); this.ClearFields(); this.showGrid(); } } }
private void btnSalvar_Click(object sender, EventArgs e) { PaymentForm paymentFormVO = new PaymentForm(); int Id; if (int.TryParse(txtId.Text, out Id)) { paymentFormVO.Id = Id; paymentFormVO = PaymentFormDAO.GetByID(paymentFormVO); } if (this.validateForm(paymentFormVO)) { if (paymentFormVO.Id > 0) { if (PaymentFormDAO.Update(paymentFormVO)) { MessageBox.Show("Alterado com sucesso."); this.ClearFields(); this.showGrid(); return; } MessageBox.Show("Erro: Ocorreu um erro inesperado alterar."); } else { if (PaymentFormDAO.Insert(paymentFormVO)) { MessageBox.Show("Cadastrado com sucesso."); this.ClearFields(); this.showGrid(); return; } MessageBox.Show("Erro: Ocorreu um erro inesperado cadastrar."); } } }
private void btnSalvar_Click(object sender, EventArgs e) { Finance finance = new Finance(); int Id; if (int.TryParse(txtId.Text, out Id)) { finance.Id = Id; finance = FinanceDAO.GetByID(finance); } FinanceCategorySub financeCategorySub = new FinanceCategorySub(); financeCategorySub = (FinanceCategorySub)cmbCategorySub.SelectedItem; financeCategorySub = FinanceCategorySubDAO.GetByID(financeCategorySub); finance.FinanceCategorySub = financeCategorySub; PaymentForm paymentForm = new PaymentForm(); paymentForm = (PaymentForm)cmbPaymentForm.SelectedItem; paymentForm = PaymentFormDAO.GetByID(paymentForm); finance.PaymentForm = paymentForm; finance.Date = dtDateTime.Value; if (rbSituationPago.Checked) { finance.Situation = FinanceU.SITUATION_PAGO; finance.DateClose = finance.Date; } else { finance.Situation = FinanceU.SITUATION_PENDENTE; finance.DateClose = DateTime.Now; } finance.Text = txtText.Text; if (this.validateForm(finance)) { if (finance.Id > 0) { if (FinanceDAO.Update(finance)) { MessageBox.Show("Alterado com sucesso."); this.ClearFields(); this.showGrid(); return; } MessageBox.Show("Erro: Ocorreu um erro inesperado alterar."); } else { if (FinanceDAO.Insert(finance)) { MessageBox.Show("Cadastrado com sucesso."); this.ClearFields(); this.showGrid(); return; } MessageBox.Show("Erro: Ocorreu um erro inesperado cadastrar."); } } }