RTFormwork/项目代码/RTBasicsV1/T05贸易门市管理/U_TradeDispatchedList.pas
2024-09-13 17:30:30 +08:00

1493 lines
43 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_TradeDispatchedList;
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, cxImage, cxDBEdit, Menus, RM_Common, RM_Class, RM_e_Xls,
RM_Dataset, RM_System, RM_GridReport, cxGridCustomPopupMenu, cxGridPopupMenu,
cxPC, cxSplitter, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient,
IdFTP, ShellAPI, cxDropDownEdit, cxCheckBox, RM_e_Graphic, RM_e_Jpeg,
cxLookAndFeels, cxLookAndFeelPainters, cxNavigator, dxBarBuiltInMenu, Math,
dxSkinsCore, dxSkinsDefaultPainters, dxDateRanges,
IdExplicitTLSClientServerBase, U_BaseList, Vcl.Clipbrd, 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,
FrameDateSel, dxCore, cxDateUtils;
type
TfrmTradeDispatchedList = class(TfrmBaseList)
ToolBar1: TToolBar;
TBRafresh: TToolButton;
TBPrint: TToolButton;
TBClose: TToolButton;
Panel1: TPanel;
Tv1: TcxGridDBTableView;
cxGrid1Level1: TcxGridLevel;
cxGrid1: TcxGrid;
cxgrdpmn1: TcxGridPopupMenu;
ADOQueryCmd: TADOQuery;
ADOQueryMain: TADOQuery;
ADOQueryTemp: TADOQuery;
DataSource1: TDataSource;
Label3: TLabel;
TMMNo: TcxTextEdit;
v1OrdDate: TcxGridDBColumn;
v1DeliveryDate: TcxGridDBColumn;
Order_Main: TClientDataSet;
TBCK: TToolButton;
Label12: TLabel;
MPRTKZ: TcxTextEdit;
ADOQuerySub: TADOQuery;
DataSource2: TDataSource;
TBFJ: TToolButton;
Panel2: TPanel;
ADOQueryImage: TADOQuery;
DSImage: TDataSource;
IdFTP1: TIdFTP;
v1Column11: TcxGridDBColumn;
v1Column16: TcxGridDBColumn;
ORDER_SUB: TClientDataSet;
PopupMenu2: TPopupMenu;
N3: TMenuItem;
N4: TMenuItem;
Label1: TLabel;
CustName: TcxTextEdit;
Tv1Column6: TcxGridDBColumn;
cxgrdpmn2: TcxGridPopupMenu;
Tv1Column2: TcxGridDBColumn;
Tv1Column10: TcxGridDBColumn;
Tv1Column11: TcxGridDBColumn;
Tv1Column1: TcxGridDBColumn;
Label2: TLabel;
C_Name: TcxTextEdit;
CDS_WXTS: TClientDataSet;
ToolButton2: TToolButton;
PM_1: TPopupMenu;
N1: TMenuItem;
N2: TMenuItem;
GPM_3: TcxGridPopupMenu;
Tv1Column4: TcxGridDBColumn;
Tv1Column3: TcxGridDBColumn;
Tv1Column5: TcxGridDBColumn;
cxTabControl1: TcxTabControl;
Panel3: TPanel;
Label14: TLabel;
Label15: TLabel;
Panel4: TPanel;
Edit1: TcxTextEdit;
ADO_PH: TADOQuery;
DS_PH: TDataSource;
CDS_PH: TClientDataSet;
Tv1Column7: TcxGridDBColumn;
Tv1Column8: TcxGridDBColumn;
Tv1Column9: TcxGridDBColumn;
Tv1Column12: TcxGridDBColumn;
Tv1Column13: TcxGridDBColumn;
cxGrid2: TcxGrid;
TV2: TcxGridDBTableView;
V2Column13: TcxGridDBColumn;
V2Column10: TcxGridDBColumn;
V2Column2: TcxGridDBColumn;
V2Column3: TcxGridDBColumn;
V2C_Color: TcxGridDBColumn;
V2Column5: TcxGridDBColumn;
V2Column6: TcxGridDBColumn;
V2Column11: TcxGridDBColumn;
V2Filler: TcxGridDBColumn;
V2Column12: TcxGridDBColumn;
V2Column14: TcxGridDBColumn;
V2Column15: TcxGridDBColumn;
V2Column16: TcxGridDBColumn;
cxGrid2Level1: TcxGridLevel;
ToolBar2: TToolBar;
ToolButton4: TToolButton;
phwc: TToolButton;
Tv1Column14: TcxGridDBColumn;
TV2Column1: TcxGridDBColumn;
Tv1Column15: TcxGridDBColumn;
TV2Column2: TcxGridDBColumn;
ToolButton6: TToolButton;
phok: TToolButton;
fh: TToolButton;
TBPrint1: TToolButton;
ToolButton9: TToolButton;
del: TToolButton;
ADOQueryPrint: TADOQuery;
RMDB_1: TRMDBDataSet;
RM1: TRMGridReport;
ToolButton5: TToolButton;
Tdbchexiao: TToolButton;
ToolButton1: TToolButton;
ToolButton3: TToolButton;
cxCheckBox1: TcxCheckBox;
cxCheckBox2: TcxCheckBox;
frmFrameDateSel1: TfrmFrameDateSel;
Label4: TLabel;
Label5: TLabel;
CRdate: TcxDateEdit;
procedure FormDestroy(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormCreate(Sender: TObject);
procedure TBCloseClick(Sender: TObject);
procedure TBPrintClick(Sender: TObject);
procedure TBRafreshClick(Sender: TObject);
procedure TMMNoMChange(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure TBTPClick(Sender: TObject);
procedure CheckBox1Click(Sender: TObject);
procedure TBCKClick(Sender: TObject);
procedure TMMNoKeyPress(Sender: TObject; var Key: Char);
procedure Tv1FocusedRecordChanged(Sender: TcxCustomGridTableView; APrevFocusedRecord, AFocusedRecord: TcxCustomGridRecord; ANewItemRecordFocusingChanged: Boolean);
procedure TBFJClick(Sender: TObject);
procedure cxTabControl1Change(Sender: TObject);
procedure N3Click(Sender: TObject);
procedure N4Click(Sender: TObject);
procedure ComboBox1Change(Sender: TObject);
procedure CustomerNoNameKeyPress(Sender: TObject; var Key: Char);
procedure ToolButton5Click(Sender: TObject);
procedure JGTypeChange(Sender: TObject);
procedure ToolButton2Click(Sender: TObject);
procedure N1Click(Sender: TObject);
procedure N2Click(Sender: TObject);
procedure ToolButton4Click(Sender: TObject);
procedure phwcClick(Sender: TObject);
procedure ToolButton6Click(Sender: TObject);
procedure phokClick(Sender: TObject);
procedure fhClick(Sender: TObject);
procedure TBPrint1Click(Sender: TObject);
procedure ToolButton9Click(Sender: TObject);
procedure delClick(Sender: TObject);
procedure TdbchexiaoClick(Sender: TObject);
procedure ToolButton1Click(Sender: TObject);
procedure ToolButton3Click(Sender: TObject);
procedure cxCheckBox1Click(Sender: TObject);
procedure cxCheckBox2Click(Sender: TObject);
private
DQdate: TDateTime;
MSubIds: string;
procedure InitGrid();
procedure InitForm();
function DelData(): Boolean;
procedure InitGridFH();
procedure InitSub();
procedure InitPH();
procedure SetStatus();
procedure InitImage(fwbid: string);
function SaveData(): Boolean;
procedure SendMessageQR(MDateId, KeyWord1, KeyWord2, KeyWord3: string);
{ Private declarations }
public
FFInt, FCloth: Integer;
canshu1, canshu2: string;
fFlileFlag: string;
FNOTE: string;
{ Public declarations }
end;
implementation
uses
U_DataLink, U_RTFun, U_ZDYHelp, U_LabelPrint, U_AttachmentUpload,
U_TradeMarketInPut, U_TradeMarketDisSel, U_TradeMarketDisScan;
{$R *.dfm}
procedure TfrmTradeDispatchedList.InitImage(fwbid: string);
begin
ADOQueryImage.close;
if fwbid = '' then
exit;
with ADOQueryImage do
begin
close;
sql.Clear;
sql.Add('select * from TP_File A');
sql.Add('where WBID=' + quotedstr(trim(fwbid)));
open;
end;
end;
procedure TfrmTradeDispatchedList.SetStatus();
begin
del.Visible := false;
phwc.Visible := false;
phok.Visible := false;
fh.Visible := false;
ToolButton4.Visible := false;
ToolButton5.Visible := false;
TBPrint1.Visible := false;
ToolButton6.Visible := false;
Tdbchexiao.Visible := false;
ToolButton3.Visible := false;
case cxTabControl1.TabIndex of
0:
begin
del.Visible := true;
phwc.Visible := true;
Panel2.Visible := true;
ToolButton4.Visible := true;
end;
1:
begin
fh.Visible := true;
ToolButton5.Visible := true;
Tdbchexiao.Visible := true;
end;
2:
begin
TBPrint1.Visible := true;
ToolButton3.Visible := True;
end;
end;
application.ProcessMessages;
end;
procedure TfrmTradeDispatchedList.InitSub();
begin
ADOQuerySub.Close;
if Order_Main.IsEmpty then
exit;
ADOQuerySub.DisableControls;
with ADOQuerySub do
begin
close;
sql.Clear;
sql.Add('select * ');
sql.Add(' from Trade_Market_Sub A');
sql.Add('where TMMId =' + quotedstr((Order_Main.fieldbyname('TMMId').AsString)));
open;
end;
SCreateCDS(ADOQuerySub, ORDER_SUB);
SInitCDSData(ADOQuerySub, ORDER_SUB);
ADOQuerySub.EnableControls;
TV2.DataController.Filter.Clear;
end;
procedure TfrmTradeDispatchedList.InitPH();
begin
if ADOQueryMain.Active = False then
Exit;
if Order_Main.IsEmpty then
EXIT;
try
ADO_PH.DisableControls;
with ADO_PH do
begin
Close;
sql.Clear;
Filtered := False;
sql.Add('select A.*,B.* ');
sql.Add('from Trade_Market_Distribution A ');
sql.Add('INNER join Trade_Cloth_Stock B on B.STKID=A.STKID ');
sql.Add('LEFT join Trade_Cloth_IO C on C.STKID=B.STKID and IOFlag=''<27><><EFBFBD><EFBFBD>''');
sql.Add('where A.TMMID=' + quotedstr(trim(Order_Main.fieldbyname('TMMID').asstring)));
sql.Add('and A.TMSID=' + quotedstr(trim(Order_Main.fieldbyname('TMSID').asstring)));
sql.Add('order by A.TMDID ');
// ShowMessage(SQL.Text);
Open;
end;
SCreateCDS(ADO_PH, CDS_PH);
SInitCDSData(ADO_PH, CDS_PH);
finally
ADO_PH.EnableControls;
end;
end;
procedure TfrmTradeDispatchedList.JGTypeChange(Sender: TObject);
begin
InitGrid();
end;
procedure TfrmTradeDispatchedList.FormDestroy(Sender: TObject);
begin
inherited;
// frmProductOrderList:=nil;
end;
procedure TfrmTradeDispatchedList.FormClose(Sender: TObject; var Action: TCloseAction);
begin
inherited;
Action := caFree;
end;
procedure TfrmTradeDispatchedList.FormCreate(Sender: TObject);
begin
inherited;
cxgrid1.Align := alClient;
DQdate := SGetServerDate(ADOQueryTemp);
CRdate.Date := DQdate;
end;
procedure TfrmTradeDispatchedList.TBCloseClick(Sender: TObject);
begin
Close;
end;
procedure TfrmTradeDispatchedList.InitGrid();
var
STRwhere, Pwhere: string;
begin
STRwhere := '';
Pwhere := SGetFilters(Panel1, 1, 2);
begin
if trim(Pwhere) <> '' then
STRwhere := STRwhere + ' and ' + trim(Pwhere);
end;
STRwhere := STRwhere + ' and isnull(A.Status,''0'')=''9'' ';
if cxTabControl1.TabIndex = 0 then
begin
STRwhere := STRwhere + ' and isnull(substatus,''0'')=''' + inttostr(cxTabControl1.TabIndex) + '''';
end;
if (cxTabControl1.TabIndex >= 1) and (cxTabControl1.TabIndex < 3) then
STRwhere := STRwhere + ' and isnull(substatus,''0'')=''' + inttostr(cxTabControl1.TabIndex + 1) + '''';
try
ADOQueryMain.DisableControls;
with ADOQueryMain do
begin
Filtered := False;
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 ');
if (cxComboBox1.Text = '<27>Ƶ<EFBFBD><C6B5><EFBFBD><EFBFBD><EFBFBD>') and (cxCheckBox3.Checked = True) then
begin
sql.add(' where A.TMMDate>=' + quotedstr(Trim(FormatDateTime('yyyy-MM-dd', frmFrameDateSel1.BegDate.Date))));
sql.add(' and A.TMMDate<' + quotedstr(Trim(FormatDateTime('yyyy-MM-dd', frmFrameDateSel1.enddate.Date + 1))));
end;
if (cxComboBox1.Text = '<27>Ƶ<EFBFBD><C6B5><EFBFBD><EFBFBD><EFBFBD>') and (cxCheckBox3.Checked = False) then
begin
sql.add(' where A.TMMDate>=' + quotedstr(Trim(FormatDateTime('yyyy-MM-dd', frmFrameDateSel1.BegDate.Date - 39999))));
sql.add(' and A.TMMDate<' + quotedstr(Trim(FormatDateTime('yyyy-MM-dd', frmFrameDateSel1.enddate.Date + 1))));
end;
if (cxComboBox1.Text = '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>') and (cxCheckBox3.Checked = True) then
begin
sql.add(' where A.DlyDate>=' + quotedstr(Trim(FormatDateTime('yyyy-MM-dd', frmFrameDateSel1.BegDate.Date))));
sql.add(' and A.DlyDate<' + quotedstr(Trim(FormatDateTime('yyyy-MM-dd', frmFrameDateSel1.enddate.Date + 1))));
end;
if (cxComboBox1.Text = '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>') and (cxCheckBox3.Checked = False) then
begin
sql.add(' where A.DlyDate>=' + quotedstr(Trim(FormatDateTime('yyyy-MM-dd', frmFrameDateSel1.BegDate.Date - 39999))));
sql.add(' and A.DlyDate<' + quotedstr(Trim(FormatDateTime('yyyy-MM-dd', frmFrameDateSel1.enddate.Date + 1))));
end;
if canshu1 = <><C2BC>' then
begin
sql.add(' and A.Filler= ' + QuotedStr(Trim(DName)));
end;
sql.add(' ' + STRwhere);
sql.Add(' and ordtype=''<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'' ');
sql.add(' order by filltime desc');
// ShowMessage(SQL.Text);
Open;
end;
SCreateCDS(ADOQueryMain, Order_Main);
SInitCDSData(ADOQueryMain, Order_Main);
finally
ADOQueryMain.EnableControls;
TV1.DataController.Filter.Clear;
end;
end;
procedure TfrmTradeDispatchedList.SendMessageQR(MDateId, KeyWord1, KeyWord2, KeyWord3: string);
begin
// with ADOQueryTemp do
// begin
// Close;
// SQL.Clear;
// sql.Add('select distinct A.* from SY_User A inner join SY_Purview B on A.UserID=B.UserID where A.Valid=''Y'' ');
// SQL.Add('and isnull(A.wxid,'''')<>''''');
// SQL.Add(' and exists(select 1 from SY_ModuleSub X where X.ModuleID=B.ModuleID and X.ModuleSubID=B.ModuleSubID and X.FormName=''<27><><EFBFBD><EFBFBD><EFBFBD>ƻ<EFBFBD><C6BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'' )');
//// showmessage(sql.text);
// Open;
// end;
// SCreateCDS(ADOQueryTemp, CDS_WXTS);
// SInitCDSData(ADOQueryTemp, CDS_WXTS);
//
// if CDS_WXTS.IsEmpty then
// begin
// Application.MessageBox('<27>û<EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD>΢<EFBFBD><CEA2>,<2C>ύʧ<E1BDBB>ܣ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
// Exit;
// end;
CDS_WXTS.First;
while not CDS_WXTS.eof do
begin
with ADOQueryCmd do
begin
Close;
SQL.Clear;
SQL.Add('select * from WeixinMessage where 1<>1');
Open;
Append;
FieldByName('MessageType').Value := 'OrderToAudit';
FieldByName('MessageName').Value := '<27>ƻ<EFBFBD><C6BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
FieldByName('Title').Value := '<27><><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD><C2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƻ<EFBFBD><C6BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
FieldByName('URL').Value := 'subpages/plan/view?id=' + Trim(MDateId);
FieldByName('OpenId').Value := Trim(CDS_WXTS.FieldByName('wxid').AsString);
FieldByName('Status').Value := '0';
FieldByName('CreateDate').Value := FormatDateTime('yyyymmdd', SGetServerDateTime(ADOQueryTemp));
FieldByName('CreateTime').Value := FormatDateTime('HH:mm:ss', SGetServerDateTime(ADOQueryTemp));
FieldByName('BusinessId').Value := Trim(MDateId);
FieldByName('KeyWord1').Value := Trim(KeyWord1);
FieldByName('KeyWord2').Value := Trim(KeyWord2);
FieldByName('KeyWord3').Value := Trim(KeyWord3);
FieldByName('Remark').Value := '<27><><EFBFBD><EFBFBD><EFBFBD>ɲ<EFBFBD>ѯ<EFBFBD><D1AF><EFBFBD>飡';
Post;
end;
CDS_WXTS.Next;
end;
GetHTTP('http://aotang.rightsoft.top/api/message/send/OrderToAudit');
end;
procedure TfrmTradeDispatchedList.InitGridFH();
begin
try
ADOQueryMain.DisableControls;
with ADOQueryMain do
begin
Filtered := False;
Close;
sql.Clear;
sql.Add('exec Order_QryList :TMMId,:WSql');
Parameters.ParamByName('WSql').Value := ' and FillTime>=''' + Trim(FormatDateTime('yyyy-MM-dd', frmFrameDateSel1.BegDate.Date)) + '''' + ' and FillTime<''' + Trim(FormatDateTime('yyyy-MM-dd', frmFrameDateSel1.EndDate.Date + 1)) + '''';
Open;
end;
SCreateCDS(ADOQueryMain, Order_Main);
SInitCDSData(ADOQueryMain, Order_Main);
finally
ADOQueryMain.EnableControls;
end;
end;
procedure TfrmTradeDispatchedList.InitForm();
begin
ReadCxGrid(ʾ<D6B8><CABE><EFBFBD>б<EFBFBD>FF1', Tv1, '<27><><EFBFBD><EFBFBD>ָʾ<D6B8><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
ReadCxGrid(ʾ<D6B8><CABE><EFBFBD>б<EFBFBD>FFTv21', Tv2, '<27><><EFBFBD><EFBFBD>ָʾ<D6B8><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
frmFrameDateSel1.BegDate.Date := SGetServerDate(ADOQueryTemp) - 180;
frmFrameDateSel1.EndDate.Date := SGetServerDate(ADOQueryTemp);
SetStatus();
InitGrid();
end;
function TfrmTradeDispatchedList.DelData(): Boolean;
begin
try
Result := false;
ADOQueryCmd.Connection.BeginTrans;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('delete Trade_Market_Main where TMMId=''' + Trim(Order_Main.fieldbyname('TMMId').AsString) + '''');
sql.Add('delete Trade_Market_Sub where TMMId=''' + Trim(Order_Main.fieldbyname('TMMId').AsString) + '''');
sql.Add('delete Trade_Plan_Fty where TMMId=''' + Trim(Order_Main.fieldbyname('TMMId').AsString) + '''');
sql.Add('insert into SY_SysLog(operor,opertime,Model,acction,opevent,result) values( ');
sql.Add(' ' + quotedstr(trim(DName)));
sql.Add(',getdate() ');
sql.Add(',' + quotedstr(trim(self.Caption)));
sql.Add(',' + quotedstr(trim(ʾ<D6B8><CABE>ɾ<EFBFBD><C9BE>')));
sql.Add(',' + quotedstr(trim(ʾ<D6B8><CABE><EFBFBD>ţ<EFBFBD>' + trim(Order_Main.FieldByName('TMMNo').AsString))));
sql.Add(',' + quotedstr(trim('<27>ɹ<EFBFBD>')));
sql.Add(')');
ExecSQL;
end;
ADOQueryCmd.Connection.CommitTrans;
Result := True;
except
ADOQueryCmd.Connection.RollbackTrans;
Result := False;
Application.MessageBox('<27><><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE><EFBFBD><EFBFBD><ECB3A3>', '<27><>ʾ', 0);
end;
end;
procedure TfrmTradeDispatchedList.TBPrintClick(Sender: TObject);
begin
if Order_Main.IsEmpty then
Exit;
try
frmLabelPrint := TfrmLabelPrint.Create(Application);
with frmLabelPrint do
begin
FLMType := 'TradePlanPrint';
FFiltration1 := Trim(Order_Main.fieldbyname('TMMId').AsString);
if ShowModal = 1 then
begin
// Self.InitGrid();
end;
end;
finally
frmLabelPrint.Free;
end;
end;
procedure TfrmTradeDispatchedList.TBRafreshClick(Sender: TObject);
begin
InitGrid();
end;
procedure TfrmTradeDispatchedList.TMMNoMChange(Sender: TObject);
begin
if ADOQueryMain.Active = False then
Exit;
SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2));
SCreateCDS(ADOQueryMain, Order_Main);
SInitCDSData(ADOQueryMain, Order_Main);
end;
procedure TfrmTradeDispatchedList.FormShow(Sender: TObject);
begin
inherited;
canshu1 := self.fParameters1;
fFlileFlag := UserDataFlag + 'HX';
cxTabControl1.TabIndex := 0;
InitForm();
end;
procedure TfrmTradeDispatchedList.TBTPClick(Sender: TObject);
var
FQty, FQty1, FMxQty, FPQty, FMxQtyS, FPQtyS: string;
begin
end;
procedure TfrmTradeDispatchedList.CheckBox1Click(Sender: TObject);
begin
InitGrid();
end;
procedure TfrmTradeDispatchedList.TBCKClick(Sender: TObject);
begin
if Order_Main.IsEmpty then
Exit;
try
frmTradeMarketInPut := TfrmTradeMarketInPut.Create(Application);
with frmTradeMarketInPut do
begin
PState := 1;
FTMMId := Trim(Self.Order_Main.fieldbyname('TMMId').AsString);
ToolBar2.Visible := False;
TBSave.Visible := False;
ScrollBox1.Enabled := True;
N2.Visible := False;
if ShowModal = 1 then
begin
end;
end;
finally
frmTradeMarketInPut.Free;
end;
end;
procedure TfrmTradeDispatchedList.TMMNoKeyPress(Sender: TObject; var Key: Char);
begin
if Key = #13 then
begin
initgrid();
end;
end;
procedure TfrmTradeDispatchedList.Tv1FocusedRecordChanged(Sender: TcxCustomGridTableView; APrevFocusedRecord, AFocusedRecord: TcxCustomGridRecord; ANewItemRecordFocusingChanged: Boolean);
begin
if Order_Main.IsEmpty then
exit;
InitPH();
end;
procedure TfrmTradeDispatchedList.TBFJClick(Sender: TObject);
begin
if Order_Main.IsEmpty then
Exit;
try
frmAttachmentUpload := TfrmAttachmentUpload.Create(Application);
with frmAttachmentUpload do
begin
if Trim(canshu1) <> '<27><>ѯ' then
FEditAuthority := True;
fkeyNO := Trim(Self.Order_Main.fieldbyname('TMMId').AsString);
fType := ʾ<D6B8><CABE>';
if ShowModal = 1 then
begin
end;
end;
finally
frmAttachmentUpload.Free;
end;
end;
procedure TfrmTradeDispatchedList.ToolButton6Click(Sender: TObject);
begin
inherited;
if Order_Main.IsEmpty then
exit;
frmTradeMarketDisSel := TfrmTradeMarketDisSel.create(self);
with frmTradeMarketDisSel do
begin
fmainID := trim(self.Order_Main.FieldByName('mainID').AsString);
if showmodal = 1 then
begin
end;
free;
end;
TBRafresh.Click;
end;
procedure TfrmTradeDispatchedList.phokClick(Sender: TObject);
begin
inherited;
if cds_ph.IsEmpty then
exit;
try
with ADOQueryCmd do
begin
close;
sql.Clear;
sql.Add('select * from Trade_Market_Sub ');
sql.Add('where TMMID=' + quotedstr(trim(Order_Main.fieldbyname('TMMID').AsString)));
sql.Add('and TMSID=' + quotedstr(trim(Order_Main.fieldbyname('TMSID').AsString)));
open;
edit;
fieldbyname('substatus').Value := '2';
post;
end;
application.MessageBox('<27><><EFBFBD><EFBFBD>ȷ<EFBFBD>ϳɹ<CFB3><C9B9><EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ');
TBRafresh.Click;
except
application.MessageBox('<27><><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
end;
end;
procedure TfrmTradeDispatchedList.fhClick(Sender: TObject);
var
MStkIds, maxno: string;
i, fRoll: integer;
fNum: double;
begin
if cds_ph.IsEmpty then
exit;
if Order_Main.Locate('ssel', true, []) = false then
begin
Application.MessageBox(<><C3BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!', '<27><>ʾ', 0);
Exit;
end;
if Application.MessageBox(<><C8B7>Ҫ<EFBFBD><D2AA>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ', 32 + 4) <> IDYES then
Exit;
if GetLSNo(ADOQueryCmd, maxno, 'CK', 'Trade_Cloth_IO', 3, 1) = False then
begin
Application.MessageBox(<><C8A1><EFBFBD><EFBFBD><E2B5A5>ʧ<EFBFBD><CAA7>!', '<27><>ʾ', 0);
Exit;
end;
ADOQueryCmd.Connection.BeginTrans;
try
Order_Main.First;
Order_Main.DisableControls;
CDS_ph.DisableControls;
MSubIds := '';
MStkIds := '';
while not Order_Main.eof do
begin
if Order_Main.FieldByName('ssel').AsBoolean then
begin
InitPH();
MSubIds := MSubIds + (Trim(Order_Main.FieldByName('TMSID').AsString)) + ',';
with cds_ph do
begin
while not eof do
begin
MStkIds := MStkIds + (Trim(cds_ph.FieldByName('StkId').AsString)) + ',';
next;
end;
end;
end;
Order_Main.Next;
end;
MStkIds := copy(MStkIds, 1, Length(MStkIds) - 1);
MSubIds := copy(MSubIds, 1, Length(MSubIds) - 1);
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('insert into Trade_Need_Up(UType,UDataId,UOperation,UOperator,UModule,UDetails) ');
sql.Add('values(''<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'' ');
sql.Add(',' + quotedstr(MSubIds));
sql.Add(',''<27><><EFBFBD><EFBFBD>'' ');
sql.Add(',' + quotedstr(DName));
sql.Add(',' + quotedstr(trim(self.Caption)));
sql.Add(',' + quotedstr(MStkIds));
sql.Add(') ');
execsql;
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('insert into Finance_Need_Up(UType,UDataId,UOperation,UOperator,UModule,UDetails) ');
sql.Add('values('<>׳<EFBFBD>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD>'' ');
sql.Add(',' + quotedstr(maxno));
sql.Add(',''<27><><EFBFBD><EFBFBD>'' ');
sql.Add(',' + quotedstr(DName));
sql.Add(',' + quotedstr(trim(self.Caption)));
sql.Add(',' + quotedstr(MStkIds));
sql.Add(') ');
execsql;
end;
with ADOQueryCmd do
begin
Close;
Sql.Clear;
Sql.Add('exec P_Trade_Cloth_Out ');
Sql.Add(' @StkIds=' + quotedstr(trim(MStkIds)));
Sql.Add(',@IOTime=' + Quotedstr(FormatDateTime('yyyy-MM-dd', CRDate.Date)));
Sql.Add(',@IOType=' + Quotedstr('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'));
Sql.Add(',@IONO=' + Quotedstr(maxno));
Sql.Add(',@FillId=' + Quotedstr(DCode));
Sql.Add(',@Filler=' + Quotedstr(DName));
Open;
end;
if ADOQueryCmd.FieldByName('intReturn').AsInteger = -1 then
begin
raise Exception.Create(pchar(trim(ADOQueryCmd.FieldByName('ShowMsg').AsString)));
end;
with ADOQueryCmd do
begin
close;
sql.Clear;
sql.Add('update Trade_Market_Sub set substatus =3 ');
sql.add('where EXISTS(select X.RTValue from [dbo].[F_Tool_SplitString](''' + MSubIds + ''','','') X where X.RTValue=Trade_Market_Sub.TMSID ) ');
// ShowMessage(sql.text);
execsql;
end;
CDS_ph.EnableControls;
Order_Main.EnableControls;
ADOQueryCmd.Connection.CommitTrans;
if Application.MessageBox(<><C8B7>Ҫ<EFBFBD><D2AA>ӡ<EFBFBD><D3A1><EFBFBD><EFBFBD><E2B5A5><EFBFBD><EFBFBD>', '<27><>ʾ', 32 + 4) = IDYES then
begin
TBPrint1.Click;
end;
TBRafresh.Click;
CRdate.Date := DQdate;
except
CDS_ph.EnableControls;
Order_Main.EnableControls;
ADOQueryCmd.Connection.RollbackTrans;
application.MessageBox('<27><><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ');
end;
end;
procedure TfrmTradeDispatchedList.ToolButton9Click(Sender: TObject);
var
fPrintFile, FLabVolume: string;
begin
if CDS_PH.IsEmpty then
Exit;
if CDS_PH.Locate('SSel', True, []) = False then
begin
Application.MessageBox(<><C3BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!', '<27><>ʾ', 0);
Exit;
end;
CDS_PH.DisableControls;
with CDS_PH do
begin
First;
while not Eof do
begin
if CDS_PH.FieldByName('SSel').AsBoolean = True then
begin
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('Update Trade_Cloth_Inspect Set PrtCount=PrtCount+1,PrtDate=getdate(),Prter=''' + Trim(DName) + '''');
sql.Add(' where CIID=''' + Trim(CDS_PH.fieldbyname('CIID').AsString) + '''');
ExecSQL;
end;
with ADOQueryPrint do
begin
Close;
SQL.Clear;
sql.Add(' EXEC P_Trade_Insp_Prt_Lab ');
SQL.Add(' @CIID=''' + Trim(CDS_PH.fieldbyname('CIID').AsString) + '''');
Open;
end;
if ADOQueryPrint.IsEmpty then
begin
application.MessageBox('<27><>ǩ<EFBFBD><C7A9><EFBFBD><EFBFBD>δ<EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', MB_ICONERROR);
CDS_PH.EnableControls;
exit;
end;
if Trim(ADOQueryPrint.fieldbyname('Grade').AsString) = '<27><>Ʒ' then
FLabVolume := Trim(ADOQueryPrint.fieldbyname('LabVolume').AsString)
else
FLabVolume := '<27><>Ʒ<EFBFBD><C6B7>ǩ';
ExportFtErpFile(FLabVolume + '.rmf', ADOQueryTemp);
fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\' + FLabVolume + '.rmf';
if FileExists(fPrintFile) then
begin
RM1.LoadFromFile(fPrintFile);
if Trim(ADOQueryPrint.fieldbyname('LabVolume').AsString) <> '<27><>Ʒ<EFBFBD><C6B7>ǩ' then
Rm1.DefaultCopies := 1
else
Rm1.DefaultCopies := 1;
RM1.PrintReport;
end
else
begin
Application.MessageBox(PChar(<><C3BB><EFBFBD><EFBFBD>' + fPrintFile), '<27><>ʾ', 0);
end;
end;
Next;
end;
end;
CDS_PH.EnableControls;
initPH();
end;
procedure TfrmTradeDispatchedList.delClick(Sender: TObject);
begin
inherited;
if cds_ph.IsEmpty then
exit;
with ADOQueryCmd do
begin
close;
sql.Clear;
sql.Add('delete from Trade_Market_Distribution ');
sql.Add('where TMD=' + quotedstr(trim(cds_ph.fieldbyname('TMD').AsString)));
execsql;
end;
cds_ph.Delete;
end;
procedure TfrmTradeDispatchedList.TBPrint1Click(Sender: TObject);
begin
inherited;
if Order_Main.IsEmpty then
Exit;
MSubIds := '';
Order_Main.DisableControls;
with Order_Main do
begin
First;
while Order_Main.Locate('SSel', True, []) do
begin
MSubIds := MSubIds + (Trim(Order_Main.fieldbyname('TMSID').AsString)) + ',';
Edit;
FieldByName('SSel').Value := False;
Post;
end;
end;
Order_Main.EnableControls;
MSubIds := copy(MSubIds, 1, Length(MSubIds) - 1);
try
frmLabelPrint := TfrmLabelPrint.Create(Application);
with frmLabelPrint do
begin
FLMType := 'DistributionPrint';
FFiltration1 := Trim(MSubIds);
if ShowModal = 1 then
begin
// Self.InitGrid();
end;
end;
finally
frmLabelPrint.Free;
end;
end;
procedure TfrmTradeDispatchedList.cxCheckBox1Click(Sender: TObject);
begin
inherited;
if Order_Main.IsEmpty then
exit;
with Order_Main do
begin
DisableControls;
first;
while not eof do
begin
edit;
fieldbyname('ssel').Value := cxcheckbox1.Checked;
post;
next;
end;
First;
EnableControls;
end;
end;
procedure TfrmTradeDispatchedList.cxCheckBox2Click(Sender: TObject);
begin
if CDS_PH.IsEmpty then
exit;
with CDS_PH do
begin
DisableControls;
first;
while not eof do
begin
edit;
fieldbyname('ssel').Value := cxcheckbox2.Checked;
post;
next;
end;
First;
EnableControls;
end;
end;
procedure TfrmTradeDispatchedList.cxTabControl1Change(Sender: TObject);
begin
SetStatus();
InitGrid();
end;
procedure TfrmTradeDispatchedList.N1Click(Sender: TObject);
begin
Clipboard.SetTextBuf(PChar(Trim(Order_Main.fieldbyname(TV1.Controller.FocusedColumn.DataBinding.FilterFieldName).AsString)));
end;
procedure TfrmTradeDispatchedList.N2Click(Sender: TObject);
begin
Clipboard.SetTextBuf(PChar(Trim(ORDER_SUB.fieldbyname(TV2.Controller.FocusedColumn.DataBinding.FilterFieldName).AsString)));
end;
procedure TfrmTradeDispatchedList.N3Click(Sender: TObject);
begin
SelOKNoFiler(Tv1, True); //ȫѡ
end;
procedure TfrmTradeDispatchedList.N4Click(Sender: TObject);
begin
SelOKNoFiler(Tv1, False); //ȫ<><C8AB>
end;
procedure TfrmTradeDispatchedList.ComboBox1Change(Sender: TObject);
begin
InitGrid();
end;
procedure TfrmTradeDispatchedList.CustomerNoNameKeyPress(Sender: TObject; var Key: Char);
begin
if Key = #13 then
begin
InitGrid();
end;
end;
procedure TfrmTradeDispatchedList.ToolButton5Click(Sender: TObject);
begin
if cds_ph.IsEmpty then
exit;
if cxTabControl1.TabIndex = 1 then
begin
if Application.MessageBox(<><C8B7>Ҫִ<D2AA>в<EFBFBD><D0B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ', 32 + 4) <> IDYES then
Exit;
try
ADOQueryCmd.Connection.BeginTrans;
with ADOQueryCmd do
begin
close;
sql.Clear;
sql.Add('select * from Trade_Market_Sub ');
sql.Add('where TMMID=' + quotedstr(trim(Order_Main.fieldbyname('TMMID').AsString)));
sql.Add('and TMSID=' + quotedstr(trim(Order_Main.fieldbyname('TMSID').AsString)));
open;
edit;
fieldbyname('substatus').Value := '0';
post;
end;
with ADOQueryCmd do
begin
close;
sql.Clear;
sql.Add('update Trade_Cloth_Stock SET disstatus=null ');
sql.Add('from Trade_Cloth_Stock A ');
sql.Add('inner join Trade_Market_Distribution B on B.stkid=A.stkid ');
sql.Add('where TMMID=' + quotedstr(trim(Order_Main.fieldbyname('TMMID').AsString)));
sql.Add('and TMSID=' + quotedstr(trim(Order_Main.fieldbyname('TMSID').AsString)));
execsql;
end;
with ADOQueryCmd do
begin
close;
sql.Clear;
sql.Add('delete from Trade_Market_Distribution ');
sql.Add('where TMSID=' + quotedstr(trim(Order_Main.fieldbyname('TMSID').AsString)));
execsql;
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('insert into SY_SysLog(operor,opertime,Model,acction,opevent,result) values( ');
sql.Add(' ' + quotedstr(trim(DName)));
sql.Add(',getdate() ');
sql.Add(',' + quotedstr(trim(self.Caption)));
sql.Add(',' + quotedstr(trim('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>')));
sql.Add(',' + quotedstr(trim('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:' + trim(Order_Main.FieldByName('TMMNO').AsString) + ' <20><><EFBFBD><EFBFBD>:' + trim(Order_Main.FieldByName('C_Code').AsString) + ' <20><>ɫ:' + trim(Order_Main.FieldByName('C_Color').AsString) + ' <20><><EFBFBD><EFBFBD>:' + trim(Order_Main.FieldByName('C_Pattern').AsString))));
sql.Add(',' + quotedstr(trim('<27>ɹ<EFBFBD>')));
sql.Add(')');
ExecSQL;
end;
ADOQueryCmd.Connection.CommitTrans;
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ');
TBRafresh.Click;
except
ADOQueryCmd.Connection.RollbackTrans;
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
end;
end;
end;
procedure TfrmTradeDispatchedList.TdbchexiaoClick(Sender: TObject);
begin
inherited;
if CDS_PH.IsEmpty then
exit;
CDS_PH.first;
try
if Application.MessageBox(<><C8B7>Ҫִ<D2AA>в<EFBFBD><D0B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ', 32 + 4) <> IDYES then
Exit;
ADOQueryCmd.Connection.BeginTrans;
while not CDS_PH.eof do
begin
if CDS_PH.FieldByName('ssel').AsBoolean then
begin
with ADOQueryCmd do
begin
close;
sql.Clear;
sql.Add('update Trade_Cloth_Stock SET disstatus=null ');
sql.Add('where stkid=' + quotedstr(trim(CDS_PH.fieldbyname('stkid').AsString)));
execsql;
end;
with ADOQueryCmd do
begin
close;
sql.Clear;
sql.Add('delete from Trade_Market_Distribution ');
sql.Add('where TMDID=' + quotedstr(trim(CDS_PH.fieldbyname('TMDID').AsString)));
execsql;
end;
end;
CDS_PH.next;
end;
with ADOQueryTemp do
begin
close;
sql.Clear;
sql.Add('select * from Trade_Market_Distribution ');
sql.Add('where TMMID=' + quotedstr(trim(Order_Main.fieldbyname('TMMID').AsString)));
sql.Add('and TMSID=' + quotedstr(trim(Order_Main.fieldbyname('TMSID').AsString)));
open;
end;
if ADOQueryTemp.IsEmpty then
begin
with ADOQueryCmd do
begin
close;
sql.Clear;
sql.Add('select * from Trade_Market_Sub ');
sql.Add('where TMMID=' + quotedstr(trim(Order_Main.fieldbyname('TMMID').AsString)));
sql.Add('and TMSID=' + quotedstr(trim(Order_Main.fieldbyname('TMSID').AsString)));
open;
edit;
fieldbyname('substatus').Value := '0';
post;
end;
end;
CDS_PH.first;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('insert into SY_SysLog(operor,opertime,Model,acction,opevent,result) values( ');
sql.Add(' ' + quotedstr(trim(DName)));
sql.Add(',getdate() ');
sql.Add(',' + quotedstr(trim(self.Caption)));
sql.Add(',' + quotedstr(trim('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>')));
sql.Add(',' + quotedstr(trim('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:' + trim(Order_Main.FieldByName('TMMNO').AsString) + ' <20><><EFBFBD><EFBFBD>:' + trim(Order_Main.FieldByName('C_Code').AsString) + ' <20><>ɫ:' + trim(Order_Main.FieldByName('C_Color').AsString) + ' <20><><EFBFBD><EFBFBD>:' + trim(Order_Main.FieldByName('C_Pattern').AsString))));
sql.Add(',' + quotedstr(trim('<27>ɹ<EFBFBD>')));
sql.Add(')');
ExecSQL;
end;
ADOQueryCmd.Connection.CommitTrans;
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>!', '<27><>ʾ', 0);
initph();
except
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>쳣!', '<27><>ʾ', 0);
end;
end;
procedure TfrmTradeDispatchedList.ToolButton4Click(Sender: TObject);
var
fsubid: string;
begin
inherited;
if Order_Main.IsEmpty then
exit;
fsubid := order_main.FieldByName('TMSID').AsString;
frmTradeMarketDisSel := TfrmTradeMarketDisSel.create(self);
with frmTradeMarketDisSel do
begin
fmainID := trim(self.Order_Main.FieldByName('TMMID').AsString);
if showmodal = 1 then
begin
end;
free;
end;
TBRafresh.Click;
Order_Main.Locate('Tmsid', fsubid, []);
end;
procedure TfrmTradeDispatchedList.ToolButton1Click(Sender: TObject);
begin
inherited;
try
frmTradeMarketDisScan := TfrmTradeMarketDisScan.Create(Application);
with frmTradeMarketDisScan do
begin
show;
end;
finally
end;
end;
procedure TfrmTradeDispatchedList.ToolButton2Click(Sender: TObject);
begin
WriteCxGrid(ʾ<D6B8><CABE><EFBFBD>б<EFBFBD>FF1', Tv1, '<27><><EFBFBD><EFBFBD>ָʾ<D6B8><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
WriteCxGrid(ʾ<D6B8><CABE><EFBFBD>б<EFBFBD>FFTv21', Tv2, '<27><><EFBFBD><EFBFBD>ָʾ<D6B8><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
end;
procedure TfrmTradeDispatchedList.ToolButton3Click(Sender: TObject);
var
MStkIds: string;
begin
if Order_Main.Locate('ssel', true, []) = false then
begin
Application.MessageBox(<><C3BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!', '<27><>ʾ', 0);
Exit;
end;
try
ADOQueryCmd.Connection.BeginTrans;
MSubIds := '';
MStkIds := '';
Order_Main.First;
while not Order_Main.eof do
begin
if Order_Main.FieldByName('ssel').AsBoolean then
begin
InitPH();
MSubIds := MSubIds + (Trim(Order_Main.FieldByName('TMSID').AsString)) + ',';
with cds_ph do
begin
while not eof do
begin
MStkIds := MStkIds + (Trim(cds_ph.FieldByName('StkId').AsString)) + ',';
next;
end;
end;
end;
Order_Main.Next;
end;
MStkIds := copy(MStkIds, 1, Length(MStkIds) - 1);
MSubIds := copy(MSubIds, 1, Length(MSubIds) - 1);
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('insert into Trade_Need_Up(UType,UDataId,UOperation,UOperator,UModule,UDetails) ');
sql.Add('values('<>׳<EFBFBD>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD>'' ');
sql.Add(',' + quotedstr(MSubIDS));
sql.Add(',''<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'' ');
sql.Add(',' + quotedstr(DName));
sql.Add(',' + quotedstr(trim(self.Caption)));
sql.Add(',' + quotedstr(MStkIds));
sql.Add(') ');
execsql;
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('insert into Finance_Need_Up(UType,UDataId,UOperation,UOperator,UModule,UDetails) ');
sql.Add('values('<>׳<EFBFBD>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD>'' ');
sql.Add(',' + quotedstr(''));
sql.Add(',''<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'' ');
sql.Add(',' + quotedstr(DName));
sql.Add(',' + quotedstr(trim(self.Caption)));
sql.Add(',' + quotedstr(MStkIds));
sql.Add(') ');
execsql;
end;
with ADOQueryCmd do
begin
Close;
Sql.Clear;
Sql.Add('exec P_Trade_Cloth_ReOut ');
Sql.Add(' @StkIds=' + quotedstr(trim(MStkIds)));
Sql.Add(',@IOIDS=' + quotedstr(trim('')));
Sql.Add(',@FillId=' + Quotedstr(DCode));
Sql.Add(',@Filler=' + Quotedstr(DName));
// ShowMessage(sql.Text);
Open;
end;
if ADOQueryCmd.FieldByName('intReturn').AsInteger = -1 then
begin
raise Exception.Create(pchar(trim(ADOQueryCmd.FieldByName('ShowMsg').AsString)));
end;
with ADOQueryCmd do
begin
close;
sql.Clear;
sql.Add('update Trade_Market_Sub set substatus =2 ');
sql.add('where EXISTS(select X.RTValue from [dbo].[F_Tool_SplitString](''' + MSubIds + ''','','') X where X.RTValue=Trade_Market_Sub.TMSID ) ');
// ShowMessage(sql.text);
execsql;
end;
// PlayWav('<27><>ȷ');
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>!', '<27><>ʾ', 0);
ADOQueryCmd.Connection.CommitTrans;
TBRafresh.Click;
except
Application.MessageBox('<27><><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>!', '<27><>ʾ', 0);
order_main.EnableControls;
ADOQueryCmd.Connection.RollbackTrans;
end;
end;
procedure TfrmTradeDispatchedList.phwcClick(Sender: TObject);
var
phRollNum, phQty: double;
begin
if cds_ph.IsEmpty then
exit;
with CDS_PH do
begin
DisableControls;
first;
while not eof do
begin
if (trim(fieldbyname('C_Code').AsString) <> trim(Order_Main.FieldByName('C_Code').AsString)) or (trim(fieldbyname('C_Color').AsString) <> trim(Order_Main.FieldByName('C_Color').AsString)) or (trim(fieldbyname('C_Pattern').AsString) <> trim(Order_Main.FieldByName('C_Pattern').AsString)) then
begin
application.MessageBox('<27><>Ʒ<EFBFBD><C6B7><EFBFBD>ţ<EFBFBD><C5A3><EFBFBD><EFBFBD>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB>һ<EFBFBD>£<EFBFBD><C2A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
EnableControls;
exit;
end;
next;
end;
first;
EnableControls;
end;
phRollNum := 0;
phQty := 0;
with CDS_PH do
begin
DisableControls;
first;
while not eof do
begin
phRollNum := phRollNum + 1;
phQty := phQty + CDS_PH.fieldbyname('stkmeter').AsFloat;
next;
end;
first;
EnableControls;
end;
if (phRollNum <> Order_Main.FieldByName('TMSPiece').AsFloat) or (phQty <> Order_Main.FieldByName('TMSQty').AsFloat) then
begin
if Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>δ<EFBFBD><EFBFBD><EFB5BD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', 32 + 4) <> IDYES then
Exit;
end;
if SaveData() then
begin
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>!', '<27><>ʾ<EFBFBD><CABE>Ϣ');
TBRafresh.Click;
end
else
begin
application.MessageBox('<27><><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>!', '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
end;
end;
function TfrmTradeDispatchedList.SaveData(): Boolean;
var
phID: string;
begin
Result := false;
ADOQueryCmd.Connection.BeginTrans;
try
with ADOQueryCmd do
begin
close;
sql.Clear;
sql.Add('delete from Trade_Market_Distribution ');
sql.Add('where TMMID=' + quotedstr(trim(Order_Main.fieldbyname('TMMID').AsString)));
sql.Add('and TMSID=' + quotedstr(trim(Order_Main.fieldbyname('TMSID').AsString)));
execsql;
end;
with CDS_PH do
begin
DisableControls;
first;
while not eof do
begin
if fieldbyname('stkmeter').AsFloat = 0 then
continue;
if GetLSNo(ADOQueryTemp, phID, 'PH', 'Trade_Market_Distribution', 4, 1) = False then
begin
ADOQueryCmd.Connection.RollbackTrans;
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 TMMID=' + quotedstr(trim(Order_Main.fieldbyname('TMMID').AsString)));
sql.Add('and TMSID=' + quotedstr(trim(Order_Main.fieldbyname('TMSID').AsString)));
open;
end;
ADOQueryCmd.Append;
ADOQueryCmd.FieldByName('TMDID').Value := trim(phID);
ADOQueryCmd.FieldByName('TMMID').Value := trim(Order_main.fieldbyname('TMMID').AsString);
ADOQueryCmd.FieldByName('TMSID').Value := trim(Order_main.fieldbyname('TMSID').AsString);
ADOQueryCmd.FieldByName('STKID').Value := trim(CDS_PH.fieldbyname('STKID').AsString);
ADOQueryCmd.FieldByName('Filler').Value := trim(DName);
ADOQueryCmd.Post;
with ADOQueryCmd do
begin
close;
sql.Clear;
sql.Add('select * from Trade_Cloth_Stock ');
sql.Add('where StkID=' + quotedstr(trim(CDS_PH.fieldbyname('StkID').AsString)));
open;
edit;
fieldbyname('Disstatus').Value := '1';
post;
end;
next;
end;
first;
EnableControls;
with ADOQueryCmd do
begin
close;
sql.Clear;
sql.Add('select * from Trade_Market_Sub ');
sql.Add('where TMMID=' + quotedstr(trim(Order_Main.fieldbyname('TMMID').AsString)));
sql.Add('and TMSID=' + quotedstr(trim(Order_Main.fieldbyname('TMSID').AsString)));
open;
edit;
fieldbyname('substatus').Value := '2';
post;
end;
end;
ADOQueryCmd.Connection.CommitTrans;
Result := true;
except
ADOQueryCmd.Connection.RollbackTrans;
end;
end;
end.