257 lines
7.0 KiB
ObjectPascal
257 lines
7.0 KiB
ObjectPascal
unit U_CPKWListSel;
|
||
|
||
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, cxCalendar,
|
||
cxButtonEdit, cxTextEdit;
|
||
|
||
type
|
||
TfrmCPKWListSel = class(TForm)
|
||
ToolBar1: TToolBar;
|
||
TBRafresh: TToolButton;
|
||
TBClose: TToolButton;
|
||
ADOQueryTemp: TADOQuery;
|
||
ADOQueryCmd: TADOQuery;
|
||
Panel1: TPanel;
|
||
ToolButton2: TToolButton;
|
||
ADOQueryMain: TADOQuery;
|
||
ToolButton1: TToolButton;
|
||
RM1: TRMGridReport;
|
||
RMDB_Main: TRMDBDataSet;
|
||
Label3: TLabel;
|
||
defstr1: TEdit;
|
||
cxGrid2: TcxGrid;
|
||
Tv2: TcxGridDBTableView;
|
||
cxGridLevel1: TcxGridLevel;
|
||
cxGridPopupMenu2: TcxGridPopupMenu;
|
||
DS_HZ: TDataSource;
|
||
CDS_HZ: TClientDataSet;
|
||
v2Column6: TcxGridDBColumn;
|
||
v2Column1: TcxGridDBColumn;
|
||
v2Column3: TcxGridDBColumn;
|
||
Label1: TLabel;
|
||
ZdyCode: TEdit;
|
||
v2Column8: TcxGridDBColumn;
|
||
Label2: TLabel;
|
||
DEFstr3: TComboBox;
|
||
v2Column10: TcxGridDBColumn;
|
||
v2Column11: TcxGridDBColumn;
|
||
v2Column12: TcxGridDBColumn;
|
||
v2Column13: TcxGridDBColumn;
|
||
defstr2: TEdit;
|
||
Label4: TLabel;
|
||
v2Column2: TcxGridDBColumn;
|
||
v2Column4: TcxGridDBColumn;
|
||
v2Column5: TcxGridDBColumn;
|
||
ToolButton6: TToolButton;
|
||
ADOQueryPrint: TADOQuery;
|
||
CheckBox1: TCheckBox;
|
||
TBOK: TToolButton;
|
||
procedure FormDestroy(Sender: TObject);
|
||
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
||
procedure TBCloseClick(Sender: TObject);
|
||
procedure FormShow(Sender: TObject);
|
||
procedure TBRafreshClick(Sender: TObject);
|
||
procedure ToolButton2Click(Sender: TObject);
|
||
procedure defstr1Change(Sender: TObject);
|
||
procedure ToolButton1Click(Sender: TObject);
|
||
procedure ToolButton6Click(Sender: TObject);
|
||
procedure CheckBox1Click(Sender: TObject);
|
||
procedure TBOKClick(Sender: TObject);
|
||
procedure Tv2CellDblClick(Sender: TcxCustomGridTableView;
|
||
ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
|
||
AShift: TShiftState; var AHandled: Boolean);
|
||
private
|
||
{ Private declarations }
|
||
procedure InitGrid();
|
||
|
||
public
|
||
|
||
end;
|
||
|
||
var
|
||
frmCPKWListSel: TfrmCPKWListSel;
|
||
|
||
implementation
|
||
uses
|
||
U_DataLink,U_Fun,U_ZDYHelp;
|
||
|
||
{$R *.dfm}
|
||
|
||
procedure TfrmCPKWListSel.InitGrid();
|
||
begin
|
||
try
|
||
ADOQueryMain.DisableControls;
|
||
with ADOQueryMain do
|
||
begin
|
||
Filtered:=False;
|
||
Close;
|
||
SQL.Clear;
|
||
sql.Add(' select A.*, ');
|
||
sql.Add(' cpRollNum=(select count(MJID) from CK_BanCP_KC X where X.KCKW=A.zdyCode and X.kcQty>0),');
|
||
sql.Add(' cpQty=(select sum(kcQty) from CK_BanCP_KC X where X.KCKW=A.zdyCode and X.kcQty>0)');
|
||
sql.Add(' from KH_Zdy_Attachment A ');
|
||
sql.Add(' where Type=''CPKW'' ');
|
||
Open;
|
||
end;
|
||
SCreateCDS20(ADOQueryMain,CDS_HZ);
|
||
SInitCDSData20(ADOQueryMain,CDS_HZ);
|
||
finally
|
||
ADOQueryMain.EnableControls;
|
||
end;
|
||
ToolButton2.Click;
|
||
end;
|
||
|
||
|
||
procedure TfrmCPKWListSel.FormDestroy(Sender: TObject);
|
||
begin
|
||
frmCPKWListSel:=nil;
|
||
end;
|
||
|
||
procedure TfrmCPKWListSel.FormClose(Sender: TObject; var Action: TCloseAction);
|
||
begin
|
||
Action:=caFree;
|
||
end;
|
||
|
||
procedure TfrmCPKWListSel.TBCloseClick(Sender: TObject);
|
||
begin
|
||
WriteCxGrid(self.Caption,Tv2,'<27>ͻ<EFBFBD><CDBB>Զ<EFBFBD><D4B6><EFBFBD>');
|
||
Close;
|
||
end;
|
||
procedure TfrmCPKWListSel.FormShow(Sender: TObject);
|
||
begin
|
||
cxGrid2.Align:=alclient;
|
||
ReadCxGrid(self.Caption,Tv2,'<27>ͻ<EFBFBD><CDBB>Զ<EFBFBD><D4B6><EFBFBD>');
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmCPKWListSel.TBRafreshClick(Sender: TObject);
|
||
begin
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmCPKWListSel.ToolButton2Click(Sender: TObject);
|
||
begin
|
||
if ADOQueryMain.Active then
|
||
begin
|
||
SDofilter(ADOQueryMain,SGetFilters(Panel1,1,2));
|
||
SCreateCDS20(ADOQueryMain,CDS_HZ);
|
||
SInitCDSData20(ADOQueryMain,CDS_HZ);
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmCPKWListSel.defstr1Change(Sender: TObject);
|
||
begin
|
||
ToolButton2.Click;
|
||
end;
|
||
|
||
|
||
procedure TfrmCPKWListSel.ToolButton1Click(Sender: TObject);
|
||
begin
|
||
if ADOQueryMain.IsEmpty then Exit;
|
||
TcxGridToExcel(self.Caption,cxgrid2);
|
||
// SelExportData(Tv2,ADOQueryMain,'<27><>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>');
|
||
end;
|
||
|
||
procedure TfrmCPKWListSel.ToolButton6Click(Sender: TObject);
|
||
var
|
||
fPrintFile:string;
|
||
Txt,fImagePath:string;
|
||
Moudle: THandle;
|
||
Makebar:TMakebar;
|
||
Mixtext:TMixtext;
|
||
begin
|
||
if CDS_HZ.IsEmpty then Exit;
|
||
if CDS_HZ.Locate('SSel',True,[])=False then
|
||
begin
|
||
Application.MessageBox('û<><C3BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
CDS_HZ.DisableControls;
|
||
with CDS_HZ do
|
||
begin
|
||
First;
|
||
while not Eof do
|
||
begin
|
||
if CDS_HZ.FieldByName('SSel').AsBoolean then
|
||
begin
|
||
with ADOQueryPrint do
|
||
begin
|
||
Close;
|
||
SQL.Clear;
|
||
sql.Add('select A.* ');
|
||
sql.Add(' from KH_Zdy_Attachment A') ;
|
||
SQL.Add(' where ATID='''+Trim(CDS_HZ.fieldbyname('ATID').AsString)+'''');
|
||
SQL.Add(' and Type=''CPKW'' ');
|
||
Open;
|
||
end;
|
||
try
|
||
Moudle:=LoadLibrary('MakeQRBarcode.dll');
|
||
@Makebar:=GetProcAddress(Moudle,'Make');
|
||
@Mixtext:=GetProcAddress(Moudle,'MixText');
|
||
Txt:=Trim(ADOQueryPrint.fieldbyname('ATID').AsString);
|
||
fImagePath:=ExtractFilePath(Application.ExeName)+'image\temp.bmp';
|
||
if not DirectoryExists(pchar(ExtractFilePath(Application.ExeName)+'image')) then
|
||
CreateDirectory(pchar(ExtractFilePath(Application.ExeName)+'image'),nil);
|
||
if FileExists(fImagePath) then DeleteFile(fImagePath);
|
||
Makebar(pchar(Txt),Length(Txt),3,3,0,PChar(fImagePath),3);
|
||
except
|
||
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>','<27><>ʾ<EFBFBD><CABE>Ϣ',MB_ICONERROR);
|
||
CDS_HZ.EnableControls;
|
||
exit;
|
||
end;
|
||
|
||
fPrintFile:=ExtractFilePath(Application.ExeName)+'Report\<5C><>Ʒ<EFBFBD><C6B7>λ<EFBFBD><CEBB>ǩ.rmf' ;
|
||
if FileExists(fPrintFile) then
|
||
begin
|
||
RMVariables['QRBARCODE']:=fImagePath;
|
||
RM1.LoadFromFile(fPrintFile);
|
||
// RM1.ShowReport;
|
||
RM1.PrintReport;
|
||
sleep(200);
|
||
|
||
end else
|
||
begin
|
||
CDS_HZ.EnableControls;
|
||
Application.MessageBox(PChar('û<><C3BB><EFBFBD><EFBFBD>'+trim(fPrintFile)),'<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
end;
|
||
Next;
|
||
end;
|
||
end;
|
||
CDS_HZ.EnableControls;
|
||
|
||
end;
|
||
|
||
procedure TfrmCPKWListSel.CheckBox1Click(Sender: TObject);
|
||
begin
|
||
SelOKNo(CDS_HZ,checkbox1.Checked);
|
||
end;
|
||
|
||
procedure TfrmCPKWListSel.TBOKClick(Sender: TObject);
|
||
begin
|
||
IF CDS_HZ.IsEmpty then exit;
|
||
self.ModalResult:=1;
|
||
end;
|
||
|
||
procedure TfrmCPKWListSel.Tv2CellDblClick(Sender: TcxCustomGridTableView;
|
||
ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
|
||
AShift: TShiftState; var AHandled: Boolean);
|
||
begin
|
||
TBOK.Click;
|
||
end;
|
||
|
||
end.
|
||
|
||
|