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 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
|
//page TabSheet2
impression3 == false;
Edit14->Clear();
double tcolis=0, tsncb=0, tcumul=0, ttransport=0, tadmin=0, prepa=0, tprepa=0, rod=0, trod=0, her=0, ther=0;
double grandtotal = 0;
Query4->Close() ;
Query4->SQL->Clear() ;
Query4->SQL->Add("delete from facturecomportetemp ") ;
Query4->ExecSQL();
Query4->Close() ;
Query4->SQL->Clear() ;
Query4->SQL->Add("SELECT feuilleroute.refroute, feuilleroute.dateroute, chauffeur.nomchauffeur ") ;
Query4->SQL->Add("FROM feuilleroute INNER JOIN chauffeur ON feuilleroute.refchauffeur = chauffeur.refchauffeur ") ;
Query4->SQL->Add("WHERE chauffeur.nomchauffeur = :nomchauffeur AND (feuilleroute.dateroute BETWEEN :datedebut AND :datefin) ") ;
Query4->SQL->Add("ORDER BY refroute ASC ") ;
Query4->ParamByName("nomchauffeur")->AsString = ComboBox1->Text;
Query4->ParamByName("datedebut")->AsString = datedebut;
Query4->ParamByName("datefin")->AsString = datefin;
Query4->Prepare();
Query4->Open() ;
Table3->Close();
Table3->Open();
int zzz,yyy;
yyy = Query4->RecordCount;
Query4->First();
for (zzz=0;zzz<yyy;zzz++)
{
//ajout des enregistrements dans facturecomportetemp
Table3->Append();
Table3refroute->Value = Query4refroute->Value;
Table3dateroute->Value = Query4dateroute->Value;
Table3colis->Value = 0;
Table3sncb->Value = 0;
Table3cumul->Value = 0;
Table3transport->Value = 0;
Table3administratif->Value = Query4administratif->Value;
Table3nbprepa->Value = Query4prepa->Value;
Table3totalprepa->Value = 0.00;
Table3nrod->Value = Query4rod->Value;
Table3trod->Value = 0.00;
Table3nher->Value = Query4herent->Value;
Table3ther->Value = 0.00;
Table3->Post();
Table3->Close();
Table3->Open();
Table3->First();
Query4->Next();
}
yyy = Table3->RecordCount;
Table3->First();
for (zzz=0;zzz<yyy;zzz++)
{
Query5->Close() ;
Query5->SQL->Clear() ;
Query5->SQL->Add("SELECT feuilleroute.refroute, Sum(bon.colis) AS SommeColis ") ;
Query5->SQL->Add("FROM (feuilleroute INNER JOIN feuilleroutecomporte ON feuilleroute.refroute = feuilleroutecomporte.refroute) INNER JOIN bon ON feuilleroutecomporte.refbon = bon.refbon ") ;
Query5->SQL->Add("WHERE feuilleroute.refroute = :refroute ") ;
Query5->SQL->Add("GROUP BY feuilleroute.refroute; ") ;
Query5->ParamByName("refroute")->AsString = Table3refroute->Value;
Query5->Prepare();
Query5->Open() ;
Query6->Close() ;
Query6->SQL->Clear() ;
Query6->SQL->Add("SELECT feuilleroute.refroute, Sum(bon.colis) AS SommeDeColis ") ;
Query6->SQL->Add("FROM ((feuilleroute INNER JOIN feuilleroutecomporte ON feuilleroute.refroute = feuilleroutecomporte.refroute) INNER JOIN bon ON feuilleroutecomporte.refbon = bon.refbon) INNER JOIN client ON bon.refclient = client.REFCLIENT ") ;
Query6->SQL->Add("WHERE feuilleroute.refroute = :refroute AND client.typeclient = 'Normal' ") ;
Query6->SQL->Add("GROUP BY feuilleroute.refroute; ") ;
Query6->ParamByName("refroute")->AsString = Table3refroute->Value;
Query6->Prepare();
Query6->Open() ;
Table3->Edit();
Table3colis->Value = Query6SommeDeColis->Value;
Table3cumul->Value = Query5SommeColis->Value;
Table3sncb->Value = Table3cumul->Value - Table3colis->Value;
Table3->Post();
Table3->Next();
}
Table3->First();
//calcul du prix total du transport
double totaltransport = 0;
yyy = Table3->RecordCount;
Table3->First();
for (zzz=0;zzz<yyy;zzz++)
{
if (Table3cumul->Value == 0)
{
totaltransport = 0;
}
else
{
if(Table3cumul->Value > 0 && Table3cumul->Value < 35)
{
totaltransport = Edit10->Text.ToDouble() + (Table3sncb->Value * Edit13->Text.ToDouble());
}
else
{
if(Table3cumul->Value >= 35 && Table3cumul->Value < 51)
{
totaltransport = (Table3colis->Value * Edit3->Text.ToDouble()) + (Table3sncb->Value * Edit13->Text.ToDouble());
}
else
{
if(Table3cumul->Value >= 51 && Table3cumul->Value < 71)
{
double diff = Edit13->Text.ToDouble() - Edit4->Text.ToDouble();
totaltransport = ((Table3cumul->Value - 50) * Edit4->Text.ToDouble()) + (50 * Edit3->Text.ToDouble()) + (Table3sncb->Value * diff);
}
else
{
if(Table3cumul->Value >= 71)
{
double diff2 = Edit13->Text.ToDouble() - Edit7->Text.ToDouble();
totaltransport = ((Table3cumul->Value - 70) * Edit7->Text.ToDouble()) + ((50 * Edit3->Text.ToDouble()) + (20 * Edit4->Text.ToDouble()) + (Table3sncb->Value * diff2));
}
}
}
}
}
Table3->Edit();
Table3transport->Value = totaltransport;
Table3->Post();
Table3->Next();
}
Table3->Close();
Table3->Open();
Table3->First();
//calcul des totaux
yyy = Table3->RecordCount;
Table3->First();
for (zzz=0;zzz<yyy;zzz++)
{
tcolis = tcolis + Table3colis->Value;
tsncb = tsncb + Table3sncb->Value;
tcumul = tcumul + Table3cumul->Value;
ttransport = ttransport + Table3transport->Value;
tadmin = tadmin + Table3administratif->Value;
prepa = prepa + Table3nbprepa->Value;
tprepa = tprepa + Table3totalprepa->Value;
rod = rod + Table3nrod->Value;
trod = trod + Table3trod->Value;
her = her + Table3nher->Value;
ther = ther + Table3ther->Value;
Table3->Next();
}
Label18->Caption = tcolis;
Label19->Caption = tsncb;
Label20->Caption = tcumul;
Label21->Caption = ttransport;
Label22->Caption = tadmin;
Label23->Caption = prepa;
Label24->Caption = tprepa;
Label25->Caption = rod;
Label26->Caption = trod;
Label27->Caption = her;
Label28->Caption = ther;
grandtotal = ttransport + tadmin + tprepa + trod + ther;
Label16->Caption = grandtotal; |
Partager