private void button1_Click(object sender, EventArgs e) { if (txtConfirmarSenha.Text != txtSenha.Text) { MessageBox.Show("Senha diferentes!"); return; } Funcionario funcionario = new Funcionario(); funcionario.CPF = txtCpf.Text; funcionario.DataNascimento = dtpDataNascimento.Value; funcionario.Email = txtEmail.Text; funcionario.Nome = txtNome.Text; funcionario.Senha = txtSenha.Text; funcionario.Telefone = txtTelefone.Text; Response response = funcionarioBLL.Insert(funcionario); if (response.Sucesso) { MessageBox.Show("Cadastrado com sucesso!"); dataGridView1.DataSource = funcionarioBLL.GetFuncionarios().Data; } else { MessageBox.Show(response.GetErrorMessage()); } }
// Adiciona um funcionário private void btnAdiciona_Click(object sender, EventArgs e) { try { Funcionario funcionario = new Funcionario(); funcionario.Nome = txtNome.Text; funcionario.CPF = txtCPF.Text; funcionario.RG = txtRG.Text; funcionario.Email = txtEmail.Text; funcionario.Senha = txtSenha.Text; funcionario.Cargo = (CargosFuncionarios)cbCargo.SelectedIndex; funcionario.Rua = txtRua.Text; funcionario.Bairro = txtBairro.Text; funcionario.NumeroCasa = int.Parse(txtNumeroCasa.Text); funcionario.IsADM = cbAdministrador.Checked; Response response = funcionarioBLL.Insert(funcionario); MessageBox.Show(response.Message); if (response.Success) { UpdateGridView(); FerramentasTextBox.LimpaTextBoxes(this); } } catch (FormatException) { MessageBox.Show("Existem valores inválidos!"); } }
public ActionResult Create(Funcionario funcionario, Usuario usuario) { try { if (!ModelState.IsValid) { return(View(funcionario)); } _funcionarioBll.Insert(funcionario); TempData["Success"] = "Adicionado com sucesso!"; return(RedirectToAction("Create", "Usuario")); } catch (Exception ex) { TempData["Error"] = ex.Message; return(View(funcionario)); } }
public static void DefineType(Object obj, string command) { try { if (obj != null) { string nome = obj.GetType().FullName.ToLower(); if (nome.Trim().ToLower().Contains("cliente")) { Cliente cliente = new Cliente(); cliente = (Cliente)obj; ClienteBLL clienteBLL = new ClienteBLL(); switch (command.ToUpper()[0]) { case 'A': clienteBLL.Update(cliente); System.Windows.Forms.MessageBox.Show("O registro foi atualizado com sucesso!"); break; case 'D': clienteBLL.Delete(cliente); System.Windows.Forms.MessageBox.Show("O registro foi deletado com sucesso!"); break; case 'I': clienteBLL.Insert(cliente); System.Windows.Forms.MessageBox.Show("O registro foi inserido com sucesso!"); break; default: break; } } else if (nome.Trim().ToLower().Contains("fornecedor")) { Fornecedor fornecedor = new Fornecedor(); fornecedor = (Fornecedor)obj; FornecedorBLL fornecedorBLL = new FornecedorBLL(); switch (command.ToUpper()[0]) { case 'A': fornecedorBLL.Update(fornecedor); System.Windows.Forms.MessageBox.Show("O registro foi atualizado com sucesso!"); break; case 'D': fornecedorBLL.Delete(fornecedor); System.Windows.Forms.MessageBox.Show("O registro foi deletado com sucesso!"); break; case 'I': fornecedorBLL.Insert(fornecedor); System.Windows.Forms.MessageBox.Show("O registro foi inserido com sucesso!"); break; default: break; } } else if (nome.Trim().ToLower().Contains("funcionario")) { Funcionario funcionario = new Funcionario(); funcionario = (Funcionario)obj; FuncionarioBLL funcionarioBLL = new FuncionarioBLL(); switch (command.ToUpper()[0]) { case 'A': funcionarioBLL.Update(funcionario); System.Windows.Forms.MessageBox.Show("O registro foi atualizado com sucesso!"); break; case 'D': funcionarioBLL.Delete(funcionario); System.Windows.Forms.MessageBox.Show("O registro foi deletado com sucesso!"); break; case 'I': funcionarioBLL.Insert(funcionario); System.Windows.Forms.MessageBox.Show("O registro foi inserido com sucesso!"); break; default: break; } } else if (nome.Trim().ToLower().Contains("produto")) { Produto produto = new Produto(); produto = (Produto)obj; ProdutoBLL produtoBLL = new ProdutoBLL(); switch (command.ToUpper()[0]) { case 'A': produtoBLL.Update(produto); System.Windows.Forms.MessageBox.Show("O registro foi atualizado com sucesso!"); break; case 'D': produtoBLL.Delete(produto); System.Windows.Forms.MessageBox.Show("O registro foi deletado com sucesso!"); break; case 'I': produtoBLL.Insert(produto); System.Windows.Forms.MessageBox.Show("O registro foi inserido com sucesso!"); break; default: break; } } else if (nome.Trim().ToLower().Contains("itemVenda")) { ItemVenda itemVenda = new ItemVenda(); itemVenda = (ItemVenda)obj; ItemVendaBLL itemVendaBLL = new ItemVendaBLL(); switch (command.ToUpper()[0]) { case 'A': itemVendaBLL.Update(itemVenda); System.Windows.Forms.MessageBox.Show("O registro foi atualizado com sucesso!"); break; case 'D': itemVendaBLL.Delete(itemVenda); System.Windows.Forms.MessageBox.Show("O registro foi deletado com sucesso!"); break; case 'I': itemVendaBLL.Insert(itemVenda); System.Windows.Forms.MessageBox.Show("O registro foi inserido com sucesso!"); break; default: break; } } else if (nome.Trim().ToLower().Contains("itemEntrada")) { ItemEntrada itemEntrada = new ItemEntrada(); itemEntrada = (ItemEntrada)obj; ItemEntradaBLL itemEntradaBLL = new ItemEntradaBLL(); switch (command.ToUpper()[0]) { case 'A': itemEntradaBLL.Update(itemEntrada); System.Windows.Forms.MessageBox.Show("O registro foi atualizado com sucesso!"); break; case 'D': itemEntradaBLL.Delete(itemEntrada); System.Windows.Forms.MessageBox.Show("O registro foi deletado com sucesso!"); break; case 'I': itemEntradaBLL.Insert(itemEntrada); System.Windows.Forms.MessageBox.Show("O registro foi inserido com sucesso!"); break; default: break; } } else if (nome.Trim().ToLower().Contains("entrada")) { Entrada entrada = new Entrada(); entrada = (Entrada)obj; EntradaBLL entradaBLL = new EntradaBLL(); switch (command.ToUpper()[0]) { case 'A': entradaBLL.Update(entrada); System.Windows.Forms.MessageBox.Show("O registro foi atualizado com sucesso!"); break; case 'D': entradaBLL.Delete(entrada); System.Windows.Forms.MessageBox.Show("O registro foi deletado com sucesso!"); break; case 'I': entradaBLL.Insert(entrada); System.Windows.Forms.MessageBox.Show("O registro foi inserido com sucesso!"); break; default: break; } } else if (nome.Trim().ToLower().Contains("venda")) { Venda venda = new Venda(); venda = (Venda)obj; VendaBLL vendaBLL = new VendaBLL(); switch (command.ToUpper()[0]) { case 'A': vendaBLL.Update(venda); System.Windows.Forms.MessageBox.Show("O registro foi atualizado com sucesso!"); break; case 'D': vendaBLL.Delete(venda); System.Windows.Forms.MessageBox.Show("O registro foi deletado com sucesso!"); break; case 'I': vendaBLL.Insert(venda); System.Windows.Forms.MessageBox.Show("O registro foi inserido com sucesso!"); break; default: break; } } } } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message);; } }