Exemple #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            try {
                string tipoConta   = (string)comboConta.SelectedItem;
                string rua         = textoRua.Text;
                int    numero      = Convert.ToInt32(textoNumero.Text);
                string bairro      = textoBairro.Text;
                int    cep         = Convert.ToInt32(textoCep.Text);
                string complemento = textoComplemento.Text;
                string cidade      = textoCidade.Text;
                string estado      = textoEstado.Text;
                bool   cadastrado  = false;

                Endereco endereco = new Endereco(rua, numero, bairro, cep, complemento, cidade, estado);

                foreach (Usuario user in formPrincipal.usuarios)
                {
                    if (textoEmail.Text == user.Email)
                    {
                        cadastrado = true;
                    }
                }

                if (tipoConta == "Cliente" && !cadastrado)
                {
                    Cliente cliente = new Cliente();

                    cliente.Nome     = textoNome.Text;
                    cliente.Cpf      = textoCpf.Text;
                    cliente.Email    = textoEmail.Text;
                    cliente.Telefone = textoTelefone.Text;
                    cliente.Senha    = textoSenha.Text;
                    cliente.Endereco = endereco;

                    this.formPrincipal.usuarios.Add(cliente);
                }
                else if (tipoConta == "Lojista" && !cadastrado)
                {
                    Logista cliente = new Logista();

                    cliente.Nome     = textoNome.Text;
                    cliente.Cpf      = textoCpf.Text;
                    cliente.Email    = textoEmail.Text;
                    cliente.Telefone = textoTelefone.Text;
                    cliente.Senha    = textoSenha.Text;
                    cliente.Endereco = endereco;

                    this.formPrincipal.usuarios.Add(cliente);
                }

                if (cadastrado)
                {
                    MessageBox.Show("Usuario já cadastrado");
                }
                else
                {
                    MessageBox.Show("Conta Cadastrada com Sucesso");
                    this.Hide();
                }
            } catch (Exception) {
                MessageBox.Show("Preencha os campos corretamente");
            }
        }
Exemple #2
0
 public FormLogista(Usuario u, Form1 form)
 {
     logista       = (Logista)u;
     formPrincipal = form;
     InitializeComponent();
 }
 public FormCadastroEstabelecimento(Logista logista)
 {
     this.logista = logista;
     InitializeComponent();
 }