예제 #1
0
        private void buttonAtualizarMarca_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.Text;
                cCliente.Email          = txtEmail.Text;
                if (checkboxStatus.Checked == true)
                {
                    cCliente.Status = 1;
                }

                else
                {
                    cCliente.Status = 0;
                }

                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 = "";
                }

                cCliente.CodigoCliente = Convert.ToInt32(txtCodCliente.Text);
                bool aux = cCliente.AtualizarCliente();
                if (aux)
                {
                    MessageBox.Show("Cliente: " + cCliente.NomeCliente + " atualizado com sucesso.", "Sistema Loja Cosméticos", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close(); // fecha form
                }

                else
                {
                    MessageBox.Show("Erro ao atualizar o Cliente " + cCliente.NomeCliente, " Sistema Loja Cosméticos", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
                }
            }
        }
예제 #2
0
        private void btAtualizar_Click(object sender, EventArgs e)
        {
            classCliente cCliente = new classCliente();

            //VERIFICAR CAMPOS OBRIGATÓRIOS
            if (txtNome.Text != "" && mskCpf.Text != "   .   .   -" && mskDataNasc.Text != "  /  /" && txtRua.Text != "" && txtNumero.Text != "" &&
                txtEmail.Text != "")
            {
                //PASSAR PARA AS PROPRIEDADES O CONTEÚDO DO FORMULÁRIO
                //TODOS OS CAMPOS QUE O USUÁRIO VAI PREENCHER
                cCliente.NomeCliente    = txtNome.Text;
                cCliente.RG             = mskRg.Text;
                cCliente.CPF            = mskCpf.Text;
                cCliente.DataNascimento = Convert.ToDateTime(mskDataNasc.Text);

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

                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();
                cCliente.CEP         = mskCep.Text;
                cCliente.Email       = txtEmail.Text;

                if (mskTelefone.Text != "(  )     -")
                {
                    cCliente.TelefoneResidencial = mskTelefone.Text;
                }
                else
                {
                    cCliente.TelefoneResidencial = "";
                }

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

                if (ckStatus.Checked == true)
                {
                    cCliente.Status = 1;
                }
                else
                {
                    cCliente.Status = 0;
                }

                cCliente.CodigoCliente = Convert.ToInt32(txtCodigoCliente.Text);

                bool aux = cCliente.AtualizarCliente();

                if (aux)
                {
                    MessageBox.Show(" Cliente: " + cCliente.NomeCliente + " Atualizado com Sucesso.",
                                    "Sistema Loja de Cosméticos", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Erro ao atualizar.", "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;
                txtNome.Focus();
            }
        }