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; }
private void BtnBuscar_Click(object sender, EventArgs e) { BtnCadastrar.Enabled = false; TxtCodCliente.Enabled = true; LimpaDados(); TxtCodCliente.Focus(); }
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; } } }
//............................................................................... 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(); } } } }
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); } } }