示例#1
0
        public bool VerCliente(Cadastro_FuncionarioM cad)        //Verifica se CPF ja esta cadastrado no banco de dados
        {
            if (!Con.Checkconection())
            {
                Con.Conectar();
            }

            if (Con.Checkconection())
            {
                DataTable        table   = new DataTable();
                MySqlDataAdapter adapter = new MySqlDataAdapter();
                MySqlCommand     command = new MySqlCommand("SELECT * FROM cliente WHERE CPF = @cpf", Con.Traz_Conexao());
                command.Parameters.Add("@cpf", MySqlDbType.VarChar).Value = cad.GetCPF();
                adapter.SelectCommand = command;
                adapter.Fill(table);

                //Verifica se há uma lina no banco com esse Cliente"CPF".
                if (table.Rows.Count > 0)
                {
                    Cliente_Exists = true;
                }

                Con.Desconectar();
            }

            return(Cliente_Exists);
        }
示例#2
0
        public void CadastraCliente(Cadastro_FuncionarioM cad)
        {
            if (!Con.Checkconection())
            {
                Con.Conectar();
            }

            if (Con.Checkconection())
            {
                MySqlDataAdapter adapter = new MySqlDataAdapter();
                MySqlCommand     command = new MySqlCommand("INSERT INTO cliente (NOME, CPF, END) VALUES (@nome, @cpf, @end)", Con.Traz_Conexao());
                command.Parameters.Add("@nome", MySqlDbType.VarChar, 80).Value = cad.GetNome();
                command.Parameters.Add("@cpf", MySqlDbType.VarChar, 11).Value  = cad.GetCPF();
                command.Parameters.Add("@end", MySqlDbType.VarChar, 80).Value  = cad.GetEnd();
                command.ExecuteNonQuery();

                Con.Desconectar();
            }
        }