Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void button3_Click(object sender, EventArgs e)
- {
- Dictionary<string, DocumentoTesouraria[]> docs;
- string erro = "";
- string retorno = "";
- Boolean excp = false;
- Boolean selecionou = false;
- if (carregado)
- {
- try
- {
- foreach (DataGridViewRow row in dataGridView1.Rows)
- {
- if (Convert.ToBoolean(row.Cells[0].Value))
- {
- selecionou = true;
- string iddoc = Convert.ToString(row.Cells[1].Value);
- docs = Api.getDataFromWebAPI_EX<DocumentoTesouraria[]>(Api.EnderecoWebAPI + "/rest/api/v1/documentos-tesouraria?showres=0&showid=" + iddoc + "", new DocumentoTesouraria[] { });
- if (docs.Count > 0)
- {
- foreach (DocumentoTesouraria doc in docs["documentoTesouraria"])
- {
- try
- {
- if (doc.tipodoc.referencia == 8)
- {
- retorno = importaApl(doc);
- if (!retorno.Contains("Importado"))
- excp = true;
- erro += "\n" + doc.tipodoc.codigo + " - " + doc.numDoc + " - " + retorno;
- }
- else
- if (doc.tipodoc.referencia == 1)
- {
- retorno = importaTrans(doc);
- if (!retorno.Contains("Importado"))
- excp = true;
- erro += "\n" + doc.tipodoc.codigo + " - " + doc.numDoc + " - " + retorno;
- }
- else
- if (doc.tipodoc.referencia == 4)
- {
- retorno = importaABTCX(doc);
- if (!retorno.Contains("Importado"))
- excp = true;
- erro += "\n" + doc.tipodoc.codigo + " - " + doc.numDoc + " - " + retorno;
- }
- else
- if (doc.tipodoc.referencia == 2)
- {
- retorno = importaPag(doc);
- if (!retorno.Contains("Importado"))
- excp = true;
- erro += "\n" + doc.tipodoc.codigo + " - " + doc.numDoc + " - " + retorno;
- }
- else
- if (doc.tipodoc.referencia == 7)
- {
- retorno = importaFCHCX(doc);
- if (!retorno.Contains("Importado"))
- excp = true;
- erro += "\n" + doc.tipodoc.codigo + " - " + doc.numDoc + " - " + retorno;
- }
- else
- if (doc.tipodoc.referencia == 0 || doc.tipodoc.referencia == 6)
- {
- retorno = importaSAICX(doc);
- if (!retorno.Contains("Importado"))
- excp = true;
- erro += "\n" + doc.tipodoc.codigo + " - " + doc.numDoc + " - " + retorno;
- }
- }
- catch (Exception ex)
- {
- excp = true;
- erro += "\n" + doc.tipodoc.codigo + " - " + doc.numDoc + " - " + ex.Message;
- }
- }
- }
- }
- }
- if (selecionou)
- {
- if (excp)
- MessageBox.Show(erro, "Importação", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
- else
- MessageBox.Show(erro, "Importação", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- else
- {
- MessageBox.Show("Seleciona um documento.", "Importação", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show("erro: " + ex.Message);
- }
- }
- else
- {
- MessageBox.Show("Carregue os documentos e seleciona-os", "Importação", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement