private void btndel_Click(object sender, EventArgs e)
        {
            string        sql = "DELETE FROM corretor WHERE cod_corretor=@Id";
            SqlConnection con = Conexao.obterConexao();
            SqlCommand    cmd = new SqlCommand(sql, con);

            cmd.Parameters.AddWithValue("@Id", cod);
            cmd.CommandType = CommandType.Text;
            Conexao.obterConexao();

            try
            {
                int i = cmd.ExecuteNonQuery();
                if (i > 0)
                {
                    MessageBox.Show("Registro excluído com sucesso!");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro: " + ex.ToString());
            }
            finally
            {
                Conexao.fecharConexao();
            }
            txtcorretor.Clear();
            txtendereco.Clear();
            txttelefone.Clear();
            txtregistro.Clear();
            txtsenha.Clear();
            textpesquisa.Clear();
        }
        private void btn_Alterar_Click(object sender, EventArgs e)
        {
            string sql = "UPDATE cliente SET nome_cli = @nome, cpf = @cpf, data_nasc = @data_nasc, telefone_cli = @telefone, " +
                         "endereco_cli = @endereco WHERE cod_cli = @cod_cli";
            SqlConnection conn = Conexao.obterConexao();
            SqlCommand    cmd  = new SqlCommand(sql, conn);

            cmd.Parameters.Add(new SqlParameter("@nome", txt_nomeCliente.Text));
            cmd.Parameters.Add(new SqlParameter("@cpf", txt_Cpf.Text));
            cmd.Parameters.Add(new SqlParameter("@data_nasc", txt_nascCliente.Text));
            cmd.Parameters.Add(new SqlParameter("@telefone", txt_telefoneCliente.Text));
            cmd.Parameters.Add(new SqlParameter("@endereco", txt_enderecoCliente.Text));
            cmd.Parameters.Add(new SqlParameter("@cod_cli", int.Parse(txt_codCliente.Text)));

            cmd.CommandType = CommandType.Text;
            Conexao.obterConexao();
            try
            {
                int i = cmd.ExecuteNonQuery();
                if (i > 0)
                {
                    MessageBox.Show("Registro atualizado com sucesso!");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro: " + ex.ToString());
            }
            finally
            {
                Conexao.fecharConexao();
            }
        }
        private void btnsalvar_Click(object sender, EventArgs e)
        {
            string sql = "UPDATE acidente SET local=@local, data=@data, hora=@hora," +
                         " descricao=@descricao WHERE cod_aci=@cod_aci;";
            SqlConnection conn = Conexao.obterConexao();
            SqlCommand    comm = new SqlCommand(sql, conn);

            comm.Parameters.Add(new SqlParameter("@local", txtlocal.Text));
            comm.Parameters.Add(new SqlParameter("@data", txtdata.Text));
            comm.Parameters.Add(new SqlParameter("@hora", txthora.Text));
            comm.Parameters.Add(new SqlParameter("@descricao", txtdescricao.Text));
            comm.Parameters.Add(new SqlParameter("@cod_aci", int.Parse(txtaci.Text)));
            comm.CommandType = CommandType.Text;
            Conexao.obterConexao();
            try
            {
                int i = comm.ExecuteNonQuery();
                if (i > 0)
                {
                    MessageBox.Show("Registro atualizado com sucesso!");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro: " + ex.ToString());
            }
            finally
            {
                Conexao.fecharConexao();
            }
        }
        private void btn_Excluir_Click(object sender, EventArgs e)
        {
            string        sql  = "DELETE FROM cliente WHERE cod_cli = @cod_cli";
            SqlConnection conn = Conexao.obterConexao();
            SqlCommand    cmd  = new SqlCommand(sql, conn);

            cmd.Parameters.Add(new SqlParameter("@cod_cli", int.Parse(txt_codCliente.Text)));

            cmd.CommandType = CommandType.Text;
            Conexao.obterConexao();
            try
            {
                int i = cmd.ExecuteNonQuery();
                if (i > 0)
                {
                    MessageBox.Show("Registro excluído com sucesso!");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro: " + ex.ToString());
            }
            finally
            {
                Conexao.fecharConexao();
            }
        }
        private void button3_Click(object sender, EventArgs e)
        {
            string sql = "INSERT INTO acidente (cod_carro,local,data,hora,descricao) "
                         + "VALUES ('" + txtchassi.Text + "', '" + txtlocal.Text + "', '" + txtdata.Text + "', '" + txthora.Text + "', '" + txtdescricao + "')";

            // SqlConnection con = new SqlConnection(strconn);
            SqlConnection conn = Conexao.obterConexao();
            SqlCommand    cmd  = new SqlCommand(sql, conn);

            cmd.CommandType = CommandType.Text;
            Conexao.obterConexao();
            try
            {
                int i = cmd.ExecuteNonQuery();
                if (i > 0)
                {
                    MessageBox.Show("Cadastro realizado com sucesso!");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro: " + ex.ToString());
            }
            finally
            {
                Conexao.fecharConexao();
            }
        }
Exemple #6
0
        private void btnsalvar_Click(object sender, EventArgs e)
        {
            string sql = "INSERT INTO acidente (descricao, local, data, hora, cod_carro ) VALUES ( @descricao,@local,@data,@hora,@fk_acicarro)";
            // SqlConnection con = new SqlConnection(strconn);
            SqlConnection conn = Conexao.obterConexao();
            SqlCommand    cmd  = new SqlCommand(sql, conn);

            cmd.Parameters.Add(new SqlParameter("@descricao", txtdescricao.Text));
            cmd.Parameters.Add(new SqlParameter("@local", txtlocal.Text));
            cmd.Parameters.Add(new SqlParameter("@data", txtdata.Text));
            cmd.Parameters.Add(new SqlParameter("@hora", txthora.Text));
            cmd.Parameters.Add(new SqlParameter("@fk_acicarro", fk_acicarro));
            cmd.CommandType = CommandType.Text;
            Conexao.obterConexao();
            try
            {
                int i = cmd.ExecuteNonQuery();
                if (i > 0)
                {
                    MessageBox.Show("Cadastro realizado com sucesso!");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro: " + ex.ToString());
            }
            finally
            {
                Conexao.fecharConexao();
            }
        }
Exemple #7
0
        private void btn_Excluir_Click(object sender, EventArgs e)
        {
            string        sql  = "DELETE FROM apolice WHERE cod_apolice = @cod_apolice";
            SqlConnection conn = Conexao.obterConexao();
            SqlCommand    cmd  = new SqlCommand(sql, conn);

            cmd.Parameters.AddWithValue("@cod_apolice", txt_ApoliceCod.Text);

            cmd.CommandType = CommandType.Text;
            Conexao.obterConexao();

            try
            {
                int i = cmd.ExecuteNonQuery();
                if (i > 0)
                {
                    MessageBox.Show("Registro excluído com sucesso!");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro: " + ex.ToString());
            }
            finally
            {
                Conexao.fecharConexao();
            }

            limparTodosCampos();
        }
Exemple #8
0
        private void btnsalvar_Click(object sender, EventArgs e)
        {
            string        sql  = "INSERT INTO cliente (nome_cli, data_nasc, telefone_cli, endereco_cli, cpf)  VALUES ( @nome,@data_nasc,@endereco,@telefone,@cpf)";
            SqlConnection conn = Conexao.obterConexao();
            SqlCommand    cmd  = new SqlCommand(sql, conn);

            cmd.Parameters.Add(new SqlParameter("@nome", txt_nomeCliente.Text));
            cmd.Parameters.Add(new SqlParameter("@data_nasc", txt_nascCliente.Text));
            cmd.Parameters.Add(new SqlParameter("@endereco", txt_enderecoCliente.Text));
            cmd.Parameters.Add(new SqlParameter("@telefone", txt_telefoneCliente.Text));
            cmd.Parameters.Add(new SqlParameter("@cpf", txtcpf.Text));
            cmd.CommandType = CommandType.Text;
            Conexao.obterConexao();
            try
            {
                int i = cmd.ExecuteNonQuery();
                if (i > 0)
                {
                    MessageBox.Show("Cadastro realizado com sucesso!");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro: " + ex.ToString());
            }
            finally
            {
                Conexao.fecharConexao();
            }
        }
        private void btnbusca_Click(object sender, EventArgs e)
        {
            SqlConnection conn = Conexao.obterConexao();
            SqlCommand    comm = new SqlCommand("select c.modelo,c.marca,c.placa,c.ano_modelo,c.ano_fabricao," +
                                                "c.chassi,a.local,a.cod_aci,a.descricao,a.hora, a.data from carro c, acidente a where a.cod_carro=c.cod_car and c.placa='" + txtplaca.Text + "';", conn);

            comm.CommandType = CommandType.Text;
            comm.Parameters.Add(new SqlParameter("@modelo", "modelo"));
            comm.Parameters.Add(new SqlParameter("@marca", "marca"));
            comm.Parameters.Add(new SqlParameter("@ano_modelo", "ano_modelo"));
            comm.Parameters.Add(new SqlParameter("@ano_fabricao", "ano_fabricao"));
            comm.Parameters.Add(new SqlParameter("@chassi", "chassi"));
            comm.Parameters.Add(new SqlParameter("@local", "local"));
            comm.Parameters.Add(new SqlParameter("@data", "data"));
            comm.Parameters.Add(new SqlParameter("@hora", "hora"));
            comm.Parameters.Add(new SqlParameter("@cod_aci", "cod_aci"));
            comm.Parameters.Add(new SqlParameter("@descricao", "descricao"));


            Conexao.obterConexao();
            DbDataReader dr = comm.ExecuteReader();

            try
            {
                if (dr.Read())
                {
                    txtmodelo.Text    = dr["modelo"].ToString();
                    txtmarca.Text     = dr["marca"].ToString();
                    txtanomodelo.Text = dr["ano_modelo"].ToString();
                    txtfabricao.Text  = dr["ano_fabricao"].ToString();
                    txtchassi.Text    = dr["chassi"].ToString();
                    txtlocal.Text     = dr["local"].ToString();
                    txtdata.Text      = dr["data"].ToString();
                    txthora.Text      = dr["hora"].ToString();
                    txtaci.Text       = dr["cod_aci"].ToString();
                    txtdescricao.Text = dr["descricao"].ToString();
                }

                else
                {
                    MessageBox.Show("Nenhum registro encontrado com a placa informada!");
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show("Erro: " + ex.ToString());
            }
            finally
            {
                Conexao.fecharConexao();
            }
        }
Exemple #10
0
        private void txtchassi_MouseClick(object sender, MouseEventArgs e)
        {
            string m = txtplaca.Text.ToUpper();

            txtplaca.Text = m;
            SqlConnection conn = Conexao.obterConexao();
            SqlCommand    comm = new SqlCommand("SELECT *from carro WHERE " +
                                                "placa = '" + txtplaca.Text + "';", conn);

            comm.CommandType = CommandType.Text;
            comm.Parameters.Add(new SqlParameter("@marca", "marca"));
            comm.Parameters.Add(new SqlParameter("@modelo", "modelo"));
            comm.Parameters.Add(new SqlParameter("@ano_fabricao", "ano_fabricao"));
            comm.Parameters.Add(new SqlParameter("@ano_modelo", "ano_modelo"));
            comm.Parameters.Add(new SqlParameter("@placa", "placa"));
            comm.Parameters.Add(new SqlParameter("@cor", "cor"));
            comm.Parameters.Add(new SqlParameter("@chassi", "chassi"));
            comm.Parameters.Add(new SqlParameter("@cod_car", "cod_car"));

            Conexao.obterConexao();
            DbDataReader dr = comm.ExecuteReader();

            try
            {
                if (dr.Read())
                {
                    txtmarca.Text    = dr["marca"].ToString();
                    txtmodelo.Text   = dr["modelo"].ToString();
                    txtfabricao.Text = dr["ano_fabricao"].ToString();
                    txtanom.Text     = dr["ano_modelo"].ToString();
                    txtplaca.Text    = dr["placa"].ToString();
                    txtcor.Text      = dr["cor"].ToString();
                    txtchassi.Text   = dr["chassi"].ToString();
                    fk_acicarro      = int.Parse(dr["cod_car"].ToString());
                }
                else
                {
                    MessageBox.Show("Nenhum registro encontrado com a placa informada!");
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show("Erro: " + ex.ToString());
            }
            finally
            {
                Conexao.fecharConexao();
            }
        }
        private void btnconsultar_Click(object sender, EventArgs e)
        {
            SqlConnection conn = Conexao.obterConexao();
            SqlCommand    comm = new SqlCommand("SELECT cor.nome, cor.endereco, " +
                                                "cor.telefone, cor.regi_corretor,cor.senha,cor.cod_corretor, emp.cod_empresa  FROM " +
                                                "corretor cor INNER JOIN empresa emp ON cor.cod_empresa = emp.cod_empresa WHERE " +
                                                "cor.regi_corretor = '" + textpesquisa.Text + "';", conn);

            comm.CommandType = CommandType.Text;
            comm.Parameters.Add(new SqlParameter("@corretor", "corretor"));
            comm.Parameters.Add(new SqlParameter("@endereco", "endereco"));
            comm.Parameters.Add(new SqlParameter("@telefone", "telefone"));
            comm.Parameters.Add(new SqlParameter("@registro", "regi_corretor"));
            comm.Parameters.Add(new SqlParameter("@senha", "senha"));
            comm.Parameters.Add(new SqlParameter("@cod_empresa", "cod_empresa"));
            comm.Parameters.Add(new SqlParameter("@cod_corretor", "cod_corretor"));

            Conexao.obterConexao();
            DbDataReader dr = comm.ExecuteReader();

            // while (dr.Read())
            try
            {
                if (dr.Read())
                {
                    txtcorretor.Text = dr["nome"].ToString();
                    txtendereco.Text = dr["endereco"].ToString();
                    txttelefone.Text = dr["telefone"].ToString();
                    lblempresa.Text  = dr["cod_empresa"].ToString();
                    txtregistro.Text = dr["regi_corretor"].ToString();
                    txtsenha.Text    = dr["senha"].ToString();
                    pk_regi_corretor = int.Parse(dr["cod_empresa"].ToString());
                    cod = int.Parse(dr["cod_corretor"].ToString());
                }
                else
                {
                    MessageBox.Show("Nenhum registro encontrado com o Registro de Habilitação informado!");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro: " + ex.ToString());
            }
            finally
            {
                Conexao.fecharConexao();
            }
        }
Exemple #12
0
        private void btn_consultaPlaca_Click(object sender, EventArgs e)
        {
            String sql = "SELECT cli.nome_cli, cli.CPF, cli.data_nasc, " +
                         "cli.telefone_cli, cli.endereco_cli, car.marca, car.modelo, car.ano_fabricao, " +
                         "car.ano_modelo, car.placa, car.cor, car.chassi, car.cod_car FROM " +
                         "cliente cli INNER JOIN carro car ON cli.cod_cli = car.cod_cli WHERE " +
                         "car.placa = @pesquisa_placa;";
            SqlConnection conn = Conexao.obterConexao();
            SqlCommand    cmd  = new SqlCommand(sql, conn);

            cmd.Parameters.Add(new SqlParameter("@pesquisa_placa", txt_consultaPlaca.Text));

            cmd.CommandType = CommandType.Text;
            Conexao.obterConexao();
            DbDataReader dr = cmd.ExecuteReader();

            try
            {
                if (dr.Read())
                {
                    txt_nomeCliente.Text     = dr["nome_cli"].ToString();
                    txt_cpfCliente.Text      = dr["CPF"].ToString();
                    txt_nascCliente.Text     = dr["data_nasc"].ToString();
                    txt_telefoneCliente.Text = dr["telefone_cli"].ToString();
                    txt_enderecoCliente.Text = dr["endereco_cli"].ToString();
                    txt_marcaCarro.Text      = dr["marca"].ToString();
                    txt_modeloCarro.Text     = dr["modelo"].ToString();
                    txt_anoFabCarro.Text     = dr["ano_fabricao"].ToString();
                    txt_anoModCarro.Text     = dr["ano_modelo"].ToString();
                    txt_placaCarro.Text      = dr["placa"].ToString();
                    txt_corCarro.Text        = dr["cor"].ToString();
                    txt_chassiCarro.Text     = dr["chassi"].ToString();
                    txt_CodCarro.Text        = dr["cod_car"].ToString();
                }
                else
                {
                    MessageBox.Show("Nenhum registro encontrado com a placa informada!");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro: " + ex.ToString());
            }
            finally
            {
                Conexao.fecharConexao();
            }
        }
Exemple #13
0
        private void btn_Alterar_Click(object sender, EventArgs e)
        {
            if (txt_CorretorCod.Text != "" && txt_CarroCod.Text != "" && txt_ClienteCod.Text != "" && txt_ApoliceCod.Text != "" &&
                txt_CarroModelo.Text != "" && txt_ApoliceValor.Text != "" && txt_ApoliceVigencia.Text != "" &&
                txt_ApoliceFranquia.Text != "" && txt_ApoliceData.Text != "")
            {
                string sql = "UPDATE apolice SET valor = @valor, vigencia = @vigencia, franquia = @franquia, " +
                             "data = @data, modelo = @modelo, cod_corretor = @cod_corretor, cod_cli = @cod_cli, " +
                             "cod_car = @cod_car WHERE cod_apolice = @cod_apolice";
                SqlConnection conn = Conexao.obterConexao();
                SqlCommand    cmd  = new SqlCommand(sql, conn);

                cmd.Parameters.Add(new SqlParameter("@valor", float.Parse(txt_ApoliceValor.Text)));
                cmd.Parameters.Add(new SqlParameter("@vigencia", txt_ApoliceVigencia.Text));
                cmd.Parameters.Add(new SqlParameter("@franquia", float.Parse(txt_ApoliceFranquia.Text)));
                cmd.Parameters.Add(new SqlParameter("@data", txt_ApoliceData.Text));
                cmd.Parameters.Add(new SqlParameter("@modelo", txt_CarroModelo.Text));
                cmd.Parameters.Add(new SqlParameter("@cod_corretor", int.Parse(txt_CorretorCod.Text)));
                cmd.Parameters.Add(new SqlParameter("@cod_cli", int.Parse(txt_ClienteCod.Text)));
                cmd.Parameters.Add(new SqlParameter("@cod_car", int.Parse(txt_CarroCod.Text)));
                cmd.Parameters.Add(new SqlParameter("@cod_apolice", int.Parse(txt_ApoliceCod.Text)));

                cmd.CommandType = CommandType.Text;
                Conexao.obterConexao();

                try
                {
                    int i = cmd.ExecuteNonQuery();
                    if (i > 0)
                    {
                        MessageBox.Show("Registro atualizado com sucesso!");
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Erro: " + ex.ToString());
                }
                finally
                {
                    Conexao.fecharConexao();
                }
            }
            else
            {
                MessageBox.Show("Informe todos os campos!");
            }
        }
Exemple #14
0
        private void btn_Salvar_Click(object sender, EventArgs e)
        {
            if (txt_CorretorCod.Text != "" && txt_CarroCod.Text != "" && txt_ClienteCod.Text != "" &&
                txt_CarroModelo.Text != "" && txt_ApoliceValor.Text != "" && txt_ApoliceVigencia.Text != "" &&
                txt_ApoliceFranquia.Text != "" && txt_ApoliceData.Text != "")
            {
                string sql = "INSERT INTO apolice(valor, vigencia, franquia, data, modelo, cod_corretor, cod_cli, cod_car) " +
                             "VALUES(@valor, @vigencia, @franquia, @data, @modelo, @cod_corretor, @cod_cli, @cod_car)";
                SqlConnection conn = Conexao.obterConexao();
                SqlCommand    cmd  = new SqlCommand(sql, conn);

                cmd.Parameters.Add(new SqlParameter("@valor", float.Parse(txt_ApoliceValor.Text)));
                cmd.Parameters.Add(new SqlParameter("@vigencia", txt_ApoliceVigencia.Text));
                cmd.Parameters.Add(new SqlParameter("@franquia", float.Parse(txt_ApoliceFranquia.Text)));
                cmd.Parameters.Add(new SqlParameter("@data", txt_ApoliceData.Text));
                cmd.Parameters.Add(new SqlParameter("@modelo", txt_CarroModelo.Text));
                cmd.Parameters.Add(new SqlParameter("@cod_corretor", int.Parse(txt_CorretorCod.Text)));
                cmd.Parameters.Add(new SqlParameter("@cod_cli", int.Parse(txt_ClienteCod.Text)));
                cmd.Parameters.Add(new SqlParameter("@cod_car", int.Parse(txt_CarroCod.Text)));

                cmd.CommandType = CommandType.Text;
                Conexao.obterConexao();

                try
                {
                    int i = cmd.ExecuteNonQuery();
                    if (i > 0)
                    {
                        MessageBox.Show("Cadastro realizado com sucesso!");
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Erro: " + ex.ToString());
                }
                finally
                {
                    Conexao.fecharConexao();
                }
            }
            else
            {
                MessageBox.Show("Informe todos os campos!");
            }
        }
Exemple #15
0
        private void txt_CarroMarca_MouseClick(object sender, MouseEventArgs e)
        {
            String        sql  = "SELECT * FROM carro car INNER JOIN cliente cli ON car.cod_cli = cli.cod_cli WHERE car.placa = @placa;";
            SqlConnection conn = Conexao.obterConexao();
            SqlCommand    cmd  = new SqlCommand(sql, conn);

            cmd.Parameters.Add(new SqlParameter("@placa", txt_ConsultarCarro.Text));

            cmd.CommandType = CommandType.Text;
            Conexao.obterConexao();
            DbDataReader dr = cmd.ExecuteReader();

            try
            {
                if (dr.Read())
                {
                    txt_CarroCod.Text        = dr["cod_car"].ToString();
                    txt_CarroMarca.Text      = dr["marca"].ToString();
                    txt_CarroModelo.Text     = dr["modelo"].ToString();
                    txt_CarroCor.Text        = dr["cor"].ToString();
                    txt_CarroAnoFab.Text     = dr["ano_fabricao"].ToString();
                    txt_CarroAnoModelo.Text  = dr["ano_modelo"].ToString();
                    txt_CarroChassis.Text    = dr["chassi"].ToString();
                    txt_CarroPlaca.Text      = dr["placa"].ToString();
                    txt_ClienteCod.Text      = dr["cod_cli"].ToString();
                    txt_ClienteNome.Text     = dr["nome_cli"].ToString();
                    txt_ClienteCpf.Text      = dr["cpf"].ToString();
                    txt_ClienteDataNasc.Text = dr["data_nasc"].ToString();
                    txt_ClienteEndereco.Text = dr["endereco_cli"].ToString();
                    txt_ClienteTelefone.Text = dr["telefone_cli"].ToString();
                }
                else
                {
                    MessageBox.Show("Nenhum registro encontrado com a placa informada!");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro: " + ex.ToString());
            }
            finally
            {
                Conexao.fecharConexao();
            }
        }
        private void Empresa_Load(object sender, EventArgs e)
        {
            SqlConnection conn = Conexao.obterConexao();
            SqlCommand    comm = new SqlCommand("SELECT * from empresa", conn);

            comm.CommandType = CommandType.Text;
            comm.Parameters.Add(new SqlParameter("@nome", "nome"));
            comm.Parameters.Add(new SqlParameter("@razao", "razao_social"));

            Conexao.obterConexao();
            DbDataReader dr = comm.ExecuteReader();

            while (dr.Read())
            {
                lblempresa.Text = dr["nome"].ToString();
                txtrazao.Text   = dr["razao_social"].ToString();
            }
            Conexao.fecharConexao();
        }
        private void btnsalvar_Click(object sender, EventArgs e)
        {
            if (contarcamposmudados == 0)
            {
                MessageBox.Show("Nenhum campo alterado");
            }
            else
            {
                if (txtsenhac.Text == txtsenha.Text)
                {
                    string        sql  = "UPDATE corretor SET senha = @senha WHERE cod_corretor = @cod_corretor";
                    SqlConnection conn = Conexao.obterConexao();
                    SqlCommand    comm = new SqlCommand(sql, conn);

                    comm.Parameters.Add(new SqlParameter("@senha", txtsenha.Text));
                    comm.Parameters.Add(new SqlParameter("@cod_corretor", (cod)));
                    comm.CommandType = CommandType.Text;
                    Conexao.obterConexao();
                    try
                    {
                        int i = comm.ExecuteNonQuery();
                        if (i > 0)
                        {
                            MessageBox.Show("Registro atualizado com sucesso!");
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Erro: " + ex.ToString());
                    }
                    finally
                    {
                        Conexao.fecharConexao();
                    }
                }
                else
                {
                    MessageBox.Show("As senhas não são parecidas");
                }
            }
        }
 private void btnsalvar_Click(object sender, EventArgs e)
 {
     if (contarcamposmudados == 0)
     {
         MessageBox.Show("Nenhum campo alterado");
     }
     else
     {
         string sql = "UPDATE corretor SET nome = @nome, endereco = @endereco, " +
                      "telefone = @telefone, cod_empresa = @cod_empresa, regi_corretor = @regi_corretor, " +
                      "senha = @senha WHERE cod_corretor = @cod_corretor";
         SqlConnection conn = Conexao.obterConexao();
         SqlCommand    comm = new SqlCommand(sql, conn);
         comm.Parameters.Add(new SqlParameter("@nome", txtcorretor.Text));
         comm.Parameters.Add(new SqlParameter("@endereco", txtendereco.Text));
         comm.Parameters.Add(new SqlParameter("@telefone", txttelefone.Text));
         comm.Parameters.Add(new SqlParameter("@regi_corretor", txtregistro.Text));
         comm.Parameters.Add(new SqlParameter("@senha", txtsenha.Text));
         comm.Parameters.Add(new SqlParameter("@cod_empresa", pk_regi_corretor));
         comm.Parameters.Add(new SqlParameter("@cod_corretor", (cod)));
         comm.CommandType = CommandType.Text;
         Conexao.obterConexao();
         try
         {
             int i = comm.ExecuteNonQuery();
             if (i > 0)
             {
                 MessageBox.Show("Registro atualizado com sucesso!");
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show("Erro: " + ex.ToString());
         }
         finally
         {
             Conexao.fecharConexao();
         }
     }
 }
Exemple #19
0
        private void btn_Salvar_Click(object sender, EventArgs e)
        {
            string sql = "INSERT INTO carro (chassi, modelo, marca, cor, ano_fabricao, ano_modelo, placa, cod_cli) " +
                         "VALUES (@chassi, @modelo, @marca, @cor, @ano_fabricao, @ano_modelo, @placa, @cod_cli)";

            // SqlConnection con = new SqlConnection(strconn);
            SqlConnection conn = Conexao.obterConexao();
            SqlCommand    cmd  = new SqlCommand(sql, conn);

            cmd.Parameters.Add(new SqlParameter("@chassi", txt_chassiCarro.Text));
            cmd.Parameters.Add(new SqlParameter("@modelo", txt_modeloCarro.Text));
            cmd.Parameters.Add(new SqlParameter("@marca", txt_marcaCarro.Text));
            cmd.Parameters.Add(new SqlParameter("@cor", txt_corCarro.Text));
            cmd.Parameters.Add(new SqlParameter("@ano_fabricao", int.Parse(txt_anoFabCarro.Text)));
            cmd.Parameters.Add(new SqlParameter("@ano_modelo", int.Parse(txt_anoModCarro.Text)));
            cmd.Parameters.Add(new SqlParameter("@placa", txt_placaCarro.Text));
            cmd.Parameters.Add(new SqlParameter("@cod_cli", int.Parse(txt_codCliente.Text)));

            cmd.CommandType = CommandType.Text;
            Conexao.obterConexao();

            try
            {
                int i = cmd.ExecuteNonQuery();
                if (i > 0)
                {
                    MessageBox.Show("Cadastro realizado com sucesso!");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro: " + ex.ToString());
            }
            finally
            {
                Conexao.fecharConexao();
            }
        }
Exemple #20
0
        bool VerificaLogin()
        {
            bool result = false;

            // string StringDeConexao = "Data Source=.\\SQLEXPRESS;AttachDbFilename=E:\\seguradora\\seguradora.mdf;Integrated Security=True;User Instance=True";
            using (SqlConnection cn = Conexao.obterConexao())
            {
                // cn.ConnectionString = StringDeConexao;
                try
                {
                    SqlCommand cmd = new SqlCommand("Select regi_corretor,senha from corretor where regi_corretor='" + txtnomeacesso.Text + "'and senha='" + txtkey.Text + "';", cn);
                    Conexao.obterConexao();
                    SqlDataReader dados = cmd.ExecuteReader();
                    result = dados.HasRows;
                }
                catch (Exception erro)
                {
                    MessageBox.Show(erro.Message);
                }
                Conexao.fecharConexao();
            }
            return(result);
        }
        private void btnALTERAR_Click(object sender, EventArgs e)
        {
            string        sql = "DELETE FROM acidente WHERE cod_aci=@Id";
            SqlConnection con = Conexao.obterConexao();
            SqlCommand    cmd = new SqlCommand(sql, con);

            cmd.Parameters.AddWithValue("@Id", txtaci.Text);
            cmd.CommandType = CommandType.Text;
            Conexao.obterConexao();

            try
            {
                int i = cmd.ExecuteNonQuery();
                if (i > 0)
                {
                    MessageBox.Show("Registro excluído com sucesso!");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro: " + ex.ToString());
            }
            finally
            {
                Conexao.fecharConexao();
            }
            txtaci.Clear();
            txtplaca.Clear();
            txthora.Clear();
            txtdata.Clear();
            txtanomodelo.Clear();
            txtlocal.Clear();
            txtdescricao.Clear();
            txtfabricao.Clear();
            txtmodelo.Clear();
            txtmarca.Clear();
        }
Exemple #22
0
        private void btn_Alterar_Click(object sender, EventArgs e)
        {
            string sql = "UPDATE carro SET marca = @marca, modelo = @modelo, " +
                         "ano_fabricao = @ano_fabricao, ano_modelo = @ano_modelo, placa = @placa, " +
                         "cor = @cor, chassi = @chassi WHERE cod_car = @cod_car";
            SqlConnection conn = Conexao.obterConexao();
            SqlCommand    comm = new SqlCommand(sql, conn);

            comm.Parameters.Add(new SqlParameter("@marca", txt_marcaCarro.Text));
            comm.Parameters.Add(new SqlParameter("@modelo", txt_modeloCarro.Text));
            comm.Parameters.Add(new SqlParameter("@ano_fabricao", int.Parse(txt_anoFabCarro.Text)));
            comm.Parameters.Add(new SqlParameter("@ano_modelo", int.Parse(txt_anoModCarro.Text)));
            comm.Parameters.Add(new SqlParameter("@placa", txt_placaCarro.Text));
            comm.Parameters.Add(new SqlParameter("@cor", txt_corCarro.Text));
            comm.Parameters.Add(new SqlParameter("@chassi", txt_chassiCarro.Text));
            comm.Parameters.Add(new SqlParameter("@cod_car", int.Parse(txt_CodCarro.Text)));

            comm.CommandType = CommandType.Text;
            Conexao.obterConexao();

            try
            {
                int i = comm.ExecuteNonQuery();
                if (i > 0)
                {
                    MessageBox.Show("Registro atualizado com sucesso!");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro: " + ex.ToString());
            }
            finally
            {
                Conexao.fecharConexao();
            }
        }
Exemple #23
0
        private void btn_ConsultarCorretor_Click(object sender, EventArgs e)
        {
            String        sql  = "SELECT * FROM corretor WHERE regi_corretor = @regi_corretor";
            SqlConnection conn = Conexao.obterConexao();
            SqlCommand    cmd  = new SqlCommand(sql, conn);

            cmd.Parameters.Add(new SqlParameter("@regi_corretor", txt_ConsultarCorretor.Text));

            cmd.CommandType = CommandType.Text;
            Conexao.obterConexao();
            DbDataReader dr = cmd.ExecuteReader();

            try
            {
                if (dr.Read())
                {
                    txt_CorretorCod.Text      = dr["cod_corretor"].ToString();
                    txt_CorretorNome.Text     = dr["nome"].ToString();
                    txt_EmpresaCod.Text       = dr["cod_empresa"].ToString();
                    txt_CorretorRegistro.Text = dr["regi_corretor"].ToString();
                    txt_CorretorEndereco.Text = dr["endereco"].ToString();
                    txt_CorretorTelefone.Text = dr["telefone"].ToString();
                }
                else
                {
                    MessageBox.Show("Nenhum registro encontrado com o Registro de Habilitação informado!");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro: " + ex.ToString());
            }
            finally
            {
                Conexao.fecharConexao();
            }
        }
        private void btn_ConsultarCliente_Click(object sender, EventArgs e)
        {
            String        sql  = "SELECT * FROM cliente WHERE cpf = @cpf";
            SqlConnection conn = Conexao.obterConexao();
            SqlCommand    cmd  = new SqlCommand(sql, conn);

            cmd.Parameters.Add(new SqlParameter("@cpf", txt_consultaCpf.Text));

            cmd.CommandType = CommandType.Text;
            Conexao.obterConexao();
            DbDataReader dr = cmd.ExecuteReader();

            try
            {
                if (dr.Read())
                {
                    txt_codCliente.Text      = dr["cod_cli"].ToString();
                    txt_nomeCliente.Text     = dr["nome_cli"].ToString();
                    txt_Cpf.Text             = dr["cpf"].ToString();
                    txt_nascCliente.Text     = dr["data_nasc"].ToString();
                    txt_enderecoCliente.Text = dr["endereco_cli"].ToString();
                    txt_telefoneCliente.Text = dr["telefone_cli"].ToString();
                }
                else
                {
                    MessageBox.Show("Nenhum registro encontrado com o CPF informado!");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro: " + ex.ToString());
            }
            finally
            {
                Conexao.fecharConexao();
            }
        }
Exemple #25
0
        private void btn_Consultar_Click(object sender, EventArgs e)
        {
            String sql = "SELECT * FROM carro car " +
                         "INNER JOIN cliente cli ON car.cod_cli = cli.cod_cli " +
                         "INNER JOIN apolice apo ON cli.cod_cli = apo.cod_cli " +
                         "INNER JOIN corretor cor ON apo.cod_corretor = cor.cod_corretor WHERE car.placa = @placa;";
            SqlConnection conn = Conexao.obterConexao();
            SqlCommand    cmd  = new SqlCommand(sql, conn);

            cmd.Parameters.Add(new SqlParameter("@placa", txt_Consultar.Text));

            cmd.CommandType = CommandType.Text;
            Conexao.obterConexao();
            DbDataReader dr = cmd.ExecuteReader();

            try
            {
                if (dr.Read())
                {
                    txt_CarroCod.Text       = dr["cod_car"].ToString();
                    txt_CarroMarca.Text     = dr["marca"].ToString();
                    txt_CarroModelo.Text    = dr[2].ToString();
                    txt_CarroCor.Text       = dr["cor"].ToString();
                    txt_CarroAnoFab.Text    = dr["ano_fabricao"].ToString();
                    txt_CarroAnoModelo.Text = dr["ano_modelo"].ToString();
                    txt_CarroChassis.Text   = dr["chassi"].ToString();
                    txt_CarroPlaca.Text     = dr["placa"].ToString();

                    txt_ClienteCod.Text      = dr["cod_cli"].ToString();
                    txt_ClienteNome.Text     = dr["nome_cli"].ToString();
                    txt_ClienteCpf.Text      = dr["cpf"].ToString();
                    txt_ClienteDataNasc.Text = dr["data_nasc"].ToString();
                    txt_ClienteEndereco.Text = dr["endereco_cli"].ToString();
                    txt_ClienteTelefone.Text = dr["telefone_cli"].ToString();

                    txt_ApoliceCod.Text      = dr["cod_apolice"].ToString();
                    txt_ApoliceValor.Text    = dr["valor"].ToString();
                    txt_ApoliceVigencia.Text = dr["vigencia"].ToString();
                    txt_ApoliceFranquia.Text = dr["franquia"].ToString();
                    txt_ApoliceData.Text     = dr["data"].ToString();

                    txt_CorretorCod.Text      = dr["cod_corretor"].ToString();
                    txt_CorretorNome.Text     = dr["nome"].ToString();
                    txt_EmpresaCod.Text       = dr["cod_empresa"].ToString();
                    txt_CorretorRegistro.Text = dr["regi_corretor"].ToString();
                    txt_CorretorEndereco.Text = dr["endereco"].ToString();
                    txt_CorretorTelefone.Text = dr["telefone"].ToString();
                }
                else
                {
                    MessageBox.Show("Nenhum registro encontrado com a placa informada!");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro: " + ex.ToString());
            }
            finally
            {
                Conexao.fecharConexao();
            }
        }
Exemple #26
0
        private void btnsalvar_Click(object sender, EventArgs e)
        {
            string[] texts = new string[6];
            texts[0] = txtcorretor.Text;
            texts[1] = txtendereco.Text;
            texts[2] = txttelefone.Text;
            texts[3] = lblempresa.Text;
            texts[4] = txtregistro.Text;
            texts[5] = txtsenha.Text;

            for (int i = 0; i < texts.Length; i++)
            {
                if (texts[i] == string.Empty)
                {
                    campos = campos - 1;
                }

                else
                {
                    campos++;
                }
            }
            // MessageBox.Show("qnt " + campos);
            if (campos < 6)
            {
                MessageBox.Show("É necessário preencher Todos Campos ");
            }

            else
            {
                string sql = "INSERT INTO corretor (nome, endereco, telefone, regi_corretor," +
                             "senha, cod_empresa)" + " VALUES ('" +
                             txtcorretor.Text + "', '" + txtendereco.Text + "', '" +
                             txttelefone.Text + "', '" + txtregistro.Text + "', '" +
                             txtsenha.Text + "', " + int.Parse(lblempresa.Text) + ")";

                SqlConnection conn = Conexao.obterConexao();
                SqlCommand    cmd  = new SqlCommand(sql, conn);
                cmd.CommandType = CommandType.Text;
                Conexao.obterConexao();
                try
                {
                    int i = cmd.ExecuteNonQuery();
                    if (i > 0)
                    {
                        MessageBox.Show("Cadastro realizado com sucesso!");
                    }
                    txtcorretor.Clear();
                    txttelefone.Clear();
                    txtregistro.Clear();
                    txtsenha.Clear();
                    txtendereco.Clear();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Erro: " + ex.ToString());
                }
                finally
                {
                    Conexao.fecharConexao();
                }
            }
        }