예제 #1
0
파일: BoletoDAL.cs 프로젝트: oraculum/CEF
        public static Int32 getNext()
        {
            Int32 last = new Int32();

            using (SqlConnection con = new SqlConnection(Common.getCon()))
            {
                try
                {
                    const string SQL = "SELECT IsNull(Max(ID), 0) FROM Boleto";

                    SqlCommand cmd = new SqlCommand(SQL, con);

                    con.Open();
                    last = Int32.Parse(cmd.ExecuteScalar().ToString());
                }
                catch
                {
                    throw;
                }
                finally
                {
                    con.Close();
                }
            }

            last += 1;
            return(last);
        }
예제 #2
0
        public static void set(Configuracao o)
        {
            using (SqlConnection con = new SqlConnection(Common.getCon()))
            {
                try
                {
                    const string SQL = "INSERT INTO Configuracao (Agencia, Conta, ContaDigito, Cedente, CNPJ, RazaoSocial, Descricao) VALUES (@Agencia, @Conta, @ContaDigito, @Cedente, @CNPJ, @RazaoSocial, @Descricao)";

                    SqlCommand cmd = new SqlCommand(SQL, con);
                    cmd.Parameters.AddWithValue("@Agencia", o.Agencia);
                    cmd.Parameters.AddWithValue("@Conta", o.Conta);
                    cmd.Parameters.AddWithValue("@ContaDigito", o.ContaDigito);
                    cmd.Parameters.AddWithValue("@Cedente", o.Cedente);
                    cmd.Parameters.AddWithValue("@CNPJ", o.CNPJ);
                    cmd.Parameters.AddWithValue("@RazaoSocial", o.RazaoSocial);
                    cmd.Parameters.AddWithValue("@Descricao", o.Descricao);

                    con.Open();
                    cmd.ExecuteNonQuery();
                }
                catch
                {
                    throw;
                }
                finally
                {
                    con.Close();
                }
            }
        }
예제 #3
0
파일: BoletoDAL.cs 프로젝트: oraculum/CEF
        public static List <Boleto> listSituacao(DateTime datain, DateTime datafn, String nome,
                                                 Boolean recebido)
        {
            List <Boleto> lo = new List <Boleto>();
            SqlDataReader dr = null;

            using (SqlConnection con = new SqlConnection(Common.getCon()))
            {
                try
                {
                    const string SQL = "SELECT ID, Cliente, Emissao, Vencimento, " +
                                       "Valor, NossoNum, Obs1, Obs2, Obs3, Recebido, DataRecebido, ValorRecebido, Cliente.Valor_Bruto " +
                                       "FROM Boleto INNER JOIN Cliente ON Boleto.Cliente = Cliente.Codigo " +
                                       "WHERE ((Cliente.Nome LIKE @Nome) OR (Cliente.Fantasia LIKE @Nome)) AND " +
                                       "(Vencimento BETWEEN @DataIN AND @DataFN) AND (Recebido = @Recebido)" +
                                       "ORDER BY ID";

                    SqlCommand cmd = new SqlCommand(SQL, con);
                    cmd.Parameters.AddWithValue("@Nome", "%" + nome + "%");
                    cmd.Parameters.AddWithValue("@DataIN", datain);
                    cmd.Parameters.AddWithValue("@DataFN", datafn);
                    cmd.Parameters.AddWithValue("@Recebido", recebido);


                    con.Open();
                    dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);

                    while (dr.Read())
                    {
                        Boleto o = new Boleto();
                        o.ID            = Int32.Parse(dr[0].ToString());
                        o.Cliente       = DAL.ClienteDAL.get(Int32.Parse(dr[1].ToString()));
                        o.Emissao       = DateTime.Parse(dr[2].ToString());
                        o.Vencimento    = DateTime.Parse(dr[3].ToString());
                        o.Valor         = Decimal.Parse(dr[4].ToString());
                        o.NossoNum      = dr[5].ToString();
                        o.Obs1          = dr[6].ToString();
                        o.Obs2          = dr[7].ToString();
                        o.Obs3          = dr[8].ToString();
                        o.Recebido      = Boolean.Parse(dr[9].ToString());
                        o.DataRecebido  = DateTime.Parse(dr[10].ToString());
                        o.ValorRecebido = Decimal.Parse(dr[11].ToString());
                        o.Valor_Bruto   = Decimal.Parse(dr[12].ToString());

                        lo.Add(o);
                    }
                }
                catch
                {
                    throw;
                }
                finally
                {
                    con.Close();
                }
            }

            return(lo);
        }
예제 #4
0
파일: ClienteDAL.cs 프로젝트: oraculum/CEF
        public static List <Cliente> list(String nome)
        {
            List <Cliente> lo = new List <Cliente>();
            SqlDataReader  dr = null;

            using (SqlConnection con = new SqlConnection(Common.getCon()))
            {
                try
                {
                    const string SQL = "SELECT Codigo, Nome, Fantasia, CNPJ, IE, Endereco, Numero, " +
                                       "Complemento, Bairro, Cidade, UF, CEP, Valor_Contrato, Valor_Bruto, Contrato_Ativo FROM Cliente " +
                                       "WHERE (Nome LIKE @Nome) OR (Fantasia LIKE @Nome) ORDER BY Nome";

                    SqlCommand cmd = new SqlCommand(SQL, con);
                    cmd.Parameters.AddWithValue("@Nome", nome + "%");


                    con.Open();
                    dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);

                    while (dr.Read())
                    {
                        Cliente o = new Cliente();
                        o.Codigo         = Int32.Parse(dr[0].ToString());
                        o.Nome           = dr[1].ToString();
                        o.Fantasia       = dr[2].ToString();
                        o.CNPJ           = dr[3].ToString();
                        o.IE             = dr[4].ToString();
                        o.Endereco       = dr[5].ToString();
                        o.Numero         = dr[6].ToString();
                        o.Complemento    = dr[7].ToString();
                        o.Bairro         = dr[8].ToString();
                        o.Cidade         = dr[9].ToString();
                        o.UF             = dr[10].ToString();
                        o.CEP            = dr[11].ToString();
                        o.Valor_Contrato = Decimal.Parse(dr[12].ToString());
                        o.Valor_Bruto    = Decimal.Parse(dr[13].ToString());
                        o.Contrato_Ativo = Boolean.Parse(dr[14].ToString());

                        lo.Add(o);
                    }
                }
                catch
                {
                    throw;
                }
                finally
                {
                    con.Close();
                }
            }

            return(lo);
        }
예제 #5
0
파일: BoletoDAL.cs 프로젝트: oraculum/CEF
        public static List <Boleto> listNossoNum(String nossonum)
        {
            List <Boleto> lo = new List <Boleto>();
            SqlDataReader dr = null;

            using (SqlConnection con = new SqlConnection(Common.getCon()))
            {
                try
                {
                    const string SQL = "SELECT ID, Cliente, Emissao, Vencimento, " +
                                       "Valor, NossoNum, Obs1, Obs2, Obs3, Recebido, DataRecebido, ValorRecebido " +
                                       "FROM Boleto WHERE (NossoNum LIKE @NossoNum) " +
                                       "ORDER BY ID";

                    SqlCommand cmd = new SqlCommand(SQL, con);
                    cmd.Parameters.AddWithValue("@NossoNum", "%" + nossonum + "%");


                    con.Open();
                    dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);

                    while (dr.Read())
                    {
                        Boleto o = new Boleto();
                        o.ID            = Int32.Parse(dr[0].ToString());
                        o.Cliente       = DAL.ClienteDAL.get(Int32.Parse(dr[1].ToString()));
                        o.Emissao       = DateTime.Parse(dr[2].ToString());
                        o.Vencimento    = DateTime.Parse(dr[3].ToString());
                        o.Valor         = Decimal.Parse(dr[4].ToString());
                        o.NossoNum      = dr[5].ToString();
                        o.Obs1          = dr[6].ToString();
                        o.Obs2          = dr[7].ToString();
                        o.Obs3          = dr[8].ToString();
                        o.Recebido      = Boolean.Parse(dr[9].ToString());
                        o.DataRecebido  = DateTime.Parse(dr[10].ToString());
                        o.ValorRecebido = Decimal.Parse(dr[11].ToString());

                        lo.Add(o);
                    }
                }
                catch
                {
                    throw;
                }
                finally
                {
                    con.Close();
                }
            }

            return(lo);
        }
예제 #6
0
파일: BoletoDAL.cs 프로젝트: oraculum/CEF
        public static Int32 set(Boleto o)
        {
            Int32 id = 0;

            using (SqlConnection con = new SqlConnection(Common.getCon()))
            {
                try
                {
                    const string SQL = "INSERT INTO Boleto (Cliente, Emissao, Vencimento, " +
                                       "Valor, NossoNum, Obs1, Obs2, Obs3, Recebido, DataRecebido, ValorRecebido) " +
                                       "VALUES (@Cliente, @Emissao, @Vencimento, " +
                                       "@Valor, @NossoNum, @Obs1, @Obs2, @Obs3, @Recebido, @DataRecebido, " +
                                       "@ValorRecebido); SELECT @@Identity";

                    SqlCommand cmd = new SqlCommand(SQL, con);
                    cmd.Parameters.AddWithValue("@Cliente", o.Cliente.Codigo);
                    cmd.Parameters.AddWithValue("@Emissao", o.Emissao);
                    cmd.Parameters.AddWithValue("@Vencimento", o.Vencimento);
                    cmd.Parameters.AddWithValue("@Valor", o.Valor);
                    cmd.Parameters.AddWithValue("@NossoNum", o.NossoNum);
                    cmd.Parameters.AddWithValue("@Obs1", o.Obs1);
                    cmd.Parameters.AddWithValue("@Obs2", o.Obs2);
                    cmd.Parameters.AddWithValue("@Obs3", o.Obs3);
                    cmd.Parameters.AddWithValue("@Recebido", o.Recebido);
                    cmd.Parameters.AddWithValue("@DataRecebido", o.DataRecebido);
                    cmd.Parameters.AddWithValue("@ValorRecebido", o.ValorRecebido);

                    con.Open();
                    id = Int32.Parse(cmd.ExecuteScalar().ToString());
                }
                catch
                {
                    throw;
                }
                finally
                {
                    con.Close();
                }
            }
            return(id);
        }
예제 #7
0
파일: ClienteDAL.cs 프로젝트: oraculum/CEF
        public static void up(Cliente o)
        {
            using (SqlConnection con = new SqlConnection(Common.getCon()))
            {
                try
                {
                    const string SQL = "UPDATE Cliente SET Nome = @Nome, Fantasia = @Fantasia, " +
                                       "CNPJ = @CNPJ, IE = @IE, Endereco = @Endereco, Numero = @Numero, " +
                                       "Complemento = @Complemento, Bairro = @Bairro, Cidade = @Cidade, " +
                                       "UF = @UF, CEP = @CEP, Valor_Contrato = @Valor_Contrato, Valor_Bruto = @Valor_Bruto, Contrato_Ativo = @Contrato_Ativo WHERE (Codigo = @Codigo)";

                    SqlCommand cmd = new SqlCommand(SQL, con);
                    cmd.Parameters.AddWithValue("@Nome", o.Nome);
                    cmd.Parameters.AddWithValue("@Fantasia", o.Fantasia);
                    cmd.Parameters.AddWithValue("@CNPJ", o.CNPJ);
                    cmd.Parameters.AddWithValue("@IE", o.IE);
                    cmd.Parameters.AddWithValue("@Endereco", o.Endereco);
                    cmd.Parameters.AddWithValue("@Numero", o.Numero);
                    cmd.Parameters.AddWithValue("@Complemento", o.Complemento);
                    cmd.Parameters.AddWithValue("@Bairro", o.Bairro);
                    cmd.Parameters.AddWithValue("@Cidade", o.Cidade);
                    cmd.Parameters.AddWithValue("@UF", o.UF);
                    cmd.Parameters.AddWithValue("@CEP", o.CEP);
                    cmd.Parameters.AddWithValue("@Valor_Contrato", o.Valor_Contrato);
                    cmd.Parameters.AddWithValue("@Valor_Bruto", o.Valor_Bruto);
                    cmd.Parameters.AddWithValue("@Codigo", o.Codigo);
                    cmd.Parameters.AddWithValue("@Contrato_Ativo", o.Contrato_Ativo);

                    con.Open();
                    cmd.ExecuteNonQuery();
                }
                catch
                {
                    throw;
                }
                finally
                {
                    con.Close();
                }
            }
        }
예제 #8
0
파일: ClienteDAL.cs 프로젝트: oraculum/CEF
        public static void set(Cliente o)
        {
            using (SqlConnection con = new SqlConnection(Common.getCon()))
            {
                try
                {
                    const string SQL = "INSERT INTO Cliente (Codigo, Nome, Fantasia, CNPJ, IE, Endereco, " +
                                       "Numero, Complemento, Bairro, Cidade, UF, CEP, Valor_Contrato, Valor_Bruto, Contrato_Ativo) VALUES (@Codigo, @Nome, " +
                                       "@Fantasia, @CNPJ, @IE, @Endereco, @Numero, @Complemento, @Bairro, @Cidade, @UF, @CEP, @Valor_Contrato, @Valor_Bruto, @Contrato_Ativo)";

                    SqlCommand cmd = new SqlCommand(SQL, con);
                    cmd.Parameters.AddWithValue("@Codigo", o.Codigo);
                    cmd.Parameters.AddWithValue("@Nome", o.Nome);
                    cmd.Parameters.AddWithValue("@Fantasia", o.Fantasia);
                    cmd.Parameters.AddWithValue("@CNPJ", o.CNPJ);
                    cmd.Parameters.AddWithValue("@IE", o.IE);
                    cmd.Parameters.AddWithValue("@Endereco", o.Endereco);
                    cmd.Parameters.AddWithValue("@Numero", o.Numero);
                    cmd.Parameters.AddWithValue("@Complemento", o.Complemento);
                    cmd.Parameters.AddWithValue("@Bairro", o.Bairro);
                    cmd.Parameters.AddWithValue("@Cidade", o.Cidade);
                    cmd.Parameters.AddWithValue("@UF", o.UF);
                    cmd.Parameters.AddWithValue("@CEP", o.CEP);
                    cmd.Parameters.AddWithValue("@Valor_Contrato", o.Valor_Contrato);
                    cmd.Parameters.AddWithValue("@Valor_Bruto", o.Valor_Bruto);
                    cmd.Parameters.AddWithValue("@Contrato_Ativo", o.Contrato_Ativo);

                    con.Open();
                    cmd.ExecuteNonQuery();
                }
                catch
                {
                    throw;
                }
                finally
                {
                    con.Close();
                }
            }
        }
예제 #9
0
파일: BoletoDAL.cs 프로젝트: oraculum/CEF
        public static void up(Boleto o)
        {
            using (SqlConnection con = new SqlConnection(Common.getCon()))
            {
                try
                {
                    const string SQL = "UPDATE Boleto SET Cliente = @Cliente, Emissao = @Emissao, " +
                                       "Vencimento = @Vencimento, Valor = @Valor, " +
                                       "NossoNum = @NossoNum, Obs1 = @Obs1, Obs2 = @Obs2, Obs3 = @obs3, " +
                                       "Recebido = @Recebido, DataRecebido = @DataRecebido, ValorRecebido = @ValorRecebido " +
                                       "WHERE (ID = @ID)";

                    SqlCommand cmd = new SqlCommand(SQL, con);
                    cmd.Parameters.AddWithValue("@Cliente", o.Cliente.Codigo);
                    cmd.Parameters.AddWithValue("@Emissao", o.Emissao);
                    cmd.Parameters.AddWithValue("@Vencimento", o.Vencimento);
                    cmd.Parameters.AddWithValue("@Valor", o.Valor);
                    cmd.Parameters.AddWithValue("@NossoNum", o.NossoNum);
                    cmd.Parameters.AddWithValue("@Obs1", o.Obs1);
                    cmd.Parameters.AddWithValue("@Obs2", o.Obs2);
                    cmd.Parameters.AddWithValue("@Obs3", o.Obs3);
                    cmd.Parameters.AddWithValue("@Recebido", o.Recebido);
                    cmd.Parameters.AddWithValue("@DataRecebido", o.DataRecebido);
                    cmd.Parameters.AddWithValue("@ValorRecebido", o.ValorRecebido);
                    cmd.Parameters.AddWithValue("@ID", o.ID);

                    con.Open();
                    cmd.ExecuteNonQuery();
                }
                catch
                {
                    throw;
                }
                finally
                {
                    con.Close();
                }
            }
        }
예제 #10
0
        public static Configuracao get()
        {
            Configuracao  o  = new Configuracao();
            SqlDataReader dr = null;

            using (SqlConnection con = new SqlConnection(Common.getCon()))
            {
                try
                {
                    const string SQL = "SELECT Agencia, Conta, ContaDigito, Cedente, CNPJ, RazaoSocial, Descricao FROM Configuracao";

                    SqlCommand cmd = new SqlCommand(SQL, con);

                    con.Open();
                    dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);

                    while (dr.Read())
                    {
                        o.Agencia     = dr[0].ToString();
                        o.Conta       = dr[1].ToString();
                        o.ContaDigito = dr[2].ToString();
                        o.Cedente     = dr[3].ToString();
                        o.CNPJ        = dr[4].ToString();
                        o.RazaoSocial = dr[5].ToString();
                        o.Descricao   = dr[6].ToString();
                        break;
                    }
                }
                catch
                {
                    throw;
                }
                finally
                {
                    con.Close();
                }
            }
            return(o);
        }
예제 #11
0
        public static void del()
        {
            using (SqlConnection con = new SqlConnection(Common.getCon()))
            {
                try
                {
                    const string SQL = "DELETE FROM Configuracao";

                    SqlCommand cmd = new SqlCommand(SQL, con);

                    con.Open();
                    cmd.ExecuteNonQuery();
                }
                catch
                {
                    throw;
                }
                finally
                {
                    con.Close();
                }
            }
        }
예제 #12
0
파일: BoletoDAL.cs 프로젝트: oraculum/CEF
        public static void del(Int32 id)
        {
            using (SqlConnection con = new SqlConnection(Common.getCon()))
            {
                try
                {
                    const string SQL = "DELETE FROM Boleto WHERE (ID = @ID)";

                    SqlCommand cmd = new SqlCommand(SQL, con);
                    cmd.Parameters.AddWithValue("@ID", id);

                    con.Open();
                    cmd.ExecuteNonQuery();
                }
                catch
                {
                    throw;
                }
                finally
                {
                    con.Close();
                }
            }
        }
예제 #13
0
파일: BoletoDAL.cs 프로젝트: oraculum/CEF
        public static Boolean val(Int32 id)
        {
            Boolean val = false;

            using (SqlConnection con = new SqlConnection(Common.getCon()))
            {
                try
                {
                    const string SQL = "SELECT COUNT(ID) AS Expr1 FROM Boleto WHERE (ID = @ID)";

                    SqlCommand cmd = new SqlCommand(SQL, con);
                    cmd.Parameters.AddWithValue("@ID", id);

                    con.Open();
                    Int16 i = Int16.Parse(cmd.ExecuteScalar().ToString());

                    if (i == 0)
                    {
                        val = true;
                    }
                    else
                    {
                        val = false;
                    }
                }
                catch
                {
                    throw;
                }
                finally
                {
                    con.Close();
                }
            }
            return(val);
        }
예제 #14
0
파일: ClienteDAL.cs 프로젝트: oraculum/CEF
        public static void del(Int32 codigo)
        {
            using (SqlConnection con = new SqlConnection(Common.getCon()))
            {
                try
                {
                    const string SQL = "DELETE FROM Cliente WHERE (Codigo = @Codigo)";

                    SqlCommand cmd = new SqlCommand(SQL, con);
                    cmd.Parameters.AddWithValue("@Codigo", codigo);

                    con.Open();
                    cmd.ExecuteNonQuery();
                }
                catch
                {
                    throw;
                }
                finally
                {
                    con.Close();
                }
            }
        }