189 lines
4.3 KiB
ObjectPascal
189 lines
4.3 KiB
ObjectPascal
unit frmPredvyroba;
|
|
|
|
interface
|
|
|
|
uses
|
|
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
|
|
Vcl.Controls, Vcl.Forms, Vcl.Dialogs,
|
|
ddPlugin_TLB, Data.DB, Vcl.Grids, Vcl.DBGrids, Vcl.ExtCtrls, Vcl.StdCtrls;
|
|
|
|
type
|
|
TformPredvyroba = class(TForm)
|
|
grdPredvyroba: TDBGrid;
|
|
GridPanel1: TGridPanel;
|
|
GridPanel2: TGridPanel;
|
|
GridPanel3: TGridPanel;
|
|
edtSZ: TEdit;
|
|
edtRegCis: TEdit;
|
|
edtBal2: TEdit;
|
|
edtNazev1: TEdit;
|
|
edtMJ: TEdit;
|
|
edtBal: TEdit;
|
|
edtStroj: TEdit;
|
|
Button1: TButton;
|
|
lblReset: TLabel;
|
|
procedure edtSZChange(Sender: TObject);
|
|
procedure edtRegCisChange(Sender: TObject);
|
|
procedure edtNazev1Change(Sender: TObject);
|
|
procedure FormShow(Sender: TObject);
|
|
procedure edtStrojChange(Sender: TObject);
|
|
procedure lblResetClick(Sender: TObject);
|
|
procedure grdPredvyrobaDblClick(Sender: TObject);
|
|
procedure grdPredvyrobaDrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState);
|
|
procedure Button1Click(Sender: TObject);
|
|
private
|
|
procedure Filtruj;
|
|
public
|
|
Helios: IHelios;
|
|
end;
|
|
|
|
var
|
|
formPredvyroba: TformPredvyroba;
|
|
|
|
implementation
|
|
uses System.StrUtils, System.DateUtils,
|
|
datMod, helUtils, helTabsBIDs, frmPredvyrobaDetail;
|
|
|
|
{$R *.dfm}
|
|
|
|
|
|
procedure TformPredvyroba.Filtruj;
|
|
var filtr: string;
|
|
begin
|
|
filtr:= '';
|
|
if (edtSZ.Text<>'') then
|
|
filtr:= 'UPPER(colSZ) LIKE ''%' + edtSZ.Text.Trim.ToUpper + '%''';
|
|
|
|
if (edtRegCis.Text<>'') then
|
|
filtr:= filtr + IfThen(filtr='', '', ' AND ') + 'UPPER(colRegCis) LIKE ''%' + edtRegCis.Text.Trim.ToUpper + '%''';
|
|
|
|
if (edtNazev1.Text<>'') then
|
|
filtr:= filtr + IfThen(filtr='', '', ' AND ') + 'UPPER(colNazev1) LIKE ''%' + edtNazev1.Text.Trim.ToUpper + '%''';
|
|
|
|
if (edtStroj.Text<>'') then
|
|
filtr:= filtr + IfThen(filtr='', '', ' AND ') + 'UPPER(colStroj) LIKE ''%' + edtStroj.Text.Trim.ToUpper + '%''';
|
|
|
|
|
|
if (filtr='') then
|
|
begin
|
|
dm.vtPredvyroba.Filter:= filtr;
|
|
dm.vtPredvyroba.Filtered:= false;
|
|
end
|
|
else
|
|
begin
|
|
dm.vtPredvyroba.Filter:= filtr;
|
|
dm.vtPredvyroba.Filtered:= true;
|
|
end;
|
|
|
|
grdPredvyroba.Invalidate;
|
|
end;
|
|
|
|
|
|
|
|
|
|
procedure TformPredvyroba.FormShow(Sender: TObject);
|
|
begin
|
|
dm.NactiPredvyrobu (self);
|
|
grdPredvyroba.SetFocus;
|
|
end;
|
|
|
|
|
|
|
|
|
|
procedure TformPredvyroba.grdPredvyrobaDblClick (Sender: TObject);
|
|
var f: TformPredvyrobaDetail;
|
|
begin
|
|
if (grdPredvyroba.DataSource.DataSet.FieldByName('colNazev1').AsString<>'') then
|
|
begin
|
|
f:= TformPredvyrobaDetail.Create(nil);
|
|
try
|
|
f.Helios:= Helios;
|
|
f.idKmen:= grdPredvyroba.DataSource.DataSet.FieldByName('colIDKmen').AsInteger;
|
|
f.ShowModal;
|
|
finally
|
|
f.Free;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
procedure TformPredvyroba.grdPredvyrobaDrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState);
|
|
begin
|
|
if (not(gdSelected in State)) then
|
|
begin
|
|
if (Odd(grdPredvyroba.DataSource.DataSet.RecNo)) then
|
|
TDBGrid(Sender).Canvas.Brush.Color:= clWindow // bila
|
|
else
|
|
TDBGrid(Sender).Canvas.Brush.Color:= $00E0E0E0; // seda
|
|
end;
|
|
|
|
if (Column.FieldName='colNazev1') then
|
|
begin
|
|
TDBGrid(Sender).Canvas.Brush.Color:= $00D0FEC6; // zelena
|
|
if (gdSelected in State) then
|
|
begin
|
|
TDBGrid(Sender).Canvas.Brush.Color:= $0061F0FC; // zluta
|
|
TDBGrid(Sender).Canvas.Font.Color:= clBlack; // cerne pismo na zlutem pozadi
|
|
end;
|
|
end;
|
|
|
|
TDBGrid(Sender).DefaultDrawColumnCell (Rect, DataCol, Column, State);
|
|
end;
|
|
|
|
|
|
|
|
|
|
procedure TformPredvyroba.lblResetClick(Sender: TObject);
|
|
begin
|
|
edtSZ.Text:= '';
|
|
edtRegCis.Text:= '';
|
|
edtNazev1.Text:= '';
|
|
edtStroj.Text:= '';
|
|
Filtruj;
|
|
grdPredvyroba.SetFocus;
|
|
end;
|
|
|
|
|
|
|
|
|
|
procedure TformPredvyroba.Button1Click(Sender: TObject);
|
|
begin
|
|
grdPredvyrobaDblClick (Sender);
|
|
end;
|
|
|
|
|
|
|
|
procedure TformPredvyroba.edtNazev1Change(Sender: TObject);
|
|
begin
|
|
Filtruj;
|
|
end;
|
|
|
|
|
|
|
|
|
|
procedure TformPredvyroba.edtRegCisChange(Sender: TObject);
|
|
begin
|
|
Filtruj;
|
|
end;
|
|
|
|
|
|
|
|
|
|
procedure TformPredvyroba.edtStrojChange(Sender: TObject);
|
|
begin
|
|
Filtruj;
|
|
end;
|
|
|
|
|
|
|
|
|
|
procedure TformPredvyroba.edtSZChange(Sender: TObject);
|
|
begin
|
|
edtSZ.Text:= edtSZ.Text.Trim;
|
|
Filtruj;
|
|
end;
|
|
|
|
end.
|