Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.82 KB | None | 0 0
  1. public List<List<ItNota>> SelecionaDadosItNota(out String pstrMsg, out Boolean pbooRetorno, Util.ObjTransf pobjTransf, List<Cliente> plstCliente)
  2. {
  3. List<List<ItNota>> lstListItNota = default(List<List<ItNota>>);
  4.  
  5. SqlConnection conn = ConexaoBD.CriarConexao(out pstrMsg, out pbooRetorno);
  6.  
  7. if (pbooRetorno)
  8. {
  9. using (conn)
  10. {
  11. using (SqlCommand cmd = new SqlCommand("uspCtzSelectDadosProd", conn))
  12. {
  13. cmd.CommandType = CommandType.StoredProcedure;
  14. cmd.Parameters.AddWithValue("@cd_emp", null);
  15. cmd.Parameters.AddWithValue("@nu_rom", null);
  16. cmd.Parameters.AddWithValue("@cd_clien", null);
  17.  
  18. try
  19. {
  20. lstListItNota = new List<List<ItNota>>();
  21.  
  22. foreach (var cliente in plstCliente)
  23. {
  24. cmd.Parameters["@cd_emp"].Value = pobjTransf.CdEmp;
  25. cmd.Parameters["@nu_rom"].Value = pobjTransf.NuRom;
  26. cmd.Parameters["@cd_clien"].Value = cliente.CdClien;
  27.  
  28. using (SqlDataReader rd = cmd.ExecuteReader())
  29. {
  30. if (rd.HasRows)
  31. {
  32. List<ItNota> lstItNota = new List<ItNota>();
  33.  
  34. while (rd.Read())
  35. {
  36. ItNota itNota = new ItNota();
  37.  
  38. itNota.CdClien = cliente.CdClien;
  39. itNota.Seq = rd["seq"].ToString();
  40. itNota.Codigo = rd["codigo"].ToString();
  41. itNota.Descricao = rd["descricao"].ToString();
  42. itNota.Valor = rd["valor"].ToString();
  43. itNota.Nf = rd["nf"].ToString();
  44. itNota.Perecivel = rd["perecivel"].ToString();
  45. itNota.Embarcador = rd["embarcador"].ToString();
  46.  
  47. lstItNota.Add(itNota);
  48. }
  49. lstListItNota.Add(lstItNota);
  50. }
  51. pbooRetorno = true;
  52. }
  53. }
  54. }
  55. catch (SqlException ex)
  56. {
  57. pstrMsg = ex.Message;
  58. pbooRetorno = false;
  59. }
  60. }
  61. }
  62. }
  63. else
  64. {
  65. conn.Close();
  66. }
  67. return lstListItNota;
  68. }
  69.  
  70. // Busca os dados dos itens da nota
  71. List<List<ItNota>> lstListItNota = seleciona.SelecionaDadosItNota(out pstrMsg, out pbooRetorno, pobjTransf, lstCliente);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement