344 lines
9.0 KiB
ObjectPascal
344 lines
9.0 KiB
ObjectPascal
|
unit U_TradePlanProfit;
|
|||
|
|
|||
|
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, cxDBLookupComboBox, cxGridBandedTableView, cxGridDBBandedTableView,
|
|||
|
cxLookAndFeels, cxLookAndFeelPainters, cxNavigator, dxSkinsCore,
|
|||
|
dxSkinsDefaultPainters, dxDateRanges, dxBarBuiltInMenu, U_BaseList, dxSkinWXI,
|
|||
|
dxScrollbarAnnotations;
|
|||
|
|
|||
|
type
|
|||
|
TfrmTradePlanProfit = class(TfrmBaseList)
|
|||
|
ToolBar1: TToolBar;
|
|||
|
TBRafresh: TToolButton;
|
|||
|
TBClose: TToolButton;
|
|||
|
ADOQueryTemp: TADOQuery;
|
|||
|
ADOQueryCmd: TADOQuery;
|
|||
|
Panel1: TPanel;
|
|||
|
ToolButton2: TToolButton;
|
|||
|
ToolButton1: TToolButton;
|
|||
|
RM1: TRMGridReport;
|
|||
|
RMDB_1: TRMDBDataSet;
|
|||
|
Label3: TLabel;
|
|||
|
CustName: TEdit;
|
|||
|
cxGridPopupMenu2: TcxGridPopupMenu;
|
|||
|
Label1: TLabel;
|
|||
|
EndDate: TDateTimePicker;
|
|||
|
Label4: TLabel;
|
|||
|
Label5: TLabel;
|
|||
|
Begdate: TDateTimePicker;
|
|||
|
Label2: TLabel;
|
|||
|
OrderNo: TEdit;
|
|||
|
CDS_P1: TClientDataSet;
|
|||
|
CDS_P2: TClientDataSet;
|
|||
|
RMDB_2: TRMDBDataSet;
|
|||
|
ADOQueryMain: TADOQuery;
|
|||
|
DataSource1: TDataSource;
|
|||
|
CDS_1: TClientDataSet;
|
|||
|
cxGrid1: TcxGrid;
|
|||
|
Tv1: TcxGridDBTableView;
|
|||
|
v1CustomerNoName: TcxGridDBColumn;
|
|||
|
v1OrdDate: TcxGridDBColumn;
|
|||
|
v1OrderNo: TcxGridDBColumn;
|
|||
|
v1MPRTCodeName: TcxGridDBColumn;
|
|||
|
v1MPRTSpec: TcxGridDBColumn;
|
|||
|
cxGrid1Level1: TcxGridLevel;
|
|||
|
cxStyleRepository1: TcxStyleRepository;
|
|||
|
cxStyle1: TcxStyle;
|
|||
|
Label7: TLabel;
|
|||
|
Tallyer: TEdit;
|
|||
|
Label6: TLabel;
|
|||
|
Saleser: TEdit;
|
|||
|
Tv1Column14: TcxGridDBColumn;
|
|||
|
Tv1Column15: TcxGridDBColumn;
|
|||
|
Tv1Column1: TcxGridDBColumn;
|
|||
|
Tv1Column2: TcxGridDBColumn;
|
|||
|
Tv1Column3: TcxGridDBColumn;
|
|||
|
Tv1Column4: TcxGridDBColumn;
|
|||
|
Tv1Column5: TcxGridDBColumn;
|
|||
|
Tv1Column6: TcxGridDBColumn;
|
|||
|
Tv1Column7: TcxGridDBColumn;
|
|||
|
Tv1Column8: TcxGridDBColumn;
|
|||
|
Tv1Column9: TcxGridDBColumn;
|
|||
|
Tv1Column10: TcxGridDBColumn;
|
|||
|
C_Name: TEdit;
|
|||
|
ToolButton3: TToolButton;
|
|||
|
ToolButton4: TToolButton;
|
|||
|
ToolButton5: TToolButton;
|
|||
|
CDS_P3: TClientDataSet;
|
|||
|
RMDB_3: TRMDBDataSet;
|
|||
|
CDS_P4: TClientDataSet;
|
|||
|
RMDB_4: TRMDBDataSet;
|
|||
|
CDS_P5: TClientDataSet;
|
|||
|
RMDB_5: TRMDBDataSet;
|
|||
|
RMDB_6: TRMDBDataSet;
|
|||
|
CDS_P6: TClientDataSet;
|
|||
|
CDS_P7: TClientDataSet;
|
|||
|
RMDB_7: TRMDBDataSet;
|
|||
|
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 CustNameChange(Sender: TObject);
|
|||
|
procedure ToolButton1Click(Sender: TObject);
|
|||
|
procedure FormCreate(Sender: TObject);
|
|||
|
procedure ToolButton3Click(Sender: TObject);
|
|||
|
procedure ToolButton4Click(Sender: TObject);
|
|||
|
procedure Tv1DblClick(Sender: TObject);
|
|||
|
procedure ToolButton5Click(Sender: TObject);
|
|||
|
private
|
|||
|
|
|||
|
{ Private declarations }
|
|||
|
|
|||
|
procedure InitGrid();
|
|||
|
public
|
|||
|
fkhType: string;
|
|||
|
Fmanage: string;
|
|||
|
canshu1: string;
|
|||
|
end;
|
|||
|
|
|||
|
var
|
|||
|
frmTradePlanProfit: TfrmTradePlanProfit;
|
|||
|
|
|||
|
implementation
|
|||
|
|
|||
|
uses
|
|||
|
U_DataLink, U_RTFun, U_ZDYHelp, U_TradePlanProfitDetails;
|
|||
|
|
|||
|
{$R *.dfm}
|
|||
|
|
|||
|
procedure TfrmTradePlanProfit.InitGrid();
|
|||
|
begin
|
|||
|
try
|
|||
|
ADOQueryMain.DisableControls;
|
|||
|
with ADOQueryMain do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
SQL.Clear;
|
|||
|
sql.Add(' exec P_Trade_Profit_Plan @Begdate=' + quotedstr(trim(FormatDateTime('yyyy-MM-dd', Begdate.DateTime))));
|
|||
|
sql.Add(' ,@enddate=' + quotedstr(trim(FormatDateTime('yyyy-MM-dd', EndDate.DateTime + 1))));
|
|||
|
if canshu1 = '<27><>ѯ' then
|
|||
|
begin
|
|||
|
sql.Add(',@canshu=' + QuotedStr(Trim(DName)));
|
|||
|
end;
|
|||
|
Open;
|
|||
|
end;
|
|||
|
SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2));
|
|||
|
SCreateCDS(ADOQueryMain, CDS_1);
|
|||
|
SInitCDSData(ADOQueryMain, CDS_1);
|
|||
|
finally
|
|||
|
ADOQueryMain.EnableControls;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmTradePlanProfit.FormDestroy(Sender: TObject);
|
|||
|
begin
|
|||
|
frmTradePlanProfit := nil;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmTradePlanProfit.FormClose(Sender: TObject; var Action: TCloseAction);
|
|||
|
begin
|
|||
|
Action := caFree;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmTradePlanProfit.TBCloseClick(Sender: TObject);
|
|||
|
begin
|
|||
|
|
|||
|
Close;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmTradePlanProfit.FormShow(Sender: TObject);
|
|||
|
var
|
|||
|
fsj: string;
|
|||
|
begin
|
|||
|
ReadCxGrid(trim(self.caption), Tv1, '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>22');
|
|||
|
InitGrid();
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmTradePlanProfit.TBRafreshClick(Sender: TObject);
|
|||
|
begin
|
|||
|
InitGrid();
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmTradePlanProfit.ToolButton2Click(Sender: TObject);
|
|||
|
begin
|
|||
|
if ADOQueryMain.Active then
|
|||
|
begin
|
|||
|
SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2));
|
|||
|
SCreateCDS(ADOQueryMain, CDS_1);
|
|||
|
SInitCDSData(ADOQueryMain, CDS_1);
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmTradePlanProfit.ToolButton3Click(Sender: TObject);
|
|||
|
begin
|
|||
|
WriteCxGrid(trim(self.caption), Tv1, '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>22');
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmTradePlanProfit.ToolButton4Click(Sender: TObject);
|
|||
|
begin
|
|||
|
try
|
|||
|
frmTradePlanProfitDetails := TfrmTradePlanProfitDetails.Create(Application);
|
|||
|
with frmTradePlanProfitDetails do
|
|||
|
begin
|
|||
|
|
|||
|
FOrderNo := Trim(Self.CDS_1.fieldbyname('OrderNo').AsString);
|
|||
|
if ShowModal = 1 then
|
|||
|
begin
|
|||
|
InitGrid();
|
|||
|
end;
|
|||
|
end;
|
|||
|
finally
|
|||
|
frmTradePlanProfitDetails.Free;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmTradePlanProfit.ToolButton5Click(Sender: TObject);
|
|||
|
var
|
|||
|
filepath: string;
|
|||
|
mBegdate, mEnddate: string;
|
|||
|
begin
|
|||
|
if CDS_1.IsEmpty then
|
|||
|
exit;
|
|||
|
|
|||
|
with ADOQueryTemp do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
SQL.Clear;
|
|||
|
sql.Add('exec P_Trade_Profit_Plan_Details ');
|
|||
|
sql.Add('@PFType=''<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'' ');
|
|||
|
sql.Add(',@OrderNo= ' + quotedstr(Trim(Trim(Self.CDS_1.fieldbyname('OrderNo').AsString))));
|
|||
|
Open;
|
|||
|
end;
|
|||
|
SCreateCDS(ADOQueryTemp, CDS_P1);
|
|||
|
SInitCDSData(ADOQueryTemp, CDS_P1);
|
|||
|
|
|||
|
with ADOQueryTemp do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
SQL.Clear;
|
|||
|
sql.Add('exec P_Trade_Profit_Plan_Details ');
|
|||
|
sql.Add('@PFType=''<27>ƻ<EFBFBD><C6BB><EFBFBD>'' ');
|
|||
|
sql.Add(',@OrderNo= ' + quotedstr(Trim(Trim(Self.CDS_1.fieldbyname('OrderNo').AsString))));
|
|||
|
Open;
|
|||
|
end;
|
|||
|
SCreateCDS(ADOQueryTemp, CDS_P2);
|
|||
|
SInitCDSData(ADOQueryTemp, CDS_P2);
|
|||
|
|
|||
|
with ADOQueryTemp do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
SQL.Clear;
|
|||
|
sql.Add('exec P_Trade_Profit_Plan_Details ');
|
|||
|
sql.Add('@PFType=''<27>ɹ<EFBFBD>'' ');
|
|||
|
sql.Add(',@OrderNo= ' + quotedstr(Trim(Trim(Self.CDS_1.fieldbyname('OrderNo').AsString))));
|
|||
|
Open;
|
|||
|
end;
|
|||
|
SCreateCDS(ADOQueryTemp, CDS_P3);
|
|||
|
SInitCDSData(ADOQueryTemp, CDS_P3);
|
|||
|
|
|||
|
with ADOQueryTemp do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
SQL.Clear;
|
|||
|
sql.Add('exec P_Trade_Profit_Plan_Details ');
|
|||
|
sql.Add('@PFType=''<27>ӹ<EFBFBD>'' ');
|
|||
|
sql.Add(',@OrderNo= ' + quotedstr(Trim(Trim(Self.CDS_1.fieldbyname('OrderNo').AsString))));
|
|||
|
Open;
|
|||
|
end;
|
|||
|
SCreateCDS(ADOQueryTemp, CDS_P4);
|
|||
|
SInitCDSData(ADOQueryTemp, CDS_P4);
|
|||
|
|
|||
|
with ADOQueryTemp do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
SQL.Clear;
|
|||
|
sql.Add('exec P_Trade_Profit_Plan_Details ');
|
|||
|
sql.Add('@PFType=''<27><><EFBFBD><EFBFBD>'' ');
|
|||
|
sql.Add(',@OrderNo= ' + quotedstr(Trim(Trim(Self.CDS_1.fieldbyname('OrderNo').AsString))));
|
|||
|
Open;
|
|||
|
end;
|
|||
|
SCreateCDS(ADOQueryTemp, CDS_P5);
|
|||
|
SInitCDSData(ADOQueryTemp, CDS_P5);
|
|||
|
|
|||
|
with ADOQueryTemp do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
SQL.Clear;
|
|||
|
sql.Add('exec P_Trade_Profit_Plan_Details ');
|
|||
|
sql.Add('@PFType=''<27><><EFBFBD><EFBFBD>'' ');
|
|||
|
sql.Add(',@OrderNo= ' + quotedstr(Trim(Trim(Self.CDS_1.fieldbyname('OrderNo').AsString))));
|
|||
|
Open;
|
|||
|
end;
|
|||
|
SCreateCDS(ADOQueryTemp, CDS_P6);
|
|||
|
SInitCDSData(ADOQueryTemp, CDS_P6);
|
|||
|
|
|||
|
with ADOQueryTemp do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
SQL.Clear;
|
|||
|
sql.Add('exec P_Trade_Profit_Plan_Details ');
|
|||
|
sql.Add('@PFType=''Ӧ<><D3A6>'' ');
|
|||
|
sql.Add(',@OrderNo= ' + quotedstr(Trim(Trim(Self.CDS_1.fieldbyname('OrderNo').AsString))));
|
|||
|
Open;
|
|||
|
end;
|
|||
|
SCreateCDS(ADOQueryTemp, CDS_P7);
|
|||
|
SInitCDSData(ADOQueryTemp, CDS_P7);
|
|||
|
|
|||
|
try
|
|||
|
ExportFtErpFile('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.rmf', ADOQueryTemp);
|
|||
|
|
|||
|
filepath := ExtractFilePath(Application.ExeName) + 'report\<5C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.rmf';
|
|||
|
if not FileExists(Pchar(filepath)) then
|
|||
|
begin
|
|||
|
application.MessageBox(pchar('<27>ļ<EFBFBD>[' + filepath + ']<5D><><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD>'), '<27><>ʾ<EFBFBD><CABE>Ϣ', MB_IConError);
|
|||
|
exit;
|
|||
|
end;
|
|||
|
|
|||
|
RM1.LoadFromFile(filepath);
|
|||
|
RM1.ShowReport;
|
|||
|
finally
|
|||
|
|
|||
|
end;
|
|||
|
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmTradePlanProfit.Tv1DblClick(Sender: TObject);
|
|||
|
begin
|
|||
|
ToolButton4.Click;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmTradePlanProfit.CustNameChange(Sender: TObject);
|
|||
|
begin
|
|||
|
ToolButton2.Click;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmTradePlanProfit.ToolButton1Click(Sender: TObject);
|
|||
|
begin
|
|||
|
if ADOQueryMain.IsEmpty then
|
|||
|
Exit;
|
|||
|
TcxGridToExcel(self.Caption, cxgrid1);
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmTradePlanProfit.FormCreate(Sender: TObject);
|
|||
|
begin
|
|||
|
canshu1 := Trim(DParameters1);
|
|||
|
EndDate.DateTime := SGetServerDate(ADOQueryTemp);
|
|||
|
BegDate.DateTime := EndDate.DateTime - 90;
|
|||
|
end;
|
|||
|
|
|||
|
end.
|
|||
|
|