322 lines
9.8 KiB
ObjectPascal
322 lines
9.8 KiB
ObjectPascal
|
unit U_TradePlanSchedule1;
|
|||
|
|
|||
|
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, cxButtonEdit, cxDropDownEdit,
|
|||
|
cxContainer;
|
|||
|
|
|||
|
type
|
|||
|
TfrmTradePlanSchedule1 = class(TfrmBaseList)
|
|||
|
ToolBar1: TToolBar;
|
|||
|
TBRafresh: TToolButton;
|
|||
|
TBClose: TToolButton;
|
|||
|
ADOQueryTemp: TADOQuery;
|
|||
|
ADOQueryCmd: TADOQuery;
|
|||
|
Panel1: TPanel;
|
|||
|
ToolButton2: TToolButton;
|
|||
|
ADOQueryMain: TADOQuery;
|
|||
|
ToolButton1: TToolButton;
|
|||
|
GPM_1: TcxGridPopupMenu;
|
|||
|
DS_1: TDataSource;
|
|||
|
CDS_1: TClientDataSet;
|
|||
|
ToolButton3: TToolButton;
|
|||
|
RMGridReport1: TRMGridReport;
|
|||
|
RMDBDataSet1: TRMDBDataSet;
|
|||
|
RMXLSExport1: TRMXLSExport;
|
|||
|
ADOQueryPrint: TADOQuery;
|
|||
|
cxStyleRepository1: TcxStyleRepository;
|
|||
|
cxStyle1: TcxStyle;
|
|||
|
ToolButton5: TToolButton;
|
|||
|
frmFrameDateSel1: TfrmFrameDateSel;
|
|||
|
cxGrid1: TcxGrid;
|
|||
|
TV1: TcxGridDBTableView;
|
|||
|
TV1Column4: TcxGridDBColumn;
|
|||
|
TV1Column2: TcxGridDBColumn;
|
|||
|
TV1Column1: TcxGridDBColumn;
|
|||
|
TV1Column3: TcxGridDBColumn;
|
|||
|
TV1Column5: TcxGridDBColumn;
|
|||
|
VC_SCSCode: TcxGridDBColumn;
|
|||
|
cxGridDBColumn2: TcxGridDBColumn;
|
|||
|
TV1Column12: TcxGridDBColumn;
|
|||
|
TV1Column14: TcxGridDBColumn;
|
|||
|
TV1Column13: TcxGridDBColumn;
|
|||
|
v1Column5: TcxGridDBColumn;
|
|||
|
TV1Column6: TcxGridDBColumn;
|
|||
|
TV1Column9: TcxGridDBColumn;
|
|||
|
cxGridDBColumn4: TcxGridDBColumn;
|
|||
|
cxGridDBColumn5: TcxGridDBColumn;
|
|||
|
v1PRTOrderQty: TcxGridDBColumn;
|
|||
|
v1OrderUnit: TcxGridDBColumn;
|
|||
|
v1PRTPrice: TcxGridDBColumn;
|
|||
|
cxGridDBColumn9: TcxGridDBColumn;
|
|||
|
v1Column2: TcxGridDBColumn;
|
|||
|
TV1Column8: TcxGridDBColumn;
|
|||
|
TV1Column7: TcxGridDBColumn;
|
|||
|
cxGridLevel1: TcxGridLevel;
|
|||
|
Panel2: TPanel;
|
|||
|
cxGrid2: TcxGrid;
|
|||
|
TV2: TcxGridDBTableView;
|
|||
|
TV2Column1: TcxGridDBColumn;
|
|||
|
v1Column10: TcxGridDBColumn;
|
|||
|
v1Column15: TcxGridDBColumn;
|
|||
|
v2Column6: TcxGridDBColumn;
|
|||
|
v1Column3: TcxGridDBColumn;
|
|||
|
cxGrid1Level1: TcxGridLevel;
|
|||
|
cxGrid3: TcxGrid;
|
|||
|
TV3: TcxGridDBTableView;
|
|||
|
cxGridDBColumn3: TcxGridDBColumn;
|
|||
|
cxGridDBColumn6: TcxGridDBColumn;
|
|||
|
TV3Column1: TcxGridDBColumn;
|
|||
|
cxGridDBColumn7: TcxGridDBColumn;
|
|||
|
cxGridDBColumn8: TcxGridDBColumn;
|
|||
|
cxGridLevel2: TcxGridLevel;
|
|||
|
TV3Column2: TcxGridDBColumn;
|
|||
|
TV3Column3: TcxGridDBColumn;
|
|||
|
TV3Column4: TcxGridDBColumn;
|
|||
|
TV3Column5: TcxGridDBColumn;
|
|||
|
TV3Column6: TcxGridDBColumn;
|
|||
|
TV3Column7: TcxGridDBColumn;
|
|||
|
TV3Column8: TcxGridDBColumn;
|
|||
|
Label4: TLabel;
|
|||
|
Label9: TLabel;
|
|||
|
Label3: TLabel;
|
|||
|
BuyName: TcxTextEdit;
|
|||
|
PurNo: TcxTextEdit;
|
|||
|
SellName: TcxTextEdit;
|
|||
|
CDS_2: TClientDataSet;
|
|||
|
GPM_2: TcxGridPopupMenu;
|
|||
|
DS_2: TDataSource;
|
|||
|
ADO_2: TADOQuery;
|
|||
|
CDS_3: TClientDataSet;
|
|||
|
GPM_3: TcxGridPopupMenu;
|
|||
|
ADO_3: TADOQuery;
|
|||
|
DS_3: TDataSource;
|
|||
|
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 TV1FocusedRecordChanged(Sender: TcxCustomGridTableView; APrevFocusedRecord, AFocusedRecord: TcxCustomGridRecord; ANewItemRecordFocusingChanged: Boolean);
|
|||
|
private
|
|||
|
{ Private declarations }
|
|||
|
|
|||
|
procedure InitGrid();
|
|||
|
public
|
|||
|
{ Public declarations }
|
|||
|
RKFlag, FCYID, FZKType, FBZType: string;
|
|||
|
fType: string;
|
|||
|
end;
|
|||
|
|
|||
|
var
|
|||
|
frmTradePlanSchedule1: TfrmTradePlanSchedule1;
|
|||
|
|
|||
|
implementation
|
|||
|
|
|||
|
uses
|
|||
|
U_DataLink, U_RTFun, U_ZDYHelp, U_TradePlanScheduleDetail;
|
|||
|
|
|||
|
{$R *.dfm}
|
|||
|
|
|||
|
procedure TfrmTradePlanSchedule1.InitGrid();
|
|||
|
var
|
|||
|
SqlStr: string;
|
|||
|
begin
|
|||
|
|
|||
|
SqlStr := ' select A.*,B.*';
|
|||
|
SqlStr := SqlStr + ',LJHCPiece= (select SUM(X.Piece) from BS_Cloth_IO X where X.FromPurSId = B.PurSId and X.IOType =''<27>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><EFBFBD>'' and STKName=''ó<>ײ<EFBFBD>ƥ'')';
|
|||
|
SqlStr := SqlStr + ',LJHCQty= (select SUM(X.Qty) from BS_Cloth_IO X where X.FromPurSId = B.PurSId and X.IOType =''<27>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><EFBFBD>'' and STKName=''ó<>ײ<EFBFBD>ƥ'')';
|
|||
|
SqlStr := SqlStr + ' from Pur_ClothPlan_Main A inner join Pur_ClothPlan_sub B on A.PurMId=B.PurMId ';
|
|||
|
SqlStr := SqlStr + 'where C_Degree=''<27><><EFBFBD><EFBFBD>'' ';
|
|||
|
|
|||
|
InitCDSData(ADOQueryMain, CDS_1, Tv1, SqlStr, SGetFilters(Panel1, 1, 2), 'PurNo');
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmTradePlanSchedule1.FormDestroy(Sender: TObject);
|
|||
|
begin
|
|||
|
inherited;
|
|||
|
frmTradePlanSchedule1 := nil;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmTradePlanSchedule1.ConNoChange(Sender: TObject);
|
|||
|
begin
|
|||
|
ToolButton2.Click;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmTradePlanSchedule1.cxTabControl1Change(Sender: TObject);
|
|||
|
begin
|
|||
|
|
|||
|
InitGrid();
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmTradePlanSchedule1.CustNameChange(Sender: TObject);
|
|||
|
begin
|
|||
|
ToolButton2.Click;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmTradePlanSchedule1.FormClose(Sender: TObject; var Action: TCloseAction);
|
|||
|
begin
|
|||
|
inherited;
|
|||
|
Action := caFree;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmTradePlanSchedule1.TBCloseClick(Sender: TObject);
|
|||
|
begin
|
|||
|
|
|||
|
Close;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmTradePlanSchedule1.FormShow(Sender: TObject);
|
|||
|
begin
|
|||
|
inherited;
|
|||
|
readCxGrid(self.Caption + 'Tv1', Tv1, '<27><><EFBFBD><EFBFBD>ͳ<EFBFBD>Ʋ<EFBFBD>ѯ');
|
|||
|
readCxGrid(self.Caption + 'Tv2', Tv2, '<27><><EFBFBD><EFBFBD>ͳ<EFBFBD>Ʋ<EFBFBD>ѯ');
|
|||
|
readCxGrid(self.Caption + 'Tv3', Tv3, '<27><><EFBFBD><EFBFBD>ͳ<EFBFBD>Ʋ<EFBFBD>ѯ');
|
|||
|
InitGrid();
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmTradePlanSchedule1.TBRafreshClick(Sender: TObject);
|
|||
|
begin
|
|||
|
frmFrameDateSel1.begdate.SetFocus;
|
|||
|
InitGrid();
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmTradePlanSchedule1.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 TfrmTradePlanSchedule1.P_OrderNo_YSK(Sender: TObject);
|
|||
|
begin
|
|||
|
ToolButton2.Click;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmTradePlanSchedule1.ToolButton1Click(Sender: TObject);
|
|||
|
begin
|
|||
|
if ADOQueryMain.IsEmpty then
|
|||
|
Exit;
|
|||
|
TcxGridToExcel(self.Caption, cxgrid1);
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmTradePlanSchedule1.MPRTCodeNameChange(Sender: TObject);
|
|||
|
begin
|
|||
|
ToolButton2.Click;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmTradePlanSchedule1.FormCreate(Sender: TObject);
|
|||
|
begin
|
|||
|
inherited;
|
|||
|
frmFrameDateSel1.Enddate.Date := SGetServerDate(ADOQueryTemp);
|
|||
|
frmFrameDateSel1.begdate.Date := frmFrameDateSel1.Enddate.Date - 60;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmTradePlanSchedule1.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 TfrmTradePlanSchedule1.ToolButton5Click(Sender: TObject);
|
|||
|
begin
|
|||
|
|
|||
|
WriteCxGrid(self.Caption + 'Tv1', Tv1, '<27><><EFBFBD><EFBFBD>ͳ<EFBFBD>Ʋ<EFBFBD>ѯ');
|
|||
|
WriteCxGrid(self.Caption + 'Tv2', Tv2, '<27><><EFBFBD><EFBFBD>ͳ<EFBFBD>Ʋ<EFBFBD>ѯ');
|
|||
|
WriteCxGrid(self.Caption + 'Tv3', Tv3, '<27><><EFBFBD><EFBFBD>ͳ<EFBFBD>Ʋ<EFBFBD>ѯ');
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmTradePlanSchedule1.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;
|
|||
|
|
|||
|
procedure TfrmTradePlanSchedule1.TV1FocusedRecordChanged(Sender: TcxCustomGridTableView; APrevFocusedRecord, AFocusedRecord: TcxCustomGridRecord; ANewItemRecordFocusingChanged: Boolean);
|
|||
|
var
|
|||
|
SqlStr: string;
|
|||
|
begin
|
|||
|
|
|||
|
SqlStr := ' select A.*';
|
|||
|
|
|||
|
SqlStr := SqlStr + ' from BS_Cloth_IO A ';
|
|||
|
SqlStr := SqlStr + 'where A.FromPurSId = ' + quotedstr(Trim(CDS_1.fieldbyname('PurSId').AsString));
|
|||
|
SqlStr := SqlStr + 'and A.IOType =''<27>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><EFBFBD>'' and STKName=''ó<>ײ<EFBFBD>ƥ'' ';
|
|||
|
|
|||
|
InitCDSData(ADO_2, CDS_2, Tv2, SqlStr, '', '');
|
|||
|
|
|||
|
SqlStr := ' select A.IOTime,A.ToCoName,TPPiece=A.Piece,TPQty=A.Qty,WGPiece=B.Piece,WGQty=B.Qty,B.STKPiece,B.STKQty,B.FtyPCId,B.C_Color,B.StkCoName ';
|
|||
|
SqlStr := SqlStr + ' ,sl=cast(round((1-ISNULL(B.Qty, 0)/A.Qty)*100,2) as DECIMAL(18,2)) ';
|
|||
|
SqlStr := SqlStr + ' from BS_Cloth_IO A left join BS_Cloth_IO B on A.ToSubID=B.FromSubId AND B.IOType=''<27>ӹ<EFBFBD><D3B9><EFBFBD><EFBFBD><EFBFBD>'' ';
|
|||
|
SqlStr := SqlStr + ' where A.IOType=''Ͷ<><CDB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'' ';
|
|||
|
SqlStr := SqlStr + ' and A.FromPurSId = ' + quotedstr(Trim(CDS_1.fieldbyname('PurSId').AsString));
|
|||
|
|
|||
|
InitCDSData(ADO_3, CDS_3, Tv3, SqlStr, '', '');
|
|||
|
|
|||
|
end;
|
|||
|
|
|||
|
end.
|
|||
|
|