public void BuscarConfigs() { string query = "SELECT CADASTRO, DELAY_CICLO, EMAIL_VALIDACAO, TIPO_UPLOAD, VALOR_UPLOAD, DELAY_UPLOAD, HORA_INICIO, HORA_FIM, TOKEN " + "FROM " + Tabelas_Portal.ConfigUpload + " " + "WHERE ROTINA = 'CLIENTE'"; using (SqlConnection conexao = new SqlConnection(ConexaoERP.Conexao())) { using (SqlCommand command = new SqlCommand(query, conexao)) { conexao.Open(); using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { if (reader["CADASTRO"].ToString().TrimStart().TrimEnd() == "S") { Service_Config.CadastroHabilitado = true; } Service_Config.DelayCiclo = Convert.ToDouble(reader["DELAY_CICLO"].ToString().TrimStart().TrimEnd()); Service_Config.EmailValidacao = reader["EMAIL_VALIDACAO"].ToString().TrimStart().TrimEnd(); Service_Config.TipoUpload = reader["TIPO_UPLOAD"].ToString().TrimStart().TrimEnd(); Service_Config.ValorUpload = reader["VALOR_UPLOAD"].ToString().TrimStart().TrimEnd(); Service_Config.DelayUpload = Convert.ToDouble(reader["DELAY_UPLOAD"].ToString().TrimStart().TrimEnd()); Service_Config.UploadHoraInicio = Convert.ToDateTime(reader["HORA_INICIO"].ToString().TrimStart().TrimEnd()); Service_Config.UploadHoraFim = Convert.ToDateTime(reader["HORA_FIM"].ToString().TrimStart().TrimEnd()); Service_Config.Token = reader["TOKEN"].ToString().TrimStart().TrimEnd(); } } } } }
private void Home_Load(object sender, EventArgs e) { #region Validação e Cadastro do Cliente no banco de Controle de Versão ConexaoERP ConnERP = new ConexaoERP(); dadosws = new WSVersoesERP.VersoesERP(); dados = new AcessoDados(); string retorno = ""; dados.GravaErro("VersaoCli: " + VersaoCli.ToString() + " DocCliente: " + DocCliente + " IDConex: " + IDConex + " UrlAtualizador: " + UrlAtualizador + " Opcao: " + Opcao.ToString()); //Primeiro Valida se o cliente já está Cadastrado no Banco de Dados de Atualização se não estiver faz o cadastro. var cli = dadosws.GetCliente(DocCliente); //dados.BuscaCli(DocCliente); if (cli.ClienteId == 0) //Se não achou o cliente Faz o Cadastro dele. { //Cadastra os Dados do Cliente. //1 - Obtem os dados de Acesso ao Banco de Dados via Arquivo de Conexão do ERP. ConnERP = dados.LeConfTXT(IDConex); if (ConnERP.ConexaoId > 0) { //2 - Acessa o Banco de Dados do ERP e Obtem os dados do Cliente pra Gravar var CliERP = dados.DadosCliERP(IDConex); //3 - Grava os Dados do Cliente no Banco do Controle de Versões retorno = dadosws.CadCliente(CliERP, 0); //dados.CadCliente(CliERP, 0); //Cadastra o Cliente if (retorno == "OK") //Gravou o cliente com sucesso. { tb_info.Text = "Cliente Cadastrado com Sucesso!!!"; } else { MessageBox.Show("Ocorreram Erros ao Cadastrar o Cliente: \n" + retorno, "Controller ERP"); } } else { tb_info.Text = "Arquivo da Conexão código: " + IDConex + ", não foi encontrado!!!"; } } #endregion switch (Opcao) { case 0: //A versão do Executável é maior que a versão interna do Banco de Dados - Necessára a Atualização Completa (Banco e EXEs) tb_info.Text = ""; InfoUpdate infUpd = new InfoUpdate(0, IDConex, UrlAtualizador); infUpd.ShowDialog(); break; case 1: //A versão do Executável é MENOR que a versão interna do BD? - Necessária apenas baixar os Executáveis e Atualizar a Estação de Trabalho. tb_info.Text = ""; InfoUpdate infUpd2 = new InfoUpdate(1, IDConex, UrlAtualizador); infUpd2.ShowDialog(); break; } this.Close(); }
public bool Inserir(Client client, string nome) { string query = ""; try { query = "INSERT INTO " + Tabelas_Guardian.ZA1 + " " + "(ZA1_IDCLIE, ZA1_NOME, ZA1_SNOME, " + "ZA1_TIPO, ZA1_ID, ZA1_RG, ZA1_EMAIL, " + "ZA1_SEXO, ZA1_DTCAD, ZA1_DTALT, ZA1_DTEXC, " + "ZA1_DTNAS, ZA1_DDIT, ZA1_DDDT, ZA1_TEL, " + "ZA1_DDIC, ZA1_DDDC, ZA1_CEL, ZA1_IDCLIC, ZA1_NOTAS, ZA1_ID_T_C) " + "VALUES " + "(" + " '" + client.fk_tbl_cliente_id_empresa + "', " + " '" + client.nome + "', " + " '" + client.sobrenome + "', " + " '" + client.tipo + "', " + " '" + client.identificador + "', " + " '" + client.rg + "', " + " '" + client.email + "', " + " '" + client.sexo + "', " + " '" + client.dt_cadastro + "', " + " '" + client.dt_alteracao + "', " + " '" + client.dt_exclusao + "', " + " '" + client.dt_nascimento + "', " + " '" + client.ddi_telefone + "', " + " '" + client.ddd_telefone + "', " + " '" + client.telefone + "', " + " '" + client.ddi_celular + "', " + " '" + client.ddd_celular + "', " + " '" + client.celular + "', " + " '" + client.fk_tbl_cliente_id_cliente + "', " + " '" + client.anotacao + "', " + " '" + client.id_tbl_cliente + "' " + ")"; using (SqlConnection connection = new SqlConnection(ConexaoERP.Conexao())) { using (SqlCommand command = new SqlCommand(query, connection)) { connection.Open(); command.ExecuteNonQuery(); } } return(true); } catch (Exception ex) { Guardian_Log.Log_Rotina(Service_Config.NomeServico, Tipo.Erro, "Erro na Rotina de inserção de Cliente. " + ex.ToString()); return(false); } }
public static void Log_Rotina(string nomeRotina, Tipo tipo, string textoLivre) { LogRotina logRotina = new LogRotina { Origem = "APLICACAO", Data = DateTime.Now.ToString("yyyyMMdd"), Hora = DateTime.Now.ToString("HH:mm:ss"), Tipo = tipo.ToString(), Rotina = nomeRotina, Log = textoLivre, }; LogDAO logDAO = new LogDAO(); logDAO.RegistrarLogRotina(logRotina, ConexaoERP.Conexao()); }
public List <Client> BuscarERP() { List <Client> Clientes = new List <Client>(); string query = ""; try { query = "SELECT " + "ZA1_IDCLIE, ZA1_NOME, ZA1_SNOME, " + "ZA1_TIPO, ZA1_ID, ZA1_RG, ZA1_EMAIL, " + "ZA1_SEXO, ZA1_DTCAD, ZA1_DTALT, ZA1_DTEXC, " + "ZA1_DTNAS, ZA1_DDIT, ZA1_DDDT, ZA1_TEL, " + "ZA1_DDIC, ZA1_DDDC, ZA1_CEL, ZA1_IDCLIC, ZA1_NOTAS, ZA1_ID_T_C " + "FROM " + Tabelas_Guardian.ZA1; using (SqlConnection connection = new SqlConnection(ConexaoERP.Conexao())) { using (SqlCommand command = new SqlCommand(query, connection)) { command.CommandTimeout = 500; connection.Open(); using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { Client cliente = new Client { fk_tbl_cliente_id_empresa = reader["ZA1_IDCLIE"].ToString().Trim(), nome = reader["ZA1_NOME"].ToString().Trim(), sobrenome = reader["ZA1_SNOME"].ToString().Trim(), tipo = reader["ZA1_TIPO"].ToString().Trim(), identificador = reader["ZA1_ID"].ToString().Trim(), rg = reader["ZA1_RG"].ToString().Trim(), email = reader["ZA1_EMAIL"].ToString().Trim(), sexo = reader["ZA1_SEXO"].ToString().Trim(), dt_cadastro = reader["ZA1_DTCAD"].ToString().Trim(), dt_alteracao = reader["ZA1_DTALT"].ToString().Trim(), dt_exclusao = reader["ZA1_DTEXC"].ToString().Trim(), dt_nascimento = reader["ZA1_DTNAS"].ToString().Trim(), ddi_telefone = reader["ZA1_DDIT"].ToString().Trim(), ddd_telefone = reader["ZA1_DDDT"].ToString().Trim(), telefone = reader["ZA1_TEL"].ToString().Trim(), ddi_celular = reader["ZA1_DDIC"].ToString().Trim(), ddd_celular = reader["ZA1_DDDC"].ToString().Trim(), celular = reader["ZA1_CEL"].ToString().Trim(), fk_tbl_cliente_id_cliente = reader["ZA1_IDCLIC"].ToString().Trim(), anotacao = reader["ZA1_NOTAS"].ToString().Trim(), id_tbl_cliente = reader["ZA1_ID_T_C"].ToString().Trim(), }; Clientes.Add(cliente); } ; } } } } catch (Exception ex) { throw new Exception("Query: " + query + Environment.NewLine, ex); } return(Clientes); }