//consulta aba auditoria na telade clientes //select na tela de cliente na aba Auditoria, alimenta o DataSet que está vinculado ao datagrid view public void ClienteAuditSelect(comercial ds, string codigo, string data1, string data2) { //uma query igual , pra rodar antes e depois string query = "SELECT CAU_CODIGO, CAU_DATA, us_nome as CAU_USUARIO, CAU_OBS FROM CLIENTES_AUDITORIA inner join usuarios on us_id = CAU_USUARIO WHERE CAU_DATA BETWEEN '" + data1 + " 00:00:00' AND '" + data2 + " 23:59:59' and CAU_CODIGO = '" + codigo + "' order by cau_data desc "; this.cmd = new System.Data.SqlClient.SqlCommand(query, this.ConexaoAtiva); this.cmd.CommandType = System.Data.CommandType.Text; //usando sqlDataReader para ler os dados do banco de dados this.reader = this.cmd.ExecuteReader(); //verifica retorno das linhas if (this.reader.HasRows) { ds.CLIENTES_AUDITORIA.Rows.Clear(); while (this.reader.Read()) { //cria um dataRow com a estrutura da tabela bugs System.Data.DataRow row = ds.CLIENTES_AUDITORIA.NewRow(); //pega o item a item da linha atual do reader row[0] = this.reader.GetString(0); row[1] = this.reader.GetDateTime(1); row[2] = this.reader.GetString(2); row[3] = this.reader.GetString(3); //adiciona o DataRow preenchido na tabela do DataSet ds.CLIENTES_AUDITORIA.Rows.Add(row); } } //liberar o reader (leitor) this.reader.Close(); }
public void SelectObs(comercial ds, string CodigoObs) { this.cmd = new System.Data.SqlClient.SqlCommand("sp_cliente_obs_Select", this.ConexaoAtiva); //define o tipo do comando this.cmd.CommandType = System.Data.CommandType.StoredProcedure; this.cmd.Parameters.AddWithValue("@COB_CODIGO", CodigoObs); this.reader = this.cmd.ExecuteReader(); //verifica retorno das linhas if (this.reader.HasRows) { ds.CLIENTES_OBS.Rows.Clear(); while (this.reader.Read()) { //cria um dataRow com a estrutura da tabela bugs System.Data.DataRow row = ds.CLIENTES_OBS.NewRow(); //pega o item a item da linha atual do reader row[0] = this.reader.GetValue(0); row[1] = this.reader.GetString(1); row[2] = this.reader.GetDateTime(2); row[3] = this.reader.GetString(3); //adiciona o DataRow preenchido na tabela do DataSet ds.CLIENTES_OBS.Rows.Add(row); } } //liberar o reader (leitor) this.reader.Close(); }
public void SelectMeiosProspeccao(comercial ds) { string query = "SELECT [mei_CODIGO],[mei_NOME] FROM [dbo].[PROSPECCAO_MEIOS] where mei_inativo = 0 order by mei_nome"; this.cmd = new System.Data.SqlClient.SqlCommand(query, ConexaoAtiva); this.cmd.CommandType = System.Data.CommandType.Text; this.adp = new System.Data.SqlClient.SqlDataAdapter(this.cmd); ds.PROSPECCAO_MEIOS.Clear(); //preenche a tabela 'setores' dos dataset recebido por paramentro this.adp.Fill(ds.PROSPECCAO_MEIOS); }
//SELECT PARA DATA GRI VIEW , SOMENTE CLIENTES DO USUSARIO LOGADO public void GetClientesPorConsultor(comercial ds3, string codigo, string inativos, int IdConsultor) { //crias a query sql string query = "select clientes.CLI_CODIGO AS CODIGO, CLI_NOME_FANTASIA AS NOME_FANTASIA, '(' + CLI_DDD + ')' + CLI_TELEFONE1 , '(' + CLI_DDD + ')' + CLI_TELEFONE2, CLI_DECISOR, '(' + CLI_DDD + ')' + CLI_TELDECISOR, CLI_QTDPONTOS, CON_NOME, CLI_CADASTRO, CLI_ATUALIZACAO,cli_fase from clientes "; query += "INNER JOIN CLIENTES_CONCORRENTE ON CON_CODIGO = CLI_CONCORRENTE "; query += "INNER JOIN CLIENTES_INDICACAO ON IND_CODIGO = CLI_INDICACAO "; query += "INNER JOIN CLIENTES_RAMOATUACAO ON RAM_CODIGO = CLI_RAMOATUACAO "; query += " where cli_nome_fantasia LIKE '%" + codigo + "%' "; query += " and cli_inativo = '" + inativos + "'"; query += " and cli_consultor = " + IdConsultor + ""; query += "order by CLI_NOME_FANTASIA"; this.cmd = new System.Data.SqlClient.SqlCommand(query, this.ConexaoAtiva); this.cmd.CommandType = System.Data.CommandType.Text; //usando sqlDataReader para ler os dados do banco de dados this.reader = this.cmd.ExecuteReader(); //verifica retorno das linhas if (this.reader.HasRows) { ds3.CLIENTES_GRIDVIEW.Rows.Clear(); while (this.reader.Read()) { //cria um dataRow com a estrutura da tabela bugs System.Data.DataRow row = ds3.CLIENTES_GRIDVIEW.NewRow(); //pega o item a item da linha atual do reader row[0] = this.reader.GetString(0); row[1] = this.reader.GetString(1); row[2] = this.reader.GetString(2); row[3] = this.reader.GetString(3); row[4] = this.reader.GetString(4); row[5] = this.reader.GetString(5); row[6] = this.reader.GetValue(6); row[7] = this.reader.GetString(7); row[8] = this.reader.GetDateTime(8); row[9] = this.reader.GetDateTime(9); row[10] = this.reader.GetValue(10); //adiciona o DataRow preenchido na tabela do DataSet ds3.CLIENTES_GRIDVIEW.Rows.Add(row); } } //liberar o reader (leitor) this.reader.Close(); }
public void GetUf(comercial ds) { string query = "select EST_CODIGO, EST_UF from ENDERECO_ESTADO"; this.cmd = new System.Data.SqlClient.SqlCommand(query, this.ConexaoAtiva); this.cmd.CommandType = System.Data.CommandType.Text; //cria uma nova instancia do sqldata adapter, passnado o comando this.adp = new System.Data.SqlClient.SqlDataAdapter(this.cmd); ds.ENDERECO_ESTADO.Clear(); //preenche a tabela 'setores' dos dataset recebido por paramentro this.adp.Fill(ds.ENDERECO_ESTADO); }
public void GetMunicipionovo(comercial ds) { //UTILIZADO NO CARREGAMENTO DO FORM CLIENTE CASO UTILIZE O CEP PARA PESQUISAR string query = "select mun_codigo, mun_nome from endereco_municipio"; this.cmd = new System.Data.SqlClient.SqlCommand(query, this.ConexaoAtiva); this.cmd.CommandType = System.Data.CommandType.Text; this.adp = new System.Data.SqlClient.SqlDataAdapter(this.cmd); ds.ENDERECO_MUNICIPIO.Clear(); //preenche a tabela 'setores' dos dataset recebido por paramentro this.adp.Fill(ds.ENDERECO_MUNICIPIO); }
public void SelectRamoAtuacao(comercial ds) { string query = "select ram_codigo, ram_nome from clientes_ramoatuacao where ram_inativo = '0' order by ram_nome"; //cria uma nova instancia do sql comando e para a query a conexao ativa this.cmd = new System.Data.SqlClient.SqlCommand(query, this.ConexaoAtiva); //define o tipo de comando this.cmd.CommandType = System.Data.CommandType.Text; //cria uma nova instancia do sqldata adapter, passnado o comando this.adp = new System.Data.SqlClient.SqlDataAdapter(this.cmd); ds.view_RamoAtuacao.Clear(); //preenche a tabela 'setores' dos dataset recebido por paramentro this.adp.Fill(ds.view_RamoAtuacao); }
public void GetMunicipio(comercial ds, string ufpreenchido) { if (ufpreenchido == "") { return; } string query = "select mun_codigo, mun_nome from endereco_municipio where mun_uf = " + ufpreenchido + ""; this.cmd = new System.Data.SqlClient.SqlCommand(query, this.ConexaoAtiva); this.cmd.CommandType = System.Data.CommandType.Text; this.adp = new System.Data.SqlClient.SqlDataAdapter(this.cmd); ds.ENDERECO_MUNICIPIO.Clear(); //preenche a tabela 'setores' dos dataset recebido por paramentro this.adp.Fill(ds.ENDERECO_MUNICIPIO); }