コード例 #1
0
ファイル: Login.cs プロジェクト: rafaelferreira1951/POO
        private void Button2_Click(object sender, EventArgs e)
        {
            String nome  = txtNomeUser.Text;
            String senha = txtSenha.Text;
            String tipo  = logarcomo.Text;

            if (nome == "" || senha == "" || tipo == "")
            {
                MessageBox.Show("Por favor preencha todos os Campos!");
                txtNomeUser.Focus();
            }
            else
            {
                if (tipo.Equals("Cliente"))
                {
                    Principal principal = new Principal();

                    cliente client = new cliente();

                    if (client.Login(nome, senha))
                    {
                        MessageBox.Show("CLIENTE: LOGADO COM SUCESSO");
                        Principal p = new Principal();
                        p.Show();
                        this.Hide();
                    }
                    else
                    {
                        MessageBox.Show("Houve um erro ao logar!!");
                    }
                }
                else if (tipo.Equals("MotoBoy"))
                {
                    TelaMotoboy tlmotoboy = new TelaMotoboy();

                    motoboy mot = new motoboy();

                    if (mot.Login(nome, senha))
                    {
                        MessageBox.Show("MOTOBOY: LOGADO COM SUCESSO");
                        //TelaMotoboy tlmotoboy = new TelaMotoboy();
                        tlmotoboy.Show();
                        this.Hide();
                    }
                    else
                    {
                        MessageBox.Show("Houve um erro ao logar!!");
                    }
                }
                else
                {
                    MessageBox.Show("Verifique o tipo de conta");
                }
            }
        }
コード例 #2
0
        private void BtnCadastrar_Click(object sender, EventArgs e)
        {
            TelaMotoboy tmb         = new TelaMotoboy();
            String      nome        = txtNome.Text;
            String      nomeUsuario = txtNomeUser.Text;
            String      senha       = txtSenha.Text;
            String      rg          = txtRG.Text;
            String      cnh         = txtCNH.Text;
            String      email       = txtEmail.Text;
            String      tel         = txtTel.Text;
            String      cel         = txtCel.Text;

            if (nome == "" || nomeUsuario == "" || senha == "" || rg == "" || cnh == "" || email == "" || tel == "" || cel == "")
            {
                MessageBox.Show("Por favor preencha todos os Campos!");
            }
            else
            {
                MessageBox.Show("Cadastrado Com Sucesso!");

                connection = Conexao.GetConnection();
                connection.Open();
                MySqlCommand inserir = new MySqlCommand("INSERT INTO motoboy (email, usuario, senha, rg, cnh, telefone, celular, nome) VALUES (@email, @User, @Pass, @rg, @cnh, @tel, @cel, @nome) ", connection);
                inserir.Parameters.AddWithValue("@email", email);
                inserir.Parameters.AddWithValue("@User", nomeUsuario);
                inserir.Parameters.AddWithValue("@Pass", senha);
                inserir.Parameters.AddWithValue("@rg", rg);
                inserir.Parameters.AddWithValue("@cnh", cnh);
                inserir.Parameters.AddWithValue("@tel", tel);
                inserir.Parameters.AddWithValue("@cel", cel);
                inserir.Parameters.AddWithValue("@nome", nome);
                inserir.ExecuteNonQuery();
                Session.Logar(nomeUsuario, senha, "Motoboy");
                this.Hide();
                tmb.ShowDialog();
                connection.Close();
            }
        }