Beispiel #1
0
        private void BtnDeletar_Click_1(object sender, EventArgs e)
        {
            if (TxtCodCliente.Text == "")
            {
                MessageBox.Show("Favor Digitar Código Cliente!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                try
                {
                    conn.Open();
                    SqlCommand comando = new SqlCommand(@"DELETE FROM CLIENTES  where (Id_Cliente='" + TxtCodCliente.Text + "')", conn)
                    {
                        CommandType = CommandType.Text
                    };
                    comando.ExecuteNonQuery();
                    TxtCodCliente.Clear();
                    MessageBox.Show("Cliente Excluído com Sucesso!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }

                catch
                {
                    MessageBox.Show("Erro ao Excluir Cliente", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            conn.Close();
            LimpaDados();
            BtnCadastrar.Enabled  = true;
            BtnAlterar.Enabled    = false;
            BtnDeletar.Enabled    = false;
            TxtCodCliente.Enabled = false;
            TxtNome.Focus();
        }
Beispiel #2
0
 private void BtnAlterar_Click_1(object sender, EventArgs e)
 {
     if (TxtCodCliente.Text == "")
     {
         MessageBox.Show("Digite um Código Válido!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Error);
         TxtCodCliente.Focus();
     }
     else
     {
         try
         {
             conn.Open();
             SqlCommand comando = new SqlCommand(@"UPDATE CLIENTES SET Nome='" + TxtNome.Text + "',Sexo='" + CboSexo.Text + "',Endereco='" + TxtEndereco.Text + "',Bairro='" + TxtBairro.Text + "',Cidade='" + TxtCidade.Text + "',Cep='" + MktCep.Text + "',Estado='" + CmbEstado.Text + "',FoneFixo='" + MktFoneFixo.Text + "',FoneComercial='" + MkFoneComercial.Text + "',Celular='" + MktCelular.Text + "',Rg='" + TxtRG.Text + "',Email='" + TxtEmail.Text + "',CPF='" + MktCPF.Text + "',DataNascimento='" + dataNasc.Value.ToString("dd/MM/yyyy") + "'  where (Id_Cliente='" + TxtCodCliente.Text + "')", conn)
             {
                 CommandType = CommandType.Text
             };
             comando.ExecuteNonQuery();
             LimpaDados();
             CboCadPor.Enabled = true;
             MessageBox.Show("Cliente Atualizado Com Sucesso!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         catch
         {
             MessageBox.Show("Erro ao Atualizar Cliente!", "SIG", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     conn.Close();
     LimpaDados();
     TxtCodCliente.Enabled = false;
     BtnCadastrar.Enabled  = true;
     BtnAlterar.Enabled    = false;
     BtnDeletar.Enabled    = false;
     TxtNome.Focus();
     CboCadPor.Enabled = true;
 }
Beispiel #3
0
 private void BtnBuscar_Click(object sender, EventArgs e)
 {
     BtnCadastrar.Enabled  = false;
     TxtCodCliente.Enabled = true;
     LimpaDados();
     TxtCodCliente.Focus();
 }
Beispiel #4
0
        private void TxtCodCliente_Leave(object sender, EventArgs e)
        {
            //.................................................................................
            if (TxtCodCliente.Text.Trim() != "")
            {
                int ClienteDoBayer;
                if (int.TryParse(TxtCodCliente.Text, out ClienteDoBayer))
                {
                    Cliente oCliente = _Control.SelecionarCliente(ClienteDoBayer);
                    if (oCliente != null)
                    {
                        CarregaCliente(oCliente);
                    }
                    else
                    {
                        MessageBox.Show("O codigo do cliente nao é valido");
                        TxtCodCliente.Focus();
                    }
                }
            }

            //.......................................................................................
            if (TxtCodCliente.Text.Trim() != "")
            {
                int Codigo;
                if (int.TryParse(TxtCodCliente.Text, out Codigo))
                {
                    Pet oPet = _Control.SelecionarPet(Codigo);
                    if (oPet != null)
                    {
                        TxtNomeAnimal.Text = oPet.Pnome;
                        TxtEspecie.Text    = oPet.Pespecie;
                        TxtCor.Text        = oPet.Pcor;
                        TxtCodCliente.Text = oPet.Pcodigo.ToString();
                        TxtInformaçao.Text = oPet.Pinfo;
                        BtnIncluir.Enabled = true;
                        BtnAlterar.Enabled = true;
                        BtnExcluir.Enabled = true;
                        Incluir            = true;
                    }
                    else
                    {
                        // permite a inclusao
                        LimpaControles();
                        BtnIncluir.Enabled = true;
                        BtnAlterar.Enabled = true;
                        BtnExcluir.Enabled = false;
                        Incluir            = true;
                    }
                }
                else
                {
                    LimpaControles();
                    BtnIncluir.Enabled = false;
                    BtnAlterar.Enabled = false;
                    BtnExcluir.Enabled = false;
                }
            }
        }
Beispiel #5
0
 public void LimpaVenda()
 {
     TxtCodVenda.Clear();
     TxtNome.Clear();
     TxtCodCliente.Clear();
     CboFormaPag.Text = "Selecione";
     dataGridView1.Rows.Clear();
     listBox1.Enabled      = false;
     listBox2.Enabled      = false;
     CboFormaPag.Enabled   = false;
     TxtQtde.Enabled       = false;
     BtnAddProduto.Enabled = false;
     BtnRemoveItem.Enabled = false;
     LblValorTotal.Text    = "";
     listBox1.Items.Clear();
     listBox2.Items.Clear();
     BtnFimCompra.Enabled = false;
 }
Beispiel #6
0
 public void LimpaDados()
 {
     TxtCodCliente.Clear();
     TxtNome.Clear();
     CboSexo.Text = "Selecione";
     TxtEndereco.Clear();
     TxtBairro.Clear();
     TxtCidade.Clear();
     MktCep.Clear();
     CmbEstado.Text = "Selecione";
     MktFoneFixo.Clear();
     MkFoneComercial.Clear();
     MktCelular.Clear();
     TxtRG.Clear();
     TxtEmail.Clear();
     MktCPF.Clear();
     dataNasc.Text     = "";
     CboCadPor.Text    = "Selecione";
     CboCadPor.Enabled = true;
 }
Beispiel #7
0
        //...............................................................................
        private void TxtCodCliente_Leave(object sender, EventArgs e)

        {
            if (TxtCodCliente.Text.Trim() != "")
            {
                int ClienteDoBayer;
                if (int.TryParse(TxtCodCliente.Text, out ClienteDoBayer))
                {
                    Cliente oCliente = _Control.SelecionarCliente(ClienteDoBayer);
                    if (oCliente != null)
                    {
                        CarregaCliente(oCliente);
                    }
                    else
                    {
                        MessageBox.Show("O codigo do cliente nao é valido");
                        TxtCodCliente.Focus();
                    }
                }
            }
        }
Beispiel #8
0
 private void BtnExcluir_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Se confirmar será impossível recuperar o pet. Deseja continuar?", ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
     {
         Pet oPet = new Pet();
         oPet.Pcodigo = TxtCodCliente.TextLength;
         try
         {
             _Control.ExcluirPet(oPet);
             LimpaControles();
             TxtCodCliente.Text = "";
             TxtCodCliente.Focus();
             Incluir = true;
             MessageBox.Show("Pet excluído com sucesso.");
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
     }
 }