Beispiel #1
0
        private void btcadastro_Click(object sender, EventArgs e)
        {
            // instanciando a classe cliente para usar as propriedades

            classcliente ccliente = new classcliente();

            // verificando condicao dos Campos

            if (txtnome.Text != "" && mtxdatanascimento.Text != "" && mtxcpf.Text != "" && mtxtelefone.Text != "" && mtxcelular.Text != "" && txbairro.Text != "" && txrua.Text != "" && txnumero.Text != "" && cestado.Text != "" && tbcidade.Text != "")
            {
                // atribuindo os nome da caixinhas a propriedade que esta no objeto
                ccliente.nome           = txtnome.Text;
                ccliente.datanascimento = Convert.ToDateTime(mtxdatanascimento.Text);
                ccliente.cpf            = mtxcpf.Text;
                ccliente.telefone       = mtxtelefone.Text;
                ccliente.celular        = mtxcelular.Text;
                ccliente.bairro         = txbairro.Text;
                ccliente.rua            = txrua.Text;
                ccliente.estado         = cestado.Text;
                ccliente.cidade         = tbcidade.Text;
                ccliente.numerocasa     = Convert.ToInt32(txnumero.Text);

                // checa o sexo "F" ou "M"

                if (rbfemenino.Checked)
                {
                    ccliente.sexo = "F";
                }
                else
                {
                    ccliente.sexo = "M";
                }

                // checa os campos celular e telefone

                if (mtxcelular.Text != "() -")
                {
                    ccliente.celular = tbcelular.Text;
                }
                else
                {
                    ccliente.celular = "";
                }

                if (mtxtelefone.Text != "() -")
                {
                    ccliente.telefone = mtxtelefone.Text;
                }
                else
                {
                    ccliente.telefone = "";
                }



                // metodo para cadastro de cliente

                int chm = ccliente.cadastracliente();

                // se a resposta retornar = 1

                if (chm != 0)
                {
                    MessageBox.Show("Cliente " + ccliente.nome + " Cadastrado Com Sucesso ", "Sistema MasterSports", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    btlimpar_Click(this, new EventArgs());
                }

                else

                // se a resposta for retornar = 0
                {
                    MessageBox.Show("Erro ao Realizar o Cadastro", "Sistema MasterSports", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }

            else
            {
                MessageBox.Show("Verificar os Campos Obrigatorios", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txtnome.BackColor           = Color.LemonChiffon;
                mtxdatanascimento.BackColor = Color.LemonChiffon;
                mtxcpf.BackColor            = Color.LemonChiffon;
                mtxtelefone.BackColor       = Color.LemonChiffon;
                mtxcelular.BackColor        = Color.LemonChiffon;
                txbairro.BackColor          = Color.LemonChiffon;
                txrua.BackColor             = Color.LemonChiffon;
                txnumero.BackColor          = Color.LemonChiffon;
                tbcidade.BackColor          = Color.LemonChiffon;
                tbnome.Focus();
            }
        }