373 lines
11 KiB
ObjectPascal
373 lines
11 KiB
ObjectPascal
|
unit U_TradeBaseList;
|
|||
|
|
|||
|
interface
|
|||
|
|
|||
|
uses
|
|||
|
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
|
|||
|
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ComCtrls, Vcl.ToolWin, cxGraphics,
|
|||
|
cxControls, cxLookAndFeels, cxLookAndFeelPainters, dxSkinsCore,U_WindowFormdesign,
|
|||
|
dxSkinsDefaultPainters, dxSkinWXI, cxStyles, cxCustomData, cxFilter, cxData,
|
|||
|
cxDataStorage, cxEdit, cxNavigator, dxDateRanges, dxScrollbarAnnotations,
|
|||
|
Data.DB, cxDBData, cxGridLevel, cxGridCustomTableView, cxGridTableView,
|
|||
|
cxGridDBTableView, cxClasses, cxGridCustomView, cxGrid, Data.Win.ADODB,math,
|
|||
|
dxBarBuiltInMenu, cxGridCustomPopupMenu, cxGridPopupMenu, cxCheckBox,
|
|||
|
cxContainer, dxCore, cxDateUtils, dxLayoutcxEditAdapters, dxLayoutContainer,
|
|||
|
cxMaskEdit, cxDropDownEdit, cxCalendar, cxTextEdit, dxLayoutControl,
|
|||
|
FrameDateSel, Datasnap.DBClient, cxMemo, Vcl.StdCtrls, Vcl.ExtCtrls,
|
|||
|
cxGeometry, dxFramedControl, dxPanel;
|
|||
|
|
|||
|
type
|
|||
|
TfrmTradeBaseList = class(TForm)
|
|||
|
ToolBar3: TToolBar;
|
|||
|
Trefresh: TToolButton;
|
|||
|
Tprint: TToolButton;
|
|||
|
TprintGrid: TToolButton;
|
|||
|
TsaveGrid: TToolButton;
|
|||
|
Tclose: TToolButton;
|
|||
|
cxGrid1: TcxGrid;
|
|||
|
tv1: TcxGridDBTableView;
|
|||
|
tv1custName: TcxGridDBColumn;
|
|||
|
tv1OrderNo: TcxGridDBColumn;
|
|||
|
tv1ConNo: TcxGridDBColumn;
|
|||
|
cxGrid1Level1: TcxGridLevel;
|
|||
|
DataSource1: TDataSource;
|
|||
|
ADOQueryList: TADOQuery;
|
|||
|
cxGridPopupMenu1: TcxGridPopupMenu;
|
|||
|
ADOQueryBaseCmd: TADOQuery;
|
|||
|
ADOQueryBaseTemp: TADOQuery;
|
|||
|
tv1C_Name: TcxGridDBColumn;
|
|||
|
tv1C_Color: TcxGridDBColumn;
|
|||
|
tv1C_ColorNo: TcxGridDBColumn;
|
|||
|
tv1C_EColor: TcxGridDBColumn;
|
|||
|
tv1C_Pattern: TcxGridDBColumn;
|
|||
|
tv1C_StyleNo: TcxGridDBColumn;
|
|||
|
tv1C_Width: TcxGridDBColumn;
|
|||
|
tv1C_GramWeight: TcxGridDBColumn;
|
|||
|
tv1SSel: TcxGridDBColumn;
|
|||
|
dxLayoutControl_query: TdxLayoutControl;
|
|||
|
custName: TcxTextEdit;
|
|||
|
ConNo: TcxTextEdit;
|
|||
|
BuyConNo: TcxTextEdit;
|
|||
|
OrderNo: TcxTextEdit;
|
|||
|
dxLayoutControl_queryGroup_Root: TdxLayoutGroup;
|
|||
|
dxLayoutItem1: TdxLayoutItem;
|
|||
|
dxLayoutItem2: TdxLayoutItem;
|
|||
|
dxLayoutItem_hth: TdxLayoutItem;
|
|||
|
dxLayoutItem_khdh: TdxLayoutItem;
|
|||
|
frmFrameDateSel1: TfrmFrameDateSel;
|
|||
|
CDS_List: TClientDataSet;
|
|||
|
Panel_page: TPanel;
|
|||
|
BTNP: TButton;
|
|||
|
LBCPAP: TLabel;
|
|||
|
BTLP: TButton;
|
|||
|
TCBNOR: TcxComboBox;
|
|||
|
Label31: TLabel;
|
|||
|
TgridLiSet: TToolButton;
|
|||
|
procedure TrefreshClick(Sender: TObject);
|
|||
|
procedure TprintClick(Sender: TObject);
|
|||
|
procedure TprintGridClick(Sender: TObject);
|
|||
|
procedure FormShow(Sender: TObject);
|
|||
|
procedure FormCreate(Sender: TObject);
|
|||
|
procedure FormDestroy(Sender: TObject);
|
|||
|
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
|||
|
procedure TcloseClick(Sender: TObject);
|
|||
|
procedure TsaveGridClick(Sender: TObject);
|
|||
|
procedure BTLPClick(Sender: TObject);
|
|||
|
procedure BTNPClick(Sender: TObject);
|
|||
|
procedure TCBNORPropertiesChange(Sender: TObject);
|
|||
|
procedure dxLayoutControl_queryDblClick(Sender: TObject);
|
|||
|
procedure TgridLiSetClick(Sender: TObject);
|
|||
|
private
|
|||
|
fWindowDesign: TWindowFormdesign;
|
|||
|
CurrentPage, RecordsNumber: Integer;
|
|||
|
fDesignCode:string;
|
|||
|
procedure doQuery();
|
|||
|
procedure doQueryByCriteria();
|
|||
|
procedure initGrid();
|
|||
|
protected
|
|||
|
fParameters1: string;
|
|||
|
fParameters2: string;
|
|||
|
fParameters3: string;
|
|||
|
fParameters4: string;
|
|||
|
fParameters5: string;
|
|||
|
fParameters10: string;
|
|||
|
public
|
|||
|
fFormId: integer;
|
|||
|
fProcedureName:string; //<2F>洢<EFBFBD><E6B4A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
FLMType:string; //<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>ͱ<EFBFBD>־
|
|||
|
ftimeType:string; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
fQueryType:String; //<2F><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD>
|
|||
|
FFiltration1:string; //<2F><>ӡ<EFBFBD><D3A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
fCriteria:string; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
constructor Create(AOwner: TComponent; ACaption: string=''; Parameters1: string=''; Parameters2: string=''; Parameters3: string=''; Parameters4: string=''; Parameters5: string=''; Parameters10: string='';FormID:Integer=0);
|
|||
|
|
|||
|
end;
|
|||
|
|
|||
|
var
|
|||
|
frmTradeBaseList: TfrmTradeBaseList;
|
|||
|
|
|||
|
implementation
|
|||
|
uses
|
|||
|
U_RTFun, U_globalVar, U_dataLink,U_FormLayOutDesign, U_LabelPrint;
|
|||
|
{$R *.dfm}
|
|||
|
|
|||
|
procedure TfrmTradeBaseList.BTLPClick(Sender: TObject);
|
|||
|
begin
|
|||
|
if CurrentPage > 1 then
|
|||
|
CurrentPage := CurrentPage - 1;
|
|||
|
doQuery();
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmTradeBaseList.BTNPClick(Sender: TObject);
|
|||
|
begin
|
|||
|
if CurrentPage < cds_List.FieldByName('TotalCount').AsInteger / RecordsNumber then
|
|||
|
CurrentPage := CurrentPage + 1;
|
|||
|
doQuery();
|
|||
|
end;
|
|||
|
|
|||
|
constructor TfrmTradeBaseList.Create(AOwner: TComponent; ACaption: string=''; Parameters1: string=''; Parameters2: string=''; Parameters3: string=''; Parameters4: string=''; Parameters5: string=''; Parameters10: string='';FormID:Integer=0);
|
|||
|
begin
|
|||
|
inherited Create(AOwner);
|
|||
|
if ACaption <> '' then
|
|||
|
Caption := ACaption;
|
|||
|
|
|||
|
fParameters1 := Parameters1;
|
|||
|
fParameters2 := Parameters2;
|
|||
|
fParameters3 := Parameters3;
|
|||
|
fParameters4 := Parameters4;
|
|||
|
fParameters5 := Parameters5;
|
|||
|
fParameters10 := Parameters10;
|
|||
|
fFormId:= FormID ;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmTradeBaseList.TCBNORPropertiesChange(Sender: TObject);
|
|||
|
begin
|
|||
|
RecordsNumber := StrToInt(TCBNOR.Text);
|
|||
|
CurrentPage := 1;
|
|||
|
initGrid();
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmTradeBaseList.TcloseClick(Sender: TObject);
|
|||
|
begin
|
|||
|
close;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmTradeBaseList.TgridLiSetClick(Sender: TObject);
|
|||
|
begin
|
|||
|
fWindowDesign.OpenGridDesignWin10(fDesignCode,'cxgrid1',tv1);
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmTradeBaseList.TprintClick(Sender: TObject);
|
|||
|
begin
|
|||
|
if cds_List.IsEmpty then
|
|||
|
Exit;
|
|||
|
TcxGridToExcel(self.Caption, cxgrid1);
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmTradeBaseList.TprintGridClick(Sender: TObject);
|
|||
|
begin
|
|||
|
if cds_List.IsEmpty then
|
|||
|
Exit;
|
|||
|
if trim(self.FLMType)='' then
|
|||
|
begin
|
|||
|
application.MessageBox('δ<><CEB4><EFBFBD>ô<EFBFBD>ӡ<EFBFBD><D3A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!','<27><>ʾ<EFBFBD><CABE>Ϣ',0);
|
|||
|
exit;
|
|||
|
end;
|
|||
|
try
|
|||
|
frmLabelPrint := TfrmLabelPrint.Create(Application);
|
|||
|
with frmLabelPrint do
|
|||
|
begin
|
|||
|
FLMType := self.FLMType;
|
|||
|
FFiltration1 := self.FFiltration1;
|
|||
|
if ShowModal = 1 then
|
|||
|
begin
|
|||
|
// Self.InitGrid();
|
|||
|
end;
|
|||
|
end;
|
|||
|
finally
|
|||
|
frmLabelPrint.Free;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmTradeBaseList.TrefreshClick(Sender: TObject);
|
|||
|
begin
|
|||
|
if frmFrameDateSel1.BegDate.Visible then
|
|||
|
begin
|
|||
|
frmFrameDateSel1.BegDate.SetFocus;
|
|||
|
end;
|
|||
|
CurrentPage := 1;
|
|||
|
initGrid();
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmTradeBaseList.TsaveGridClick(Sender: TObject);
|
|||
|
begin
|
|||
|
WriteCxGrid(trim(self.Caption) + 'Tv1', Tv1, gDllFileCaption);
|
|||
|
if gIsCanDesign then
|
|||
|
begin
|
|||
|
saveLayOut(application, dxLayoutControl_query, ADOQueryBaseCmd,PWideChar( fDllFileName + '|' + Self.Name + '|' + dxLayoutControl_query.Name + '.ini'));
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
////////////////////////////////////
|
|||
|
procedure TfrmTradeBaseList.doQuery();
|
|||
|
var
|
|||
|
strwhere: string;
|
|||
|
begin
|
|||
|
if fProcedureName='' then
|
|||
|
begin
|
|||
|
application.MessageBox('<27>洢<EFBFBD><E6B4A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʋ<EFBFBD><C6B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>!','<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ',0);
|
|||
|
exit;
|
|||
|
end;
|
|||
|
strwhere := GetProcedureParam(dxLayoutControl_query);
|
|||
|
|
|||
|
try
|
|||
|
Tv1.BeginUpdate();
|
|||
|
CDS_List.DisableControls;
|
|||
|
with ADOQueryList do
|
|||
|
begin
|
|||
|
close;
|
|||
|
Filtered := false;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('exec '+fProcedureName);
|
|||
|
sql.Add('@timeType='+quotedstr(fTimeType));
|
|||
|
sql.Add(',@begDate='+quotedstr(FormatDateTime('yyyy-MM-dd', frmFrameDateSel1.begdate.Date)));
|
|||
|
sql.Add(',@endDate='+quotedstr(FormatDateTime('yyyy-MM-dd', frmFrameDateSel1.enddate.Date+1)));
|
|||
|
if frmFrameDateSel1.jqModel.Checked then
|
|||
|
sql.Add(',@jqModel=1')
|
|||
|
else
|
|||
|
sql.Add(',@jqModel=0');
|
|||
|
if Panel_page.Visible then
|
|||
|
begin
|
|||
|
sql.Add(',@pageIndex=' + inttostr(CurrentPage));
|
|||
|
sql.Add(',@pageSize=' + inttostr(RecordsNumber));
|
|||
|
end;
|
|||
|
sql.Add(',@criteria='+ quotedstr(fcriteria));
|
|||
|
if strwhere<>'' then
|
|||
|
sql.Add(','+strwhere);
|
|||
|
open;
|
|||
|
end;
|
|||
|
SCreateCDS(ADOQueryList, CDS_List);
|
|||
|
SInitCDSData(ADOQueryList, CDS_List);
|
|||
|
if Panel_page.Visible then
|
|||
|
begin
|
|||
|
LBCPAP.Caption := inttostr(CurrentPage) + '/' + inttostr(ceil(cds_list.FieldByName('TotalCount').AsInteger / RecordsNumber));
|
|||
|
end;
|
|||
|
finally
|
|||
|
CDS_List.EnableControls;
|
|||
|
Tv1.EndUpdate;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
////////////////////////////////////
|
|||
|
procedure TfrmTradeBaseList.doQueryByCriteria();
|
|||
|
var
|
|||
|
mSqlWhere: string;
|
|||
|
begin
|
|||
|
if fProcedureName='' then
|
|||
|
begin
|
|||
|
application.MessageBox('<27>洢<EFBFBD><E6B4A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʋ<EFBFBD><C6B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>!','<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ',0);
|
|||
|
exit;
|
|||
|
end;
|
|||
|
|
|||
|
mSqlWhere := SLGetFilters(dxLayoutControl_query, 1, 2);
|
|||
|
if trim(mSqlWhere) <> '' then
|
|||
|
begin
|
|||
|
mSqlWhere := ' and ' + trim(mSqlWhere);
|
|||
|
end;
|
|||
|
mSqlWhere:=fCriteria + ' ' + mSqlWhere ;
|
|||
|
try
|
|||
|
Tv1.BeginUpdate();
|
|||
|
CDS_List.DisableControls;
|
|||
|
with ADOQueryList do
|
|||
|
begin
|
|||
|
close;
|
|||
|
Filtered := false;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('exec '+fProcedureName);
|
|||
|
sql.Add('@timeType='+quotedstr(fTimeType));
|
|||
|
sql.Add(',@begDate='+quotedstr(FormatDateTime('yyyy-MM-dd', frmFrameDateSel1.begdate.Date)));
|
|||
|
sql.Add(',@endDate='+quotedstr(FormatDateTime('yyyy-MM-dd', frmFrameDateSel1.enddate.Date+1)));
|
|||
|
if Panel_page.Visible then
|
|||
|
begin
|
|||
|
sql.Add(',@pageIndex=' + inttostr(CurrentPage));
|
|||
|
sql.Add(',@pageSize=' + inttostr(RecordsNumber));
|
|||
|
end;
|
|||
|
sql.Add(',@criteria='+ quotedstr(mSqlWhere));
|
|||
|
|
|||
|
//cxMemo1.Text:= sql.Text ;
|
|||
|
open;
|
|||
|
end;
|
|||
|
SCreateCDS(ADOQueryList, CDS_List);
|
|||
|
SInitCDSData(ADOQueryList, CDS_List);
|
|||
|
if Panel_page.Visible then
|
|||
|
begin
|
|||
|
LBCPAP.Caption := inttostr(CurrentPage) + '/' + inttostr(ceil(cds_list.FieldByName('TotalCount').AsInteger / RecordsNumber));
|
|||
|
end;
|
|||
|
finally
|
|||
|
CDS_List.EnableControls;
|
|||
|
Tv1.EndUpdate;
|
|||
|
end;
|
|||
|
end;
|
|||
|
procedure TfrmTradeBaseList.dxLayoutControl_queryDblClick(Sender: TObject);
|
|||
|
begin
|
|||
|
layoutDesign(TdxLayoutControl(Sender),ADOQueryBaseCmd,PWideChar(dcode));
|
|||
|
end;
|
|||
|
|
|||
|
///
|
|||
|
procedure TfrmTradeBaseList.FormClose(Sender: TObject; var Action: TCloseAction);
|
|||
|
begin
|
|||
|
if WriteCloseWin(ADOQueryBaseCmd, self.Caption, fFormId, gDllFileName) then
|
|||
|
begin
|
|||
|
Sendmessage(application.MainForm.Handle, WM_CloseForm, 4, 0);
|
|||
|
end;
|
|||
|
Action:=cafree;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmTradeBaseList.FormCreate(Sender: TObject);
|
|||
|
begin
|
|||
|
cxgrid1.Align:=alClient;
|
|||
|
CurrentPage := 1;
|
|||
|
RecordsNumber := 500;
|
|||
|
fWindowDesign := TWindowFormdesign.Create();
|
|||
|
frmFrameDateSel1.begdate.Date:=SGetServerDate(ADOQueryBaseTemp);
|
|||
|
frmFrameDateSel1.enddate.Date:=frmFrameDateSel1.begdate.Date;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmTradeBaseList.FormDestroy(Sender: TObject);
|
|||
|
begin
|
|||
|
fWindowDesign.free;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmTradeBaseList.FormShow(Sender: TObject);
|
|||
|
begin
|
|||
|
fDesignCode := fDllFileName +'|'+self.name+ '|' + intTostr(fformId) + '|' + 'cxgrid1';
|
|||
|
if DParameters8<>'1' then
|
|||
|
begin
|
|||
|
fWindowDesign.FormStyleInit10(self, fFormId, ADOQueryBaseTemp, ADOQueryBaseCmd, '', fParameters10);
|
|||
|
end;
|
|||
|
if dxLayoutControl_query.Tag<>999 then
|
|||
|
readLayOut(dxLayoutControl_query,ADOQueryBaseTemp,PWideChar( fDllFileName+'|'+self.name+'|'+dxLayoutControl_query.Name+'.ini'));
|
|||
|
fWindowDesign.fProcedureName:=fProcedureName;
|
|||
|
|
|||
|
//<2F><><EFBFBD>Ӷ<EFBFBD>̬<EFBFBD><CCAC><EFBFBD><EFBFBD>
|
|||
|
addQryContionByLay(ADOQueryBaseTemp,fformId,'cxgrid1',dxLayoutControl_query,7);
|
|||
|
ReadCxGrid(trim(self.Caption) + 'Tv1', Tv1, gDllFileCaption);
|
|||
|
initGrid();
|
|||
|
end;
|
|||
|
|
|||
|
///////////////////////////////
|
|||
|
///
|
|||
|
procedure TfrmTradeBaseList.initGrid();
|
|||
|
begin
|
|||
|
if fQueryType='criteria' then
|
|||
|
begin
|
|||
|
doQueryByCriteria() ;
|
|||
|
end
|
|||
|
else
|
|||
|
begin
|
|||
|
frmFrameDateSel1.jqModel.Checked:=true;
|
|||
|
doQuery() ;
|
|||
|
end;
|
|||
|
end;
|
|||
|
end.
|