Пример #1
0
        private void BTN_CONF_Click(object sender, EventArgs e)
        {
            DataBaseConnection bd = new DataBaseConnection();

            bd.openConnection();



            String nome  = textBox1.Text;
            String cpf   = Validador.FormataCpfAndRg(CPF_CLIE.Text);
            String tel   = Validador.FormataTelAndCel(TEL_CLIE.Text);
            String cel   = Validador.FormataTelAndCel(CEL_CLIE.Text);
            float  saldo = 1000;


            if ((Validador.campoPreenchido(cpf) &&
                 Validador.campoPreenchido(nome) &&
                 Validador.campoPreenchido(tel)) ||
                (Validador.campoPreenchido(cpf) &&
                 Validador.campoPreenchido(nome) &&
                 Validador.campoPreenchido(cel)))



            {
                String query = "INSERT INTO CLIENTE " +
                               "(CPF_CLIENTE, NOME_CLIENTE, TELEFONE_CLIENTE, CEL_CLIENTE, SALDO_ATUAL_CLIENTE)" +
                               " VALUES ('" + cpf + "','" + nome + "','" + tel + "','" + cel + "','" + saldo + "')";

                //MessageBox.Show(query);

                MySqlCommand cmd = new MySqlCommand(query, bd.retornaConexao());
                cmd.ExecuteNonQuery();
                System.Windows.Forms.MessageBox.Show("Cliente cadastrado com sucesso");

                this.Close();
            }

            else
            {
                MessageBox.Show("Preencha os campos obrigatorios");
            }


            bd.closeConnection();
        }
Пример #2
0
        private void BTN_CONF_Click(object sender, EventArgs e)
        {
            DataBaseConnection bd = new DataBaseConnection();

            bd.openConnection();

            String nome = TXT_NOME_CLIENTE.Text;
            String cpf  = Validador.FormataCpfAndRg(TXT_CPF_CLIENTE.Text);
            String tel  = Validador.FormataTelAndCel(TXT_TEL_CLIENTE.Text);
            String cel  = Validador.FormataTelAndCel(TXT_CEL_CLIENTE.Text);

            cpfAnterior = Validador.FormataCpfAndRg(cpfAnterior);

            String query = "UPDATE cliente SET " +
                           "NOME_CLIENTE = '" + nome +
                           "', CPF_CLIENTE = '" + cpfAnterior +
                           "', TELEFONE_CLIENTE = '" + tel +
                           "', CEL_CLIENTE = '" + cel +
                           "' WHERE CPF_CLIENTE = " + cpfAnterior;


            if (Validador.campoPreenchido(nome))
            {
                MySqlCommand cmd = new MySqlCommand(query, bd.retornaConexao());
                try
                {
                    int numRowAfetada = cmd.ExecuteNonQuery();
                    if (numRowAfetada > 0)
                    {
                        System.Windows.Forms.MessageBox.Show("DADOS ALTERADOS COM SUCESSO");
                        this.Hide();
                    }
                }
                catch (MySqlException ex)
                {
                    MessageBox.Show(ex.ToString());
                    System.Windows.Forms.MessageBox.Show("ERRO NA ALTERAÇÃO");
                }
            }
            else
            {
                MessageBox.Show("PREENCHA OS CAMPOS OBRIGATÓRIOS");
            }

            bd.closeConnection();
        }
Пример #3
0
        private void BTN_CONF_Click(object sender, EventArgs e)
        {
            DataBaseConnection bd = new DataBaseConnection();

            bd.openConnection();



            String nome          = textBox1.Text;
            String dtnascimento  = dateTimePicker1.Value.ToString("yyyy-MM-dd HH:mm:ss");
            String rg            = Validador.FormataCpfAndRg(RG_FUNC.Text);
            String cpf           = Validador.FormataCpfAndRg(CPF_FUNC.Text);
            String tel           = Validador.FormataTelAndCel(TEL_FUNC.Text);
            String cel           = Validador.FormataTelAndCel(CEL_FUNC.Text);
            String email         = textBox4.Text;
            String senha         = textBox7.Text;
            String confirmasenha = textBox8.Text;
            String sexo          = null;
            String tipo          = null;



            if (radioButton1.Checked == true)
            {
                sexo = "m";
            }
            else if (radioButton2.Checked == true)
            {
                sexo = "f";
            }

            if (radioButton3.Checked == true)
            {
                tipo = "B";
            }
            else if (radioButton4.Checked == true)
            {
                tipo = "A";
            }



            if (Validador.campoPreenchido(rg) &&
                Validador.campoPreenchido(cpf) &&
                Validador.campoPreenchido(senha) &&
                Validador.campoPreenchido(confirmasenha) &&
                Validador.campoPreenchido(nome))
            {
                if (senha == confirmasenha)
                {
                    String query = "INSERT INTO USUARIO " +
                                   "(CPF_USER, NOME_USER, TEL_USER, CEL_USER, EMAIL_USER, NIVEL_USER, DTNASCIMENTO_USER, SEXO_USER, RG_USER, SENHA_USER)" +
                                   " VALUES ('" + cpf + "','" + nome + "','" + tel + "','" + cel + "','" +
                                   email + "','" + tipo + "','" + dtnascimento + "','" + sexo + "','" + rg + "','" + senha + "')";

                    //MessageBox.Show(query);

                    MySqlCommand cmd = new MySqlCommand(query, bd.retornaConexao());
                    cmd.ExecuteNonQuery();
                    System.Windows.Forms.MessageBox.Show("USUÁRIO CADASTRADO COM SUCESSO");

                    this.Close();
                }
                else
                {
                    System.Windows.Forms.MessageBox.Show("AS SENHAS DEVEM SER IGUAIS");
                    textBox7.Text = "";
                    textBox8.Text = "";
                }
            }
            else
            {
                MessageBox.Show("PREENCHA OS CAMPOS OBRIGATÓRIOS");
            }


            bd.closeConnection();
        }
Пример #4
0
        private void BTN_CONF_Click(object sender, EventArgs e)
        {
            DataBaseConnection bd = new DataBaseConnection();

            bd.openConnection();

            String nome           = TXT_NOME.Text;
            String cpf            = TXT_CPF.Text;
            String tel            = Validador.FormataTelAndCel(TXT_TEL.Text);
            String cel            = Validador.FormataTelAndCel(TXT_CEL.Text);
            String email          = TXT_EMAIL.Text;
            String senha          = TXT_SENHA.Text;
            String rg             = Validador.FormataCpfAndRg(TXT_RG.Text);
            String datanascimento = TXT_DATE.Value.ToString("yyyy-MM-dd HH:mm:ss");

            String nivel = null;
            String sexo  = null;

            if (RD_ADMIN.Checked == true)
            {
                nivel = "A";
            }
            else if (RD_FUNC.Checked == true)
            {
                nivel = "B";
            }

            if (RD_FEM.Checked == true)
            {
                sexo = "f";
            }
            else if (RD_MASC.Checked == true)
            {
                sexo = "m";
            }

            cpfAnterior = Validador.FormataCpfAndRg(cpfAnterior);

            String query = "UPDATE USUARIO SET " +
                           "NOME_USER = '******', CPF_USER = '******', TEL_USER = '******', CEL_USER = '******', EMAIL_USER = '******', NIVEL_USER = '******', SEXO_USER = '******', SENHA_USER = '******', RG_USER = '******', DTNASCIMENTO_USER = '******' WHERE CPF_USER = "******"DADOS ALTERADOS COM SUCESSO");
                        new GerenUser().Show();
                        this.Hide();
                    }
                }
                catch (MySqlException ex)
                {
                    MessageBox.Show(ex.ToString());
                    System.Windows.Forms.MessageBox.Show("ERRO NA ALTERAÇÃO");
                }
            }
            else
            {
                MessageBox.Show("PREENCHA OS CAMPOS OBRIGATÓRIOS");
            }

            bd.closeConnection();
        }