www.pudn.com > Source.rar > Unit21.pas, change:2007-02-04,size:5179b


unit Unit21; 
 
interface 
 
uses 
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, 
  Dialogs, ExtCtrls, DBCtrls, StdCtrls, Buttons, Grids, DBGrids, ComCtrls; 
 
type 
  TStockform = class(TForm) 
    DBGrid1: TDBGrid; 
    Timer: TTimer; 
    Panel2: TPanel; 
    Label4: TLabel; 
    Image1: TImage; 
    Modifier: TBitBtn; 
    Supprimer: TBitBtn; 
    Nouveau: TBitBtn; 
    DBNavigator1: TDBNavigator; 
    Panel1: TPanel; 
    Label5: TLabel; 
    Label2: TLabel; 
    Label3: TLabel; 
    Choix_Filtre: TRadioGroup; 
    TypePiece: TComboBox; 
    N_piece: TEdit; 
    GroupBox3: TGroupBox; 
    Date_Au: TDateTimePicker; 
    Date_Du: TDateTimePicker; 
    GroupBox1: TGroupBox; 
    Tri: TComboBox; 
    BitBtn2: TBitBtn; 
    procedure NouveauClick(Sender: TObject); 
    procedure ModifierClick(Sender: TObject); 
    procedure TimerTimer(Sender: TObject); 
    procedure FormActivate(Sender: TObject); 
    procedure FormClose(Sender: TObject; var Action: TCloseAction); 
    procedure SupprimerClick(Sender: TObject); 
    procedure TriCloseUp(Sender: TObject); 
    procedure Date_DuCloseUp(Sender: TObject); 
    procedure Date_AuCloseUp(Sender: TObject); 
    procedure N_pieceChange(Sender: TObject); 
    procedure TypePieceCloseUp(Sender: TObject); 
    procedure imprimerClick(Sender: TObject); 
  private 
    { Private declarations } 
  public 
    { Public declarations } 
  end; 
 
var 
  Stockform: TStockform; 
 
implementation 
 
uses Unit3, Unit22, Unit29, Unit55, Unit74; 
 
{$R *.dfm} 
 
procedure TStockform.NouveauClick(Sender: TObject); 
begin 
If data.Articles.IsEmpty then Raise exception.Create('il n''existe Aucun Articles...'); 
//if Not( FileExists('C:\Windows\System\_sqldb.dll'))  AND (data.CompteurFacture.Value>5) then 
// RAise exception.Create('Version Démo !'); 
//**************************** 
if Choix_stock.ShowModal=mrok then 
begin 
 Data.T_Stock.Append; 
 Sai_Stock.ShowModal; 
end; 
end; 
 
procedure TStockform.ModifierClick(Sender: TObject); 
begin 
if  Data.T_StockType.Value='Entrée' Then choix_Stock.Choix.ItemIndex:=0; 
if  Data.T_StockType.Value='Sortie' Then choix_Stock.Choix.ItemIndex:=1; 
if Data.T_StockType.Value='Inventaire' then choix_Stock.Choix.ItemIndex:=2; 
data.T_Stock.Edit; 
Sai_Stock.ShowModal; 
end; 
 
procedure TStockform.TimerTimer(Sender: TObject); 
begin 
case Choix_Filtre.ItemIndex of 
0: Begin 
   Date_Du.Enabled:=True; 
   Date_Du.Color:=Clwhite; 
   Date_Au.Enabled:=True; 
   Date_Au.Color:=clwhite; 
   N_piece.Enabled:=false; 
   N_Piece.Color:=clBtnFace; 
   TypePiece.Enabled:=False; 
   TypePiece.Color:=clBtnFace; 
end; 
 
1: Begin 
   Date_Du.Enabled:=False; 
   date_du.Color:=clBtnFace; 
   Date_Au.Enabled:=False; 
   date_au.Color:=clBtnFace; 
   N_piece.Enabled:=True; 
   N_piece.Color:=clwhite; 
   TypePiece.Enabled:=True; 
   TypePiece.Color:=clWhite; 
   end; 
END; 
 
 
if data.T_Stock.IsEmpty then 
        Begin 
        Modifier.Enabled:=False; 
        Supprimer.Enabled:=False; 
//        imprimer.Enabled:=False; 
        end 
else 
        Begin 
        Modifier.Enabled:=True; 
        Supprimer.Enabled:=True; 
//        Imprimer.Enabled:=true; 
        end; 
end; 
 
procedure TStockform.FormActivate(Sender: TObject); 
begin 
Timer.Enabled:=true; 
data.Articles.CachedUpdates:=True; 
data.Matier_p.CachedUpdates:=True 
end; 
 
procedure TStockform.FormClose(Sender: TObject; var Action: TCloseAction); 
begin 
Timer.Enabled:=False; 
Data.T_Stock.Filtered:=false; 
data.Articles.CachedUpdates:=False; 
data.Matier_p.CachedUpdates:=False; 
//action:=cafree; 
end; 
 
procedure TStockform.SupprimerClick(Sender: TObject); 
begin 
if MessageDlg('Confirmer la Suppression',mtConfirmation, [mbYes, mbNo], 0) = mrYes then 
    Data.T_Stock.Delete; 
 
end; 
 
procedure TStockform.TriCloseUp(Sender: TObject); 
begin 
IF Tri.ItemIndex<>0 then 
begin 
Data.T_Stock.Filter:='Type='''+Tri.Items.Strings[Tri.ItemIndex]+'*'''; 
Data.T_Stock.Filtered:=true; 
end 
else 
Data.T_Stock.Filtered:=false; 
 
end; 
 
procedure TStockform.Date_DuCloseUp(Sender: TObject); 
begin 
Data.T_Stock.Filter:='(Date>='''+DatetoStr(Date_du.date)+''')And (Date<='''+DateToStr(Date_Au.date)+''')'; 
Data.T_Stock.Filtered:=True; 
 
end; 
 
procedure TStockform.Date_AuCloseUp(Sender: TObject); 
begin 
Data.T_Stock.Filter:='(Date>='''+DatetoStr(Date_du.date)+''')And (Date<='''+DateToStr(Date_Au.date)+''')'; 
Data.T_Stock.Filtered:=True; 
 
end; 
 
procedure TStockform.N_pieceChange(Sender: TObject); 
begin 
IF N_Piece.GetTextLen<> 0 then 
begin 
Data.T_Stock.Filter:='Type='''+TRIM(TypePiece.items.Strings[TypePiece.ItemIndex])+''' AND Code='''+N_Piece.Text+''''; 
Data.T_Stock.Filtered:=true; 
end 
else 
Data.T_Stock.Filtered:=false; 
 
end; 
 
procedure TStockform.TypePieceCloseUp(Sender: TObject); 
begin 
//N_piece.Text:='' 
IF N_Piece.GetTextLen<> 0 then 
begin 
Data.T_Stock.Filter:='Code='''+TRIM(TypePiece.items.Strings[TypePiece.ItemIndex])+' '+N_Piece.Text+'*'''; 
Data.T_Stock.Filtered:=true; 
end 
else 
Data.T_Stock.Filtered:=false; 
 
end; 
 
procedure TStockform.imprimerClick(Sender: TObject); 
begin 
imprime_Stock.ShowModal; 
end; 
 
end.