RTFormwork/项目代码/RTBasicsV1/T01贸易生产计划/U_TradePlanSchedule.pas
“ddf” 61630656e9 1
2024-07-07 09:35:27 +08:00

315 lines
9.0 KiB
ObjectPascal
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

unit U_TradePlanSchedule;
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, U_BaseList, cxLookAndFeels,
cxLookAndFeelPainters, dxSkinsCore, dxSkinsDefaultPainters, dxSkinWXI,
cxNavigator, dxDateRanges, dxScrollbarAnnotations, cxTextEdit,
dxBarBuiltInMenu, Vcl.Menus, RM_e_Xls, cxPC, cxGridBandedTableView,
cxGridDBBandedTableView, FrameDateSel;
type
TfrmTradePlanSchedule = class(TfrmBaseList)
ToolBar1: TToolBar;
TBRafresh: TToolButton;
TBClose: TToolButton;
ADOQueryTemp: TADOQuery;
ADOQueryCmd: TADOQuery;
Panel1: TPanel;
ToolButton2: TToolButton;
ADOQueryMain: TADOQuery;
ToolButton1: TToolButton;
cxGrid1: TcxGrid;
cxGridLevel1: TcxGridLevel;
GPM_1: TcxGridPopupMenu;
DS_1: TDataSource;
CDS_1: TClientDataSet;
Label5: TLabel;
ToolButton3: TToolButton;
RMGridReport1: TRMGridReport;
RMDBDataSet1: TRMDBDataSet;
RMXLSExport1: TRMXLSExport;
ADOQueryPrint: TADOQuery;
TV1: TcxGridDBBandedTableView;
V1Column1: TcxGridDBBandedColumn;
V1Column2: TcxGridDBBandedColumn;
V1Column6: TcxGridDBBandedColumn;
VCConNo: TcxGridDBBandedColumn;
cxStyleRepository1: TcxStyleRepository;
cxStyle1: TcxStyle;
V1Column16: TcxGridDBBandedColumn;
V1Column17: TcxGridDBBandedColumn;
V1Column18: TcxGridDBBandedColumn;
V1Column19: TcxGridDBBandedColumn;
V1Column20: TcxGridDBBandedColumn;
CustName: TEdit;
TV1Column4: TcxGridDBBandedColumn;
TV1Column5: TcxGridDBBandedColumn;
TV1Column6: TcxGridDBBandedColumn;
Label7: TLabel;
ConNo: TEdit;
TV1Column13: TcxGridDBBandedColumn;
TV1Column14: TcxGridDBBandedColumn;
TV1Column15: TcxGridDBBandedColumn;
TV1Column10: TcxGridDBBandedColumn;
TV1Column12: TcxGridDBBandedColumn;
TV1Column21: TcxGridDBBandedColumn;
TV1Column23: TcxGridDBBandedColumn;
TV1Column26: TcxGridDBBandedColumn;
cxTabControl1: TcxTabControl;
ToolButton5: TToolButton;
TV1Column29: TcxGridDBBandedColumn;
TV1Column30: TcxGridDBBandedColumn;
TV1Column32: TcxGridDBBandedColumn;
TV1Column33: TcxGridDBBandedColumn;
Label9: TLabel;
PMGY: TEdit;
TV1Column34: TcxGridDBBandedColumn;
TV1Column27: TcxGridDBBandedColumn;
TV1Column3: TcxGridDBBandedColumn;
TV1Column20: TcxGridDBBandedColumn;
TV1Column1: TcxGridDBBandedColumn;
TV1Column2: TcxGridDBBandedColumn;
TV1Column7: TcxGridDBBandedColumn;
frmFrameDateSel1: TfrmFrameDateSel;
lbl1: TLabel;
Edit1: TEdit;
Edit2: TEdit;
lbl2: TLabel;
TV1Column8: TcxGridDBBandedColumn;
V1MasterOrderNo: TcxGridDBBandedColumn;
VTV1Column9: TcxGridDBBandedColumn;
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 P_OrderNo_YSK(Sender: TObject);
procedure ToolButton1Click(Sender: TObject);
procedure MPRTCodeNameChange(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure ToolButton3Click(Sender: TObject);
procedure CustNameChange(Sender: TObject);
procedure ConNoChange(Sender: TObject);
procedure cxTabControl1Change(Sender: TObject);
procedure TV1DblClick(Sender: TObject);
procedure ToolButton5Click(Sender: TObject);
procedure TV1Column20CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
private
{ Private declarations }
procedure InitGrid();
public
{ Public declarations }
RKFlag, FCYID, FZKType, FBZType: string;
fType: string;
end;
var
frmTradePlanSchedule: TfrmTradePlanSchedule;
implementation
uses
U_DataLink, U_RTFun, U_ZDYHelp, U_TradePlanScheduleDetail;
{$R *.dfm}
procedure TfrmTradePlanSchedule.InitGrid();
begin
screen.Cursor := crsqlwait;
application.ProcessMessages;
try
ADOQueryMain.DisableControls;
with ADOQueryMain do
begin
Close;
SQL.Clear;
Filtered := False;
sql.Add(' exec P_Trade_Plan_Schedule ');
sql.Add(' @begdate=' + QuotedStr(Trim(FormatDateTime('yyyy-MM-dd', frmFrameDateSel1.begdate.Date))));
sql.Add(' ,@Enddate=' + QuotedStr(Trim(FormatDateTime('yyyy-MM-dd', frmFrameDateSel1.Enddate.Date + 1))));
case cxTabControl1.TabIndex of
0:
begin
sql.Add(' ,@WCFlag='<><CEB4><EFBFBD><EFBFBD>'' ');
end;
1:
begin
sql.Add(' ,@WCFlag=''<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'' ');
end;
2:
begin
sql.Add(' ,@WCFlag='<><C8AB>'' ');
end;
end;
Open;
end;
SCreateCDS(ADOQueryMain, CDS_1);
SInitCDSData(ADOQueryMain, CDS_1);
finally
ADOQueryMain.EnableControls;
ToolButton2.Click;
screen.Cursor := crdefault;
TV1.DataController.Filter.Clear;
end;
end;
procedure TfrmTradePlanSchedule.FormDestroy(Sender: TObject);
begin
inherited;
frmTradePlanSchedule := nil;
end;
procedure TfrmTradePlanSchedule.ConNoChange(Sender: TObject);
begin
ToolButton2.Click;
end;
procedure TfrmTradePlanSchedule.cxTabControl1Change(Sender: TObject);
begin
InitGrid();
end;
procedure TfrmTradePlanSchedule.CustNameChange(Sender: TObject);
begin
ToolButton2.Click;
end;
procedure TfrmTradePlanSchedule.FormClose(Sender: TObject; var Action: TCloseAction);
begin
inherited;
Action := caFree;
end;
procedure TfrmTradePlanSchedule.TBCloseClick(Sender: TObject);
begin
Close;
end;
procedure TfrmTradePlanSchedule.FormShow(Sender: TObject);
begin
inherited;
readCxBandedGrid(self.Caption + '2', Tv1, '<27><><EFBFBD><EFBFBD>ͳ<EFBFBD>Ʋ<EFBFBD>ѯ');
InitGrid();
end;
procedure TfrmTradePlanSchedule.TBRafreshClick(Sender: TObject);
begin
frmFrameDateSel1.begdate.SetFocus;
InitGrid();
end;
procedure TfrmTradePlanSchedule.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 TfrmTradePlanSchedule.P_OrderNo_YSK(Sender: TObject);
begin
ToolButton2.Click;
end;
procedure TfrmTradePlanSchedule.ToolButton1Click(Sender: TObject);
begin
if ADOQueryMain.IsEmpty then
Exit;
TcxGridToExcel(self.Caption, cxgrid1);
end;
procedure TfrmTradePlanSchedule.MPRTCodeNameChange(Sender: TObject);
begin
ToolButton2.Click;
end;
procedure TfrmTradePlanSchedule.FormCreate(Sender: TObject);
begin
inherited;
frmFrameDateSel1.Enddate.Date := SGetServerDate(ADOQueryTemp);
frmFrameDateSel1.begdate.Date := frmFrameDateSel1.Enddate.Date - 60;
end;
procedure TfrmTradePlanSchedule.ToolButton3Click(Sender: TObject);
var
filepath: string;
mBegdate, mEnddate: string;
begin
mBegdate := FormatDateTime('yyyy-MM-dd', frmFrameDateSel1.begdate.Date);
mEnddate := FormatDateTime('yyyy-MM-dd', frmFrameDateSel1.enddate.Date);
if CDS_1.IsEmpty then
exit;
try
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;
RMGridReport1.LoadFromFile(filepath);
RMGridReport1.ShowReport;
finally
end;
end;
procedure TfrmTradePlanSchedule.ToolButton5Click(Sender: TObject);
begin
WriteCxBandedGrid(self.Caption + '2', Tv1, '<27><><EFBFBD><EFBFBD>ͳ<EFBFBD>Ʋ<EFBFBD>ѯ');
end;
procedure TfrmTradePlanSchedule.TV1Column20CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
begin
if ARow1.Values[V1MasterOrderNo.Index] = ARow2.Values[V1MasterOrderNo.Index] then
AAreEqual := True
else
AAreEqual := False;
end;
procedure TfrmTradePlanSchedule.TV1DblClick(Sender: TObject);
begin
try
frmTradePlanScheduleDetail := TfrmTradePlanScheduleDetail.Create(Application);
with frmTradePlanScheduleDetail do
begin
FMainId := self.CDS_1.FieldByName('MainId').AsString;
FOrderNo := self.CDS_1.FieldByName('OrderNo').AsString;
FMasterOrderNo := self.CDS_1.FieldByName('MasterOrderNo').AsString;
if ShowModal = 1 then
begin
Self.InitGrid();
end;
end;
finally
frmTradePlanScheduleDetail.Free;
end;
end;
end.