コード例 #1
0
ファイル: AcessoBD.cs プロジェクト: gurgelff/Natal_ID
        public static DataTable BD_juridico(String cod, String cnpj, String nome)
        {
            using (SqlConnection conexaoBD = AcessoBD.getinstancia().getconexao())
                try
                {
                    if (cod != "")
                    {
                        cod = " CodEmpresa=" + cod;

                        if (cnpj != "")
                        {
                            cnpj = " and CNPJ=" + cnpj;
                        }


                        if (nome != "")
                        {
                            nome = " and NomeEmpresa=" + nome;
                        }
                    }
                    else
                    {
                        if (cnpj != "")
                        {
                            cnpj = " CNPJ=" + cnpj;

                            if (nome != "")
                            {
                                nome = " and NomeEmpresa=" + nome;
                            }
                        }
                        else
                        {
                            if (nome != "")
                            {
                                nome = " NomeEmpresa=" + nome;
                            }
                        }
                    }

                    conexaoBD.Open();
                    string         ssql          = "select * from Empresa Where" + cod + cnpj + nome;
                    SqlCommand     cmdCommand    = new SqlCommand(ssql, conexaoBD);
                    SqlDataAdapter daDataAdapter = new SqlDataAdapter(cmdCommand);
                    DataTable      dtDatatable   = new DataTable();
                    daDataAdapter.Fill(dtDatatable);
                    return(dtDatatable);
                }
                catch (SqlException bdex)
                {
                    throw bdex;
                }
            finally
            {
                conexaoBD.Close();
            }
        }
コード例 #2
0
ファイル: AcessoBD.cs プロジェクト: gurgelff/Natal_ID
        public static DataTable BD_dep(String codDep, String nomeDep)
        {
            using (SqlConnection conexaoBD = AcessoBD.getinstancia().getconexao())
                try
                {
                    if (codDep != "")
                    {
                        codDep = "  d.CodDependente=" + codDep;

                        if (nomeDep != "")
                        {
                            nomeDep = " and d.NomeDependente like %" + nomeDep + "%";
                        }
                    }
                    else
                    {
                        if (nomeDep != "")
                        {
                            nomeDep = " d.NomeDependente like %" + nomeDep + "%";
                        }
                    }

                    conexaoBD.Open();
                    string         ssql          = "select * from Dependente as d inner join Responsavel as r on d.CodResponsavel=r.CodResponsavel where" + codDep + nomeDep;
                    SqlCommand     cmdCommand    = new SqlCommand(ssql, conexaoBD);
                    SqlDataAdapter daDataAdapter = new SqlDataAdapter(cmdCommand);
                    DataTable      dtDatatable   = new DataTable();
                    daDataAdapter.Fill(dtDatatable);
                    return(dtDatatable);
                }
                catch (SqlException bdex)
                {
                    throw bdex;
                }
            finally
            {
                conexaoBD.Close();
            }
        }
コード例 #3
0
ファイル: AcessoBD.cs プロジェクト: gurgelff/Natal_ID
        //bd_senha=Responsavel
        public static DataTable bd_senha(String serial, String nome)
        {
            try
            {
                using (SqlConnection conexaoBD = AcessoBD.getinstancia().getconexao())


                    try
                    {
                        if (serial != "")
                        {
                            serial = " CodResponsavel=" + serial;

                            if (nome != "")
                            {
                                nome = " and NomeResponsavel=" + nome;
                            }
                        }
                        else
                        {
                            if (nome != "")
                            {
                                nome = " NomeResponsavel=" + nome;
                            }
                        }
                        conexaoBD.Open();
                        string         ssql          = "select * from Responsavel Where" + serial + nome;
                        SqlCommand     cmdCommand    = new SqlCommand(ssql, conexaoBD);
                        SqlDataAdapter daDataAdapter = new SqlDataAdapter(cmdCommand);
                        DataTable      dtDatatable   = new DataTable();
                        daDataAdapter.Fill(dtDatatable);
                        return(dtDatatable);
                    }
                    catch (SqlException bdex)
                    {
                        throw bdex;
                    }
                finally
                {
                    conexaoBD.Close();
                }
            }
            catch {
                using (SqlConnection conexaoBD = AcessoBD.getinstancia().getconexaosa())


                    try
                    {
                        if (serial != "")
                        {
                            serial = " CodResponsavel=" + serial;

                            if (nome != "")
                            {
                                nome = " and NomeResponsavel=" + nome;
                            }
                        }
                        else
                        {
                            if (nome != "")
                            {
                                nome = " NomeResponsavel=" + nome;
                            }
                        }
                        conexaoBD.Open();
                        string         ssql          = "select * from Responsavel Where" + serial + nome;
                        SqlCommand     cmdCommand    = new SqlCommand(ssql, conexaoBD);
                        SqlDataAdapter daDataAdapter = new SqlDataAdapter(cmdCommand);
                        DataTable      dtDatatable   = new DataTable();
                        daDataAdapter.Fill(dtDatatable);
                        return(dtDatatable);
                    }
                    catch (SqlException bdex)
                    {
                        throw bdex;
                    }
                finally
                {
                    conexaoBD.Close();
                }
            }
        }