604 lines
20 KiB
ObjectPascal
604 lines
20 KiB
ObjectPascal
|
unit U_TradeMarketDisScan;
|
|||
|
|
|||
|
interface
|
|||
|
|
|||
|
uses
|
|||
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|||
|
Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData, cxDataStorage,
|
|||
|
cxEdit, DB, cxDBData, cxGridLevel, cxGridCustomTableView, cxGridTableView,
|
|||
|
cxGridDBTableView, cxClasses, cxControls, cxGridCustomView, cxGrid, cxMemo,
|
|||
|
cxRichEdit, ComCtrls, cxContainer, cxTextEdit, cxMaskEdit, cxButtonEdit,
|
|||
|
StdCtrls, ToolWin, DBClient, ADODB, ExtCtrls, BtnEdit, cxCalendar, StrUtils,
|
|||
|
cxCurrencyEdit, cxGridCustomPopupMenu, cxGridPopupMenu, cxDropDownEdit,
|
|||
|
RM_Common, RM_Preview, RM_System, RM_Class, RM_GridReport, RM_Dataset, Menus,
|
|||
|
cxSplitter, cxLookAndFeels, cxLookAndFeelPainters, cxNavigator, cxCheckBox,
|
|||
|
dxSkinsCore, dxSkinsDefaultPainters, dxDateRanges, dxBarBuiltInMenu, cxPC,
|
|||
|
System.ImageList, Vcl.ImgList, U_BaseInput, cxImage, cxDBEdit, IdBaseComponent,
|
|||
|
IdComponent, IdTCPConnection, IdTCPClient, IdExplicitTLSClientServerBase,
|
|||
|
IdFTP, ShellAPI, MovePanel, RM_e_Xls, MMSystem, dxSkinBasic, dxSkinBlack,
|
|||
|
dxSkinBlue, dxSkinBlueprint, dxSkinCaramel, dxSkinCoffee, dxSkinDarkroom,
|
|||
|
dxSkinDarkSide, dxSkinDevExpressDarkStyle, dxSkinDevExpressStyle, dxSkinFoggy,
|
|||
|
dxSkinGlassOceans, dxSkinHighContrast, dxSkiniMaginary, dxSkinLilian,
|
|||
|
dxSkinLiquidSky, dxSkinLondonLiquidSky, dxSkinMcSkin, dxSkinMetropolis,
|
|||
|
dxSkinMetropolisDark, dxSkinMoneyTwins, dxSkinOffice2007Black,
|
|||
|
dxSkinOffice2007Blue, dxSkinOffice2007Green, dxSkinOffice2007Pink,
|
|||
|
dxSkinOffice2007Silver, dxSkinOffice2010Black, dxSkinOffice2010Blue,
|
|||
|
dxSkinOffice2010Silver, dxSkinOffice2013DarkGray, dxSkinOffice2013LightGray,
|
|||
|
dxSkinOffice2013White, dxSkinOffice2016Colorful, dxSkinOffice2016Dark,
|
|||
|
dxSkinOffice2019Black, dxSkinOffice2019Colorful, dxSkinOffice2019DarkGray,
|
|||
|
dxSkinOffice2019White, dxSkinPumpkin, dxSkinSeven, dxSkinSevenClassic,
|
|||
|
dxSkinSharp, dxSkinSharpPlus, dxSkinSilver, dxSkinSpringtime, dxSkinStardust,
|
|||
|
dxSkinSummer2008, dxSkinTheAsphaltWorld, dxSkinTheBezier, dxSkinValentine,
|
|||
|
dxSkinVisualStudio2013Blue, dxSkinVisualStudio2013Dark,
|
|||
|
dxSkinVisualStudio2013Light, dxSkinVS2010, dxSkinWhiteprint, dxSkinWXI,
|
|||
|
dxSkinXmas2008Blue, dxScrollbarAnnotations;
|
|||
|
|
|||
|
type
|
|||
|
TfrmTradeMarketDisScan = class(TfrmBaseInput)
|
|||
|
ToolBar1: TToolBar;
|
|||
|
TBSave: TToolButton;
|
|||
|
TBClose: TToolButton;
|
|||
|
GPM_1: TcxGridPopupMenu;
|
|||
|
ToolButton3: TToolButton;
|
|||
|
MovePanel2: TMovePanel;
|
|||
|
Panel1: TPanel;
|
|||
|
cxGrid1: TcxGrid;
|
|||
|
Tv1: TcxGridDBTableView;
|
|||
|
v1MJID: TcxGridDBColumn;
|
|||
|
v1MJXH: TcxGridDBColumn;
|
|||
|
v1P_Code: TcxGridDBColumn;
|
|||
|
v1P_Color: TcxGridDBColumn;
|
|||
|
v1RollNum: TcxGridDBColumn;
|
|||
|
v1Qty: TcxGridDBColumn;
|
|||
|
v1PHRollNum: TcxGridDBColumn;
|
|||
|
v1PHQty: TcxGridDBColumn;
|
|||
|
cxGrid1Level1: TcxGridLevel;
|
|||
|
cxGrid2: TcxGrid;
|
|||
|
TV2: TcxGridDBTableView;
|
|||
|
V2Column2: TcxGridDBColumn;
|
|||
|
cxGridDBColumn1: TcxGridDBColumn;
|
|||
|
cxGridDBColumn5: TcxGridDBColumn;
|
|||
|
cxGridDBColumn6: TcxGridDBColumn;
|
|||
|
cxGridDBColumn2: TcxGridDBColumn;
|
|||
|
cxGridDBColumn4: TcxGridDBColumn;
|
|||
|
cxGridDBColumn3: TcxGridDBColumn;
|
|||
|
V2Column1: TcxGridDBColumn;
|
|||
|
cxGridDBColumn7: TcxGridDBColumn;
|
|||
|
V2Column3: TcxGridDBColumn;
|
|||
|
V2Column4: TcxGridDBColumn;
|
|||
|
cxGridLevel1: TcxGridLevel;
|
|||
|
MovePanel1: TMovePanel;
|
|||
|
Label2: TLabel;
|
|||
|
Edit2: TEdit;
|
|||
|
Button4: TButton;
|
|||
|
Label1: TLabel;
|
|||
|
SmNO: TEdit;
|
|||
|
Label15: TLabel;
|
|||
|
PHYG: TBtnEditA;
|
|||
|
cxStyleRepository1: TcxStyleRepository;
|
|||
|
cxStyle1: TcxStyle;
|
|||
|
cxStyle2: TcxStyle;
|
|||
|
cxStyle_gridRow: TcxStyle;
|
|||
|
cxStyle_gridFoot: TcxStyle;
|
|||
|
cxStyle_gridHead: TcxStyle;
|
|||
|
cxStyle_gridGroupBox: TcxStyle;
|
|||
|
cxStyle_yellow: TcxStyle;
|
|||
|
cxStyle_Red: TcxStyle;
|
|||
|
cxStyle_fontBlack: TcxStyle;
|
|||
|
cxStyle_fontclFuchsia: TcxStyle;
|
|||
|
cxStyle_fontclPurple: TcxStyle;
|
|||
|
cxStyle_fontclGreen: TcxStyle;
|
|||
|
cxStyle_fontclBlue: TcxStyle;
|
|||
|
cxStyle_fontclTeal: TcxStyle;
|
|||
|
cxStyle_fontclOlive: TcxStyle;
|
|||
|
CDSOrder: TClientDataSet;
|
|||
|
DataSource1: TDataSource;
|
|||
|
ADOQueryTmp: TADOQuery;
|
|||
|
ADOQueryPrint: TADOQuery;
|
|||
|
ADOQueryMain: TADOQuery;
|
|||
|
ADOQueryCmd: TADOQuery;
|
|||
|
RMDB_Main: TRMDBDataSet;
|
|||
|
ADOQuery1: TADOQuery;
|
|||
|
CDSMJID: TClientDataSet;
|
|||
|
DataSource2: TDataSource;
|
|||
|
RMXLSExport2: TRMXLSExport;
|
|||
|
RM1: TRMGridReport;
|
|||
|
Tv1Column2: TcxGridDBColumn;
|
|||
|
TV2Column1: TcxGridDBColumn;
|
|||
|
Button1: TButton;
|
|||
|
procedure TBCloseClick(Sender: TObject);
|
|||
|
procedure CustomerNoNameBtnDnClick(Sender: TObject);
|
|||
|
procedure TBRafreshClick(Sender: TObject);
|
|||
|
procedure FormShow(Sender: TObject);
|
|||
|
procedure TV2CustomDrawCell(Sender: TcxCustomGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
|
|||
|
procedure SmNOKeyPress(Sender: TObject; var Key: Char);
|
|||
|
procedure TBSaveClick(Sender: TObject);
|
|||
|
procedure Button4Click(Sender: TObject);
|
|||
|
procedure Button1Click(Sender: TObject);
|
|||
|
private
|
|||
|
fCode, fColor, FPattern: string;
|
|||
|
function SaveData(): Boolean;
|
|||
|
procedure InitOrder();
|
|||
|
procedure InitMJID();
|
|||
|
procedure initGrid();
|
|||
|
|
|||
|
{ Private declarations }
|
|||
|
public
|
|||
|
FMainid: string;
|
|||
|
{ Public declarations }
|
|||
|
end;
|
|||
|
|
|||
|
var
|
|||
|
frmTradeMarketDisScan: TfrmTradeMarketDisScan;
|
|||
|
newh: hwnd;
|
|||
|
|
|||
|
implementation
|
|||
|
|
|||
|
uses
|
|||
|
U_DataLink, U_ZDYHelp, U_ZDYHelpSel, U_RTFun, U_CompanySel, U_PictureUpload,
|
|||
|
U_ClothInfoSel, U_TradeDispatchedSel;
|
|||
|
|
|||
|
|
|||
|
{$R *.dfm}
|
|||
|
|
|||
|
procedure TfrmTradeMarketDisScan.TBCloseClick(Sender: TObject);
|
|||
|
begin
|
|||
|
|
|||
|
Close;
|
|||
|
|
|||
|
end;
|
|||
|
|
|||
|
function TfrmTradeMarketDisScan.SaveData(): Boolean;
|
|||
|
var
|
|||
|
phID: string;
|
|||
|
P_ID: integer;
|
|||
|
begin
|
|||
|
|
|||
|
Result := false;
|
|||
|
ADOQueryCmd.Connection.BeginTrans;
|
|||
|
P_ID := 1;
|
|||
|
try
|
|||
|
with CDSMJID do
|
|||
|
begin
|
|||
|
DisableControls;
|
|||
|
first;
|
|||
|
while not eof do
|
|||
|
begin
|
|||
|
if trim(CDSMJID.fieldbyname('SDefNote').AsString) = 'ɨ<><C9A8><EFBFBD>ɹ<EFBFBD>' then
|
|||
|
begin
|
|||
|
if GetLSNo(ADOQueryTmp, phID, 'PH', 'Trade_Market_Distribution', 4, 1) = False then
|
|||
|
begin
|
|||
|
Application.MessageBox('ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ', 0);
|
|||
|
Exit;
|
|||
|
end;
|
|||
|
with ADOQueryCmd do
|
|||
|
begin
|
|||
|
close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('select * from Trade_Market_Distribution ');
|
|||
|
sql.Add('where 1=2 ');
|
|||
|
open;
|
|||
|
end;
|
|||
|
ADOQueryCmd.Append;
|
|||
|
ADOQueryCmd.FieldByName('TMDID').Value := trim(phID);
|
|||
|
ADOQueryCmd.FieldByName('TMMID').Value := trim(cdsmjid.fieldbyname('TMMID').AsString);
|
|||
|
ADOQueryCmd.FieldByName('TMSID').Value := trim(cdsmjid.fieldbyname('TMSID').AsString);
|
|||
|
ADOQueryCmd.FieldByName('STKID').Value := trim(cdsmjid.fieldbyname('STKID').AsString);
|
|||
|
ADOQueryCmd.FieldByName('Filler').Value := trim(DName);
|
|||
|
ADOQueryCmd.FieldByName('PHYG').Value := trim(PHYG.Text);
|
|||
|
ADOQueryCmd.FieldByName('TMDType').Value := 'ɨ<><C9A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
|
|||
|
ADOQueryCmd.Post;
|
|||
|
|
|||
|
with ADOQueryCmd do
|
|||
|
begin
|
|||
|
close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('select * from Trade_Cloth_Stock ');
|
|||
|
sql.Add('where stkid=' + quotedstr(trim(CDSMJID.fieldbyname('stkid').AsString)));
|
|||
|
open;
|
|||
|
edit;
|
|||
|
fieldbyname('DISstatus').Value := '1';
|
|||
|
post;
|
|||
|
end;
|
|||
|
with ADOQueryCmd do
|
|||
|
begin
|
|||
|
close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('select * from Trade_Market_Sub ');
|
|||
|
sql.Add('where TMSID=' + quotedstr(trim(CDSMJID.fieldbyname('TMSID').AsString)));
|
|||
|
open;
|
|||
|
edit;
|
|||
|
fieldbyname('substatus').Value := '2';
|
|||
|
post;
|
|||
|
end;
|
|||
|
end;
|
|||
|
next;
|
|||
|
end;
|
|||
|
first;
|
|||
|
EnableControls;
|
|||
|
end;
|
|||
|
ADOQueryCmd.Connection.CommitTrans;
|
|||
|
Result := true;
|
|||
|
except
|
|||
|
ADOQueryCmd.Connection.RollbackTrans;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmTradeMarketDisScan.SmNOKeyPress(Sender: TObject; var Key: Char);
|
|||
|
begin
|
|||
|
inherited;
|
|||
|
if Key = #13 then
|
|||
|
begin
|
|||
|
MovePanel1.Visible := false;
|
|||
|
if trim(smno.Text) = '' then
|
|||
|
exit;
|
|||
|
if uppercase(leftBstr(trim(smno.Text), 2)) = 'JM' then
|
|||
|
begin
|
|||
|
if not CDSMJID.IsEmpty then
|
|||
|
begin
|
|||
|
if FileExists(PChar(ExtractFilePath(Application.ExeName) + 'wav\<5C><><EFBFBD><EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD>.wav')) then
|
|||
|
PlaySound(PChar(ExtractFilePath(Application.ExeName) + 'wav\<5C><><EFBFBD><EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD>.wav'), 0, SND_ASYNC);
|
|||
|
exit;
|
|||
|
end;
|
|||
|
inItorder();
|
|||
|
end
|
|||
|
else
|
|||
|
begin
|
|||
|
if CDSOrder.IsEmpty then
|
|||
|
begin
|
|||
|
MovePanel1.Visible := true;
|
|||
|
Edit2.Text := SmNO.Text;
|
|||
|
Label2.Caption := '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>';
|
|||
|
smno.Text := '';
|
|||
|
if FileExists(PChar(ExtractFilePath(Application.ExeName) + 'wav\<5C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>.wav')) then
|
|||
|
PlaySound(PChar(ExtractFilePath(Application.ExeName) + 'wav\<5C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>.wav'), 0, SND_ASYNC);
|
|||
|
exit;
|
|||
|
end;
|
|||
|
if not CDSMJID.Locate('CIID', trim(smNo.Text), []) then
|
|||
|
begin
|
|||
|
initMjid();
|
|||
|
end
|
|||
|
else
|
|||
|
begin
|
|||
|
if FileExists(PChar(ExtractFilePath(Application.ExeName) + 'wav\<5C>ظ<EFBFBD>ɨ<EFBFBD><C9A8>.wav')) then
|
|||
|
PlaySound(PChar(ExtractFilePath(Application.ExeName) + 'wav\<5C>ظ<EFBFBD>ɨ<EFBFBD><C9A8>.wav'), 0, SND_ASYNC);
|
|||
|
end;
|
|||
|
end;
|
|||
|
smno.Text := '';
|
|||
|
smno.SetFocus;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmTradeMarketDisScan.TBRafreshClick(Sender: TObject);
|
|||
|
begin
|
|||
|
inherited;
|
|||
|
MovePanel2.Visible := True;
|
|||
|
MovePanel2.Refresh;
|
|||
|
initOrder();
|
|||
|
MovePanel2.Visible := False;
|
|||
|
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmTradeMarketDisScan.TBSaveClick(Sender: TObject);
|
|||
|
begin
|
|||
|
inherited;
|
|||
|
if CDSOrder.IsEmpty then
|
|||
|
exit;
|
|||
|
if CDSMJID.IsEmpty then
|
|||
|
exit;
|
|||
|
|
|||
|
try
|
|||
|
if not SaveData() then
|
|||
|
begin
|
|||
|
if FileExists(PChar(ExtractFilePath(Application.ExeName) + 'wav\<5C><><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>.wav')) then
|
|||
|
PlaySound(PChar(ExtractFilePath(Application.ExeName) + 'wav\<5C><><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>.wav'), 0, SND_ASYNC);
|
|||
|
exit;
|
|||
|
end
|
|||
|
else
|
|||
|
begin
|
|||
|
if FileExists(PChar(ExtractFilePath(Application.ExeName) + 'wav\<5C><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>.wav')) then
|
|||
|
PlaySound(PChar(ExtractFilePath(Application.ExeName) + 'wav\<5C><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>.wav'), 0, SND_ASYNC);
|
|||
|
initGrid();
|
|||
|
exit;
|
|||
|
end;
|
|||
|
except
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmTradeMarketDisScan.TV2CustomDrawCell(Sender: TcxCustomGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
|
|||
|
begin
|
|||
|
inherited;
|
|||
|
var i: integer;
|
|||
|
begin
|
|||
|
i := tv2.GetColumnByFieldName('SDefNote').Index;
|
|||
|
if (AViewInfo.GridRecord.Values[i] <> 'ɨ<><C9A8><EFBFBD>ɹ<EFBFBD>') then
|
|||
|
ACanvas.Brush.Color := clred;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmTradeMarketDisScan.Button1Click(Sender: TObject);
|
|||
|
var
|
|||
|
key: Char;
|
|||
|
begin
|
|||
|
inherited;
|
|||
|
key := #13;
|
|||
|
frmTradeDispatchedSel := TfrmTradeDispatchedSel.create(self);
|
|||
|
with frmTradeDispatchedSel do
|
|||
|
begin
|
|||
|
|
|||
|
if showmodal = 1 then
|
|||
|
begin
|
|||
|
smno.Text := trim(Order_Main.FieldByName('TMMID').AsString);
|
|||
|
|
|||
|
SmNOKeyPress(smno, key);
|
|||
|
end;
|
|||
|
free;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmTradeMarketDisScan.Button4Click(Sender: TObject);
|
|||
|
begin
|
|||
|
inherited;
|
|||
|
MovePanel1.Visible := False;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmTradeMarketDisScan.CustomerNoNameBtnDnClick(Sender: TObject);
|
|||
|
begin
|
|||
|
TBtnEditC(Sender).Text := '';
|
|||
|
TBtnEditC(Sender).TxtCode := '';
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmTradeMarketDisScan.InitOrder();
|
|||
|
var
|
|||
|
fP_No: string;
|
|||
|
begin
|
|||
|
MovePanel1.Visible := false;
|
|||
|
CDSMJID.EmptyDataSet;
|
|||
|
with ADOQueryMain do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
sql.add(' select * ');
|
|||
|
sql.Add(' ,PHRollNum=(select count(STKID) from Trade_Market_Distribution X where X.TMMID=A.TMMID and X.TMSID=B.TMSID),');
|
|||
|
sql.Add(' PHQty=(select sum(STKMeter) from Trade_Market_Distribution X inner join Trade_Cloth_Stock XX on X.stkid=XX.stkid where X.TMMID=A.TMMID and X.TMSID=B.TMSID)');
|
|||
|
sql.add(' from Trade_Market_Sub B');
|
|||
|
sql.add(' inner join Trade_Market_Main A on B.TMMID=A.TMMID ');
|
|||
|
SQL.Add(' where A.TMMID=' + quotedstr(trim(SmNO.text)));
|
|||
|
SQL.Add(' and isnull(B.substatus,''0'')<=''2'' ');
|
|||
|
Open;
|
|||
|
end;
|
|||
|
if ADOQueryMain.IsEmpty then
|
|||
|
begin
|
|||
|
MovePanel1.Visible := true;
|
|||
|
Edit2.text := SmNO.Text;
|
|||
|
Label2.Caption := '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>δ<EFBFBD><CEB4><EFBFBD>˻<EFBFBD><CBBB>ѷ<EFBFBD><D1B7><EFBFBD><EFBFBD><EFBFBD>';
|
|||
|
if FileExists(PChar(ExtractFilePath(Application.ExeName) + 'wav\<5C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.wav')) then
|
|||
|
PlaySound(PChar(ExtractFilePath(Application.ExeName) + 'wav\<5C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.wav'), 0, SND_ASYNC);
|
|||
|
exit;
|
|||
|
end
|
|||
|
else
|
|||
|
begin
|
|||
|
SCreateCDS(ADOQueryMain, CDSOrder);
|
|||
|
SInitCDSData(ADOQueryMain, CDSOrder);
|
|||
|
with CDSOrder do
|
|||
|
begin
|
|||
|
DisableControls;
|
|||
|
first;
|
|||
|
while not eof do
|
|||
|
begin
|
|||
|
|
|||
|
next;
|
|||
|
end;
|
|||
|
first;
|
|||
|
EnableControls;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmTradeMarketDisScan.InitGrid();
|
|||
|
begin
|
|||
|
with ADOQueryMain do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
sql.add(' select * ');
|
|||
|
sql.Add(' ,PHRollNum=(select count(X.STKID) from Trade_Market_Distribution X where X.TMMID=A.TMMID and X.TMSID=B.TMSID),');
|
|||
|
sql.Add(' PHQty=(select sum(STKMeter) from Trade_Market_Distribution X inner join Trade_Cloth_Stock XX on X.stkid=XX.stkid where X.TMMID=A.TMMID and X.TMSID=B.TMSID)');
|
|||
|
sql.add(' from Trade_Market_Sub B');
|
|||
|
sql.add(' inner join Trade_Market_Main A on B.TMMID=A.TMMID ');
|
|||
|
SQL.Add(' where 1=2 ');
|
|||
|
Open;
|
|||
|
end;
|
|||
|
SCreateCDS(ADOQueryMain, CDSOrder);
|
|||
|
SInitCDSData(ADOQueryMain, CDSOrder);
|
|||
|
|
|||
|
with ADOQueryMain do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
SQL.Add('select A.*,B.TMMID,TMSID,TMDID,cast(0 as int) as RollNum from Trade_Cloth_Stock A ');
|
|||
|
SQL.Add('inner join Trade_Market_Distribution B on B.STKID=A.STKID ');
|
|||
|
SQL.Add('where 1=2 ');
|
|||
|
Open;
|
|||
|
end;
|
|||
|
SCreateCDS(ADOQueryMain, CDSMJID);
|
|||
|
SInitCDSData(ADOQueryMain, CDSMJID);
|
|||
|
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmTradeMarketDisScan.FormShow(Sender: TObject);
|
|||
|
begin
|
|||
|
MovePanel1.Left := (Width - MovePanel1.Width) div 2;
|
|||
|
MovePanel1.top := (Height - MovePanel1.Height - 200) div 2;
|
|||
|
InitGrid();
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmTradeMarketDisScan.InitMJID();
|
|||
|
var
|
|||
|
fP_No: string;
|
|||
|
i: integer;
|
|||
|
begin
|
|||
|
MovePanel1.Visible := false;
|
|||
|
|
|||
|
with ADOQueryTmp do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
SQL.Add('select CIID from Trade_Cloth_Inspect A');
|
|||
|
SQL.Add('where A.CIID=' + quotedstr(trim(SmNO.text)));
|
|||
|
SQL.Add('and CIIOFlag=''δ<><CEB4><EFBFBD><EFBFBD>''');
|
|||
|
Open;
|
|||
|
if not IsEmpty then
|
|||
|
begin
|
|||
|
CDSMJID.Append;
|
|||
|
CDSMJID.FieldByName('SDefNote').Value := '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD>';
|
|||
|
CDSMJID.FieldByName('CIID').Value := trim(SmNO.Text);
|
|||
|
CDSMJID.Post;
|
|||
|
if FileExists(PChar(ExtractFilePath(Application.ExeName) + 'wav\<5C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD>.wav')) then
|
|||
|
PlaySound(PChar(ExtractFilePath(Application.ExeName) + 'wav\<5C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD>.wav'), 0, SND_ASYNC);
|
|||
|
Exit;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
with ADOQueryTmp do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
SQL.Add('select Stkid from Trade_Cloth_IO A');
|
|||
|
SQL.Add('where A.stkid=' + quotedstr(trim(SmNO.text)));
|
|||
|
SQL.Add('and IOFlag=''<27><><EFBFBD><EFBFBD>''');
|
|||
|
Open;
|
|||
|
if not IsEmpty then
|
|||
|
begin
|
|||
|
CDSMJID.Append;
|
|||
|
CDSMJID.FieldByName('SDefNote').Value := '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѳ<EFBFBD><D1B3><EFBFBD>';
|
|||
|
CDSMJID.FieldByName('Stkid').Value := trim(SmNO.Text);
|
|||
|
CDSMJID.Post;
|
|||
|
if FileExists(PChar(ExtractFilePath(Application.ExeName) + 'wav\<5C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѳ<EFBFBD><D1B3><EFBFBD>.wav')) then
|
|||
|
PlaySound(PChar(ExtractFilePath(Application.ExeName) + 'wav\<5C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѳ<EFBFBD><D1B3><EFBFBD>.wav'), 0, SND_ASYNC);
|
|||
|
Exit;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
with ADOQueryMain do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
SQL.Add('select A.* from Trade_Market_Distribution A');
|
|||
|
SQL.Add('where A.STKID=' + quotedstr(trim(SmNO.text)));
|
|||
|
// ShowMessage(sql.Text);
|
|||
|
Open;
|
|||
|
end;
|
|||
|
if ADOQueryMain.IsEmpty = false then
|
|||
|
begin
|
|||
|
CDSMJID.Append;
|
|||
|
CDSMJID.FieldByName('SDefNote').Value := '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
|
|||
|
CDSMJID.FieldByName('CIID').Value := trim(SmNO.Text);
|
|||
|
CDSMJID.Post;
|
|||
|
if FileExists(PChar(ExtractFilePath(Application.ExeName) + 'wav\ɨ<><C9A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.wav')) then
|
|||
|
PlaySound(PChar(ExtractFilePath(Application.ExeName) + 'wav\ɨ<><C9A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.wav'), 0, SND_ASYNC);
|
|||
|
exit;
|
|||
|
end;
|
|||
|
|
|||
|
with ADOQueryMain do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
SQL.Add('select A.* from Trade_Cloth_Stock A');
|
|||
|
sql.add('left join Trade_Cloth_IO B on B.stkid=A.stkid and B.IOFlag=''<27><><EFBFBD><EFBFBD>'' ');
|
|||
|
SQL.Add('where A.CIID=' + quotedstr(trim(SmNO.text)));
|
|||
|
sql.Add('and isnull(A.DisStatus,''0'')=''0'' ');
|
|||
|
sql.Add('and StkExists=1 ');
|
|||
|
// ShowMessage(sql.Text);
|
|||
|
Open;
|
|||
|
end;
|
|||
|
if ADOQueryMain.IsEmpty then
|
|||
|
begin
|
|||
|
CDSMJID.Append;
|
|||
|
CDSMJID.FieldByName('SDefNote').Value := '<27><><EFBFBD><EFBFBD><EFBFBD>벻<EFBFBD><EBB2BB><EFBFBD>ڻ<EFBFBD><DABB>ѳ<EFBFBD><D1B3><EFBFBD>';
|
|||
|
CDSMJID.FieldByName('CIID').Value := trim(SmNO.Text);
|
|||
|
CDSMJID.Post;
|
|||
|
if FileExists(PChar(ExtractFilePath(Application.ExeName) + 'wav\ɨ<><C9A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.wav')) then
|
|||
|
PlaySound(PChar(ExtractFilePath(Application.ExeName) + 'wav\ɨ<><C9A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.wav'), 0, SND_ASYNC);
|
|||
|
exit;
|
|||
|
end;
|
|||
|
with ADOQueryTmp do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
SQL.Add('select A.STKID,B.TMMID,B.TMSID from Trade_Cloth_Stock A');
|
|||
|
sql.Add('inner join Trade_Market_Sub B on isnull(B.C_Name,'''')=isnull(A.C_Name,'''') and isnull(B.C_Pattern,'''')= isnull(A.C_Pattern,'''') ');
|
|||
|
SQL.Add('where A.STKID=' + quotedstr(trim(SmNO.text)));
|
|||
|
SQL.Add('and B.TMMID=' + quotedstr(trim(CDSOrder.Fieldbyname('TMMID').AsString)));
|
|||
|
// SQL.ADD('and isnull(B.PRTKZ,'''')<>'''' ');
|
|||
|
Open;
|
|||
|
end;
|
|||
|
|
|||
|
if ADOQueryTmp.IsEmpty then
|
|||
|
begin
|
|||
|
CDSMJID.Append;
|
|||
|
CDSMJID.FieldByName('SDefNote').Value := '<27><>Ʒ<EFBFBD><C6B7><EFBFBD>ƺͻ<C6BA><CDBB>Ͳ<EFBFBD><CDB2><EFBFBD>Ӧ';
|
|||
|
CDSMJID.FieldByName('STKID').Value := trim(SmNO.Text);
|
|||
|
CDSMJID.Post;
|
|||
|
if FileExists(PChar(ExtractFilePath(Application.ExeName) + 'wav\Ʒ<><C6B7><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD>Ӧ.wav')) then
|
|||
|
PlaySound(PChar(ExtractFilePath(Application.ExeName) + 'wav\Ʒ<><C6B7><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD>Ӧ.wav'), 0, SND_ASYNC);
|
|||
|
exit;
|
|||
|
end;
|
|||
|
i := 0;
|
|||
|
while not ADOQueryTmp.eof do
|
|||
|
begin
|
|||
|
if CDSOrder.Locate('TMSID', trim(ADOQueryTmp.fieldbyname('TMSID').AsString), []) then
|
|||
|
begin
|
|||
|
if (CDSOrder.fieldbyName('TMSPiece').AsInteger = CDSOrder.FieldByName('PHRollNum').AsInteger) and (CDSOrder.fieldbyName('TMSPiece').AsInteger > 0) then
|
|||
|
begin
|
|||
|
end
|
|||
|
else
|
|||
|
begin
|
|||
|
i := 1;
|
|||
|
CDSMJID.Append;
|
|||
|
CDSMJID.FieldByName('SDefNote').Value := 'ɨ<><C9A8><EFBFBD>ɹ<EFBFBD>';
|
|||
|
CDSMJID.FieldByName('CIID').Value := trim(ADOQueryMain.Fieldbyname('CIID').AsString);
|
|||
|
CDSMJID.FieldByName('stkid').Value := trim(ADOQueryMain.Fieldbyname('stkid').AsString);
|
|||
|
CDSMJID.FieldByName('C_Name').Value := trim(ADOQueryMain.Fieldbyname('C_Name').AsString);
|
|||
|
CDSMJID.FieldByName('C_Color').Value := trim(ADOQueryMain.Fieldbyname('C_Color').AsString);
|
|||
|
CDSMJID.FieldByName('Grade').Value := trim(ADOQueryMain.Fieldbyname('Grade').AsString);
|
|||
|
CDSMJID.FieldByName('RollNum').Value := 1;
|
|||
|
CDSMJID.FieldByName('stkmeter').Value := ADOQueryMain.Fieldbyname('stkmeter').AsFloat;
|
|||
|
CDSMJID.FieldByName('TMMID').Value := trim(ADOQueryTmp.Fieldbyname('TMMID').AsString);
|
|||
|
CDSMJID.FieldByName('TMSID').Value := trim(ADOQueryTmp.Fieldbyname('TMSID').AsString);
|
|||
|
CDSMJID.FieldByName('C_Width').Value := ADOQueryMain.Fieldbyname('C_Width').AsString;
|
|||
|
CDSMJID.FieldByName('C_GramWeight').Value := ADOQueryMain.Fieldbyname('C_GramWeight').AsString;
|
|||
|
// CDSMJID.FieldByName('conNo').Value:=trim(ADOQueryMain.Fieldbyname('conNo').AsString);
|
|||
|
CDSMJID.Post;
|
|||
|
if FileExists(PChar(ExtractFilePath(Application.ExeName) + 'wav\<5C><>ȷ.wav')) then
|
|||
|
PlaySound(PChar(ExtractFilePath(Application.ExeName) + 'wav\<5C><>ȷ.wav'), 0, SND_ASYNC);
|
|||
|
CDSOrder.Edit;
|
|||
|
CDSOrder.fieldbyName('PHRollNum').Value := CDSOrder.fieldbyName('PHRollNum').AsInteger + 1;
|
|||
|
CDSOrder.fieldbyName('PHQty').Value := CDSOrder.fieldbyName('PHQty').AsFloat + ADOQueryMain.Fieldbyname('stkmeter').AsFloat;
|
|||
|
CDSOrder.Post;
|
|||
|
if tv1.DataController.Summary.FooterSummaryValues[0] <> 0 then
|
|||
|
begin
|
|||
|
if tv1.DataController.Summary.FooterSummaryValues[0] = tv2.DataController.Summary.FooterSummaryValues[0] then
|
|||
|
begin
|
|||
|
TBSave.Click;
|
|||
|
exit;
|
|||
|
end;
|
|||
|
end;
|
|||
|
exit;
|
|||
|
end;
|
|||
|
end;
|
|||
|
ADOQueryTmp.Next;
|
|||
|
end;
|
|||
|
|
|||
|
if i = 0 then
|
|||
|
begin
|
|||
|
if FileExists(PChar(ExtractFilePath(Application.ExeName) + 'wav\<5C><><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD>ƥ<EFBFBD><C6A5>.wav')) then
|
|||
|
PlaySound(PChar(ExtractFilePath(Application.ExeName) + 'wav\<5C><><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD>ƥ<EFBFBD><C6A5>.wav'), 0, SND_ASYNC);
|
|||
|
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
end.
|
|||
|
|