private void btnDelete(object sender, RoutedEventArgs e) { var alerta = new Alerta(1); alerta.conteudo.Content = "Tem certeza que deseja deletar?"; alerta.ShowDialog(); if (alerta.yes) { Cliente cl = dataGrid1.SelectedItem as Cliente; DAOCliente delete = new DAOCliente(); delete.deletar(cl.Id); List <Cliente> c = delete.getTodos(); dataGrid1.ItemsSource = c; } }
//Botao Deletar private void btnDeletar(object sender, RoutedEventArgs e) { var alerta = new Alerta(1); alerta.conteudo.Content = "Tem certeza que deseja deletar?"; alerta.ShowDialog(); if (alerta.yes) { Servico sl = dataGrid1.SelectedItem as Servico; DAOServico delete = new DAOServico(); delete.deletar(sl.Id); List <Servico> c = delete.getTodos(); dataGrid1.ItemsSource = c; } }
//Botao Deletar private void btnDeletar(object sender, RoutedEventArgs e) { var alerta = new Alerta(1); alerta.conteudo.Content = "Tem certeza que deseja deletar?"; alerta.ShowDialog(); if (alerta.yes) { Peca pl = dataGrid1.SelectedItem as Peca; DAOPeca delete = new DAOPeca(); delete.deletar(pl.CodPec); List <Peca> c = delete.getTodos(); dataGrid1.ItemsSource = c; } }
private void btnSalvar(object sender, RoutedEventArgs e) { Peca novaPeca = new Peca(); string nome = textNomePec.Text.Trim(); int quantidade = int.Parse(textQtdePec.Text); double teste = 1000.22; Console.WriteLine("Valor teste" + teste); double valor = double.Parse(textValorPec.Text.Replace("$", "").Replace(",", ""), CultureInfo.InvariantCulture); Console.WriteLine("Valor alterado" + valor); if (isName(nome) && isValue(textValorPec.Text)) { novaPeca.NomePec = nome; novaPeca.QtdePeca = quantidade; novaPeca.ValPec = valor; DAOPeca peca = new DAOPeca(); peca.inserir(novaPeca); var alerta = new Alerta(); alerta.conteudo.Content = "Peça cadastrada com sucesso"; alerta.ShowDialog(); var telaListarPeca = new ListarPecas(); this.Close(); telaListarPeca.Show(); } else { if (!isName(nome)) { lblNomeIncorreto.Visibility = Visibility.Visible; } if (!isValue(textValorPec.Text)) { lblValorIncorreto.Visibility = Visibility.Visible; } var alerta = new Alerta(); alerta.conteudo.Content = "Preencha os campos corretamente!"; alerta.ShowDialog(); } }
// Botao de salvar serviço private void btnSalvar(object sender, RoutedEventArgs e) { Servico novoServico = new Servico(); if (isName(textNomeServico.Text) && isValue(textValor.Text)) { novoServico.NomeServico = textNomeServico.Text; novoServico.Valor = double.Parse(textValor.Text.Replace("$", "").Replace(",", ""), CultureInfo.InvariantCulture); DAOServico servico = new DAOServico(); servico.editar(novoServico, id); var alerta = new Alerta(); alerta.conteudo.Content = "Serviço editado com sucesso"; alerta.ShowDialog(); var telaListaServico = new ListarServico(); this.Close(); telaListaServico.Show(); } else { if (!isName(textNomeServico.Text)) { lblNomeIncorreto.Visibility = Visibility.Visible; } if (!isValue(textValor.Text)) { lblValorIncorreto.Visibility = Visibility.Visible; } var alerta = new Alerta(); alerta.conteudo.Content = "Preencha os campos corretamente!"; alerta.ShowDialog(); } }
private void btnSalvar(object sender, RoutedEventArgs e) { Cliente novoCliente = new Cliente(); string nome = textNome.Text.Trim(); string email = textEmail.Text; string cpf = textCpf.Text.Replace(".", "").Replace("-", "").Replace("_", ""); string telefone = textTelefone.Text.Replace("_", "").Replace("(", "").Replace(")", "").Replace("-", ""); string endereco = textEndereco.Text; string obs = textObservacao.Text; //Usado o método Convert.ToBoolean pois o WPF o metodo IsChecked é "bool?" //Verificando qual radioButton está selecionado para definir o CPF ou CNPJ if (Convert.ToBoolean(radioCPF.IsChecked)) { if (isName(nome) && IsValidTel(telefone) && IsValidEmailAddress(email) && IsCpf(cpf)) { novoCliente.Nome = nome; novoCliente.Email = email; novoCliente.Cpf = cpf; novoCliente.Telefone = telefone; novoCliente.Endereco = endereco; novoCliente.Observacao = obs; DAOCliente cliente = new DAOCliente(); cliente.inserir(novoCliente); var alerta = new Alerta(); alerta.conteudo.Content = "Cliente cadastrado com sucesso"; alerta.ShowDialog(); var telaListarClientes = new ListarClientes(); this.Close(); telaListarClientes.Show(); } else { var alerta = new Alerta(); alerta.conteudo.Content = "Preencha os campos corretamente!"; alerta.ShowDialog(); } } else { if (isName(nome) && IsValidTel(telefone) && IsValidEmailAddress(email) && IsCnpj(textCNPJ.Text.Replace(".", "").Replace("-", "").Replace("/", "").Replace("_", ""))) { novoCliente.Nome = nome; novoCliente.Email = email; novoCliente.Cpf = textCNPJ.Text.Replace(".", "").Replace("-", "").Replace("/", "").Replace("_", ""); novoCliente.Telefone = telefone; novoCliente.Endereco = endereco; novoCliente.Observacao = obs; DAOCliente cliente = new DAOCliente(); cliente.inserir(novoCliente); var alerta = new Alerta(); alerta.conteudo.Content = "Cliente cadastrado com sucesso"; alerta.ShowDialog(); var telaListarClientes = new ListarClientes(); this.Close(); telaListarClientes.Show(); } else { var alerta = new Alerta(); alerta.conteudo.Content = "Preencha os campos corretamente!"; alerta.ShowDialog(); } } }