Advertisement
Guest User

Untitled

a guest
Jun 25th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.76 KB | None | 0 0
  1. private void button3_Click(object sender, EventArgs e)
  2. {
  3. Dictionary<string, DocumentoTesouraria[]> docs;
  4. string erro = "";
  5. string retorno = "";
  6. Boolean excp = false;
  7. Boolean selecionou = false;
  8. if (carregado)
  9. {
  10. try
  11. {
  12. foreach (DataGridViewRow row in dataGridView1.Rows)
  13. {
  14. if (Convert.ToBoolean(row.Cells[0].Value))
  15. {
  16. selecionou = true;
  17. string iddoc = Convert.ToString(row.Cells[1].Value);
  18.  
  19. docs = Api.getDataFromWebAPI_EX<DocumentoTesouraria[]>(Api.EnderecoWebAPI + "/rest/api/v1/documentos-tesouraria?showres=0&showid=" + iddoc + "", new DocumentoTesouraria[] { });
  20. if (docs.Count > 0)
  21. {
  22. foreach (DocumentoTesouraria doc in docs["documentoTesouraria"])
  23. {
  24.  
  25. try
  26. {
  27. if (doc.tipodoc.referencia == 8)
  28. {
  29. retorno = importaApl(doc);
  30. if (!retorno.Contains("Importado"))
  31. excp = true;
  32. erro += "\n" + doc.tipodoc.codigo + " - " + doc.numDoc + " - " + retorno;
  33.  
  34. }
  35. else
  36. if (doc.tipodoc.referencia == 1)
  37. {
  38. retorno = importaTrans(doc);
  39. if (!retorno.Contains("Importado"))
  40. excp = true;
  41. erro += "\n" + doc.tipodoc.codigo + " - " + doc.numDoc + " - " + retorno;
  42. }
  43. else
  44. if (doc.tipodoc.referencia == 4)
  45. {
  46. retorno = importaABTCX(doc);
  47. if (!retorno.Contains("Importado"))
  48. excp = true;
  49. erro += "\n" + doc.tipodoc.codigo + " - " + doc.numDoc + " - " + retorno;
  50. }
  51. else
  52. if (doc.tipodoc.referencia == 2)
  53. {
  54. retorno = importaPag(doc);
  55. if (!retorno.Contains("Importado"))
  56. excp = true;
  57. erro += "\n" + doc.tipodoc.codigo + " - " + doc.numDoc + " - " + retorno;
  58. }
  59. else
  60. if (doc.tipodoc.referencia == 7)
  61. {
  62. retorno = importaFCHCX(doc);
  63. if (!retorno.Contains("Importado"))
  64. excp = true;
  65. erro += "\n" + doc.tipodoc.codigo + " - " + doc.numDoc + " - " + retorno;
  66. }
  67. else
  68. if (doc.tipodoc.referencia == 0 || doc.tipodoc.referencia == 6)
  69. {
  70. retorno = importaSAICX(doc);
  71. if (!retorno.Contains("Importado"))
  72. excp = true;
  73. erro += "\n" + doc.tipodoc.codigo + " - " + doc.numDoc + " - " + retorno;
  74. }
  75.  
  76. }
  77. catch (Exception ex)
  78. {
  79. excp = true;
  80. erro += "\n" + doc.tipodoc.codigo + " - " + doc.numDoc + " - " + ex.Message;
  81. }
  82. }
  83. }
  84. }
  85. }
  86. if (selecionou)
  87. {
  88. if (excp)
  89. MessageBox.Show(erro, "Importação", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  90. else
  91. MessageBox.Show(erro, "Importação", MessageBoxButtons.OK, MessageBoxIcon.Information);
  92. }
  93. else
  94. {
  95. MessageBox.Show("Seleciona um documento.", "Importação", MessageBoxButtons.OK, MessageBoxIcon.Information);
  96. }
  97.  
  98. }
  99. catch (Exception ex)
  100. {
  101. MessageBox.Show("erro: " + ex.Message);
  102. }
  103. }
  104. else
  105. {
  106. MessageBox.Show("Carregue os documentos e seleciona-os", "Importação", MessageBoxButtons.OK, MessageBoxIcon.Information);
  107.  
  108. }
  109. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement