Exemple #1
0
        private void buttonCadMarca_Click(object sender, EventArgs e)
        {
            classCliente cCliente = new classCliente();

            if ((mskTelefone.Text != "(  )    -" || mskCelular.Text != "(  )    -") && txtNome.Text != "" &&
                mskCPF.Text != "   .   .   -" && mskDataNascimento.Text != "  /  /" && txtEndereco.Text != "" &&
                txtNumero.Text != "" && txtEmail.Text != "")

            {
                cCliente.NomeCliente    = txtNome.Text;
                cCliente.CPF            = mskCPF.Text;
                cCliente.DataNascimento = Convert.ToDateTime(mskDataNascimento.Text);
                cCliente.Rua            = txtEndereco.Text;
                cCliente.Numero         = Convert.ToInt32(txtNumero.Text);
                cCliente.Complemento    = txtComplemento.Text;
                cCliente.Bairro         = txtBairro.Text;
                cCliente.Cidade         = txtCidade.Text;
                cCliente.Estado         = cbEstado.SelectedItem.ToString();
                cCliente.Email          = txtEmail.Text;

                if (rbFeminino.Checked)
                {
                    cCliente.Sexo = "Feminino";
                }
                else
                {
                    cCliente.Sexo = "Masculino";
                }
                if (mskTelefone.Text != "(  )    -")
                {
                    cCliente.TelefoneResidencial = mskTelefone.Text;
                }
                else
                {
                    cCliente.TelefoneResidencial = "";
                }

                if (mskCelular.Text != "")
                {
                    cCliente.TelefoneCelular = mskCelular.Text;
                }
                else
                {
                    cCliente.TelefoneCelular = "";
                }
                if (mskRG.Text != "  .   .   -")
                {
                    cCliente.RG = mskRG.Text;
                }
                else
                {
                    cCliente.RG = "";
                }

                if (mskCEP.Text != "     -")
                {
                    cCliente.CEP = mskCEP.Text;
                }
                else
                {
                    cCliente.CEP = "";
                }

                int aux = cCliente.CadastrarCliente();
                if (aux != 0)
                {
                    MessageBox.Show(" Cliente:" + cCliente.NomeCliente + " Cadastrado com Sucesso",
                                    "Sistema Loja Cosmético", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    buttonLimparCliente_Click(this, new EventArgs());
                }
                else
                {
                    MessageBox.Show("Erro ao realizar o cadastro", "Sistema Loja Cosméticos", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            else
            {
                MessageBox.Show("Verificar campos obrigatórios.", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtNome.BackColor           = Color.LemonChiffon;
                mskCPF.BackColor            = Color.LemonChiffon;
                mskDataNascimento.BackColor = Color.LemonChiffon;
                txtEndereco.BackColor       = Color.LemonChiffon;
                txtNumero.BackColor         = Color.LemonChiffon;
                txtEmail.BackColor          = Color.LemonChiffon;
                mskCelular.BackColor        = Color.Aqua;
                mskTelefone.BackColor       = Color.Aqua;
                txtNome.Focus();
            }
        }
Exemple #2
0
        private void btCadastrar_Click(object sender, EventArgs e)
        {
            //Instanciar a classe de clientes para usar métodos e propriedades
            classCliente cCliente = new classCliente();

            //Verificar campos obrigatórios (Validando pelo menos um telefone)
            if ((mskTelefone.Text != "(  )      -" || mskCelular.Text != "(  )      -") &&
                txtNome.Text != "" && mskCpf.Text != "   .   .   -" && mskDataNasc.Text != "  /  /" &&
                txtRua.Text != "" && txtNumero.Text != "" && txtEmail.Text != "")
            {
                //Passar para as propriedades o contéudo do Formulário
                //Todos os campos que o usuário pode preencher
                cCliente.NomeCliente    = txtNome.Text;
                cCliente.CPF            = mskCpf.Text;
                cCliente.DataNascimento = Convert.ToDateTime(mskDataNasc.Text);
                cCliente.Rua            = txtRua.Text;
                cCliente.Numero         = Convert.ToInt32(txtNumero.Text);
                cCliente.Complemento    = txtComplemento.Text;
                cCliente.Bairro         = txtBairro.Text;
                cCliente.Cidade         = txtCidade.Text;
                cCliente.Estado         = cbEstado.SelectedItem.ToString(); //Combo Box
                cCliente.Email          = txtEmail.Text;

                //Radio Button
                if (rbtFeminino.Checked)
                {
                    { cCliente.Sexo = "Feminino"; }
                }
                else
                {
                    { cCliente.Sexo = "Masculino"; }


                    //Campos que são máscaras e não são obrigatórios
                    if (mskTelefone.Text != "(  )      -")
                    {
                        cCliente.TelefoneResidencial = mskTelefone.Text;
                    }
                    else
                    {
                        cCliente.TelefoneResidencial = "";
                    }

                    if (mskCelular.Text != "(  )      -")
                    {
                        cCliente.TelefoneCelular = mskCelular.Text;
                    }
                    else
                    {
                        cCliente.TelefoneCelular = "";
                    }

                    if (mskRg.Text != "  .   .   -")
                    {
                        cCliente.RG = mskRg.Text;
                    }
                    else
                    {
                        cCliente.RG = "";
                    }

                    if (mskCep.Text != "     -")
                    {
                        cCliente.CEP = mskCep.Text;
                    }
                    else
                    {
                        cCliente.CEP = "";
                    }
                }

                //Método para cadastrar da classe Cliente
                int aux = cCliente.CadastrarCliente();

                //Se deu certo = 1
                if (aux != 0)
                {
                    MessageBox.Show("Cliente: " + cCliente.NomeCliente + " Cadastrado com Sucesso.", "Sistema Loja de Cosméticos",
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                    btLimpar_Click(this, new EventArgs());
                }
                //Se deu Errado = 0
                else
                {
                    MessageBox.Show("Erro ao realizar o cadastro.", "Sistema Loja de Cosméticos",
                                    MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
            else
            {
                MessageBox.Show("Verificar campos obrigatórios.", "Atenção",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txtNome.BackColor     = Color.LemonChiffon;
                mskCpf.BackColor      = Color.LemonChiffon;
                mskDataNasc.BackColor = Color.LemonChiffon;
                txtRua.BackColor      = Color.LemonChiffon;
                txtNumero.BackColor   = Color.LemonChiffon;
                txtEmail.BackColor    = Color.LemonChiffon;
                mskCelular.BackColor  = Color.LemonChiffon;
                mskTelefone.BackColor = Color.LemonChiffon;
                txtNome.Focus();
            }
        }