コード例 #1
0
        private void BtnLogin_Click(object sender, RoutedEventArgs e)
        {
            HomeEmpresa home;
            Empresa     empresa;
            string      senha = txtSenha.Password.ToString();

            empresa = EmpresaDAO.FindCompanyByEmail(txtEmail.Text);

            if (empresa != null)
            {
                if (empresa.Senha == senha)
                {
                    home = new HomeEmpresa(empresa);
                    home.Show();
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Senha incorreta");
                }
            }
            else
            {
                MessageBox.Show("Email incorreto");
            }
        }
コード例 #2
0
        private void BtnCadastrarEmpresa_Click(object sender, RoutedEventArgs e)
        {
            Empresa     empresa = new Empresa();
            HomeEmpresa home;

            if (Validacoes.ValidaCNPJ(txtCNPJ.Text))
            {
                empresa.CNPJ = txtCNPJ.Text;

                if (Validacoes.ValidaNome(txtRazao.Text))
                {
                    empresa.Razao = txtRazao.Text;

                    if (Validacoes.ValidaEmail(txtEmail.Text))
                    {
                        empresa.Email = txtEmail.Text;

                        if (Validacoes.ValidaTelefone(txtTelefone.Text))
                        {
                            empresa.Telefone = txtTelefone.Text;

                            if (Validacoes.ValidaSenha(txtSenha.Password.ToString()))
                            {
                                empresa.Senha       = txtSenha.Password.ToString();
                                empresa.Responsavel = txtResponsavel.Text;
                                EmpresaDAO.RegisterCompany(empresa);
                                MessageBox.Show(empresa.Razao + " cadastrada com sucesso!");

                                home = new HomeEmpresa(empresa);
                                home.Show();
                                this.Close();
                            }
                            else
                            {
                                MessageBox.Show("Senha inválida!");
                            }
                        }
                        else
                        {
                            MessageBox.Show("Telefone inválido!");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Email inválido!");
                    }
                }
                else
                {
                    MessageBox.Show("Nome inválido!");
                }
            }
            else
            {
                MessageBox.Show("CNPJ inválido!");
            }
        }