273 lines
8.4 KiB
ObjectPascal
273 lines
8.4 KiB
ObjectPascal
|
|
unit U_CLYouJS_CX;
|
|||
|
|
|
|||
|
|
interface
|
|||
|
|
|
|||
|
|
uses
|
|||
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|||
|
|
Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData,
|
|||
|
|
cxDataStorage, cxEdit, DB, cxDBData, cxGridCustomTableView,
|
|||
|
|
cxGridTableView, cxGridBandedTableView, cxGridDBBandedTableView,
|
|||
|
|
cxGridLevel, cxClasses, cxControls, cxGridCustomView, cxGridDBTableView,
|
|||
|
|
cxGrid, StdCtrls, ComCtrls, ExtCtrls, ToolWin, cxGridCustomPopupMenu,
|
|||
|
|
cxGridPopupMenu, ADODB, DBClient, cxDropDownEdit, cxCheckBox, RM_Common,
|
|||
|
|
RM_Class, RM_e_Xls, RM_Dataset, RM_System, RM_GridReport, Menus,
|
|||
|
|
cxCalendar, cxButtonEdit, cxTextEdit, cxPC, cxLookAndFeels,
|
|||
|
|
cxLookAndFeelPainters, cxNavigator;
|
|||
|
|
|
|||
|
|
type
|
|||
|
|
TfrmCLYouJS_CX = class(TForm)
|
|||
|
|
ToolBar1: TToolBar;
|
|||
|
|
TBRafresh: TToolButton;
|
|||
|
|
TBFind: TToolButton;
|
|||
|
|
TBExport: TToolButton;
|
|||
|
|
TBClose: TToolButton;
|
|||
|
|
Panel1: TPanel;
|
|||
|
|
ADOQueryCmd: TADOQuery;
|
|||
|
|
ADOQueryMain: TADOQuery;
|
|||
|
|
ADOQueryTemp: TADOQuery;
|
|||
|
|
DataSource1: TDataSource;
|
|||
|
|
cxGridPopupMenu1: TcxGridPopupMenu;
|
|||
|
|
Label1: TLabel;
|
|||
|
|
Label2: TLabel;
|
|||
|
|
BegDate: TDateTimePicker;
|
|||
|
|
EndDate: TDateTimePicker;
|
|||
|
|
CDS_Main: TClientDataSet;
|
|||
|
|
RM1: TRMGridReport;
|
|||
|
|
RMDBMain: TRMDBDataSet;
|
|||
|
|
RMXLSExport1: TRMXLSExport;
|
|||
|
|
RMDBHZ: TRMDBDataSet;
|
|||
|
|
CDS_HZ: TClientDataSet;
|
|||
|
|
CDS_PRT: TClientDataSet;
|
|||
|
|
PopupMenu1: TPopupMenu;
|
|||
|
|
N1: TMenuItem;
|
|||
|
|
N2: TMenuItem;
|
|||
|
|
Label3: TLabel;
|
|||
|
|
SJName: TEdit;
|
|||
|
|
cxGrid2: TcxGrid;
|
|||
|
|
Tv1: TcxGridDBTableView;
|
|||
|
|
v1SJName: TcxGridDBColumn;
|
|||
|
|
v1CheHao: TcxGridDBColumn;
|
|||
|
|
v1CZMoney: TcxGridDBColumn;
|
|||
|
|
cxGrid2Level1: TcxGridLevel;
|
|||
|
|
Label4: TLabel;
|
|||
|
|
CheHao: TEdit;
|
|||
|
|
v1YJCQty: TcxGridDBColumn;
|
|||
|
|
v1ZCQty: TcxGridDBColumn;
|
|||
|
|
v1MGLQty: TcxGridDBColumn;
|
|||
|
|
v1GLNote: TcxGridDBColumn;
|
|||
|
|
v1CBLCQty: TcxGridDBColumn;
|
|||
|
|
v1ZGLQty: TcxGridDBColumn;
|
|||
|
|
v1JSLCQty: TcxGridDBColumn;
|
|||
|
|
procedure FormDestroy(Sender: TObject);
|
|||
|
|
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
|||
|
|
procedure FormCreate(Sender: TObject);
|
|||
|
|
procedure TBRafreshClick(Sender: TObject);
|
|||
|
|
procedure ConNoMChange(Sender: TObject);
|
|||
|
|
procedure TBCloseClick(Sender: TObject);
|
|||
|
|
procedure FormShow(Sender: TObject);
|
|||
|
|
procedure TBExportClick(Sender: TObject);
|
|||
|
|
procedure TBFindClick(Sender: TObject);
|
|||
|
|
procedure N1Click(Sender: TObject);
|
|||
|
|
procedure N2Click(Sender: TObject);
|
|||
|
|
procedure SPIDChange(Sender: TObject);
|
|||
|
|
procedure SPSpecChange(Sender: TObject);
|
|||
|
|
procedure GCNameChange(Sender: TObject);
|
|||
|
|
procedure v1GLNotePropertiesEditValueChanged(Sender: TObject);
|
|||
|
|
procedure v1JSLCQtyPropertiesEditValueChanged(Sender: TObject);
|
|||
|
|
private
|
|||
|
|
canshu1,canshu2,canshu3:string;
|
|||
|
|
procedure InitGrid();
|
|||
|
|
procedure setstatus();
|
|||
|
|
{ Private declarations }
|
|||
|
|
public
|
|||
|
|
{ Public declarations }
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
var
|
|||
|
|
frmCLYouJS_CX: TfrmCLYouJS_CX;
|
|||
|
|
|
|||
|
|
implementation
|
|||
|
|
uses
|
|||
|
|
U_DataLink,U_RTFun,U_SXCKInPut, U_JGSXCKInPut, U_CLShuiPiao_Sub,U_CLYouliang_Sub;
|
|||
|
|
|
|||
|
|
{$R *.dfm}
|
|||
|
|
procedure TfrmCLYouJS_CX.setstatus();
|
|||
|
|
begin
|
|||
|
|
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmCLYouJS_CX.FormDestroy(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
frmCLYouJS_CX:=nil;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmCLYouJS_CX.FormClose(Sender: TObject;
|
|||
|
|
var Action: TCloseAction);
|
|||
|
|
begin
|
|||
|
|
Action:=caFree;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmCLYouJS_CX.FormCreate(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
//cxGrid1.Align:=alClient;
|
|||
|
|
EndDate.DateTime:=SGetServerDate10(ADOQueryTemp);
|
|||
|
|
BegDate.DateTime:=StrToDate(formatdatetime('yyyy-MM',SGetServerDate10(ADOQueryTemp))+'-01');
|
|||
|
|
canshu1:=Trim(DParameters1);
|
|||
|
|
canshu2:=Trim(DParameters2);
|
|||
|
|
canshu3:=Trim(DParameters3);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmCLYouJS_CX.InitGrid();
|
|||
|
|
begin
|
|||
|
|
try
|
|||
|
|
ADOQueryMain.DisableControls;
|
|||
|
|
with ADOQueryMain do
|
|||
|
|
begin
|
|||
|
|
Filtered:=False;
|
|||
|
|
Close;
|
|||
|
|
sql.Clear;
|
|||
|
|
sql.Add(' select AA.*,MGLQty=(case when isnull((MaxQty-MinQty),0)=0 then 0 else cast(CZMoney/(MaxQty-MinQty) as decimal(18,2)) end) ');
|
|||
|
|
sql.Add(',CBLCQty=(MaxQty-MinQty) from (select A.CheHao,A.SJName,A.GLNote,A.JSLCQty,Sum(CLQty) ZCQty,Sum(GLQty*CLQty*2) ZGLQty ');
|
|||
|
|
sql.Add(',YJCQty=(select Sum(CLQty) from CK_CP_CR B where B.CheHao=A.CheHao and B.SJName=A.SJName');
|
|||
|
|
sql.Add(' and B.CRTime>= '''+Trim(FormatDateTime('yyyy-MM-dd',BegDate.Date))+'''');
|
|||
|
|
sql.Add(' and B.CRTime<'''+Trim(FormatDateTime('yyyy-MM-dd',enddate.Date+1))+''' and B.SJType=''ҹ<><D2B9>'')');
|
|||
|
|
sql.Add(',CZMoney=(select Sum(CZMoney) from CL_YKYL_Main B where B.CheHao=A.CheHao and B.SJName=A.SJName');
|
|||
|
|
sql.Add(' and B.CRTime>= '''+Trim(FormatDateTime('yyyy-MM-dd',BegDate.Date))+'''');
|
|||
|
|
sql.Add(' and B.CRTime<'''+Trim(FormatDateTime('yyyy-MM-dd',enddate.Date+1))+''' )');
|
|||
|
|
sql.Add(',MinQty=(select top 1 MQQty from CL_YKYL_Main B where B.CheHao=A.CheHao and B.SJName=A.SJName');
|
|||
|
|
sql.Add(' and B.CRTime>= '''+Trim(FormatDateTime('yyyy-MM-dd',BegDate.Date))+'''');
|
|||
|
|
sql.Add(' and B.CRTime<'''+Trim(FormatDateTime('yyyy-MM-dd',enddate.Date+1))+''' order by B.CRTime)');
|
|||
|
|
sql.Add(',MaxQty=(select top 1 MQQty from CL_YKYL_Main B where B.CheHao=A.CheHao and B.SJName=A.SJName');
|
|||
|
|
sql.Add(' and B.CRTime>= '''+Trim(FormatDateTime('yyyy-MM-dd',BegDate.Date))+'''');
|
|||
|
|
sql.Add(' and B.CRTime<'''+Trim(FormatDateTime('yyyy-MM-dd',enddate.Date+1))+''' order by B.CRTime desc)');
|
|||
|
|
sql.Add(' from CK_CP_CR A');
|
|||
|
|
sql.add(' where A.CRTime>='''+Trim(FormatDateTime('yyyy-MM-dd',BegDate.Date))+'''');
|
|||
|
|
sql.Add(' and A.CRTime<'''+Trim(FormatDateTime('yyyy-MM-dd',enddate.Date+1))+'''');
|
|||
|
|
sql.Add(' group by A.CheHao,A.SJName,A.GLNote,A.JSLCQty) AA');
|
|||
|
|
Open;
|
|||
|
|
end;
|
|||
|
|
SCreateCDS20(ADOQueryMain,CDS_Main);
|
|||
|
|
SInitCDSData20(ADOQueryMain,CDS_Main);
|
|||
|
|
finally;
|
|||
|
|
ADOQueryMain.EnableControls;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmCLYouJS_CX.TBRafreshClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
BegDate.SetFocus;
|
|||
|
|
InitGrid();
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmCLYouJS_CX.ConNoMChange(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
if ADOQueryMain.Active then
|
|||
|
|
begin
|
|||
|
|
SDofilter(ADOQueryMain,SGetFilters(Panel1,1,2));
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmCLYouJS_CX.TBCloseClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
WriteCxGrid('<27>Ϳ<EFBFBD><CDBF><EFBFBD>ֵ<EFBFBD>б<EFBFBD>FM',Tv1,'<27>Ϳ<EFBFBD><CDBF><EFBFBD>ֵ');
|
|||
|
|
Close;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmCLYouJS_CX.FormShow(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
ReadCxGrid('<27>Ϳ<EFBFBD><CDBF><EFBFBD>ֵ<EFBFBD>б<EFBFBD>FM',Tv1,'<27>Ϳ<EFBFBD><CDBF><EFBFBD>ֵ');
|
|||
|
|
//setstatus();
|
|||
|
|
//InitGrid();
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmCLYouJS_CX.TBExportClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
if ADOQueryMain.IsEmpty then exit;
|
|||
|
|
TcxGridToExcel('<27><>ʻԱ<CABB><D4B1><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>',cxGrid2);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmCLYouJS_CX.TBFindClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
if ADOQueryMain.Active then
|
|||
|
|
begin
|
|||
|
|
SDofilter(ADOQueryMain,SGetFilters(Panel1,1,2));
|
|||
|
|
SCreateCDS20(ADOQueryMain,CDS_Main);
|
|||
|
|
SInitCDSData20(ADOQueryMain,CDS_Main);
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmCLYouJS_CX.N1Click(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
SelOKNo(CDS_Main,True);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmCLYouJS_CX.N2Click(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
SelOKNo(CDS_Main,False);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmCLYouJS_CX.SPIDChange(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
|
|||
|
|
TBFind.Click;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmCLYouJS_CX.SPSpecChange(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
TBFind.Click;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmCLYouJS_CX.GCNameChange(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
TBFind.Click;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmCLYouJS_CX.v1GLNotePropertiesEditValueChanged(
|
|||
|
|
Sender: TObject);
|
|||
|
|
var mavlue:string;
|
|||
|
|
begin
|
|||
|
|
mavlue:=TcxTextEdit(Sender).EditingText;
|
|||
|
|
with CDS_Main do
|
|||
|
|
begin
|
|||
|
|
edit;
|
|||
|
|
FieldByName('GLNote').AsString:=Trim(mavlue);
|
|||
|
|
end;
|
|||
|
|
with ADOQueryCmd do
|
|||
|
|
begin
|
|||
|
|
close;
|
|||
|
|
sql.Clear;
|
|||
|
|
sql.Add('update CK_CP_CR set GLNote='''+trim(mavlue)+'''');
|
|||
|
|
sql.add(' where CRTime>='''+Trim(FormatDateTime('yyyy-MM-dd',BegDate.Date))+'''');
|
|||
|
|
sql.Add(' and CRTime<'''+Trim(FormatDateTime('yyyy-MM-dd',enddate.Date+1))+'''');
|
|||
|
|
sql.Add(' and SJName='''+trim(CDS_Main.fieldbyname('SJName').AsString)+'''');
|
|||
|
|
sql.Add(' and CheHao='''+trim(CDS_Main.fieldbyname('CheHao').AsString)+'''');
|
|||
|
|
ExecSQL;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmCLYouJS_CX.v1JSLCQtyPropertiesEditValueChanged(
|
|||
|
|
Sender: TObject);
|
|||
|
|
var mavlue:string;
|
|||
|
|
begin
|
|||
|
|
mavlue:=TcxTextEdit(Sender).EditingText;
|
|||
|
|
if mavlue='' then mavlue:='0';
|
|||
|
|
with CDS_Main do
|
|||
|
|
begin
|
|||
|
|
edit;
|
|||
|
|
FieldByName('JSLCQty').Value:=mavlue;
|
|||
|
|
end;
|
|||
|
|
with ADOQueryCmd do
|
|||
|
|
begin
|
|||
|
|
close;
|
|||
|
|
sql.Clear;
|
|||
|
|
sql.Add('update CK_CP_CR set JSLCQty='''+trim(mavlue)+'''');
|
|||
|
|
sql.add(' where CRTime>='''+Trim(FormatDateTime('yyyy-MM-dd',BegDate.Date))+'''');
|
|||
|
|
sql.Add(' and CRTime<'''+Trim(FormatDateTime('yyyy-MM-dd',enddate.Date+1))+'''');
|
|||
|
|
sql.Add(' and SJName='''+trim(CDS_Main.fieldbyname('SJName').AsString)+'''');
|
|||
|
|
sql.Add(' and CheHao='''+trim(CDS_Main.fieldbyname('CheHao').AsString)+'''');
|
|||
|
|
ExecSQL;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
end.
|