コード例 #1
0
        private List <SqlParametros> PreencheCondicoes(FormaPagamentoPrazos formaPagamentoPrazos)
        {
            List <SqlParametros> lstParametrosCondicionais = new List <SqlParametros>();

            lstParametrosCondicionais.Add(new SqlParametros("FormaPagamentoId", formaPagamentoPrazos.FormaPagamentoId));

            return(lstParametrosCondicionais);
        }
コード例 #2
0
        private List <SqlParametros> PreencheParametros(FormaPagamentoPrazos formaPagamentoPrazos)
        {
            List <SqlParametros> lstParametros = new List <SqlParametros>();

            lstParametros.Add(new SqlParametros("FormaPagamentoId", formaPagamentoPrazos.FormaPagamentoId));
            lstParametros.Add(new SqlParametros("Parcela", formaPagamentoPrazos.Parcela));
            lstParametros.Add(new SqlParametros("Valor", formaPagamentoPrazos.Valor));
            lstParametros.Add(new SqlParametros("ValorCoeficiente", formaPagamentoPrazos.ValorCoeficiente.ToString().Replace(",", ".")));

            return(lstParametros);
        }
コード例 #3
0
        private void InserirFormaPagamentoPrazos(int formaPagamentoPrazosId)
        {
            try
            {
                for (int i = 0; i < gridParcelas.Rows.Count; i++)
                {
                    FormaPagamentoPrazos formaPagamentoPrazos = new FormaPagamentoPrazos();

                    formaPagamentoPrazos.FormaPagamentoId = formaPagamentoPrazosId;
                    formaPagamentoPrazos.Parcela          = Convert.ToInt32(gridParcelas.Rows[i].Cells["Parcela"].Value);
                    formaPagamentoPrazos.Valor            = Convert.ToInt32(gridParcelas.Rows[i].Cells["Valor"].Value);
                    formaPagamentoPrazos.ValorCoeficiente = Convert.ToDecimal(gridParcelas.Rows[i].Cells["ValorCoeficiente"].Value);

                    formaPagamentoPrazosNegocios.Inserir(formaPagamentoPrazos);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro ao tentar inserir a Formas de pagamento prazos" + ex.Message, "Aviso do sistema", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #4
0
        private void btnExcluir_Click(object sender, EventArgs e)
        {
            try
            {
                FormaPagamento formaPagamento = new FormaPagamento();
                formaPagamento.FormaPagamentoId = formaPagamentoId;

                if (MessageBox.Show("Deseja realmente excluir essa forma de pagamento?", "Pergunta do Sistema", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    //Excluindo a forma de pagamento prazos para incluir novamente
                    FormaPagamentoPrazos formaPagamentoPrazos = new FormaPagamentoPrazos();
                    formaPagamentoPrazos.FormaPagamentoId = formaPagamentoId;
                    formaPagamentoPrazosNegocios.Excluir(formaPagamentoPrazos);

                    formaPagamentoNegocios.Excluir(formaPagamento);
                    MessageBox.Show("Forma de pagamento excluído com sucesso!", "Aviso do Sistema", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    Limpar();
                    HabilitarCampos(false);

                    btnSalvar.Text     = "Salvar [ F5 ]";
                    btnSalvar.Enabled  = false;
                    btnExcluir.Enabled = false;
                    btnNovo.Text       = "Novo [ F2 ]";

                    CarregarGridFormasPagamento();
                    formaPagamentoId = 0;
                }
                else
                {
                    Limpar();
                    HabilitarCampos(false);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro ao tentar excluir a Forma de pagamento!\n\nDetalhe técnico : " + ex.Message, "Aviso do Sistema", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #5
0
 public Boolean Excluir(FormaPagamentoPrazos formaPagamentoPrazos)
 {
     return(conexao.Excluir(nomeTabela, PreencheCondicoes(formaPagamentoPrazos)));
 }
コード例 #6
0
 public Boolean Alterar(FormaPagamentoPrazos formaPagamentoPrazos)
 {
     return(conexao.Atualizar(nomeTabela, PreencheParametros(formaPagamentoPrazos), PreencheCondicoes(formaPagamentoPrazos)));
 }
コード例 #7
0
 public Boolean Inserir(FormaPagamentoPrazos formaPagamentoPrazos)
 {
     return(conexao.Inserir(nomeTabela, PreencheParametros(formaPagamentoPrazos)));
 }
コード例 #8
0
        private void btnSalvar_Click(object sender, EventArgs e)
        {
            try
            {
                if (ValidaCampos())
                {
                    FormaPagamento formaPagamento = new FormaPagamento();

                    formaPagamento.Descricao = txtDescricao.Text.Trim();
                    formaPagamento.Ativo     = chkAtivo.Checked;
                    formaPagamento.FormaPrimeiroVencimento = Convert.ToInt32(numPrimeiroVencimento.Value);
                    formaPagamento.FormaIntervaloEmDias    = Convert.ToInt32(numIntervaloEmDias.Value);
                    formaPagamento.FormaParcelas           = Convert.ToInt32(numQuantidadeParcelas.Value);

                    if (chkDebito.Checked)
                    {
                        formaPagamento.FormaCartao         = 2;
                        formaPagamento.FormaPercentualTaxa = Convert.ToDecimal(txtPercentual.Text);
                    }
                    else if (chkCredito.Checked)
                    {
                        formaPagamento.FormaCartao         = 3;
                        formaPagamento.FormaPercentualTaxa = Convert.ToDecimal(txtPercentual.Text);
                    }
                    else
                    {
                        formaPagamento.FormaCartao = 1;
                    }

                    formaPagamento.Tipo = "R"; // Receita


                    //INSERIR
                    if (formaPagamentoId <= 0)
                    {
                        try
                        {
                            if (formaPagamentoNegocios.Inserir(formaPagamento))
                            {
                                //INSERINDO A FORMA DE PAGAMENTO PRAZOS
                                int ultimoId = conexao.RetornarUltimoId("FormaPagamento", "FormaPagamentoId");
                                InserirFormaPagamentoPrazos(ultimoId);

                                MessageBox.Show("Funcionário cadastrado com sucesso!", "Aviso do Sistema", MessageBoxButtons.OK, MessageBoxIcon.Information);

                                Limpar();
                                HabilitarCampos(false);

                                btnSalvar.Text     = "Salvar [ F5 ]";
                                btnSalvar.Enabled  = false;
                                btnExcluir.Enabled = false;
                                btnNovo.Text       = "Novo [ F2 ]";

                                CarregarGridFormasPagamento();
                            }
                            else
                            {
                                MessageBox.Show("Erro ao tentar cadastrar a forma de pagamento!", "Aviso do Sistema", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show("Erro ao tentar cadastrar a forma de pagamento!\n\nDetalhe técnico : " + ex.Message, "Aviso do Sistema", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    else //ALTERAR
                    {
                        try
                        {
                            formaPagamento.FormaPagamentoId = formaPagamentoId;

                            if (formaPagamentoNegocios.Alterar(formaPagamento))
                            {
                                //Excluindo a forma de pagamento prazos para incluir novamente
                                FormaPagamentoPrazos formaPagamentoPrazos = new FormaPagamentoPrazos();
                                formaPagamentoPrazos.FormaPagamentoId = formaPagamentoId;

                                if (formaPagamentoPrazosNegocios.Excluir(formaPagamentoPrazos))
                                {
                                    InserirFormaPagamentoPrazos(formaPagamentoId);

                                    MessageBox.Show("Forma de pagamento alterado com sucesso!", "Aviso do Sistema", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                    Limpar();
                                    HabilitarCampos(false);

                                    btnSalvar.Text     = "Salvar [ F5 ]";
                                    btnSalvar.Enabled  = false;
                                    btnExcluir.Enabled = false;
                                    btnNovo.Text       = "Novo [ F2 ]";

                                    CarregarGridFormasPagamento();
                                }
                            }
                            else
                            {
                                MessageBox.Show("Erro ao tentar atualizar a forma selecionada!", "Aviso do Sistema", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show("Erro ao executar operação solicitada!\n\nDetalhe técnico : " + ex.Message, "Aviso do Sistema", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }

                    toolTip.SetToolTip(this.btnSalvar, "Salvar [ F5 ]");
                    toolTip.SetToolTip(this.btnNovo, "Novo Cadastro [ F2 ]");
                    formaPagamentoId = 0;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro ao tentar cadastrar a forma de pagamento!\n\nDetalhe técnico: " + ex.Message, "Aviso do Sistema", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }