예제 #1
0
        public ContasPagarReceberVO RetornaCabecalhoDaParcela(int pIdVenda)
        {
            ConsultaSQL = "SELECT * FROM CONTAS_PAGAR_RECEBER WHERE ID_ECF_VENDA_CABECALHO = " + Convert.ToString(pIdVenda);

            try
            {
                comando = new MySqlCommand(ConsultaSQL, conexao);
                leitor  = comando.ExecuteReader();

                if (!leitor.HasRows)
                {
                    pIdVenda = 0;
                    return(null);
                }
                else
                {
                    ContasPagarReceberVO ParcelaCabecalho = new ContasPagarReceberVO();

                    ParcelaCabecalho.Id = Convert.ToInt32(leitor["ID"]);
                    ParcelaCabecalho.IdEcfVendaCabecalho = Convert.ToInt32(leitor["ID_ECF_VENDA_CABECALHO"]);
                    ParcelaCabecalho.IdPlanoContas       = Convert.ToInt32(leitor["ID_PLANO_CONTAS"]);
                    ParcelaCabecalho.IdTipoDocumento     = Convert.ToInt32(leitor["ID_TIPO_DOCUMENTO"]);
                    ParcelaCabecalho.IdPessoa            = Convert.ToInt32(leitor["ID_PESSOA"]);
                    ParcelaCabecalho.Tipo               = Convert.ToString(leitor["TIPO"]);
                    ParcelaCabecalho.NumeroDocumento    = Convert.ToString(leitor["NUMERO_DOCUMENTO"]);
                    ParcelaCabecalho.Valor              = Convert.ToDecimal(leitor["VALOR"]);
                    ParcelaCabecalho.DataLancamento     = (Convert.ToDateTime(leitor["DATA_LANCAMENTO"]));
                    ParcelaCabecalho.PrimeiroVencimento = (Convert.ToString(leitor["PRIMEIRO_VENCIMENTO"]));
                    ParcelaCabecalho.NaturezaLancamento = Convert.ToString(leitor["NATUREZA_LANCAMENTO"]);
                    ParcelaCabecalho.QuantidadeParcela  = Convert.ToInt32(leitor["QUANTIDADE_PARCELA"]);

                    return(ParcelaCabecalho);
                }
            }

            catch (Exception eError)
            {
                Log.write(eError.ToString());
                pIdVenda = 0;
                return(null);
            }
            finally
            {
                if (leitor != null)
                {
                    leitor.Close();
                }
            }
        }
예제 #2
0
        public ContasPagarReceberVO InserirCabecalho(ContasPagarReceberVO pParcelaCabecalho)
        {
            ConsultaSQL =
                "insert into CONTAS_PAGAR_RECEBER (" +
                "ID_ECF_VENDA_CABECALHO, " +
                "ID_PLANO_CONTAS, " +
                "ID_TIPO_DOCUMENTO, " +
                "ID_PESSOA, " +
                "TIPO, " +
                "NUMERO_DOCUMENTO, " +
                "VALOR, " +
                "DATA_LANCAMENTO, " +
                "PRIMEIRO_VENCIMENTO, " +
                "NATUREZA_LANCAMENTO, " +
                "QUANTIDADE_PARCELA) " +
                "values (" +
                "?pID_ECF_VENDA_CABECALHO, " +
                "?pID_PLANO_CONTAS, " +
                "?pID_TIPO_DOCUMENTO, " +
                "?pID_PESSOA, " +
                "?pTIPO, " +
                "?pNUMERO_DOCUMENTO, " +
                "?pVALOR, " +
                "?pDATA_LANCAMENTO, " +
                "?pPRIMEIRO_VENCIMENTO, " +
                "?pNATUREZA_LANCAMENTO, " +
                "?pQUANTIDADE_PARCELA) ";

            try
            {
                comando = new MySqlCommand(ConsultaSQL, conexao);
                comando.Parameters.AddWithValue("?pID_ECF_VENDA_CABECALHO", pParcelaCabecalho.IdEcfVendaCabecalho);
                comando.Parameters.AddWithValue("?pID_PLANO_CONTAS", pParcelaCabecalho.IdPlanoContas);
                comando.Parameters.AddWithValue("?pID_TIPO_DOCUMENTO", pParcelaCabecalho.IdTipoDocumento);
                comando.Parameters.AddWithValue("?pID_PESSOA", pParcelaCabecalho.IdPessoa);
                comando.Parameters.AddWithValue("?pTIPO", pParcelaCabecalho.Tipo);
                comando.Parameters.AddWithValue("?pNUMERO_DOCUMENTO", pParcelaCabecalho.NumeroDocumento);
                comando.Parameters.AddWithValue("?pVALOR", pParcelaCabecalho.Valor);
                comando.Parameters.AddWithValue("?pDATA_LANCAMENTO", pParcelaCabecalho.DataLancamento);
                comando.Parameters.AddWithValue("?pPRIMEIRO_VENCIMENTO", pParcelaCabecalho.PrimeiroVencimento);
                comando.Parameters.AddWithValue("?pNATUREZA_LANCAMENTO", pParcelaCabecalho.NaturezaLancamento);
                comando.Parameters.AddWithValue("?pQUANTIDADE_PARCELA", pParcelaCabecalho.QuantidadeParcela);
                comando.ExecuteNonQuery();

                ConsultaSQL = "select max(ID) as ID from CONTAS_PAGAR_RECEBER";
                comando     = new MySqlCommand(ConsultaSQL, conexao);
                leitor      = comando.ExecuteReader();
                leitor.Read();
                pParcelaCabecalho.Id = Convert.ToInt32(leitor["ID"]);

                return(pParcelaCabecalho);
            }

            catch (Exception eError)
            {
                Log.write(eError.ToString());
                return(null);
            }
            finally
            {
                if (leitor != null)
                {
                    leitor.Close();
                }
            }
        }