Esempio n. 1
0
        private void btnGravarCadastroCliente_Click(object sender, EventArgs e)
        {
            //valida campos em branco
            if ((txtNomeCadastroCliente.Text == "") || (txtCPFCadastroCliente.Text == "") ||
                (txtTelefoneCadastroCliente.Text == "") || (txtEnderecoCadastroCliente.Text == "") ||
                (txtCidadeCadastroCliente.Text == "") || (txtBairroCadastroCliente.Text == "") ||
                (txtMaskCepCadastroCliente.Text == "") || (cboUFCadastroCliente.Text == "") ||
                (txtCelularCadastroCliente.Text == "") || (txtEmailCadastroCliente.Text == ""))
            {
                MessageBox.Show("Os campos com * são Obrigatórios", "item Novo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtNomeCadastroCliente.Focus();
            }
            else
            {
                ClnCliente ObjCliente = new ClnCliente();
                ObjCliente.Codigo      = txtCod.Text;
                ObjCliente.Bairro      = txtBairroCadastroCliente.Text;
                ObjCliente.Celular     = txtCelularCadastroCliente.Text;
                ObjCliente.Cep         = txtMaskCepCadastroCliente.Text;
                ObjCliente.Cidade      = txtCidadeCadastroCliente.Text;
                ObjCliente.Cpf         = txtCPFCadastroCliente.Text;
                ObjCliente.Email       = txtEmailCadastroCliente.Text;
                ObjCliente.Complemento = txtComplementoCadastroCliente.Text;
                ObjCliente.Endereco    = txtEnderecoCadastroCliente.Text;
                ObjCliente.Numero      = txtNumeroCadastroCliente.Text;
                ObjCliente.Nome        = txtNomeCadastroCliente.Text;
                ObjCliente.Rg          = txtRGCadastroCliente.Text;

                ObjCliente.Telefone = txtTelefoneCadastroCliente.Text;
                ObjCliente.UF       = cboUFCadastroCliente.SelectedValue.ToString();
                if (rbMasculino.Checked == true)
                {
                    ObjCliente.Genero = "M";
                }
                else if (rbFeminino.Checked == true)
                {
                    ObjCliente.Genero = "F";
                }

                ObjCliente.Gravar();

                /// else

                //    //alterar item
                ///ObjCliente.cd_Cliente = Convert.ToInt32(txtCod.Text);
                // ObjCliente.Atualizar();

                //}
                /// ObjCliente.Gravar();

                if (txtCod.Text == "")
                {
                    MessageBox.Show("Registro Inserido com sucesso", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("Registro Alteredo com sucesso", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
Esempio n. 2
0
 private void CadastroCliente_Load(object sender, EventArgs e)
 {
     // Ao Carregar o formulário
     cboUFCadastroCliente.DropDownStyle = ComboBoxStyle.DropDownList; // alterar o tipo da combo para somente a lista
     PreencherUF();
     txtCod.Enabled = false;
     lblUfCadastroCliente.Focus();
     if (txtCod.Text != "") // Se não há código no textbox código então não preenche
     {
         ClnCliente    ObjCliente = new ClnCliente();
         SqlDataReader ObjDrDados;
         ObjDrDados = ObjCliente.localizarCodigo(txtCod.Text);
         if (ObjDrDados.Read())
         {
             txtNomeCadastroCliente.Text        = ObjDrDados["Nome"].ToString();
             txtCPFCadastroCliente.Text         = ObjDrDados["Cpf"].ToString();
             txtRGCadastroCliente.Text          = ObjDrDados["Rg"].ToString();
             txtTelefoneCadastroCliente.Text    = ObjDrDados["Telefone"].ToString();
             txtCelularCadastroCliente.Text     = ObjDrDados["Celular"].ToString();
             txtEmailCadastroCliente.Text       = ObjDrDados["email"].ToString();
             txtMaskCepCadastroCliente.Text     = ObjDrDados["cep"].ToString();
             txtEnderecoCadastroCliente.Text    = ObjDrDados["endereco"].ToString();
             cboUFCadastroCliente.SelectedValue = ObjDrDados["UF"].ToString();
             txtNumeroCadastroCliente.Text      = ObjDrDados["Numero"].ToString();
             txtComplementoCadastroCliente.Text = ObjDrDados["Complemento"].ToString();
             txtBairroCadastroCliente.Text      = ObjDrDados["bairro"].ToString();
             txtCidadeCadastroCliente.Text      = ObjDrDados["cidade"].ToString();
         }
     }
     lblNomeCadastroCliente.Focus();
 }
Esempio n. 3
0
        public void CarregarDataGrid()
        {
            ClnCliente ObjCliente = new ClnCliente();

            string campo_Sql = "cd_cliente";

            if (cboTipoPesquisa.SelectedIndex == 0)
            {
                campo_Sql = "cd_cliente";
            }
            else if (cboTipoPesquisa.SelectedIndex == 1)
            {
                campo_Sql = "Nome";
            }
            else if (cboTipoPesquisa.SelectedIndex == 2)
            {
                campo_Sql = "Cpf";
            }
            else if (cboTipoPesquisa.SelectedIndex == 3)
            {
                campo_Sql = "Rg";
            }
            else if (cboTipoPesquisa.SelectedIndex == 3)
            {
                campo_Sql = "Telefone";
            }
            else if (cboTipoPesquisa.SelectedIndex == 3)
            {
                campo_Sql = "Celular";
            }
            DataTable dados = ObjCliente.LocalizarPorCampo(txtBuscaCliente.Text, campo_Sql);

            if (dados.Rows.Count == 0)
            {
                MessageBox.Show("A pesquisa não retornou dados", "PESQUISA", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }


            //Método Listar que passa o parâmetro do texto digitado para o grid
            dgvBuscaCliente.DataSource = dados;
            //Cria os cabeçalhos de cada coluna
            dgvBuscaCliente.Columns[1].HeaderText = ("Código"); //Nome do cabeçalho das colunas
            dgvBuscaCliente.Columns[2].HeaderText = ("Nome");
            dgvBuscaCliente.Columns[3].HeaderText = ("Cpf");
            dgvBuscaCliente.Columns[4].HeaderText = ("Rg");
            dgvBuscaCliente.Columns[5].HeaderText = ("TELEFONE");
            dgvBuscaCliente.Columns[6].HeaderText = ("CELULAR");
            dgvBuscaCliente.Columns[7].HeaderText = ("E-MAIL");
            dgvBuscaCliente.AutoResizeColumns();
        }
Esempio n. 4
0
        private void btnExcluirBuscaCliente_Click(object sender, EventArgs e)
        {
            ClnCliente ObjCliente = new ClnCliente();


            DialogResult result = MessageBox.Show("Deseja excluir o registro:" + Convert.ToString(dgvBuscaCliente.CurrentRow.Cells[0].Value + "?")
                                                  , "Exclusão", MessageBoxButtons.YesNo, MessageBoxIcon.Information);

            //Exclusão Logica, sera "escondido"no BD
            if (DialogResult.Yes == result)
            {
                //Enviar o código
                ObjCliente.Codigo = dgvBuscaCliente.CurrentRow.Cells[0].Value.ToString();
                //Alterar o estado para não mostar o codigo
                ObjCliente.ExcluirLogicamente();
                MessageBox.Show("Registro excluido com sucesso", "Exclusão", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("OPERAÇÃO CANCELADA", "CANCELADA EXCLUSÃO", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            //Preencher/ atualizar os dados no grid
            CarregarDataGrid();
        }