364 lines
11 KiB
ObjectPascal
364 lines
11 KiB
ObjectPascal
unit U_JWLKCList_HZ;
|
||
|
||
interface
|
||
|
||
uses
|
||
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
||
Dialogs, StdCtrls, ExtCtrls, ComCtrls, ToolWin, cxStyles, cxCustomData,
|
||
cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit, DB, cxDBData, ADODB,
|
||
cxGridCustomPopupMenu, cxGridPopupMenu, cxGridLevel, cxClasses,
|
||
cxControls, cxGridCustomView, cxGridCustomTableView, cxGridTableView,
|
||
cxGridDBTableView, cxGrid, cxCalendar, cxButtonEdit, cxDropDownEdit,
|
||
DBClient, Menus, cxSplitter, cxTextEdit, RM_Common, RM_Class,
|
||
RM_GridReport, RM_System, RM_Dataset, RM_e_Xls, dxPSGlbl, dxPSUtl,
|
||
dxPSEngn, dxPrnPg, dxBkgnd, dxWrap, dxPrnDev, dxPSCompsProvider,
|
||
dxPSFillPatterns, dxPSEdgePatterns, dxPSCore, dxPScxCommon, dxPScxGridLnk,
|
||
cxGridBandedTableView, cxGridDBBandedTableView;
|
||
|
||
type
|
||
TfrmJWLKCList_HZ = class(TForm)
|
||
ToolBar1: TToolBar;
|
||
TBRafresh: TToolButton;
|
||
TBFind: TToolButton;
|
||
TBPrint: TToolButton;
|
||
TBClose: TToolButton;
|
||
cxGridPopupMenu1: TcxGridPopupMenu;
|
||
ADOQueryCmd: TADOQuery;
|
||
ADOQueryMain: TADOQuery;
|
||
ADOQueryTemp: TADOQuery;
|
||
DataSource1: TDataSource;
|
||
TBExport: TToolButton;
|
||
Panel1: TPanel;
|
||
Label1: TLabel;
|
||
Label2: TLabel;
|
||
Label3: TLabel;
|
||
BegDate: TDateTimePicker;
|
||
EndDate: TDateTimePicker;
|
||
YCLName: TEdit;
|
||
cxGrid1: TcxGrid;
|
||
CDS_Main: TClientDataSet;
|
||
RMDB_Main: TRMDBDataSet;
|
||
RM1: TRMGridReport;
|
||
RMXLSExport1: TRMXLSExport;
|
||
Label8: TLabel;
|
||
cxGrid1Level1: TcxGridLevel;
|
||
TV1: TcxGridDBBandedTableView;
|
||
V1YCLSpec: TcxGridDBBandedColumn;
|
||
V1YCLName: TcxGridDBBandedColumn;
|
||
cxStyleRepository1: TcxStyleRepository;
|
||
cxStyle1: TcxStyle;
|
||
V1SQJCQty: TcxGridDBBandedColumn;
|
||
V1SQJCMoney: TcxGridDBBandedColumn;
|
||
V1BQRKQty: TcxGridDBBandedColumn;
|
||
V1BQRKMoney: TcxGridDBBandedColumn;
|
||
V1BQCKQty: TcxGridDBBandedColumn;
|
||
V1BQCKMoney: TcxGridDBBandedColumn;
|
||
V1BQJCQty: TcxGridDBBandedColumn;
|
||
V1BQJCMoney: TcxGridDBBandedColumn;
|
||
RadioGroup1: TRadioGroup;
|
||
YCLSpec: TComboBox;
|
||
cxSplitter1: TcxSplitter;
|
||
cxGrid2: TcxGrid;
|
||
TV2: TcxGridDBTableView;
|
||
v1CRTime: TcxGridDBColumn;
|
||
v1Note: TcxGridDBColumn;
|
||
cxGridLevel1: TcxGridLevel;
|
||
DataSource2: TDataSource;
|
||
JWL_Sub: TClientDataSet;
|
||
V2YCLName: TcxGridDBColumn;
|
||
V2RKQty: TcxGridDBColumn;
|
||
V2RKMoney: TcxGridDBColumn;
|
||
V2CKQty: TcxGridDBColumn;
|
||
V2CKMoney: TcxGridDBColumn;
|
||
V2Column6: TcxGridDBColumn;
|
||
V2JCMoney: TcxGridDBColumn;
|
||
V2GYSName: TcxGridDBColumn;
|
||
V2LYPerson: TcxGridDBColumn;
|
||
JWL_Money: TClientDataSet;
|
||
RMDBMain: TRMDBDataSet;
|
||
RM2: TRMGridReport;
|
||
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
||
procedure FormCreate(Sender: TObject);
|
||
procedure TBCloseClick(Sender: TObject);
|
||
procedure TBFindClick(Sender: TObject);
|
||
procedure TBExportClick(Sender: TObject);
|
||
procedure TBPrintClick(Sender: TObject);
|
||
procedure TBRafreshClick(Sender: TObject);
|
||
procedure YCLNameChange(Sender: TObject);
|
||
procedure FormShow(Sender: TObject);
|
||
procedure FormDestroy(Sender: TObject);
|
||
procedure RadioGroup1Click(Sender: TObject);
|
||
procedure CheckBox1Click(Sender: TObject);
|
||
procedure TV1FocusedRecordChanged(Sender: TcxCustomGridTableView;
|
||
APrevFocusedRecord, AFocusedRecord: TcxCustomGridRecord;
|
||
ANewItemRecordFocusingChanged: Boolean);
|
||
procedure ToolButton1Click(Sender: TObject);
|
||
private
|
||
canshu1,canshu2,canshu3:String;
|
||
procedure InitGrid();
|
||
procedure InitForm();
|
||
|
||
{ Private declarations }
|
||
public
|
||
{ Public declarations }
|
||
end;
|
||
|
||
var
|
||
frmJWLKCList_HZ: TfrmJWLKCList_HZ;
|
||
|
||
implementation
|
||
uses
|
||
U_DataLink,U_RTFun, U_ModuleNote;
|
||
|
||
{$R *.dfm}
|
||
|
||
procedure TfrmJWLKCList_HZ.FormClose(Sender: TObject;
|
||
var Action: TCloseAction);
|
||
begin
|
||
Action:=caFree;
|
||
end;
|
||
|
||
procedure TfrmJWLKCList_HZ.FormCreate(Sender: TObject);
|
||
begin
|
||
cxgrid1.Align:=alClient;
|
||
canshu1:=Trim(DParameters1);
|
||
canshu2:=Trim(DParameters2);
|
||
canshu3:=Trim(DParameters3);
|
||
end;
|
||
|
||
procedure TfrmJWLKCList_HZ.TBCloseClick(Sender: TObject);
|
||
begin
|
||
Close;
|
||
WriteCxBandedGrid('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>',Tv1,'ԭ<><D4AD><EFBFBD>ϲֿ<CFB2>');
|
||
end;
|
||
|
||
procedure TfrmJWLKCList_HZ.InitGrid();
|
||
begin
|
||
try
|
||
ADOQueryMain.DisableControls;
|
||
with ADOQueryMain do
|
||
begin
|
||
Filtered:=False;
|
||
Close;
|
||
sql.Clear;
|
||
if RadioGroup1.ItemIndex=1 then
|
||
begin
|
||
sql.Add('exec P_JWL_KC ');
|
||
SQL.Add(' @begdate='''+trim(FormatDateTime('yyyy-MM',BegDate.Date))+''' ');
|
||
SQL.Add(',@Enddate='''+trim(FormatDateTime('yyyy-MM',EndDate.Date))+''' ');
|
||
end;
|
||
if RadioGroup1.ItemIndex=0 then
|
||
begin
|
||
sql.Add('exec P_JWL_KC_Year ');
|
||
SQL.Add(' @begdate='''+trim(FormatDateTime('yyyy',BegDate.Date))+''' ');
|
||
SQL.Add(',@Enddate='''+trim(FormatDateTime('yyyy',EndDate.Date))+''' ');
|
||
end;
|
||
Open;
|
||
end;
|
||
SCreateCDS20(ADOQueryMain,CDS_Main);
|
||
SInitCDSData20(ADOQueryMain,CDS_Main);
|
||
TBFind.Click;
|
||
finally;
|
||
ADOQueryMain.EnableControls;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmJWLKCList_HZ.InitForm();
|
||
begin
|
||
ReadCxBandedGrid('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>',Tv1,'ԭ<><D4AD><EFBFBD>ϲֿ<CFB2>');
|
||
EndDate.DateTime:=SGetServerDateMEnd(ADOQueryTemp);
|
||
BegDate.DateTime:=SGetServerDateMBeg(ADOQueryTemp);
|
||
with ADOQueryTemp do
|
||
begin
|
||
close;
|
||
SQL.Clear;
|
||
sql.Add('select distinct YCLSpec from CK_YCLONE_CR ');
|
||
open;
|
||
end;
|
||
with ADOQueryTemp do
|
||
begin
|
||
first;
|
||
while not eof do
|
||
begin
|
||
YCLSpec.Items.Add(ADOQueryTemp.fieldbyname('YCLSpec').AsString);
|
||
next;
|
||
end;
|
||
end;
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmJWLKCList_HZ.TBFindClick(Sender: TObject);
|
||
begin
|
||
if ADOQueryMain.IsEmpty then Exit;
|
||
SDofilter(ADOQueryMain,SGetFilters(Panel1,1,2));
|
||
SCreateCDS20(ADOQueryMain,CDS_Main);
|
||
SInitCDSData20(ADOQueryMain,CDS_Main);
|
||
end;
|
||
|
||
procedure TfrmJWLKCList_HZ.TBExportClick(Sender: TObject);
|
||
begin
|
||
if CDS_Main.IsEmpty then Exit;
|
||
TcxGridToExcel('<27><><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>',cxGrid1);
|
||
end;
|
||
|
||
procedure TfrmJWLKCList_HZ.TBPrintClick(Sender: TObject);
|
||
var
|
||
fPrintFile,FConNoM,RPTName:string;
|
||
begin
|
||
if CDS_Main.IsEmpty then Exit;
|
||
fPrintFile:= ExtractFilePath(Application.ExeName) + 'Report\<5C><>Ⱦ<EFBFBD><C8BE><EFBFBD><EFBFBD><EFBFBD>ձ<EFBFBD><D5B1><EFBFBD>.rmf' ;
|
||
if FileExists(fPrintFile) then
|
||
begin
|
||
RMVariables['begdate']:=BegDate.DateTime;
|
||
RMVariables['enddate']:=enddate.DateTime;
|
||
//RMVariables['printtime']:=Now;
|
||
//RMVariables['printer']:=Trim(gUserName);
|
||
RM1.LoadFromFile(fPrintFile);
|
||
RM1.ShowReport;
|
||
end else
|
||
begin
|
||
Application.MessageBox(PChar('û<><C3BB><EFBFBD><EFBFBD>'+ExtractFilePath(Application.ExeName)+RPTName),'<27><>ʾ',0);
|
||
end;
|
||
|
||
end;
|
||
|
||
procedure TfrmJWLKCList_HZ.TBRafreshClick(Sender: TObject);
|
||
begin
|
||
ToolBar1.SetFocus;
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmJWLKCList_HZ.YCLNameChange(Sender: TObject);
|
||
begin
|
||
if ADOQueryMain.Active=False then Exit;
|
||
SDofilter(ADOQueryMain,SGetFilters(Panel1,1,2));
|
||
SCreateCDS20(ADOQueryMain,CDS_Main);
|
||
SInitCDSData20(ADOQueryMain,CDS_Main);
|
||
end;
|
||
|
||
procedure TfrmJWLKCList_HZ.FormShow(Sender: TObject);
|
||
begin
|
||
InitForm();
|
||
end;
|
||
|
||
|
||
procedure TfrmJWLKCList_HZ.FormDestroy(Sender: TObject);
|
||
begin
|
||
frmJWLKCList_HZ:=nil;
|
||
end;
|
||
|
||
procedure TfrmJWLKCList_HZ.RadioGroup1Click(Sender: TObject);
|
||
begin
|
||
TBRafresh.Click;
|
||
end;
|
||
|
||
procedure TfrmJWLKCList_HZ.CheckBox1Click(Sender: TObject);
|
||
begin
|
||
TBRafresh.Click;
|
||
end;
|
||
|
||
procedure TfrmJWLKCList_HZ.TV1FocusedRecordChanged(
|
||
Sender: TcxCustomGridTableView; APrevFocusedRecord,
|
||
AFocusedRecord: TcxCustomGridRecord;
|
||
ANewItemRecordFocusingChanged: Boolean);
|
||
var FJCQty,FJCMoney,SQJCQty,SQJCMoney:Double;
|
||
begin
|
||
if CDS_Main.IsEmpty then exit;
|
||
with ADOQueryCmd do
|
||
begin
|
||
close;
|
||
SQL.Clear;
|
||
sql.Add('select Sum(CRQty*JSFlag) JCQty,Sum(YCLMoney*JSFlag) JCMoney from CK_YCLONE_CR ');
|
||
sql.Add('where convert(varchar(7),CRTime,120)<'''+Trim(FormatDateTime('yyyy-MM',BegDate.DateTime))+'''');
|
||
sql.Add(' and YCLSpec='''+trim(CDS_Main.fieldbyname('YCLSpec').AsString)+'''');
|
||
sql.Add(' and YCLName='''+trim(CDS_Main.fieldbyname('YCLName').AsString)+'''');
|
||
open;
|
||
end;
|
||
SQJCQty:=ADOQueryCmd.fieldbyname('JCQty').AsFloat;
|
||
SQJCMoney:=ADOQueryCmd.fieldbyname('JCMoney').AsFloat;
|
||
with ADOQueryCmd do
|
||
begin
|
||
close;
|
||
SQL.Clear;
|
||
sql.Add('select *,RKQty=(case when CRFlag=''<27><><EFBFBD><EFBFBD>'' then CRQty else 0 end),CKQty=(case when CRFlag=''<27><><EFBFBD><EFBFBD>'' then CRQty else 0 end) ');
|
||
sql.add(',RKMoney=(case when CRFlag=''<27><><EFBFBD><EFBFBD>'' then YCLMoney else 0 end),CKMoney=(case when CRFlag=''<27><><EFBFBD><EFBFBD>'' then YCLMoney else 0 end)');
|
||
sql.add(',JCQty=cast(0 as decimal(18,2)),JCMoney=cast(0 as decimal(18,2))');
|
||
sql.Add(' from CK_YCLONE_CR ');
|
||
sql.Add('where convert(varchar(7),CRTime,120)>='''+Trim(FormatDateTime('yyyy-MM',BegDate.DateTime))+'''');
|
||
sql.Add(' and convert(varchar(7),CRTime,120)<='''+Trim(FormatDateTime('yyyy-MM',endDate.DateTime))+'''');
|
||
sql.Add(' and YCLSpec='''+trim(CDS_Main.fieldbyname('YCLSpec').AsString)+'''');
|
||
sql.Add(' and YCLName='''+trim(CDS_Main.fieldbyname('YCLName').AsString)+'''');
|
||
sql.Add(' order by CRTime');
|
||
Open;
|
||
end;
|
||
SCreateCDS20(ADOQueryCmd,JWL_Sub);
|
||
with JWL_Sub do
|
||
begin
|
||
append;
|
||
FieldByName('CRTime').Value:=StrToDate(Trim(FormatDateTime('yyyy-MM',BegDate.DateTime))+'-01');
|
||
FieldByName('YCLName').Value:=Trim(CDS_Main.fieldbyname('YCLName').AsString);
|
||
FieldByName('Note').Value:='<27><><EFBFBD>ڽ<EFBFBD><DABD><EFBFBD>';
|
||
FieldByName('JCQty').Value:=SQJCQty;
|
||
FieldByName('JCMoney').Value:=SQJCMoney;
|
||
post;
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
First;
|
||
while not eof do
|
||
begin
|
||
with JWL_Sub do
|
||
begin
|
||
append;
|
||
FieldByName('CRTime').Value:=ADOQueryCmd.fieldbyname('CRTime').AsDateTime;
|
||
FieldByName('YCLName').Value:=Trim(ADOQueryCmd.fieldbyname('YCLName').AsString);
|
||
FieldByName('GYSName').Value:=Trim(ADOQueryCmd.fieldbyname('GYSName').AsString);
|
||
FieldByName('LYPerson').Value:=Trim(ADOQueryCmd.fieldbyname('LYPerson').AsString);
|
||
FieldByName('RKQty').Value:=ADOQueryCmd.fieldbyname('RKQty').AsFloat;
|
||
FieldByName('RKMoney').Value:=ADOQueryCmd.fieldbyname('RKMoney').AsFloat;
|
||
FieldByName('CKQty').Value:=ADOQueryCmd.fieldbyname('CKQty').AsFloat;
|
||
FieldByName('CKMoney').Value:=ADOQueryCmd.fieldbyname('CKMoney').AsFloat;
|
||
FieldByName('RKQty').Value:=ADOQueryCmd.fieldbyname('RKQty').AsFloat;
|
||
FieldByName('Note').Value:=Trim(ADOQueryCmd.fieldbyname('Note').AsString);
|
||
SQJCQty:=SQJCQty+ADOQueryCmd.fieldbyname('RKQty').AsFloat-ADOQueryCmd.fieldbyname('CKQty').AsFloat;
|
||
SQJCMoney:=SQJCMoney+ADOQueryCmd.fieldbyname('RKMoney').AsFloat-ADOQueryCmd.fieldbyname('CKMoney').AsFloat;
|
||
FieldByName('JCQty').Value:=SQJCQty;
|
||
FieldByName('JCMoney').Value:=SQJCMoney;
|
||
post;
|
||
end;
|
||
next;
|
||
end;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmJWLKCList_HZ.ToolButton1Click(Sender: TObject);
|
||
var
|
||
fPrintFile,FConNoM,RPTName:string;
|
||
begin
|
||
if CDS_Main.IsEmpty then Exit;
|
||
fPrintFile:= ExtractFilePath(Application.ExeName) + 'Report\<5C><><EFBFBD><EFBFBD><EFBFBD>Ϸ<EFBFBD><CFB7>û<EFBFBD><C3BB>ܱ<EFBFBD>.rmf' ;
|
||
with ADOQueryCmd do
|
||
begin
|
||
close;
|
||
SQL.Clear;
|
||
sql.Add('exec P_JWL_MoneyKC ');
|
||
//SQL.Add(' @begdate='''+trim(FormatDateTime('yyyy-MM',BegDate.Date))+''' ');
|
||
SQL.Add(',@Enddate='''+trim(FormatDateTime('yyyy-MM',EndDate.Date))+''' ');
|
||
Open;
|
||
end;
|
||
SCreateCDS20(ADOQueryCmd,JWL_Money);
|
||
SInitCDSData20(ADOQueryCmd,JWL_Money);
|
||
if FileExists(fPrintFile) then
|
||
begin
|
||
//RMVariables['begdate']:=BegDate.DateTime;
|
||
RMVariables['enddate']:=enddate.DateTime;
|
||
RM2.LoadFromFile(fPrintFile);
|
||
RM2.ShowReport;
|
||
end else
|
||
begin
|
||
Application.MessageBox(PChar('û<><C3BB><EFBFBD><EFBFBD>'+ExtractFilePath(Application.ExeName)+RPTName),'<27><>ʾ',0);
|
||
end;
|
||
end;
|
||
|
||
end.
|