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 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150
|
[FONT=Times New Roman]private[/FONT]
[FONT=Times New Roman] { Déclarations privées }[/FONT]
[FONT=Times New Roman] procedure SaveInBD(sNom, sPNom, sSexe, sLN, sAdr, sSF, sCat, sEAf, sEAct : string;[/FONT]
[FONT=Times New Roman] sMat, sFct, sSB, sUAf, sDAf, sSAf, sNSS : integer ;[/FONT]
[FONT=Times New Roman] sDNais, sDRec, sDDep: TdateTime);[/FONT]
[FONT=Times New Roman].[/FONT]
[FONT=Times New Roman].[/FONT]
[FONT=Times New Roman].[/FONT]
[FONT=Times New Roman].[/FONT]
[FONT=Times New Roman]..[/FONT]
[FONT=Times New Roman][/FONT]
[FONT=Times New Roman]procedure TForm1.Button1Click(Sender: TObject);[/FONT]
[FONT=Times New Roman]var[/FONT]
[FONT=Times New Roman] XlsWk:_workbook;[/FONT]
[FONT=Times New Roman] XlsPage :_Worksheet;[/FONT]
[FONT=Times New Roman] sFile: string;[/FONT]
[FONT=Times New Roman] sNom, sPNom, sSexe, sLN, sAdr, sSF, sCat, sEAf, sEAct : string;[/FONT]
[FONT=Times New Roman] sMat, sFct, sSB, sUAf, sDAf, sSAf, sNSS : integer ;[/FONT]
[FONT=Times New Roman] sDNais, sDRec, sDDep: TdateTime;[/FONT]
[FONT=Times New Roman] bFin: boolean;[/FONT]
[FONT=Times New Roman] iLine: integer;[/FONT]
[FONT=Times New Roman] begin[/FONT]
[FONT=Times New Roman] XlsApp.Connect;[/FONT]
[FONT=Times New Roman] XlsApp.Visible[0] := true;[/FONT]
[FONT=Times New Roman] sFile := ExtractFilePath(Application.ExeName) + 'BD FA';[/FONT]
[FONT=Times New Roman] XlsWk := XlsApp.Workbooks.Open(sFile, False, False, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, 0);[/FONT]
[FONT=Times New Roman] XlsPage := XlsWk.Worksheets['CopiedeDEB'] as _worksheet;[/FONT]
[FONT=Times New Roman] DMGE.TEmpl.Open;[/FONT]
[FONT=Times New Roman] bFin := false;[/FONT]
[FONT=Times New Roman] iLine := 1;[/FONT]
[FONT=Times New Roman] repeat[/FONT]
[FONT=Times New Roman] // lire les données[/FONT]
[FONT=Times New Roman] sMat := XlsPage.Cells.Item[iLine, 1].Value;[/FONT]
[FONT=Times New Roman] sNom := XlsPage.Cells.Item[iLine, 2].Value;[/FONT]
[FONT=Times New Roman] sPNom := XlsPage.Cells.Item[iLine, 3].Value;[/FONT]
[FONT=Times New Roman] sSexe := XlsPage.Cells.Item[iLine, 4].Value;[/FONT]
[FONT=Times New Roman] sDNais := XlsPage.Cells.Item[iLine, 5].Value;[/FONT]
[FONT=Times New Roman] sLN := XlsPage.Cells.Item[iLine, 6].Value;[/FONT]
[FONT=Times New Roman] sAdr := XlsPage.Cells.Item[iLine, 7].Value;[/FONT]
[FONT=Times New Roman] sSF := XlsPage.Cells.Item[iLine, 8].Value;[/FONT]
[FONT=Times New Roman] sDRec := XlsPage.Cells.Item[iLine, 9].Value;[/FONT]
[FONT=Times New Roman] sFct := XlsPage.Cells.Item[iLine, 10].Value;[/FONT]
[FONT=Times New Roman] sCat := XlsPage.Cells.Item[iLine, 11].Value;[/FONT]
[FONT=Times New Roman] sSB := XlsPage.Cells.Item[iLine, 12].Value;[/FONT]
[FONT=Times New Roman] sEAf := XlsPage.Cells.Item[iLine, 13].Value;[/FONT]
[FONT=Times New Roman] sUAf := XlsPage.Cells.Item[iLine, 14].Value;[/FONT]
[FONT=Times New Roman] sDAf := XlsPage.Cells.Item[iLine, 15].Value;[/FONT]
[FONT=Times New Roman] sSAf := XlsPage.Cells.Item[iLine, 16].Value;[/FONT]
[FONT=Times New Roman] sNSS := XlsPage.Cells.Item[iLine, 17].Value;[/FONT]
[FONT=Times New Roman] sDDep := XlsPage.Cells.Item[iLine, 18].Value;[/FONT]
[FONT=Times New Roman] sEAct := XlsPage.Cells.Item[iLine, 19].Value;[/FONT]
[FONT=Times New Roman][/FONT]
[FONT=Times New Roman] if sMat = 0 then[/FONT]
[FONT=Times New Roman] Break; // fin des données XLS[/FONT]
[FONT=Times New Roman] // met à jour la table[/FONT]
[FONT=Times New Roman][/FONT]
[FONT=Times New Roman] SaveInBD(sMat,sNom, sPNom, sSexe, sDNais, sLN, sAdr, sSF, sDRec, sFct,sCat,sSB,sEAct, sUAf, sDAf, sSAf, sNSS, sDDep, sEAct);[/FONT]
[FONT=Times New Roman][/FONT]
[FONT=Times New Roman] Inc(iLine); // ligne suivante dans XLS[/FONT]
[FONT=Times New Roman] Until bFin;[/FONT]
[FONT=Times New Roman] end;[/FONT]
[FONT=Times New Roman][/FONT]
[FONT=Times New Roman]procedure TForm1.SaveInBD(sNom, sPNom, sSexe, sLN, sAdr, sSF, sCat, sEAf, sEAct : string;[/FONT]
[FONT=Times New Roman] sMat, sFct, sSB, sUAf, sDAf, sSAf, sNSS : integer ;[/FONT]
[FONT=Times New Roman] sDNais, sDRec, sDDep: TdateTime);[/FONT]
[FONT=Times New Roman] var[/FONT]
[FONT=Times New Roman] i: integer;[/FONT]
[FONT=Times New Roman] begin[/FONT]
[FONT=Times New Roman] with DMGE.TEmpl do begin[/FONT]
[FONT=Times New Roman] SetKey;[/FONT]
[FONT=Times New Roman] FieldByName('Matricule'). asInteger := sMat;[/FONT]
[FONT=Times New Roman] FieldByName('Nom'). asString := sNom;[/FONT]
[FONT=Times New Roman] FieldByName('Prenom'). asString := sPNom;[/FONT]
[FONT=Times New Roman] FieldByName('Sexe'). asString := sSexe;[/FONT]
[FONT=Times New Roman] FieldByName('Date_Naissance'). asDateTime := sDNais;[/FONT]
[FONT=Times New Roman] FieldByName('Lieu_Naissance'). asString := sLN;[/FONT]
[FONT=Times New Roman] FieldByName('Adresse'). asString := sAdr;[/FONT]
[FONT=Times New Roman] FieldByName('SF'). asString := sSF;[/FONT]
[FONT=Times New Roman] FieldByName('Date_Rec'). asDateTime := sDRec;[/FONT]
[FONT=Times New Roman] FieldByName('Fonction'). asInteger := sFct;[/FONT]
[FONT=Times New Roman] FieldByName('Cat'). asString := sCat;[/FONT]
[FONT=Times New Roman] FieldByName('SBase'). asInteger := sSB;[/FONT]
[FONT=Times New Roman] FieldByName('Entreprise_Affect'). asString := sEAf;[/FONT]
[FONT=Times New Roman] FieldByName('Unite_Affect'). asInteger := sUAf;[/FONT]
[FONT=Times New Roman] FieldByName('Departement_Affect'). asInteger := sDAf;[/FONT]
[FONT=Times New Roman] FieldByName('Service_Affect'). asInteger := sSAf;[/FONT]
[FONT=Times New Roman] FieldByName('NSS'). asInteger := sNSS;[/FONT]
[FONT=Times New Roman] FieldByName('Date_Depart'). asDateTime:= sDDep;[/FONT]
[FONT=Times New Roman] FieldByName('Etat_Actuel'). asString := sEAct;[/FONT]
[FONT=Times New Roman][/FONT]
[FONT=Times New Roman] if GotoKey then begin[/FONT]
[FONT=Times New Roman] // données existantes[/FONT]
[FONT=Times New Roman] i := 1;[/FONT]
[FONT=Times New Roman] Repeat[/FONT]
[FONT=Times New Roman] SetKey;[/FONT]
[FONT=Times New Roman] FieldByName('Matricule'). asInteger := sMat + (i);[/FONT]
[FONT=Times New Roman] FieldByName('Nom').asString := 'sNom';[/FONT]
[FONT=Times New Roman] FieldByName('Prenom').asString := 'sPNom';[/FONT]
[FONT=Times New Roman] FieldByName('Sexe'). asString := 'sSexe';[/FONT]
[FONT=Times New Roman] FieldByName('Date_Naissance'). asDateTime := sDNais;[/FONT]
[FONT=Times New Roman] FieldByName('Lieu_Naissance'). asString := 'sLN';[/FONT]
[FONT=Times New Roman] FieldByName('Adresse'). asString := 'sAdr';[/FONT]
[FONT=Times New Roman] FieldByName('SF'). asString := 'sSF';[/FONT]
[FONT=Times New Roman] FieldByName('Date_Rec'). asString := 'sDRec';[/FONT]
[FONT=Times New Roman] FieldByName('Fonction'). asInteger := sFct;[/FONT]
[FONT=Times New Roman] FieldByName('Cat'). asString := 'sCat';[/FONT]
[FONT=Times New Roman] FieldByName('SBase'). asInteger := sSB;[/FONT]
[FONT=Times New Roman] FieldByName('Entreprise_Affect'). asString := 'sEAf';[/FONT]
[FONT=Times New Roman] FieldByName('Unite_Affect'). asString := 'sUAf';[/FONT]
[FONT=Times New Roman] FieldByName('Departement_Affect'). asInteger := sDAf;[/FONT]
[FONT=Times New Roman] FieldByName('Service_Affect'). asInteger := sSAf;[/FONT]
[FONT=Times New Roman] FieldByName('NSS'). asInteger := sNSS;[/FONT]
[FONT=Times New Roman] FieldByName('Date_Depart'). asDateTime:= sDDep;[/FONT]
[FONT=Times New Roman] FieldByName('Etat_Actuel'). asString := 'sEAct';[/FONT]
[FONT=Times New Roman] Inc(i);[/FONT]
[FONT=Times New Roman] Until not Gotokey;[/FONT]
[FONT=Times New Roman] sMat := sMat + (i); // on n'écrase pas, on rajoute 1, 2, ...[/FONT]
[FONT=Times New Roman] end;[/FONT]
[FONT=Times New Roman] // ajoute[/FONT]
[FONT=Times New Roman] Append;[/FONT]
[FONT=Times New Roman] FieldByName('Matricule'). asInteger := sMat;[/FONT]
[FONT=Times New Roman] FieldByName('Nom').asString := sNom;[/FONT]
[FONT=Times New Roman] FieldByName('Prenom').asString := sPNom;[/FONT]
[FONT=Times New Roman] FieldByName('Sexe'). asString := sSexe;[/FONT]
[FONT=Times New Roman] FieldByName('Date_Naissance'). asDateTime := sDNais;[/FONT]
[FONT=Times New Roman] FieldByName('Lieu_Naissance'). asString := sLN;[/FONT]
[FONT=Times New Roman] FieldByName('Adresse'). asString := sAdr;[/FONT]
[FONT=Times New Roman] FieldByName('SF'). asString := sSF;[/FONT]
[FONT=Times New Roman] FieldByName('Date_Rec'). asdateTime := sDRec;[/FONT]
[FONT=Times New Roman] FieldByName('Fonction'). asInteger := sFct;[/FONT]
[FONT=Times New Roman] FieldByName('Cat'). asString := sCat;[/FONT]
[FONT=Times New Roman] FieldByName('SBase'). asInteger := sSB;[/FONT]
[FONT=Times New Roman] FieldByName('Entreprise_Affect'). asString := sEAf;[/FONT]
[FONT=Times New Roman] FieldByName('Unite_Affect'). asInteger:= sUAf;[/FONT]
[FONT=Times New Roman] FieldByName('Departement_Affect'). asInteger := sDAf;[/FONT]
[FONT=Times New Roman] FieldByName('Service_Affect'). asInteger := sSAf;[/FONT]
[FONT=Times New Roman] FieldByName('NSS'). asInteger := sNSS;[/FONT]
[FONT=Times New Roman] FieldByName('Date_Depart'). asDateTime:= sDDep;[/FONT]
[FONT=Times New Roman] FieldByName('Etat_Actuel'). asString := sEAct;[/FONT]
[FONT=Times New Roman] Post;[/FONT]
[FONT=Times New Roman] end; // with[/FONT]
[FONT=Times New Roman] end;[/FONT]
[FONT=Times New Roman][/FONT]
[FONT=Times New Roman][/FONT]
[FONT=Times New Roman]end.[/FONT]
[FONT=Times New Roman][/FONT]
[FONT=Times New Roman][/FONT]
[FONT=Times New Roman][/FONT]
[FONT=Times New Roman]end.[/FONT] |
Partager