unit Uprinc;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Menus, Grids, DBGrids, ExtCtrls, StdCtrls,DateUtils, jpeg,
  Calendar, ComCtrls;

type
  TFprinc = class(TForm)
    MainMenu1: TMainMenu;
    Fichier1: TMenuItem;
    Bus1: TMenuItem;
    Quitter1: TMenuItem;
    FicheBus1: TMenuItem;
    Commande1: TMenuItem;
    ypedebus2: TMenuItem;
    ypeoperation1: TMenuItem;
    Article1: TMenuItem;
    Cpville1: TMenuItem;
    Propritaire1: TMenuItem;
    Fournisseur1: TMenuItem;
    abledebase1: TMenuItem;
    Gestiondesbus1: TMenuItem;
    Gestiondeskm1: TMenuItem;
    RechercheBus1: TMenuItem;
    StringGrid1: TStringGrid;
    Listedescommandes1: TMenuItem;
    commandenonlivree1: TMenuItem;
    DateTimePicker1: TDateTimePicker;
    Edit1: TEdit;
    DBGrid1: TDBGrid;
    procedure Quitter1Click(Sender: TObject);
    procedure FormActivate(Sender: TObject);
    procedure ypeoperation1Click(Sender: TObject);
    procedure Article1Click(Sender: TObject);
    procedure ypedebus2Click(Sender: TObject);
    procedure RechercheBus1Click(Sender: TObject);
    procedure Gestiondeskm1Click(Sender: TObject);
    procedure CalculEntretienControle(Sender: TObject);
    procedure StringGrid1DblClick(Sender: TObject);
    procedure Propritaire1Click(Sender: TObject);
    procedure Cpville1Click(Sender: TObject);
    procedure Fournisseur1Click(Sender: TObject);
    procedure Listedescommandes1Click(Sender: TObject);
    procedure DateTimePicker1Change(Sender: TObject);


  private
    { Déclarations privées }
  public
    { Déclarations publiques }
  end;

var
  Fprinc: TFprinc;

implementation
{$R *.dfm}
 uses udata,ulistebus,ulisteanalyse,uarticle,uheader,ulistetypeoperation,ulistekm,
 ulistetypebus,
 udetailcommande,uproprietaire,ulisteentretien,udataquery, Ufichebusdetail,
  Ulistepro, Ucp, Ufichefou, Ulistefou;


procedure tFprinc.CalculEntretienControle(Sender: TObject);
 var i :integer;
begin
data.Tbus.First;
stringgrid1.RowCount:=1;
i:=0;
while not data.Tbus.Eof  do
begin

stringgrid1.Cells[0,i]:=data.TbusBUS_NUMPL.value;
stringgrid1.Cells[1,i]:=data.TbusBUS_NUMID.Value;

if data.Ttypebus.Locate('TYBU_ID',data.TbusBUS_TYBUID.AsInteger,[])
        then
                stringgrid1.Cells[2,i]:=data.TtypebusTYBU_MOD.Value
        else
                stringgrid1.Cells[2,i]:='pas trouve modele';

if data.Tcontrole.Locate('cont_busid',data.TbusBUS_ID.AsInteger,[])
        then

//faire le if pour le controle
                stringgrid1.Cells[3,i]:=data.TcontroleCONT_DTRE.AsString
        else
                stringgrid1.Cells[3,i]:='pas trouve date controle';

if data.Tkm.Locate('km_bus_id',data.TbusBUS_ID.AsInteger,[])
        then
                begin
                data.Tkm.IndexName:='ikm_pk';
                stringgrid1.Cells[4,i]:=data.TkmKM_KM.AsString;
                end
        else
                stringgrid1.Cells[4,i]:= 'pas trouve km du jour';


if data.Tbusoperation.Locate('bop_tybuid',data.TbusBUS_ID.AsInteger,[])
        and data.Tbusoperation.Locate('bop_tyopid',data.TtypeopTYOP_ID.AsInteger,[])
        then
                stringgrid1.Cells[5,i]:=data.TtypeopTYOP_LIB.AsString
        else
                stringgrid1.Cells[5,i]:= 'pas trouve operation';



stringgrid1.RowCount:=stringgrid1.RowCount+1;
i:=i+1;



data.Tbus.Next;

end;
end;


procedure TFprinc.Quitter1Click(Sender: TObject);
begin
Application.Terminate;
end;

procedure TFprinc.FormActivate(Sender: TObject);

begin
        fprinc.Left:=200;
        fprinc.Top:=200;

        data.Tanalyse.Active:=true;
        data.Tarticle.Active:=true;
        data.Tbus.Active:=true;
        data.Tbusoperation.Active:=true;
        data.Tcontrole.Active:=true;
        data.Tcpville.Active:=true;
        data.Tdetailcommande.Active:=true;
        data.Tentretien.Active:=true;
        data.Tfournisseur.Active:=true;
        data.Theader.Active:=true;
        data.Tkm.Active:=true;
        data.Toperation.Active:=true;
        data.Tproprietaire.Active:=true;
        data.Ttypebus.Active:=true;
        data.Ttypeop.Active:=true;
        data.Ttempo.Active:=true;

        Fprinc.CalculEntretienControle(Sender);

end;

procedure TFprinc.ypeoperation1Click(Sender: TObject);
begin
         Flistetypeoperation.showmodal;
end;

procedure TFprinc.Article1Click(Sender: TObject);
begin
         farticle.ShowModal;
end;

procedure TFprinc.ypedebus2Click(Sender: TObject);
begin
         flistetypebus.ShowModal;
end;

procedure TFprinc.RechercheBus1Click(Sender: TObject);
begin
        flistebus.ShowModal;
end;

procedure TFprinc.Gestiondeskm1Click(Sender: TObject);
begin
        flistekm.ShowModal;
end;

procedure TFprinc.StringGrid1DblClick(Sender: TObject);
begin
        Ffichebusdetail.ShowModal;
end;

procedure TFprinc.Propritaire1Click(Sender: TObject);
begin
flistepro.showmodal;

end;

procedure TFprinc.Cpville1Click(Sender: TObject);
begin
fcp.showmodal;
end;

procedure TFprinc.Fournisseur1Click(Sender: TObject);
begin
flistefou.showmodal;
end;

procedure TFprinc.Listedescommandes1Click(Sender: TObject);
begin
fheader.ShowModal;
end;

procedure TFprinc.DateTimePicker1Change(Sender: TObject);

begin

edit1.Text:= datetostr(datetimepicker1.DateTime);
end;

end.
