unit U_CPView;  //3

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, cxGraphics, cxCustomData, cxStyles, cxTL, cxMaskEdit, DB, ADODB,
  cxInplaceContainer, cxDBTL, cxControls, cxTLData, ComCtrls, ToolWin,
  StdCtrls, cxFilter, cxData, cxDataStorage, cxEdit, cxDBData, DBClient,
  cxGridCustomTableView, cxGridTableView, cxGridDBTableView, ExtCtrls,
  cxSplitter, cxGridLevel, cxClasses, cxGridCustomView, cxGrid,
  cxGridCustomPopupMenu, cxGridPopupMenu, RM_Dataset, RM_System, RM_Common,
  RM_Class, RM_GridReport, IdBaseComponent, IdComponent, IdTCPConnection,
  IdTCPClient, IdFTP,ShellAPI,IniFiles, cxCheckBox,jpeg, BtnEdit;

type
  TfrmCPView = class(TForm)
    ToolBar1: TToolBar;
    TBRafresh: TToolButton;
    TBClose: TToolButton;
    DataSource1: TDataSource;
    ADOQueryTree20: TADOQuery;
    ADOQueryTemp: TADOQuery;
    ADOQueryCmd: TADOQuery;
    cxGridPopupMenu1: TcxGridPopupMenu;
    Tv1: TcxGridDBTableView;
    cxGrid1Level1: TcxGridLevel;
    cxGrid1: TcxGrid;
    cxSplitter1: TcxSplitter;
    Panel1: TPanel;
    Label2: TLabel;
    CYID: TEdit;
    ToolButton2: TToolButton;
    Label1: TLabel;
    CYName: TEdit;
    Label4: TLabel;
    CYEName: TEdit;
    Label5: TLabel;
    CYSpec: TEdit;
    v1Column1: TcxGridDBColumn;
    v1Column2: TcxGridDBColumn;
    v1Column3: TcxGridDBColumn;
    v1Column4: TcxGridDBColumn;
    v1Column5: TcxGridDBColumn;
    v1Column6: TcxGridDBColumn;
    v1Column7: TcxGridDBColumn;
    v1Column8: TcxGridDBColumn;
    v1Column9: TcxGridDBColumn;
    v1Column11: TcxGridDBColumn;
    DataSource2: TDataSource;
    ADOQueryMain: TADOQuery;
    CDS_Main: TClientDataSet;
    v1Column12: TcxGridDBColumn;
    ToolButton1: TToolButton;
    ToolButton4: TToolButton;
    RM1: TRMGridReport;
    RMDB_Main: TRMDBDataSet;
    ODPat: TOpenDialog;
    IdFTP1: TIdFTP;
    SaveDialog1: TSaveDialog;
    ToolButton6: TToolButton;
    v1Column14: TcxGridDBColumn;
    v1Column15: TcxGridDBColumn;
    Label3: TLabel;
    CYNO: TEdit;
    v1Column16: TcxGridDBColumn;
    Panel2: TPanel;
    v1Column19: TcxGridDBColumn;
    DSCYNO: TDataSource;
    CDS_CYNO: TClientDataSet;
    Label7: TLabel;
    CYKZ: TEdit;
    Label8: TLabel;
    Label9: TLabel;
    CYCF: TEdit;
    CYECF: TEdit;
    Label10: TLabel;
    CYMF: TEdit;
    v1Column42: TcxGridDBColumn;
    v1Column10: TcxGridDBColumn;
    v1Column13: TcxGridDBColumn;
    ADOQueryTree: TClientDataSet;
    Panel5: TPanel;
    Image2: TImage;
    cxDBTreeList1: TcxDBTreeList;
    cxDBTreeList1cxDBTreeListColumn2: TcxDBTreeListColumn;
    Label11: TLabel;
    Label12: TLabel;
    Panel4: TPanel;
    Label13: TLabel;
    LabName: TBtnEditA;
    ToolButton3: TToolButton;
    Panel3: TPanel;
    Label6: TLabel;
    Edit1: TEdit;
    Label15: TLabel;
    OldCYNo: TEdit;
    v1Column17: TcxGridDBColumn;
    v1Column18: TcxGridDBColumn;
    v1Column20: TcxGridDBColumn;
    Label16: TLabel;
    OrderNo: TEdit;
    procedure FormDestroy(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure TBCloseClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure cxDBTreeList1DblClick(Sender: TObject);
    procedure TBRafreshClick(Sender: TObject);
    procedure ToolButton2Click(Sender: TObject);
    procedure CYIDKeyPress(Sender: TObject; var Key: Char);
    procedure ToolButton1Click(Sender: TObject);
    procedure ToolButton4Click(Sender: TObject);
    procedure ToolButton6Click(Sender: TObject);
    procedure Tv1CellDblClick(Sender: TcxCustomGridTableView;
      ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
      AShift: TShiftState; var AHandled: Boolean);
    procedure Tv1CellClick(Sender: TcxCustomGridTableView;
      ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
      AShift: TShiftState; var AHandled: Boolean);
    procedure FormKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure CYSpecChange(Sender: TObject);
    procedure v1Column19PropertiesChange(Sender: TObject);
    procedure CYNOKeyPress(Sender: TObject; var Key: Char);
    procedure LabNameBtnClick(Sender: TObject);
    procedure ToolButton3Click(Sender: TObject);
    procedure OldCYNoKeyPress(Sender: TObject; var Key: Char);
    procedure CYSpecKeyPress(Sender: TObject; var Key: Char);
    procedure CYNameKeyPress(Sender: TObject; var Key: Char);
    procedure CYCFKeyPress(Sender: TObject; var Key: Char);
    procedure CYENameKeyPress(Sender: TObject; var Key: Char);
    procedure OrderNoKeyPress(Sender: TObject; var Key: Char);
  private
    { Private declarations }
    CPID:string;
    PState:Integer;
    FCPID,FTopID:String;
    procedure InitTree();
    procedure InitGrid();
    procedure InitGridSql(fsj:string);
    procedure ReadINIFile();
    procedure InitImage();
    procedure TJGS();

  public
    { Public declarations }
  end;

var
  frmCPView: TfrmCPView;

implementation
uses
  U_DataLink,U_RTFun,U_CPAdd,U_FileUp,U_ZDYHelp;

{$R *.dfm}

procedure TfrmCPView.InitTree();
var
  i:Integer;
begin
  with ADOQueryTree20 do
  begin
    Close;
    SQL.Clear;
    SQL.Add('select * from CP_Type order by CPlevel,CPOrder,CPName');
    Open;
  end;
  SCreateCDS20(ADOQueryTree20,ADOQueryTree);
  SInitCDSData20(ADOQueryTree20,ADOQueryTree);
  cxDBTreeList1.Items[0].Expand(false);
  //cxDBTreeList1.Items[1].Expand(False);
end;

procedure TfrmCPView.InitGrid();
begin
  Panel2.Visible:=True;
  Panel2.Refresh;
  try
    ADOQueryMain.DisableControls;
    with ADOQueryMain do
    begin
      Filtered:=False;
      Close;
      SQL.Clear;
      SQL.Add('exec P_Select_CP_YDang :Code,:PState,:CYType');
      Parameters.ParamByName('Code').Value:='';
      Parameters.ParamByName('PState').Value:=0;
      Parameters.ParamByName('CYType').Value:=Trim(ADOQueryTree.fieldbyname('CPID').AsString);
      Open;
    end;
    SCreateCDS20(ADOQueryMain,CDS_Main);
    SInitCDSData20(ADOQueryMain,CDS_Main);
  finally
    ADOQueryMain.EnableControls;
  end;
  Panel2.Visible:=False;
end;
procedure TfrmCPView.TJGS();
var
  i,j:Integer;
begin
  i:=0;
  j:=0;
  CDS_Main.DisableControls;
  with CDS_Main do
  begin
    first;
    while not Eof do
    begin
      if FieldByName('CYPriceKg').Value=0 then
      begin
        i:=i+1;
      end else
      begin
        j:=j+1;
      end;
      Next;
    end;
  end;
  CDS_Main.EnableControls;
  Label11.Caption:='定价样品数量:'+Trim(IntToStr(j));
  Label12.Caption:='未定价样品数量:'+Trim(IntToStr(i));
end;
procedure TfrmCPView.FormDestroy(Sender: TObject);
begin
  frmCPView:=nil;
end;

procedure TfrmCPView.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  Action:=caFree;
end;

procedure TfrmCPView.TBCloseClick(Sender: TObject);
begin
  WriteCxGrid('样品列表CX',Tv1,'样品管理');
  if  DirectoryExists(ExtractFileDir('D:\Right1209')) then
    winexec('cmd /c rd /s /q D:\Right1209',sw_hide);
  Close;
end;
procedure TfrmCPView.FormShow(Sender: TObject);
begin
  InitTree();
  ReadCxGrid('样品列表CX',Tv1,'样品管理');
  with ADOQueryTemp do
  begin
    Close;
    sql.Clear;
    sql.Add('select CYID='''' ');
    Open;
  end;
  SCreateCDS20(ADOQueryTemp,CDS_CYNO);
  SInitCDSData20(ADOQueryTemp,CDS_CYNO);
  CDS_CYNO.Delete;
end;

procedure TfrmCPView.cxDBTreeList1DblClick(Sender: TObject);
begin
  InitGrid();
  TJGS();
end;

procedure TfrmCPView.TBRafreshClick(Sender: TObject);
begin
  InitTree();
  InitGrid();
  TJGS();
end;

procedure TfrmCPView.ToolButton2Click(Sender: TObject);
begin
  if ADOQueryMain.Active then
  begin
    SDofilter(ADOQueryMain,SGetFilters(Panel1,1,2));
    SCreateCDS20(ADOQueryMain,CDS_Main);
    SInitCDSData20(ADOQueryMain,CDS_Main);
    TJGS();
  end;

end;

procedure TfrmCPView.CYIDKeyPress(Sender: TObject; var Key: Char);
begin
  if Key=#13 then
  begin
    if Trim(CYID.Text)='' then Exit;
    with ADOQueryMain do
    begin
      Close;
      Filtered:=False;
      sql.Clear;
      sql.Add('exec P_Select_CP_YDang :Code,1,'''' ');
      Parameters.ParamByName('Code').Value:=Trim(CYID.Text);
      Open;
    end;
    SCreateCDS20(ADOQueryMain,CDS_Main);
    SInitCDSData20(ADOQueryMain,CDS_Main);
    CYID.Text:='';
    ADOQueryTree.Locate('CPID',CPID,[]);
  end;
end;

procedure TfrmCPView.ToolButton1Click(Sender: TObject);
begin
  if CDS_Main.IsEmpty then Exit;
  TcxGridToExcel('样品档案',cxGrid1);
end;

procedure TfrmCPView.ToolButton4Click(Sender: TObject);
var
   fPrintFile,FFCYID:string;
   DPS,i,j:Integer;
begin
  CYID.SetFocus;
  if CDS_Main.IsEmpty then Exit;
  //if CDS_CYNO.IsEmpty then Exit;
  if Trim(LabName.Text)='' then
  begin
    Application.MessageBox('标签名称不能为空!','提示',0);
    Exit;
  end;
  if Trim(Edit1.Text)<>'' then
  begin
    if TryStrToInt(Edit1.Text,i)=False then
    begin
      Application.MessageBox('份数录入错误!','提示',0);
      exit;
    end;
  end;

  fPrintFile:= ExtractFilePath(Application.ExeName) +'Report\'+Trim(LabName.Text)+'.rmf';
  CDS_Main.DisableControls;
  DPS:=0;
  FFCYID:='';
  i:=1;
  if Trim(Edit1.Text)='' then
  begin
    j:=1;
  end else
  begin
    j:=StrToInt(Edit1.Text);
  end;
  with CDS_Main do
  begin
    First;
    while not Eof do
    begin
      if CDS_Main.FieldByName('SSel').AsBoolean=True then
      begin
        for i:=1 to j do
        begin
          if FileExists(fPrintFile) then
          begin
            RM1.LoadFromFile(fPrintFile);
            RM1.PrintReport;
          end else
          begin
            Application.MessageBox(PChar('没有找'+ExtractFilePath(Application.ExeName)+'Report\'+Trim(LabName.Text)+'.rmf'),'提示',0);
            Exit;
          end;
        end;

        if DPS=0 then
        begin
          FFCYID:=Trim(CDS_Main.fieldbyname('CYID').AsString);
        end;
      end;
      //CDS_Main.Locate('CYID',Trim(CDS_CYNO.fieldbyname('CYID').AsString),[]);

      Next;
    end;
  end;
  CDS_Main.EnableControls;
  CDS_Main.Locate('CYID',FFCYID,[]);
  Edit1.Text:='1';

end;

procedure TfrmCPView.ToolButton6Click(Sender: TObject);
var
  fHandle:THandle;
  FInt:Integer;
  FFName,FPath,FFFFCPNO:String;
begin
  {FPath:='C:\HTTP1209\';
  if  DirectoryExists(ExtractFileDir(FPath)) then
    winexec('cmd /c rd /s /q C:\HTTP1209',sw_hide);}
  FFFFCPNO:=Trim(CDS_Main.fieldbyname('CYNo').AsString);
  if Pos(':',FFFFCPNO)>0 then
  begin
    Application.MessageBox('产品编号不允许存在冒号(:)！','',0);
    Exit;
  end;
  if Pos('：',FFFFCPNO)>0 then
  begin
    Application.MessageBox('产品编号不允许存在冒号(：)！','',0);
    Exit;
  end;
  if Pos('\',FFFFCPNO)>0 then
  begin
    Application.MessageBox('产品编号不允许存在反斜杠(\)！','',0);
    Exit;
  end;
  with ADOQueryTemp do
  begin
    close;
    sql.Clear;
    sql.Add('select * from XD_File where CYNO='''+Trim(CDS_Main.fieldbyname('CYNO').AsString)+'''');
    Open;
    if IsEmpty then
    begin
      Application.MessageBox('样品图片未上传！','提示',0);
      Exit;
    end;
  end;
  try
    ReadINIFile();
    server:=ReadINIFileStr('SYSTEMSET.INI','SERVER','服务器地址','127.0.0.1');
    if Length(server)<6 then
    begin
      server:='127.0.0.1';
    end;
    IdFTP1.Host :=server;//PicSvr;
    IdFTP1.Username := 'three';
    IdFTP1.Password := '641010';
    IdFTP1.Connect();
  except
    IdFTP1.Quit;
    Application.MessageBox('无法连接到文件服务器，请检查！', '提示', MB_ICONWARNING);
    Exit;
  end;
  FPath:='D:\Right1209\';
  if not DirectoryExists(ExtractFileDir(FPath)) then
    CreateDir(ExtractFileDir(FPath));
  FFName:=Trim(ADOQueryTemp.fieldbyname('FileName').AsString);
  FFName:=FPath+FFName;
  if FileExists(FFName) then
  begin
    FInt:=1;
  end;
  if FInt<>1 then
    IdFTP1.Get('YP\'+Trim(ADOQueryTemp.fieldbyname('FileName').AsString),
                   FPath+Trim(ADOQueryTemp.fieldbyname('FileName').AsString)
                    );
  if IdFTP1.Connected then IdFTP1.Quit;
  ShellExecute(Handle, 'open',PChar(FPath+Trim(ADOQueryTemp.fieldbyname('FileName').AsString)),'', '', SW_SHOWNORMAL);

end;
procedure TfrmCPView.ReadINIFile();
var
  programIni:Tinifile;  //配置文件名
  FileName:string;
begin
  FileName:=ExtractFilePath(Paramstr(0))+'SYSTEMSET.INI';
  programIni:=Tinifile.create(FileName);
  server:=programIni.ReadString('SERVER','服务器地址','127.0.0.1');
  programIni.Free;
end;

procedure TfrmCPView.Tv1CellDblClick(Sender: TcxCustomGridTableView;
  ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
  AShift: TShiftState; var AHandled: Boolean);
begin
  ToolButton6.Click;
end;

procedure TfrmCPView.Tv1CellClick(Sender: TcxCustomGridTableView;
  ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
  AShift: TShiftState; var AHandled: Boolean);
begin
  if CDS_Main.IsEmpty then Exit;
  with ADOQueryTemp do
  begin
    Close;
    sql.Clear;
    sql.Add('select * from CP_YDang where CYID='''+Trim(CDS_Main.fieldbyname('CYID').asstring)+'''');
    Open;
  end;
  CPID:=Trim(ADOQueryTemp.fieldbyname('CYType').AsString);
  ADOQueryTree.Locate('CPID',CPID,[]);
  InitImage();
end;
procedure TfrmCPView.InitImage();
var
  jpg:TJpegImage;
  myStream:TADOBlobStream;
begin
  if CDS_Main.IsEmpty then Exit;
  if Trim(CDS_Main.fieldbyname('CYID').AsString)='' then Exit;
 // if cxPageControl1.ActivePageIndex=6 then
  begin
    Image2.Picture.Assign(nil);
    try
      with ADOQueryTemp do
      begin
        close;
        sql.Clear;
        sql.Add(' select * from TP_File A where A.WBID='''+Trim(CDS_Main.fieldbyname('CYID').AsString)+'''');
        sql.Add(' and TFType=''样品'' ');
        open;
        if RecordCount>0 then
        begin
          if trim(ADOQueryTemp.fieldbyname('FilesOther').AsString)<>'' then
          begin
            myStream:=tadoblobstream.Create(tblobfield(ADOQueryTemp.fieldbyname('FilesOther')),bmread);
            if myStream=nil then exit;
            jpg:=TJPEGImage.Create;
            jpg.LoadFromStream(myStream);
            Image2.Picture.Assign(jpg);
          end;
        end;
      end;
    finally
      jpg.Free;
      myStream.Free;
    end;
  end;
end;

procedure TfrmCPView.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  {if Key= then
  begin
    if CDS_Main.IsEmpty then Exit;
    if Application.MessageBox('确定6666要删除数据吗？','提示',32+4)<>IDYES then Exit;
    if Trim(CDS_Main.fieldbyname('CYID').AsString)<>'' then
    begin
      with ADOQueryCmd do
      begin
        Close;
        SQL.Clear;
        sql.Add('delete CP_YDang where CYID='''+Trim(CDS_Main.fieldbyname('CYID').AsString)+'''');
        ExecSQL;
      end;
    end;

    CDS_Main.Delete;
  end;  }
end;

procedure TfrmCPView.CYSpecChange(Sender: TObject);
begin
  if Length(Trim(CYSpec.Text))<3 then Exit;
  if ADOQueryMain.Active then
  begin
    SDofilter(ADOQueryMain,SGetFilters(Panel1,1,2));
    SCreateCDS20(ADOQueryMain,CDS_Main);
    SInitCDSData20(ADOQueryMain,CDS_Main);
  end;
end;

procedure TfrmCPView.v1Column19PropertiesChange(Sender: TObject);
var
  mvalue:Boolean;
begin
 { mvalue:=TcxCheckBox(Sender).EditingValue;
  if mvalue=True then
  begin
    with CDS_CYNO do
    begin
      if Locate('CYID',Trim(CDS_Main.fieldbyname('CYID').AsString),[])=False then
      begin
        Append;
        FieldByName('CYID').Value:=Trim(CDS_Main.fieldbyname('CYID').AsString);
        Post;
      end;
    end;
  end else
  begin
    //with CDS_CYNO do
    //begin
    CDS_CYNO.Locate('CYID',Trim(CDS_Main.fieldbyname('CYID').AsString),[]);
    CDS_CYNO.Delete;
    //end;
  end; }
end;

procedure TfrmCPView.CYNOKeyPress(Sender: TObject; var Key: Char);
begin
  if Key=#13 then
  begin
    if Trim(CYNO.Text)='' then Exit;
    if Length(Trim(CYNO.Text))<4 then Exit;
    with ADOQueryMain do
    begin
      Close;
      Filtered:=False;
      sql.Clear;
      sql.Add('exec P_Select_CP_YDang :Code,2,'''' ');
      Parameters.ParamByName('Code').Value:='%'+Trim(CYNO.Text)+'%';
      Open;
    end;
    SCreateCDS20(ADOQueryMain,CDS_Main);
    SInitCDSData20(ADOQueryMain,CDS_Main);
    CYID.Text:='';
    ADOQueryTree.Locate('CPID',CPID,[]);
    TJGS();
  end;
end;

procedure TfrmCPView.LabNameBtnClick(Sender: TObject);
begin
  try
    frmZDYHelp:=TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag:='YPLabName';
      flagname:='样品标签';
      fnote:=True;
      TBAdd.Visible:=False;
      TBEdit.Visible:=False;
      TBDel.Visible:=False;
      if ShowModal=1 then
      begin
        Self.LabName.Text:=Trim(frmZDYHelp.ClientDataSet1.fieldbyname('ZdyName').AsString);
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

procedure TfrmCPView.ToolButton3Click(Sender: TObject);
var
   fPrintFile:string;
begin
  if CDS_Main.IsEmpty then Exit;
  if Trim(LabName.Text)='' then
  begin
    Application.MessageBox('标签名称不能为空!','提示',0);
    Exit;
  end;
  fPrintFile:= ExtractFilePath(Application.ExeName) + 'Report\'+Trim(LabName.Text)+'.rmf' ;
  if FileExists(fPrintFile) then
  begin
    RM1.LoadFromFile(fPrintFile);
    RM1.ShowReport;
  end else
  begin
    Application.MessageBox(PChar('没有找'+ExtractFilePath(Application.ExeName)+'Report\'+Trim(LabName.Text)+'.rmf'),'提示',0);
  end;
end;

procedure TfrmCPView.OldCYNoKeyPress(Sender: TObject; var Key: Char);
begin
  if Key=#13 then
  begin
    if Trim(OldCYNo.Text)='' then Exit;
    if Length(Trim(OldCYNo.Text))<4 then Exit;
    with ADOQueryMain do
    begin
      Close;
      Filtered:=False;
      sql.Clear;
      sql.Add('exec P_Select_CP_YDang :Code,8,'''' ');
      Parameters.ParamByName('Code').Value:='%'+Trim(OldCYNo.Text)+'%';
      Open;
    end;
    SCreateCDS20(ADOQueryMain,CDS_Main);
    SInitCDSData20(ADOQueryMain,CDS_Main);
    CYID.Text:='';
    ADOQueryTree.Locate('CPID',CPID,[]);
    TJGS();
  end;
end;

procedure TfrmCPView.CYSpecKeyPress(Sender: TObject; var Key: Char);
begin
  if Key=#13 then
  begin
    if ADOQueryMain.Active then
    begin
      SDofilter(ADOQueryMain,SGetFilters(Panel1,1,2));
      SCreateCDS20(ADOQueryMain,CDS_Main);
      SInitCDSData20(ADOQueryMain,CDS_Main);
      TJGS();
    end;
  end;
end;

procedure TfrmCPView.CYNameKeyPress(Sender: TObject; var Key: Char);
begin
  if Key=#13 then
  begin
    InitGridSql(' and CYName like '''+'%'+Trim(CYName.Text)+'%'+'''');
    TJGS();
  end;
end;
procedure TfrmCPView.InitGridSql(fsj:string);
begin
  Panel2.Visible:=True;
  Panel2.Refresh;
  try
    ADOQueryMain.DisableControls;
    with ADOQueryMain do
    begin
      Filtered:=False;
      Close;
      SQL.Clear;
      SQL.Add('exec P_Select_CP_YDang_Sql :WSql');
      Parameters.ParamByName('WSql').Value:=fsj;
      Open;
    end;
    SCreateCDS20(ADOQueryMain,CDS_Main);
    SInitCDSData20(ADOQueryMain,CDS_Main);
  finally
    ADOQueryMain.EnableControls;
  end;
  Panel2.Visible:=False;
end;
procedure TfrmCPView.CYCFKeyPress(Sender: TObject; var Key: Char);
begin
  if Key=#13 then
  begin
    if ADOQueryMain.Active then
    begin
      SDofilter(ADOQueryMain,SGetFilters(Panel1,1,2));
      SCreateCDS20(ADOQueryMain,CDS_Main);
      SInitCDSData20(ADOQueryMain,CDS_Main);
      TJGS();
    end;
  end;
end;

procedure TfrmCPView.CYENameKeyPress(Sender: TObject; var Key: Char);
begin
  if Key=#13 then
  begin
    InitGridSql(' and CYEName like '''+'%'+Trim(CYEName.Text)+'%'+'''');
    TJGS();
  end;
end;

procedure TfrmCPView.OrderNoKeyPress(Sender: TObject; var Key: Char);
begin
  if Key=#13 then
  begin
    InitGridSql(' and OrderNo like '''+'%'+Trim(OrderNo.Text)+'%'+'''');
    TJGS();
  end;
end;

end.
