Advertisement
Guest User

Untitled

a guest
Jul 26th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.03 KB | None | 0 0
  1. }
  2.  
  3. //
  4. cmd = new SqlCommand();
  5. cmd.Connection = ConexaoBancoSQLServer.Conectar();
  6.  
  7. cmd.Parameters.AddWithValue("@nomefunc", nome);
  8. cmd.Parameters.AddWithValue("@ativo", ativo);
  9. cmd.Parameters.AddWithValue("@idLoja", idLoja);
  10. /*
  11. cmd.Parameters.Add("@nomefunc", SqlDbType.VarChar, 60).Value = nome;
  12. cmd.Parameters.Add("@ativo", SqlDbType.Bit, 1).Value = ativo;
  13. cmd.Parameters.Add("@idLoja", SqlDbType.Int).Value = idLoja;
  14. */
  15. cmd.CommandText = _SQL;
  16.  
  17. dr = cmd.ExecuteReader();
  18.  
  19.  
  20. List<Funcionario> ListaFuncionarios = new List<Funcionario>();
  21.  
  22. while (dr.Read())
  23. {
  24. Funcionario func = new Funcionario();
  25.  
  26. func.id_Func = int.Parse(dr["Id_Func"].ToString());
  27. func.nome = dr["NomeFuncionario"].ToString();
  28. func.funcao = dr["Funcao"].ToString();
  29. func.cpf = dr["Cpf"].ToString();
  30. func.sexo = dr["Sexo"].ToString();
  31. func.id_Gerente = int.Parse(dr["id_Gerente"].ToString());
  32. func.ativo = Convert.ToBoolean(dr["Ativo"].ToString());
  33. func.id_Loja = int.Parse(dr["idLoja"].ToString());
  34.  
  35. ListaFuncionarios.Add(func);
  36. }
  37.  
  38. return ListaFuncionarios;
  39. }
  40.  
  41. if (!rdbDesativado.Checked)
  42. AtivoDesativo = true;
  43.  
  44. if (cmbLoja.Text == "")
  45. MessageBox.Show("Escolha uma loja");
  46. else
  47. AtualizarGrid(txtNome.Text, AtivoDesativo, Convert.ToInt32(cmbLoja.SelectedValue));
  48.  
  49. }
  50. catch (Exception ex)
  51. {
  52.  
  53. MessageBox.Show("Erro: " + ex.Message);
  54. }
  55.  
  56.  
  57. }
  58.  
  59. List<Funcionario> listaFuncionario = new List<Funcionario>();
  60. funcionarioNegocio = new FuncionarioNegocio();
  61.  
  62. listaFuncionario = funcionarioNegocio.SelecionarFuncionarioPorNome(nome, ativo, idLoja);
  63.  
  64. dgvPrincipal.DataSource = null;
  65. dgvPrincipal.DataSource = listaFuncionario;
  66.  
  67. dgvPrincipal.Update();
  68. dgvPrincipal.Refresh();
  69.  
  70.  
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement