209 lines
5.1 KiB
ObjectPascal
209 lines
5.1 KiB
ObjectPascal
|
|
unit U_PbMfProductHelp;
|
|||
|
|
|
|||
|
|
interface
|
|||
|
|
|
|||
|
|
uses
|
|||
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|||
|
|
Dialogs, DB, ADODB, Grids, DBGrids, ExtCtrls, ComCtrls, ImgList, ToolWin,
|
|||
|
|
StdCtrls, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData,
|
|||
|
|
cxDataStorage, cxEdit, cxDBData, cxTextEdit, cxGridCustomTableView,
|
|||
|
|
cxGridTableView, cxGridDBTableView, cxControls, cxGridCustomView,
|
|||
|
|
cxClasses, cxGridLevel, cxGrid,StrUtils, DBClient, cxCheckBox;
|
|||
|
|
|
|||
|
|
type
|
|||
|
|
TfrmPbMfProductHelp = class(TForm)
|
|||
|
|
Panel1: TPanel;
|
|||
|
|
Label1: TLabel;
|
|||
|
|
Edt_name: TEdit;
|
|||
|
|
ImageList24: TImageList;
|
|||
|
|
DataSource1: TDataSource;
|
|||
|
|
ADOQueryHelp: TADOQuery;
|
|||
|
|
ToolBar2: TToolBar;
|
|||
|
|
TOk: TToolButton;
|
|||
|
|
Tclose: TToolButton;
|
|||
|
|
cxGrid1: TcxGrid;
|
|||
|
|
cxGrid1Level1: TcxGridLevel;
|
|||
|
|
tv1: TcxGridDBTableView;
|
|||
|
|
tv1P_code1: TcxGridDBColumn;
|
|||
|
|
tv1P_chnName1: TcxGridDBColumn;
|
|||
|
|
tv1P_engName1: TcxGridDBColumn;
|
|||
|
|
tv1P_Gram1: TcxGridDBColumn;
|
|||
|
|
tv1P_breadthp: TcxGridDBColumn;
|
|||
|
|
tv1MachZsName: TcxGridDBColumn;
|
|||
|
|
tv1factoryName: TcxGridDBColumn;
|
|||
|
|
Label2: TLabel;
|
|||
|
|
Edt_spec: TEdit;
|
|||
|
|
ADOConnection1: TADOConnection;
|
|||
|
|
tv1P_spec: TcxGridDBColumn;
|
|||
|
|
cxStyleRepository1: TcxStyleRepository;
|
|||
|
|
cxStyle1: TcxStyle;
|
|||
|
|
cxStyle_Active: TcxStyle;
|
|||
|
|
cxStyle_gridRow: TcxStyle;
|
|||
|
|
cxStyle_gridFoot: TcxStyle;
|
|||
|
|
cxStyle_gridHead: TcxStyle;
|
|||
|
|
cxStyle_gridGroupBox: TcxStyle;
|
|||
|
|
cxStyle_yellow: TcxStyle;
|
|||
|
|
cxStyle_Red: TcxStyle;
|
|||
|
|
cxStyle_group: TcxStyle;
|
|||
|
|
cxStyle_fontBlue: TcxStyle;
|
|||
|
|
cxStyle_fontOlive: TcxStyle;
|
|||
|
|
cxStyle_fontbalck: TcxStyle;
|
|||
|
|
CDS_Sel: TClientDataSet;
|
|||
|
|
tv1Sel: TcxGridDBColumn;
|
|||
|
|
procedure BtnOkClick(Sender: TObject);
|
|||
|
|
procedure BtnCancelClick(Sender: TObject);
|
|||
|
|
procedure DBGrid1DblClick(Sender: TObject);
|
|||
|
|
procedure Edt_nameKeyDown(Sender: TObject; var Key: Word;
|
|||
|
|
Shift: TShiftState);
|
|||
|
|
procedure FormCreate(Sender: TObject);
|
|||
|
|
procedure FormShow(Sender: TObject);
|
|||
|
|
procedure RadioGroup1Click(Sender: TObject);
|
|||
|
|
procedure Edt_nameChange(Sender: TObject);
|
|||
|
|
procedure tv1MouseDown(Sender: TObject; Button: TMouseButton;
|
|||
|
|
Shift: TShiftState; X, Y: Integer);
|
|||
|
|
private
|
|||
|
|
procedure IntiQuery();
|
|||
|
|
procedure DoFilter();
|
|||
|
|
public
|
|||
|
|
{ Public declarations }
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
var
|
|||
|
|
frmPbMfProductHelp: TfrmPbMfProductHelp;
|
|||
|
|
|
|||
|
|
implementation
|
|||
|
|
uses
|
|||
|
|
U_adodbmd,U_global,U_FormPas;
|
|||
|
|
{$R *.dfm}
|
|||
|
|
|
|||
|
|
procedure TfrmPbMfProductHelp.BtnOkClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
if ADOQueryHelp.IsEmpty then exit;
|
|||
|
|
ModalResult:= 1;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmPbMfProductHelp.BtnCancelClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
ModalResult:= -1;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
|
|||
|
|
procedure TfrmPbMfProductHelp.IntiQuery();
|
|||
|
|
begin
|
|||
|
|
with ADOQueryHelp Do
|
|||
|
|
Begin
|
|||
|
|
DisableControls;
|
|||
|
|
Close;
|
|||
|
|
filtered:=false;
|
|||
|
|
SQL.Clear;
|
|||
|
|
SQL.Add('exec P_Get_MCMf_CatLog');
|
|||
|
|
sql.Add('P');
|
|||
|
|
Open;
|
|||
|
|
|
|||
|
|
CreateCDS20(ADOQueryHelp,CDS_Sel);
|
|||
|
|
InitCDSData20(ADOQueryHelp,CDS_Sel);
|
|||
|
|
EnableControls;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmPbMfProductHelp.DBGrid1DblClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
if ADOQueryHelp.IsEmpty then exit;
|
|||
|
|
ModalResult := 1;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmPbMfProductHelp.Edt_nameKeyDown(Sender: TObject; var Key: Word;
|
|||
|
|
Shift: TShiftState);
|
|||
|
|
Var
|
|||
|
|
TmpSql :string;
|
|||
|
|
begin
|
|||
|
|
if Key = VK_RETURN then
|
|||
|
|
begin
|
|||
|
|
IntiQuery();
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
|
|||
|
|
procedure TfrmPbMfProductHelp.FormCreate(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
with ADOConnection1 do
|
|||
|
|
begin
|
|||
|
|
Connected:=false;
|
|||
|
|
ConnectionString:=gConString;
|
|||
|
|
Connected:=true;
|
|||
|
|
end;
|
|||
|
|
cxgrid1.Align:=alClient;
|
|||
|
|
IntiQuery();
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmPbMfProductHelp.FormShow(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
Edt_Name.SetFocus;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmPbMfProductHelp.RadioGroup1Click(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
IntiQuery();
|
|||
|
|
end;
|
|||
|
|
////////////////////////////////////////////////////
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
////////////////////////////////////////////////////
|
|||
|
|
procedure TfrmPbMfProductHelp.DoFilter();
|
|||
|
|
var
|
|||
|
|
filterStr:string;
|
|||
|
|
begin
|
|||
|
|
filterStr:='';
|
|||
|
|
//<2F><><EFBFBD><EFBFBD>
|
|||
|
|
if trim(edt_Name.Text)<>'' then
|
|||
|
|
begin
|
|||
|
|
filterStr:=filterStr+' and (P_chnName like '+quotedStr('%'+trim(edt_Name.Text)+'%')+
|
|||
|
|
' or P_code like '+quotedStr('%'+trim(edt_Name.Text)+'%')+')';
|
|||
|
|
end;
|
|||
|
|
//<2F><><EFBFBD><EFBFBD>
|
|||
|
|
if trim(edt_spec.Text)<>'' then
|
|||
|
|
filterStr:=filterStr+' and P_spec like '+quotedStr('%'+trim(edt_spec.Text)+'%');
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
|
|||
|
|
ADOQueryHelp.DisableControls ;
|
|||
|
|
if trim(filterStr)='' then
|
|||
|
|
begin
|
|||
|
|
ADOQueryHelp.Filtered:=false;
|
|||
|
|
ADOQueryHelp.EnableControls;
|
|||
|
|
exit;
|
|||
|
|
end;
|
|||
|
|
filterStr:=trim(RightBStr(filterStr,length(filterStr)-4));
|
|||
|
|
with ADOQueryHelp do
|
|||
|
|
begin
|
|||
|
|
filtered:=false;
|
|||
|
|
filter:=filterStr;
|
|||
|
|
filtered:=true;
|
|||
|
|
end;
|
|||
|
|
CreateCDS20(ADOQueryHelp,CDS_Sel);
|
|||
|
|
InitCDSData20(ADOQueryHelp,CDS_Sel);
|
|||
|
|
finally
|
|||
|
|
ADOQueryHelp.EnableControls;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmPbMfProductHelp.Edt_nameChange(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
DoFilter();
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmPbMfProductHelp.tv1MouseDown(Sender: TObject;
|
|||
|
|
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
|
|||
|
|
begin
|
|||
|
|
if tv1.Controller.FocusedColumn.Name='tv1Sel' then
|
|||
|
|
begin
|
|||
|
|
CDS_Sel.Edit;
|
|||
|
|
if CDS_Sel.FieldByName('sel').AsBoolean=False then
|
|||
|
|
CDS_Sel.FieldByName('sel').Value:=True
|
|||
|
|
else
|
|||
|
|
CDS_Sel.FieldByName('sel').Value:=False;
|
|||
|
|
CDS_Sel.Post;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
end.
|