1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
|
repexc = folderBrowserDialog2.SelectedPath + "\\monfichier" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".xlsx";
-........
.........
//sirens est un tableau avec une liste de sirens
try
{
MySqlCommand cmd = new MySqlCommand();
for (int a = 0; a < sirens.Count; a++)
{
marequete = " select t1.NUMSIR , " + //1
"t1.CCOD, " +
"t0.MONtant, " +
"t0.SOLDAT, " +
"t0.ADHFER, " + //5
"t1.numeroadh, " +
"t1.fichier, " +
"t1.RAISO2, " +
"t1.RAISOC, " +
"date_format(t1.debutdate, '%m/%d/%Y') , " + //10
"t1.FINDATe, " +
"t1.DATRECe, " +
"t1.EMITOTale, " +
"t2.EMILIBelle, " +
"t2.EMIBASe, " +
"t2.EMICOE, " + //16
"t2.EMINETe, " +
"t2.EMICOTisation, " +
"t2.EMIMT, " +
"t3.ENCTOTale, " + //20
"t3.ENCDEB, " +
"t3.ENCFIN " +
" from 000pf t0 " +
" left join Table001 t1 on t1.NUMSIR = t0.NUMSIR " + //rajout
" left join Table002 t2 on t1.NUMSIR = t2.NUMSIR and t1.NOMFIC = t2.NOMFIC " +
" left join Table003 t3 on t3.NUMSIR = t2.NUMSIR " +
" where t0.numsir = " + sirens[a] + "" +
" and t1.NOMFIC = '" + fichierEnEntrée + " '";
;
cmd = new MySqlCommand(marequete, conn);
monreader = cmd.ExecuteReader();
if (monreader.Read()) //while
{
//premier reader
ws.Cells[cptCol, 1] = ReturnReaderValue(monreader, 0);
ws.Cells[cptCol, 2] = ReturnReaderValue(monreader, 1);
ws.Cells[cptCol, 3] = ReturnReaderValue(monreader, 2); //SOLMON
ws.Cells[cptCol, 4] = ReturnReaderValue(monreader, 3); //SOLDAT
ws.Cells[cptCol, 5] = ReturnReaderValue(monreader, 4); //ADHFER
ws.Cells[cptCol, 6] = ReturnReaderValue(monreader, 5); //MATADH
ws.Cells[cptCol, 7] = ReturnReaderValue(monreader, 6); //NOMFIC
ws.Cells[cptCol, 8] = ReturnReaderValue(monreader, 7); //RAISO2
ws.Cells[cptCol, 9] = ReturnReaderValue(monreader, 8); //RAISOC
ws.Cells[cptCol, 10] = ReturnReaderValue(monreader, 9); //DEBDAT
ws.Cells[cptCol, 11] = ReturnReaderValue(monreader, 10); //FINDAT
ws.Cells[cptCol, 12] = ReturnReaderValue(monreader, 11); //DATREC
//rajout
ws.Cells[cptCol, 13] = ReturnReaderValue(monreader, 12); //EMITOT
ws.Cells[cptCol, 14] = ReturnReaderValue(monreader, 13); //EMILIB
ws.Cells[cptCol, 15] = ReturnReaderValue(monreader, 14); //EMIBAS
ws.Cells[cptCol, 16] = ReturnReaderValue(monreader, 15); //EMICOE
ws.Cells[cptCol, 17] = ReturnReaderValue(monreader, 16); //EMINET
ws.Cells[cptCol, 18] = ReturnReaderValue(monreader, 17);//EMICOT
ws.Cells[cptCol, 19] = ReturnReaderValue(monreader, 18);//EMIMT
ws.Cells[cptCol, 20] = ReturnReaderValue(monreader, 19); //ENCTOT
ws.Cells[cptCol, 21] = ReturnReaderValue(monreader, 20); //ENCDEB
ws.Cells[cptCol, 22] = ReturnReaderValue(monreader, 21); //ENCFIN
cptCol++;
}
else
{
// ws.Cells[cptCol, 1] = sirens[a];
// cptCol++;
}
mabarre.PerformStep();
log.Info("compteur :" + compteur);
compteur++;
lblres.Text = compteur.ToString();
monreader.Close();
monreader.Dispose();
cmd.Dispose();
}//fin for
....
....
ws.SaveAs(repexc, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value); |