D10xhGemei/T03贸易布匹检验/U_MachRollMain.pas

1500 lines
42 KiB
ObjectPascal
Raw Normal View History

2025-02-20 14:17:49 +08:00
unit U_MachRollMain;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
System.Classes, Vcl.Graphics, mmsystem, Vcl.Controls, Vcl.Forms, Vcl.Dialogs,
cxGraphics, cxControls, cxLookAndFeels, cxLookAndFeelPainters, cxClasses,
dxLayoutContainer, dxLayoutControl, dxLayoutcxEditAdapters, cxContainer,
cxEdit, Vcl.StdCtrls, cxTextEdit, Vcl.ExtCtrls, dxLayoutControlAdapters,
U_BaseList, Data.DB, Data.Win.ADODB, Vcl.Buttons, Vcl.ComCtrls, Vcl.ToolWin,
cxImage, cxDBEdit, cxStyles, cxCustomData, cxFilter, cxData, cxDataStorage,
cxNavigator, dxDateRanges, dxScrollbarAnnotations, cxDBData, dxBarBuiltInMenu,
cxPC, cxGridLevel, cxGridCustomTableView, cxGridTableView, cxGridDBTableView,
cxGridCustomView, cxGrid, cxMemo, cxRichEdit, U_frameBads, Datasnap.DBClient,
RM_Common, RM_Class, RM_GridReport, cxCheckBox, cxMaskEdit, cxDropDownEdit,
Vcl.Menus, cxButtonEdit, RM_Dataset, cxGeometry, dxFramedControl, dxPanel,
U_KeyBoard, cxGroupBox, cxGridCustomPopupMenu, cxGridPopupMenu, MovePanel,
2025-02-21 15:28:49 +08:00
RM_RichEdit, cxProgressBar, cxCurrencyEdit, dxSkinsCore, frxBarcode, frxRich,
frxOLE, frxTableObject, frxExportXLSX, frxClass, frxExportBaseDialog,
2025-09-29 09:23:46 +08:00
frxExportPPTX, frxDBSet, dxSkinWXI, dxSkinsDefaultPainters, System.StrUtils;
2025-02-20 14:17:49 +08:00
type
TfrmMachRollMain = class(TfrmBaseList)
Panel_right: TPanel;
cds_params: TClientDataSet;
cds_paramsdabao: TStringField;
cds_paramspackRolls: TIntegerField;
cds_paramsrollNoMake: TStringField;
cds_paramsMinWeight: TIntegerField;
cds_paramsMaxWeight: TIntegerField;
cds_paramslblLenUnit: TStringField;
cds_paramsMinLen: TIntegerField;
cds_paramsmaxLen: TIntegerField;
cds_paramsweightRule: TIntegerField;
cds_paramschen: TStringField;
cds_paramsmabiao: TStringField;
cds_paramsmbunit: TStringField;
cds_paramsmplace: TIntegerField;
cds_paramsyplace: TIntegerField;
cds_paramskgplace: TIntegerField;
cds_paramslabNumber: TIntegerField;
CDS_2: TClientDataSet;
DS_2: TDataSource;
cds_1: TClientDataSet;
cds_3: TClientDataSet;
ds_3: TDataSource;
ds_1: TDataSource;
ADOQueryMain: TADOQuery;
cds_paramsoutPage: TStringField;
ADOQueryPrint: TADOQuery;
cds_paramsEndPieceNo: TIntegerField;
cds_paramsBeginPieceNo: TIntegerField;
cds_paramsFixedLength: TIntegerField;
cds_paramspacknoMake: TStringField;
cds_paramspieceOrder: TBooleanField;
cds_paramsLabVolume: TStringField;
cds_paramsLabPackage: TStringField;
cxGroupBox_keys: TcxGroupBox;
FrameKeyBoard1: TFrameKeyBoard;
cds_paramsAddwetPresent: TFloatField;
cds_paramsAddLenPresent: TFloatField;
GPM_3: TcxGridPopupMenu;
MovePanel1: TMovePanel;
ADOQueryImage: TADOQuery;
DS_IMAGE: TDataSource;
cds_paramspackPrintPreview: TBooleanField;
cds_paramspacklabNumber: TIntegerField;
cds_paramspackPostAction: TStringField;
ADO_CJ: TADOQuery;
2025-02-21 15:28:49 +08:00
fRMDB_1: TfrxDBDataset;
frxReport1: TfrxReport;
frxPPTXExport1: TfrxPPTXExport;
frxXLSXExport1: TfrxXLSXExport;
frxReportTableObject1: TfrxReportTableObject;
frxOLEObject1: TfrxOLEObject;
frxRichObject1: TfrxRichObject;
frxBarCodeObject1: TfrxBarCodeObject;
2025-03-20 16:38:30 +08:00
cxGrid2: TcxGrid;
TV2: TcxGridDBTableView;
cxGridDBColumn1: TcxGridDBColumn;
TV2Column1: TcxGridDBColumn;
TV2Column2: TcxGridDBColumn;
v1PRTColor: TcxGridDBColumn;
v1PRTOrderQty: TcxGridDBColumn;
v1OrderUnit: TcxGridDBColumn;
cxGridDBColumn7: TcxGridDBColumn;
2025-03-13 13:37:36 +08:00
cxGridLevel1: TcxGridLevel;
2025-03-20 16:38:30 +08:00
TV2Column3: TcxGridDBColumn;
TV2Column4: TcxGridDBColumn;
ADO_2: TADOQuery;
TV2Column5: TcxGridDBColumn;
TV2Column7: TcxGridDBColumn;
2025-06-27 17:30:04 +08:00
Panel1: TPanel;
edtScan: TcxTextEdit;
Label1: TLabel;
OrderNo: TcxTextEdit;
ColorNo: TcxTextEdit;
FtyPCId: TcxTextEdit;
Qty: TcxTextEdit;
BCIOID: TcxTextEdit;
Color: TcxTextEdit;
CodeName: TcxTextEdit;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
InputLen: TcxTextEdit;
lblLenUnit: TLabel;
Label10: TLabel;
InputWeight: TcxTextEdit;
Tare: TcxTextEdit;
Label11: TLabel;
BTPrint: TButton;
Coefficient: TcxTextEdit;
lblRuleConversion: TcxComboBox;
Label12: TLabel;
AOrdDefNote1: TcxRichEdit;
packnote: TcxMemo;
unitPieces: TcxTextEdit;
presentWeight: TcxTextEdit;
presentLen: TcxTextEdit;
bt_printmd: TButton;
addWet: TcxTextEdit;
addLen: TcxTextEdit;
C_GramWeight: TcxTextEdit;
C_Width: TcxTextEdit;
customStrField2: TcxTextEdit;
customStrField1: TcxTextEdit;
C_StyleNo: TcxTextEdit;
RuleYardstick: TcxTextEdit;
C_Pattern: TcxTextEdit;
OutPutWeight: TcxTextEdit;
cxDBImage1: TcxDBImage;
Button1: TButton;
TV2Column8: TcxGridDBColumn;
2025-07-15 10:37:37 +08:00
Panel2: TPanel;
cxGrid3: TcxGrid;
Tv3: TcxGridDBTableView;
v3PieceNo: TcxGridDBColumn;
Tv3Yardage: TcxGridDBColumn;
Tv3Meter: TcxGridDBColumn;
v3NetWeight: TcxGridDBColumn;
v3GrossWeight: TcxGridDBColumn;
Tv3Grade: TcxGridDBColumn;
tv3CIID: TcxGridDBColumn;
cxGridLevel2: TcxGridLevel;
ToolBar2: TToolBar;
ToolButton3: TToolButton;
Trolldel: TToolButton;
ToolButton1: TToolButton;
Tlog: TToolButton;
ToolButton8: TToolButton;
2025-09-08 10:53:41 +08:00
ToolButton2: TButton;
2025-09-29 09:23:46 +08:00
Tv3Column1: TcxGridDBColumn;
TV2Column6: TcxGridDBColumn;
TV2Column9: TcxGridDBColumn;
TV2Column10: TcxGridDBColumn;
2025-02-20 14:17:49 +08:00
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormDestroy(Sender: TObject);
procedure edtScanDblClick(Sender: TObject);
procedure edtScanKeyPress(Sender: TObject; var Key: Char);
procedure ToolButton8Click(Sender: TObject);
procedure edtScanEnter(Sender: TObject);
procedure BTPrintClick(Sender: TObject);
procedure TrolldelClick(Sender: TObject);
procedure ToolButton3Click(Sender: TObject);
procedure Tv3CustomDrawCell(Sender: TcxCustomGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
procedure InputLenKeyPress(Sender: TObject; var Key: Char);
procedure InputLenPropertiesChange(Sender: TObject);
procedure FrameKeyBoard1SpeedButton_ycClick(Sender: TObject);
procedure dxLayoutItem1CaptionClick(Sender: TObject);
procedure lblRuleConversionPropertiesChange(Sender: TObject);
procedure bt_printmdClick(Sender: TObject);
procedure dxLayoutControl_packDblClick(Sender: TObject);
procedure ToolButton1Click(Sender: TObject);
2025-02-21 15:28:49 +08:00
procedure FrameKeyBoard1SpeedButton1Click(Sender: TObject);
2025-02-25 16:04:43 +08:00
procedure ToolButton2Click(Sender: TObject);
2025-06-27 17:30:04 +08:00
procedure Button1Click(Sender: TObject);
2025-02-20 14:17:49 +08:00
private
2025-02-20 17:32:25 +08:00
FCIID, FCIFName, FWorkshop: string;
2025-09-29 09:23:46 +08:00
FBCIOID, FC_Code, FC_ColorNo, FQtyUnit, FLenUnit, FTMSId, FTMMId: string;
2025-02-20 14:17:49 +08:00
Faddwet, faddlen: double;
FFtyPCId, FGangNo, FRulePieceNo, FCDUnit: string;
FPieceNo: Integer;
fIsPack: string;
fIsCommopen: Boolean;
FPacketCIID: string;
fLabPackage, fLabVolume: string;
FPacketCount: Integer;
fAddwetVirtual: double;
fAddLenVirtual: double;
fTareType: string;
funitPiecesStr: string; //ƴƥ
procedure setFocusCtrol(controlName: string);
procedure QuantityConversion();
procedure ClearGlobal();
procedure InitPlan(MSubID: string);
procedure SetUnit(MUnit: string);
procedure SetDdetails();
procedure SetINIFile();
procedure GetINIFile();
procedure InitJYGrid();
2025-03-20 16:38:30 +08:00
procedure InitGrid2();
2025-02-20 14:17:49 +08:00
procedure OpenCom(DllName: string);
procedure CloseCom(DllName: string);
2026-02-05 17:10:07 +08:00
procedure clearCom(DllName: string);
2025-02-20 14:17:49 +08:00
function SaveData(): Boolean;
procedure PrtData(MCIID: string; againPring: Boolean = false);
procedure BadSpeedButtonClick(Sender: TObject);
procedure setFormCtrol();
procedure On1201(var Message: Tmessage); message 1201; // <20><><EFBFBD>ӳ<EFBFBD>
procedure On1301(var Message: Tmessage); message 1301; // <20><><EFBFBD><EFBFBD>
2025-02-20 17:32:25 +08:00
function CheckData(CKType: string): Boolean;
2025-02-20 14:17:49 +08:00
function deletePack(packId: string): boolean;
type
public
fmanage: string;
2025-09-29 09:23:46 +08:00
fFlileFlag, FCKLX: string; //FCKLX <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>վ<EFBFBD><D5BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2025-02-20 14:17:49 +08:00
end;
var
frmMachRollMain: TfrmMachRollMain;
newh, newh1: hwnd;
implementation
uses
U_DataLink, U_ControlData, U_ParamSet, U_RTFun, U_globalVar,
U_FormLayOutDesign, U_ZDYHelp, U_iniParam, U_ProductListHelp, U_SysLogList,
2025-06-27 17:30:04 +08:00
U_ProgressUpdate, U_LabelPrint, U_TradeClothTotalOutSel;
2025-02-20 14:17:49 +08:00
{$R *.dfm}
2026-02-05 17:10:07 +08:00
procedure TfrmMachRollMain.ClearCom(DllName: string);
type
TMyFunc = function(sCommName: PAnsiChar): hwnd; stdcall;
var
Tf1: TMyFunc;
Tp1: TFarProc;
Th1: Thandle;
begin
Th1 := LoadLibrary(pchar(trim(DllName)));
if Th1 > 0 then
begin
try
Tp1 := GetProcAddress(Th1, 'CommClear');
if Tp1 <> nil then
begin
Tf1 := TMyFunc(Tp1);
newh1 := Tf1('Comm1');
end
else
begin
end;
finally
// FreeLibrary(Th1);
end;
end
else
begin
Application.MessageBox(pchar('<27>Ҳ<EFBFBD><D2B2><EFBFBD> ' + trim(DllName) + ' <20>ļ<EFBFBD><C4BC><EFBFBD>'), '<27><>ʾ');
end;
end;
2025-03-20 16:38:30 +08:00
procedure TfrmMachRollMain.InitGrid2();
var
SqlStr: string;
begin
2025-09-29 09:23:46 +08:00
if FCKLX = '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' then
begin
SqlStr := ' exec P_Trade_Market_WaitOut_Market ';
SqlStr := SqlStr + ' @TMSId =' + quotedstr(trim(FTMSId));
end
else
begin
SqlStr := ' exec P_Trade_Market_WaitOut ';
SqlStr := SqlStr + ' @C_Code =' + quotedstr(trim(FC_Code));
SqlStr := SqlStr + ' ,@C_ColorNo =' + quotedstr(trim(FC_ColorNo));
end;
2025-03-20 16:38:30 +08:00
2025-09-29 09:23:46 +08:00
// showmessage(SqlStr);
2025-03-20 16:38:30 +08:00
InitCDSData(ADO_2, CDS_2, Tv2, SqlStr, '', '');
end;
2025-02-20 17:32:25 +08:00
function TfrmMachRollMain.CheckData(CKType: string): Boolean;
var
mvalue: double;
mCurPieceNo: Integer;
begin
Result := false;
try
if trim(FBCIOID) = '' then
raise Exception.create('<27><>ɨ<EFBFBD><C9A8><EFBFBD><EFBFBD><EFBFBD>̿<EFBFBD><CCBF><EFBFBD>');
if trim(CKType) = '<27>ύ' then
begin
2025-06-27 17:30:04 +08:00
if trim(lblLenUnit.Caption) = '' then
2025-02-20 17:32:25 +08:00
raise Exception.create('<27><><EFBFBD>ȵ<EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>!');
if trim(InputWeight.Text) <> '' then
begin
if TryStrToFloat(InputWeight.Text, mvalue) = false then
raise Exception.create('<27><><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!');
if strtofloatdef(trim(InputWeight.Text), 0) < cds_params.fieldbyName('minWeight').AsInteger then
raise Exception.create('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><D0A1>' + cds_params.fieldbyName('minWeight').AsString + '!');
if strtofloatdef(trim(InputWeight.Text), 0) > cds_params.fieldbyName('maxWeight').AsInteger then
raise Exception.create('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܴ<EFBFBD><DCB4><EFBFBD>' + cds_params.fieldbyName('maxWeight').AsString + '!');
end;
if trim(InputLen.Text) <> '' then
begin
if TryStrToFloat(InputLen.Text, mvalue) = false then
raise Exception.create('<27><><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!');
if strtofloatdef(trim(InputLen.Text), 0) < cds_params.fieldbyName('minLen').AsInteger then
raise Exception.create('<27><><EFBFBD>Ȳ<EFBFBD><C8B2><EFBFBD>С<EFBFBD><D0A1>' + cds_params.fieldbyName('minLen').AsString + '<27><>!');
if strtofloatdef(trim(InputLen.Text), 0) > cds_params.fieldbyName('maxLen').AsInteger then
raise Exception.create('<27><><EFBFBD>Ȳ<EFBFBD><C8B2>ܴ<EFBFBD><DCB4><EFBFBD>' + cds_params.fieldbyName('maxLen').AsString + '<27><>!');
end;
if FQtyUnit = 'Kg' then
begin
if (strtofloatdef(trim(InputWeight.Text), 0) = 0) then
raise Exception.create('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ0!!');
end
else
begin
if (strtofloatdef(trim(InputLen.Text), 0) = 0) then
raise Exception.create('<27><><EFBFBD>Ȳ<EFBFBD><C8B2><EFBFBD>Ϊ0!!');
end;
end;
Result := true;
except
Application.MessageBox(pchar(Exception(ExceptObject).Message), '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
end;
end;
2025-02-20 14:17:49 +08:00
procedure TfrmMachRollMain.BTPrintClick(Sender: TObject);
var
fPrintFile, MPacketId: string;
mvalue: double;
i: Integer;
begin
try
BTPrint.Enabled := false;
edtScan.SetFocus;
2025-02-20 17:32:25 +08:00
2025-02-20 14:17:49 +08:00
if CheckData('<27>ύ') = false then
exit;
if SaveData() then
begin
InputLen.Text := '';
presentLen.Text := '';
funitPiecesStr := '';
presentWeight.Text := '';
2025-02-20 17:32:25 +08:00
if fileexists(ExtractFilePath(Application.ExeName) + '<27><>ȷ.wav') then
playSound(pwidechar('<27><>ȷ.wav'), 0, SND_FILENAME or SND_ASYNC);
2025-02-20 14:17:49 +08:00
InputWeight.Text := '';
if trim(cds_params.fieldbyName('outPage').AsString) = '<27><>' then
begin
PrtData(FCIID);
end;
end;
InputLen.SetFocus;
setFocusCtrol(InputLen.Name);
InitJYGrid();
2025-03-20 16:38:30 +08:00
InitGrid2();
2025-02-20 14:17:49 +08:00
FCIID := '';
finally
BTPrint.Enabled := true;
end;
2026-02-05 17:10:07 +08:00
if fIsCommopen then
begin
ClearCom(MBDYDllName);
end;
2025-02-20 14:17:49 +08:00
end;
procedure TfrmMachRollMain.bt_printmdClick(Sender: TObject);
var
WSql: string;
begin
if cds_3.IsEmpty then
Exit;
WSql := '';
cds_3.DisableControls;
with cds_3 do
begin
First;
while not Eof do
begin
if WSql <> '' then
begin
WSql := WSql + ',' + Trim(cds_3.fieldbyname('CIID').AsString);
end
else
begin
WSql := Trim(cds_3.fieldbyname('CIID').AsString);
end;
Next;
end;
end;
cds_3.EnableControls;
// try
// frmMdPrint := TfrmMdPrint.Create(Application);
// with frmMdPrint do
// begin
// FLMType := '<27><><EFBFBD><EFBFBD><EFBFBD>뵥';
// FFiltration1 := WSql;
// FFiltration2 := WSql;
// if ShowModal = 1 then
// begin
//// Self.InitGrid();
// end;
// end;
// finally
// frmMdPrint.Free;
// end;
try
frmLabelPrint := TfrmLabelPrint.Create(Application);
with frmLabelPrint do
begin
FLMType := '<27><><EFBFBD><EFBFBD><EFBFBD>뵥';
FFiltration1 := WSql;
if ShowModal = 1 then
begin
// Self.InitGrid();
end;
end;
finally
frmLabelPrint.Free;
end;
end;
2025-06-27 17:30:04 +08:00
procedure TfrmMachRollMain.Button1Click(Sender: TObject);
var
fPrintFile, MPacketId, MTMSId: string;
mvalue: double;
i: Integer;
begin
try
2026-02-05 17:10:07 +08:00
Button1.Enabled := false;
2025-06-27 17:30:04 +08:00
MTMSId := Trim(SelTVKey(Tv2, ['TMSId'])[0]);
edtScan.SetFocus;
try
ADOQueryBaseCmd.Connection.BeginTrans;
if trim(FBCIOID) = '' then
raise Exception.create('<27><>ɨ<EFBFBD><C9A8><EFBFBD><EFBFBD><EFBFBD>̿<EFBFBD><CCBF><EFBFBD>');
with ADOQueryBaseCmd do
begin
Close;
sql.Clear;
Sql.Add('exec P_BS_Cloth_Out_DistributionAll ');
Sql.Add(' @StkID=' + quotedstr(Trim(FBCIOID)));
Sql.Add(' ,@TMSId =' + quotedstr(MTMSId));
Sql.Add(' ,@Dcode=' + quotedstr(Trim(Dcode)));
Sql.Add(' ,@DName=' + quotedstr(Trim(DName)));
2025-07-21 17:21:17 +08:00
// showmessage(sql.Text);
2025-06-27 17:30:04 +08:00
open;
end;
if ADOQueryBaseCmd.fieldbyName('intReturn').AsInteger = -1 then
begin
raise Exception.create(pchar(trim(ADOQueryBaseCmd.fieldbyName('ShowMsg').AsString)));
end;
FCIID := trim(trim(ADOQueryBaseCmd.fieldbyName('MaxIOID2').AsString));
2026-02-05 17:10:07 +08:00
if trim(cds_params.fieldbyName('outPage').AsString) = '<27><>' then
begin
PrtData(FCIID);
end;
2025-06-27 17:30:04 +08:00
ADOQueryBaseCmd.Connection.CommitTrans;
TradeMarketProgressUpdate(ADOQueryBaseCmd, MTMSId);
except
ADOQueryBaseCmd.Connection.RollbackTrans;
Application.MessageBox(pchar(Exception(ExceptObject).Message), '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
end;
InputLen.SetFocus;
setFocusCtrol(InputLen.Name);
InitJYGrid();
InitGrid2();
FCIID := '';
finally
2026-02-05 17:10:07 +08:00
Button1.Enabled := true;
end;
if fIsCommopen then
begin
ClearCom(MBDYDllName);
2025-06-27 17:30:04 +08:00
end;
end;
2025-02-20 14:17:49 +08:00
procedure TfrmMachRollMain.FormClose(Sender: TObject; var Action: TCloseAction);
begin
inherited;
if fIsCommopen then
begin
CloseCom(DZCDYDllName);
CloseCom(MBDYDllName);
end;
Action := caFree;
end;
procedure TfrmMachRollMain.FormCreate(Sender: TObject);
begin
inherited;
fIsCommopen := false;
cds_params.Close;
cds_params.CreateDataSet;
Panel_right.Align := alClient;
end;
procedure TfrmMachRollMain.FormDestroy(Sender: TObject);
begin
inherited;
frmMachRollMain := nil;
end;
procedure TfrmMachRollMain.FormShow(Sender: TObject);
var
i: Integer;
begin
inherited;
2025-02-20 17:32:25 +08:00
gIsCanDesign := gIsCanDesign;
2025-02-20 14:17:49 +08:00
gGridNativeSet := true;
2025-02-20 17:32:25 +08:00
2025-02-20 14:17:49 +08:00
ReadCxGrid(trim(Self.Caption) + 'Tv3', Tv3, gDllFileCaption);
if IsINIFile() then
ReadINIFile()
else
WriteINIFile;
GetINIFile();
setFormCtrol();
if trim(fmanage) <> '<27><>Ȩ<EFBFBD><C8A8>' then
begin
if trim(DZCDYDllName) <> '' then
OpenCom(DZCDYDllName);
if trim(MBDYDllName) <> '' then
OpenCom(MBDYDllName);
end;
if trim(fCanInputFs) = '1' then
begin
2025-08-13 17:36:55 +08:00
// cxGroupBox_keys.ClientHeight := round(cxGrid3.ClientHeight * 0.6);
2025-02-20 14:17:49 +08:00
frameKeyBoard1.SpeedButton10.Visible := true;
end
else
begin
2025-08-13 17:36:55 +08:00
// cxGroupBox_keys.ClientHeight := round(cxGrid3.ClientHeight * 0.55);
2025-02-20 14:17:49 +08:00
frameKeyBoard1.SpeedButton10.Visible := false;
end;
end;
2025-02-21 15:28:49 +08:00
procedure TfrmMachRollMain.FrameKeyBoard1SpeedButton1Click(Sender: TObject);
var
fsj: string;
mComponent: TComponent;
mkey: Char;
begin
fsj := trim(TSpeedButton(Sender).Hint);
if trim(fsj) = '' then
exit;
mComponent := FindComponent(trim(TSpeedButton(Sender).Hint));
if mComponent = nil then
exit;
if TcxTextEdit(mComponent).Name = 'KuangHao' then
exit;
if (TcxTextEdit(mComponent).Name = 'edtScan') and (trim(TSpeedButton(Sender).Caption) = '<27>س<EFBFBD>') then
begin
mkey := #13;
edtScanKeyPress(edtScan, mkey);
exit;
end;
fsj := trim(TcxTextEdit(mComponent).Text);
if mComponent is TcxCurrencyEdit then
begin
TcxCurrencyEdit(mComponent).text := fsj + trim(TSpeedButton(Sender).Caption);
TcxCurrencyEdit(mComponent).SelectAll;
end
else if mComponent is TcxTextEdit then
begin
TcxTextEdit(mComponent).Text := fsj + trim(TSpeedButton(Sender).Caption);
TcxTextEdit(mComponent).SelectAll;
end
else if mComponent is TcxComboBox then
begin
TcxComboBox(mComponent).Text := fsj + trim(TSpeedButton(Sender).Caption);
TcxComboBox(mComponent).SelectAll;
end;
end;
2025-02-20 14:17:49 +08:00
procedure TfrmMachRollMain.FrameKeyBoard1SpeedButton_ycClick(Sender: TObject);
begin
inherited;
cxGroupBox_keys.Visible := false;
end;
procedure TfrmMachRollMain.ClearGlobal();
begin
FBCIOID := '';
2025-02-20 17:32:25 +08:00
2025-02-20 14:17:49 +08:00
FQtyUnit := '';
2025-02-20 17:32:25 +08:00
2025-02-20 14:17:49 +08:00
FCIID := '';
FWorkshop := '';
InputLen.Text := '';
Coefficient.Text := '';
AOrdDefNote1.Text := '';
Tare.Text := '';
InputWeight.Text := '';
FLenUnit := '';
Faddwet := 0;
faddlen := 0;
FPacketCIID := '';
FPacketCount := 0;
2025-03-20 16:38:30 +08:00
FC_ColorNo := '';
FC_Code := '';
2025-02-20 14:17:49 +08:00
end;
procedure TfrmMachRollMain.QuantityConversion();
begin
// if trim(OrderNo.Text)='' then exit;
if cds_params.fieldbyName('weightRule').AsInteger = 0 then
// InputWeight ë<><C3AB> OutPutWeight <20><><EFBFBD><EFBFBD>
begin
if lblRuleConversion.Text <> '<27><><EFBFBD><EFBFBD>ת<EFBFBD><D7AA>' then
begin
if lblRuleConversion.Text = '<27><><EFBFBD><EFBFBD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD>' then
begin
InputWeight.Text := floattostr(strtofloatdef(trim(InputLen.Text), 0) * strtofloatdef(trim(Coefficient.Text), 0) + strtofloatdef(trim(Tare.Text), 0));
end;
if lblRuleConversion.Text = <><C3AB>ת<EFBFBD><D7AA><EFBFBD><EFBFBD>' then
begin
InputLen.Text := floattostr(strtofloatdef(trim(InputWeight.Text), 0) * strtofloatdef(trim(Coefficient.Text), 0));
end;
if lblRuleConversion.Text = '<27><><EFBFBD><EFBFBD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD>' then
begin
InputLen.Text := floattostr((RoundFloat(strtofloatdef(trim(InputWeight.Text), 0), 1) - strtofloatdef(trim(Tare.Text), 0)) * strtofloatdef(trim(Coefficient.Text), 0));
end;
end;
if strtofloatdef(trim(InputWeight.Text), 0) > 0 then
begin
OutPutWeight.Text := floattostr((strtofloatdef(trim(InputWeight.Text), 0) - strtofloatdef(trim(Tare.Text), 0))); // <20><><EFBFBD><EFBFBD>
end;
end;
if cds_params.fieldbyName('weightRule').AsInteger = 1 then
// InputWeight <20><><EFBFBD><EFBFBD> OutPutWeight ë<><C3AB>
begin
if lblRuleConversion.Text <> '<27><><EFBFBD><EFBFBD>ת<EFBFBD><D7AA>' then
begin
if lblRuleConversion.Text = '<27><><EFBFBD><EFBFBD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD>' then
begin
InputWeight.Text := floattostr(strtofloatdef(trim(InputLen.Text), 0) * strtofloatdef(trim(Coefficient.Text), 0));
end;
if lblRuleConversion.Text = <><C3AB>ת<EFBFBD><D7AA><EFBFBD><EFBFBD>' then
begin
InputLen.Text := floattostr((strtofloatdef(trim(InputWeight.Text), 0) + strtofloatdef(trim(Tare.Text), 0)) * strtofloatdef(trim(Coefficient.Text), 0));
end;
if lblRuleConversion.Text = '<27><><EFBFBD><EFBFBD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD>' then
begin
InputLen.Text := floattostr(RoundFloat(strtofloatdef(trim(InputWeight.Text), 0), 1) * strtofloatdef(trim(Coefficient.Text), 0));
end;
end;
if strtofloatdef(trim(InputWeight.Text), 0) > 0 then
begin
OutPutWeight.Text := floattostr((strtofloatdef(trim(InputWeight.Text), 0) + strtofloatdef(trim(Tare.Text), 0))); // ë<><C3AB>
end;
end;
end;
procedure TfrmMachRollMain.InitPlan(MSubID: string);
begin
2025-09-29 09:23:46 +08:00
if leftstr(MSubID, 2) = 'JS' then
begin
FCKLX := '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
Button1.visible := false;
ToolButton2.visible := False;
end
else
begin
FCKLX := '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
Button1.visible := true;
ToolButton2.visible := true;
end;
2025-02-20 14:17:49 +08:00
with ADOQueryBaseTemp do
begin
Close;
SQL.Clear;
2025-09-29 09:23:46 +08:00
if FCKLX = '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' then
begin
SQL.Add('EXEC P_Trade_Insp_Get_Market @TMSId=''' + trim(MSubID) + '''');
end
else
begin
SQL.Add('EXEC P_Trade_Insp_Get_plan @BCIOID=''' + trim(MSubID) + '''');
end;
2025-02-20 14:17:49 +08:00
Open;
if not IsEmpty then
begin
2025-02-20 17:32:25 +08:00
FLenUnit := trim(ADOQueryBaseTemp.fieldbyName('LenUnit').AsString);
2025-02-20 14:17:49 +08:00
if FLenUnit = '' then
begin
FLenUnit := 'M';
end;
2025-02-20 17:32:25 +08:00
fLabPackage := <>ϰ<EFBFBD><CFB0><EFBFBD>ǩ';
2025-06-20 13:56:26 +08:00
fLabVolume := '<27>ͻ<EFBFBD><CDBB><EFBFBD>ǩ';
2025-02-20 17:32:25 +08:00
// fLabPackage := trim(ADOQueryBaseTemp.fieldbyName('LabPackage').AsString);
// fLabVolume := trim(ADOQueryBaseTemp.fieldbyName('LabVolume').AsString);
2025-02-20 14:17:49 +08:00
SetUnit(FLenUnit);
2025-06-27 17:30:04 +08:00
FCDUnit := lblLenUnit.Caption;
2025-09-29 09:23:46 +08:00
FTMSId := trim(fieldbyName('TMSId').AsString);
FTMMId := trim(fieldbyName('TMMId').AsString);
2025-02-20 14:17:49 +08:00
FBCIOID := trim(fieldbyName('BCIOID').AsString);
2025-02-20 17:32:25 +08:00
FQtyUnit := trim(fieldbyName('QtyUnit').AsString);
2025-02-21 15:28:49 +08:00
OrderNo.Text := trim(fieldbyName('FromOrdNo').AsString);
CodeName.Text := trim(fieldbyName('C_Name').AsString);
2025-02-20 17:32:25 +08:00
C_width.Text := trim(fieldbyName('C_width').AsString);
C_GramWeight.Text := trim(fieldbyName('C_GramWeight').AsString);
2025-02-21 15:28:49 +08:00
ColorNo.Text := trim(fieldbyName('C_ColorNo').AsString);
Color.Text := trim(fieldbyName('C_Color').AsString);
2025-02-20 14:17:49 +08:00
C_Pattern.Text := trim(fieldbyName('C_Pattern').AsString);
FFtyPCId := trim(fieldbyName('FtyPCId').AsString);
2025-03-20 16:38:30 +08:00
FC_Code := trim(fieldbyName('C_Code').AsString);
FC_ColorNo := trim(fieldbyName('C_ColorNo').AsString);
2025-02-21 15:28:49 +08:00
cds_params.Edit;
2025-02-20 14:17:49 +08:00
cds_params.fieldbyName('outPage').value := '<27><>';
cds_params.Post;
2025-02-21 15:28:49 +08:00
// Coefficient.Text := trim(fieldbyName('Coefficient').AsString);
2025-02-20 14:17:49 +08:00
// ת<><D7AA>ϵ<EFBFBD><CFB5>
2025-02-21 15:28:49 +08:00
// lblRuleConversion.ItemIndex := lblRuleConversion.Properties.Items.IndexOf(fieldbyName('RuleConversion').AsString);
2025-02-20 14:17:49 +08:00
FtyPCId.Text := FFtyPCId;
BCIOID.Text := FBCIOID;
2025-02-20 17:32:25 +08:00
2025-02-21 15:28:49 +08:00
Qty.Text := trim(fieldbyName('StkQty').AsString) + trim(fieldbyName('QtyUnit').AsString);
2025-02-20 17:32:25 +08:00
2025-02-21 15:28:49 +08:00
// Tare.Text := trim(fieldbyName('RuleLaterTare').AsString);
2025-02-20 14:17:49 +08:00
fTareType := '';
2025-02-21 15:28:49 +08:00
RuleYardstick.Text := '100';
2025-02-20 17:32:25 +08:00
2025-02-20 14:17:49 +08:00
packnote.Lines.Clear;
InputLen.SetFocus;
setFocusCtrol(InputLen.Name);
SetDdetails();
end
else
begin
// ClearGlobal();
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>쳣,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD>ʹ<EFBFBD><CDB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!', '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ');
end;
end;
InitJYGrid();
2025-02-20 17:32:25 +08:00
2025-02-20 14:17:49 +08:00
edtScan.Text := '';
// <20><>ʾ<EFBFBD><CABE>
setFormCtrol();
end;
procedure TfrmMachRollMain.InputLenKeyPress(Sender: TObject; var Key: Char);
begin
if Key = #13 then
begin
Key := #0;
SelectNext(ActiveControl as TWinControl, true, true);
end;
end;
procedure TfrmMachRollMain.InputLenPropertiesChange(Sender: TObject);
begin
// if StrToIntDef(trim(InputWeight.Text), 0) = 0 then
// begin
// exit;
// end;
QuantityConversion();
end;
procedure TfrmMachRollMain.lblRuleConversionPropertiesChange(Sender: TObject);
begin
inherited;
if lblRuleConversion.Text = '<27><><EFBFBD><EFBFBD>ת<EFBFBD><D7AA>' then
begin
OutPutWeight.Text := '';
InputLen.Text := '';
InputWeight.Text := '';
end;
QuantityConversion();
end;
procedure TfrmMachRollMain.SetUnit(MUnit: string);
begin
2025-02-20 17:32:25 +08:00
2025-06-27 17:30:04 +08:00
lblLenUnit.Caption := MUnit;
2025-02-20 14:17:49 +08:00
end;
procedure TfrmMachRollMain.ToolButton1Click(Sender: TObject);
begin
frmParamSet := TfrmParamSet.create(Self);
with frmParamSet do
begin
cds_params.Data := Self.cds_params.Data;
if ShowModal = 1 then
begin
Self.cds_params.Data := cds_params.Data;
setFormCtrol();
end;
free;
end;
SetINIFile();
if trim(fmanage) <> '<27><>Ȩ<EFBFBD><C8A8>' then
begin
if (trim(MBDYDllName) <> '') and not fIsCommopen then
OpenCom(MBDYDllName);
end;
end;
2025-02-25 16:04:43 +08:00
procedure TfrmMachRollMain.ToolButton2Click(Sender: TObject);
var
fPrintFile: string;
Txt, fImagePath, Txt2, fImagePath2: string;
Moudle: Thandle;
Makebar: TMakebar;
Mixtext: TMixtext;
begin
with ADOQueryPrint do
begin
Close;
SQL.Clear;
SQL.Add(' EXEC P_BS_Cloth_Prt2 ');
SQL.Add(' @Filtration=''' + trim(FBCIOID) + '''');
2026-02-05 17:10:07 +08:00
2025-02-25 16:04:43 +08:00
Open;
end;
if ADOQueryPrint.IsEmpty then
begin
Application.MessageBox('<27><>ǩ<EFBFBD><C7A9><EFBFBD><EFBFBD>δ<EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', MB_ICONERROR);
exit;
end;
ExportFtErpFile('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǩ.fr3', ADOQueryBaseTemp);
fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\<5C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǩ.fr3';
if FileExists(fPrintFile) then
begin
frxReport1.LoadFromFile(fPrintFile);
frxReport1.PrintOptions.Copies := cds_params.fieldbyName('labNumber').AsInteger;
frxReport1.PrintOptions.ShowDialog := false;
frxReport1.PrepareReport(True);
frxReport1.Print();
end
else
begin
Application.MessageBox(PChar(<><C3BB><EFBFBD>ҵ<EFBFBD>' + fPrintFile), '<27><>ʾ', 0);
end;
end;
2025-02-20 14:17:49 +08:00
procedure TfrmMachRollMain.ToolButton3Click(Sender: TObject);
begin
if cds_3.IsEmpty then
exit;
2025-02-20 17:32:25 +08:00
PrtData(cds_3.fieldbyName('BCIOID').AsString);
2025-02-20 14:17:49 +08:00
end;
procedure TfrmMachRollMain.TrolldelClick(Sender: TObject);
var
2025-02-21 15:28:49 +08:00
MBCIOID: string;
2025-02-20 14:17:49 +08:00
begin
if cds_3.IsEmpty then
exit;
2025-02-21 15:28:49 +08:00
if Application.MessageBox(<><C8B7>Ҫɾ<D2AA><C9BE>ѡ<EFBFBD><D1A1><EFBFBD>ľ<EFBFBD><C4BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ', 32 + 4) <> IDYES then
2025-02-20 14:17:49 +08:00
exit;
2025-02-21 15:28:49 +08:00
2025-02-20 14:17:49 +08:00
ADOQueryBaseCmd.Connection.BeginTrans;
try
2025-02-21 15:28:49 +08:00
MBCIOID := trim(cds_3.fieldbyName('BCIOID').AsString);
2025-02-20 14:17:49 +08:00
with ADOQueryBaseCmd do
begin
Close;
SQL.Clear;
2025-02-21 15:28:49 +08:00
Sql.Add('exec P_BS_Cloth_Out_Del ');
Sql.Add(' @BCIOIDS=' + quotedstr(MBCIOID));
Sql.Add(',@DCode=' + quotedstr(Trim(DCode)));
Sql.Add(',@DName=' + quotedstr(Trim(DName)));
2025-02-20 14:17:49 +08:00
Open;
end;
if ADOQueryBaseCmd.fieldbyName('intReturn').AsInteger = -1 then
begin
raise Exception.create(pchar(trim(ADOQueryBaseCmd.fieldbyName('ShowMsg').AsString)));
end;
ADOQueryBaseCmd.Connection.CommitTrans;
cds_3.Delete;
Application.MessageBox(<><C9BE><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ');
except
ADOQueryBaseCmd.Connection.RollbackTrans;
Application.MessageBox(pchar(Exception(ExceptObject).Message), '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
end;
end;
procedure TfrmMachRollMain.Tv3CustomDrawCell(Sender: TcxCustomGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
begin
if AViewInfo.GridRecord.Values[TcxGridDBTableView(Sender).GetColumnByFieldName('Grade').Index] = '<27><>Ʒ' then
ACanvas.Brush.Color := clRed;
end;
procedure TfrmMachRollMain.ToolButton8Click(Sender: TObject);
begin
inherited;
Close;
end;
procedure TfrmMachRollMain.setFocusCtrol(controlName: string);
var
i: Integer;
begin
with FrameKeyBoard1.dxPanel1 do
begin
for i := 0 to ControlCount - 1 do
begin
if Controls[i] is TSpeedButton then
begin
TSpeedButton(Controls[i]).Hint := trim(controlName);
if (trim(controlName) = 'edtScan') and (TSpeedButton(Controls[i]).Name = 'SpeedButton_dot') then
begin
TSpeedButton(Controls[i]).Caption := '<27>س<EFBFBD>';
end
else if (TSpeedButton(Controls[i]).Name = 'SpeedButton_dot') then
begin
TSpeedButton(Controls[i]).Caption := '.';
end;
end;
end;
end;
cxGroupBox_keys.Left := Panel_right.Left + 5;
cxGroupBox_keys.Visible := true;
end;
procedure TfrmMachRollMain.SetDdetails();
begin
AOrdDefNote1.Text := '';
2025-02-20 17:32:25 +08:00
2025-02-20 14:17:49 +08:00
AOrdDefNote1.Text := AOrdDefNote1.Text + '<27><><EFBFBD><EFBFBD>:' + FBCIOID + #13;
if FRulePieceNo <> '' then
AOrdDefNote1.Text := AOrdDefNote1.Text + '<27><><EFBFBD>Ź<EFBFBD><C5B9><EFBFBD>:' + FRulePieceNo + #13;
if gMachOperators <> '' then
AOrdDefNote1.Text := AOrdDefNote1.Text + '<27><>̨<EFBFBD><CCA8>Ա:' + gMachOperators + #13;
end;
procedure TfrmMachRollMain.SetINIFile();
begin
IsDZCDYDll := trim(cds_params.fieldbyName('chen').AsString);
IsMBDYDll := trim(cds_params.fieldbyName('mabiao').AsString);
IsMBDYDllUnit := trim(cds_params.fieldbyName('mbunit').AsString);
LabQty := trim(cds_params.fieldbyName('labNumber').AsString);
FMinLen := trim(cds_params.fieldbyName('minLen').AsString);
FMaxLen := trim(cds_params.fieldbyName('maxLen').AsString);
FMinWeight := trim(cds_params.fieldbyName('minweight').AsString);
FMaxWeight := trim(cds_params.fieldbyName('maxweight').AsString);
FMPlace := trim(cds_params.fieldbyName('mplace').AsString);
FYPlace := trim(cds_params.fieldbyName('yplace').AsString);
FKgPlace := trim(cds_params.fieldbyName('kgplace').AsString);
WriteINIFile();
end;
procedure TfrmMachRollMain.setFormCtrol();
begin
2025-02-20 17:32:25 +08:00
2025-02-20 14:17:49 +08:00
FrameKeyBoard1.SpeedButton_zdykey1.Caption := gZdyKey1;
// FrameKeyBoard1.SpeedButton_zdykey2.Caption := gZdyKey2;
FrameKeyBoard1.SpeedButton_zdykey2.Caption := gZdyKey2;
//<2F><><EFBFBD><EFBFBD>
presentlen.text := trim(cds_params.fieldbyName('AddLenPresent').AsString);
presentWeight.text := trim(cds_params.fieldbyName('AddwetPresent').AsString);
end;
procedure TfrmMachRollMain.GetINIFile();
begin
with cds_params do
begin
if IsEmpty then
Append
else
edit;
fieldbyName('chen').value := IsDZCDYDll;
fieldbyName('mabiao').value := IsMBDYDll;
fieldbyName('mbunit').value := IsMBDYDllUnit;
fieldbyName('MinLen').value := strtointdef(FMinLen, 0);
fieldbyName('MaxLen').value := strtointdef(FMaxLen, 100);
fieldbyName('MinWeight').value := strtointdef(FMinWeight, 0);
fieldbyName('MaxWeight').value := strtointdef(FMaxWeight, 50);
fieldbyName('MPlace').value := strtointdef(FMPlace, 1);
fieldbyName('YPlace').value := strtointdef(FYPlace, 1);
fieldbyName('KgPlace').value := strtointdef(FKgPlace, 1);
fieldbyName('labNumber').value := strtointdef(trim(LabQty), 1);
Post;
end;
end;
procedure TfrmMachRollMain.InitJYGrid();
var
MNetWeight, MJYLen: double;
begin
try
cds_3.DisableControls;
2025-09-29 09:23:46 +08:00
if FCKLX = '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' then
2025-02-20 14:17:49 +08:00
begin
2025-09-29 09:23:46 +08:00
with ADOQueryMain do
begin
Close;
SQL.Clear;
SQL.Add('select A.*');
SQL.Add('from Bs_Cloth_IO A where IOType=''<27><><EFBFBD>۳<EFBFBD><DBB3><EFBFBD>'' and TMSId=''' + trim(FTMSId) + '''');
SQL.Add('order by filltime desc');
Open;
end;
end
else
begin
with ADOQueryMain do
begin
Close;
SQL.Clear;
SQL.Add('select A.*');
SQL.Add('from Bs_Cloth_IO A where IOType=''<27><><EFBFBD>۳<EFBFBD><DBB3><EFBFBD>'' and STKID=''' + trim(FBCIOID) + '''');
SQL.Add('order by filltime desc');
Open;
end;
2025-02-20 14:17:49 +08:00
end;
2025-09-29 09:23:46 +08:00
2025-02-20 14:17:49 +08:00
SCreateCDS(ADOQueryMain, cds_3);
SInitCDSData(ADOQueryMain, cds_3);
finally
cds_3.EnableControls;
end;
end;
procedure TfrmMachRollMain.OpenCom(DllName: string);
type
TMyFunc = function(fhandle: hwnd; sCommName: PAnsiChar; IntTime: Integer; IsMessage: Integer): hwnd; stdcall;
var
Tf: TMyFunc;
Tp: TFarProc;
Th: Thandle;
begin
Th := LoadLibrary(pchar(trim(DllName)));
if Th > 0 then
begin
try
Tp := GetProcAddress(Th, 'CommOpen');
if Tp <> nil then
begin
Tf := TMyFunc(Tp);
newh := Tf(Self.Handle, 'Comm1', 500, 1);
if newh < 1 then
begin
Application.MessageBox(pchar('<27>򿪴<EFBFBD><F2BFAAB4><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>'), '<27><>ʾ');
end
else
fIsCommopen := true;
end
else
begin
fIsCommopen := false;
end;
finally
2026-02-05 17:10:07 +08:00
// FreeLibrary(Th);
2025-02-20 14:17:49 +08:00
end;
end
else
begin
fIsCommopen := false;
Application.MessageBox(pchar('<27>Ҳ<EFBFBD><D2B2><EFBFBD> ' + trim(DllName) + ' <20>ļ<EFBFBD><C4BC><EFBFBD>'), '<27><>ʾ');
end;
end;
procedure TfrmMachRollMain.CloseCom(DllName: string);
type
TMyFunc = function(sCommName: PAnsiChar): hwnd; stdcall;
var
Tf1: TMyFunc;
Tp1: TFarProc;
Th1: Thandle;
begin
Th1 := LoadLibrary(pchar(trim(DllName)));
if Th1 > 0 then
begin
try
Tp1 := GetProcAddress(Th1, 'CommClose');
if Tp1 <> nil then
begin
Tf1 := TMyFunc(Tp1);
newh1 := Tf1('Comm1');
end
else
begin
end;
finally
// FreeLibrary(Th1);
end;
end
else
begin
Application.MessageBox(pchar('<27>Ҳ<EFBFBD><D2B2><EFBFBD> ' + trim(DllName) + ' <20>ļ<EFBFBD><C4BC><EFBFBD>'), '<27><>ʾ');
end;
end;
procedure TfrmMachRollMain.dxLayoutControl_packDblClick(Sender: TObject);
begin
if gIsCanDesign then
layoutDesign(TdxLayoutControl(Sender), ADOQueryBaseCmd, PWideChar(dcode));
end;
procedure TfrmMachRollMain.dxLayoutItem1CaptionClick(Sender: TObject);
var
mkey: Char;
begin
inherited;
// frmProductListHelp := TfrmProductListHelp.create(Self);
// with frmProductListHelp do
// begin
// fType := '10';
// if ShowModal = 1 then
// begin
// edtScan.Text := trim(order_main.fieldbyName('Subid').AsString);
// mkey := #13;
// edtScanKeyPress(edtScan, mkey);
// end;
// free;
// end;
frmTradeClothTotalOutSel := TfrmTradeClothTotalOutSel.create(Self);
with frmTradeClothTotalOutSel do
begin
if ShowModal = 1 then
begin
edtScan.Text := trim(CDS_Main.fieldbyName('BCIOID').AsString);
end;
free;
end;
mkey := #13;
edtScanKeyPress(edtScan, mkey);
end;
procedure TfrmMachRollMain.edtScanDblClick(Sender: TObject);
begin
inherited;
edtScan.Text := '';
end;
procedure TfrmMachRollMain.edtScanEnter(Sender: TObject);
begin
inherited;
setFocusCtrol(TWinControl(Sender).Name);
end;
procedure TfrmMachRollMain.edtScanKeyPress(Sender: TObject; var Key: Char);
begin
inherited;
if Key = #13 then
begin
if trim(edtScan.Text) = '' then
exit;
if trim(edtScan.Text) = FBCIOID then
exit;
ClearGlobal();
2025-02-20 17:32:25 +08:00
InitPlan(edtScan.Text);
2025-03-20 16:38:30 +08:00
InitGrid2();
2025-02-20 14:17:49 +08:00
if trim(OrderNo.Text) <> '' then
InputLen.SetFocus;
cxGroupBox_keys.Visible := false;
end;
end;
function TfrmMachRollMain.SaveData(): Boolean;
var
MInputLen, MMeter, MYardage: double;
MInputWeight, MGrossWeight, MNetWeight, MTare, Maddwet, maddLen: double;
mYardStick: double;
mPresentLen, mpresentWeight: double;
2025-06-27 17:30:04 +08:00
MTMSId: string;
2025-02-20 14:17:49 +08:00
begin
Result := false;
2025-06-27 17:30:04 +08:00
MTMSId := Trim(SelTVKey(Tv2, ['TMSId'])[0]);
2025-02-20 14:17:49 +08:00
Maddwet := strTofloatDef(trim(addwet.text), 0); // Faddwet;
maddLen := strTofloatDef(trim(addlen.text), 0); // faddlen;
mYardStick := strtofloatdef(trim(RuleYardstick.Text), 100);
mPresentLen := strTofloatDef(trim(presentlen.text), 0);
mpresentWeight := strTofloatDef(trim(presentWeight.text), 0);
if (strtoIntdef(Trim(unitPieces.Text), 0) > 0) and (strtoIntdef(trim(InputLen.Text), 0) > 0) then
begin
if strtoIntdef(trim(InputLen.Text), 0) > strtoIntdef(Trim(unitPieces.Text), 0) then
funitPiecesStr := intTostr((strtoIntdef(trim(InputLen.Text), 0)) - strtoIntdef(Trim(unitPieces.Text), 0)) + '+' + Trim(unitPieces.Text);
end;
//0:<3A><><EFBFBD>䣻1<E4A3BB><31><EFBFBD><EFBFBD>ȥ<EFBFBD><C8A5><EFBFBD><EFBFBD>
if gPresentNumFlag = 1 then
begin
mPresentLen := -1 * mPresentLen;
mpresentWeight := -1 * mpresentWeight;
end;
try
ADOQueryBaseCmd.Connection.BeginTrans;
2025-02-20 17:32:25 +08:00
MTare := strtofloatdef(trim(Tare.Text), 0); // Ƥ<><C6A4>
MInputWeight := RoundFloat(strtofloatdef(trim(InputWeight.Text), 0), cds_params.fieldbyName('KgPlace').AsInteger); // <20><><EFBFBD><EFBFBD>
MGrossWeight := MInputWeight + MTare + Maddwet + mpresentWeight; // ë<><C3AB>
MNetWeight := MInputWeight + Maddwet + mpresentWeight; // <20><><EFBFBD><EFBFBD> +<2B><><EFBFBD><EFBFBD>
2025-02-20 14:17:49 +08:00
2025-02-20 17:32:25 +08:00
MInputLen := RoundFloat(strtofloatdef(trim(InputLen.Text), 0), 4);
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>+mAddLen
2025-06-27 17:30:04 +08:00
if (uppercase(lblLenUnit.Caption) = 'M') or (lblLenUnit.Caption = '<27><>') then
2025-02-20 14:17:49 +08:00
begin
2025-02-20 17:32:25 +08:00
MMeter := RoundFloat((MInputLen + maddLen + mPresentLen) / (mYardStick / 100), cds_params.fieldbyName('MPlace').AsInteger);
MYardage := RoundFloat(MMeter / 0.9144, cds_params.fieldbyName('YPlace').AsInteger);
end
else
2025-02-20 14:17:49 +08:00
begin
2025-02-20 17:32:25 +08:00
MYardage := RoundFloat((MInputLen + maddLen + mPresentLen) / (mYardStick / 100), cds_params.fieldbyName('YPlace').AsInteger);
MMeter := RoundFloat(MYardage * 0.9144, cds_params.fieldbyName('MPlace').AsInteger);
2025-02-20 14:17:49 +08:00
end;
2025-09-29 09:23:46 +08:00
if FCKLX = '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' then
2025-02-20 14:17:49 +08:00
begin
2025-09-29 09:23:46 +08:00
with ADOQueryBaseCmd do
begin
Close;
sql.Clear;
Sql.Add('exec P_BS_Cloth_Out_Distribution_KC ');
Sql.Add(' @GrossWeight=' + quotedstr(Trim(FloatToStr(MGrossWeight))));
Sql.Add(' ,@Tare=' + quotedstr(Trim(FloatToStr(MTare))));
Sql.Add(' ,@NetWeight=' + quotedstr(Trim(FloatToStr(MNetWeight))));
Sql.Add(' ,@Meter=' + quotedstr(Trim(FloatToStr(MMeter))));
Sql.Add(' ,@Yardage=' + quotedstr(Trim(FloatToStr(MYardage))));
Sql.Add(' ,@QtyUnit=' + quotedstr(Trim(lblLenUnit.caption)));
Sql.Add(' ,@StkID=' + quotedstr(Trim(FBCIOID)));
Sql.Add(' ,@TMSId =' + quotedstr(FTMSId));
Sql.Add(' ,@TMMId =' + quotedstr(FTMSId));
Sql.Add(' ,@Dcode=' + quotedstr(Trim(Dcode)));
Sql.Add(' ,@DName=' + quotedstr(Trim(DName)));
// ShowMessage(sql.Text);
open;
end;
end
else
begin
with ADOQueryBaseCmd do
begin
Close;
sql.Clear;
Sql.Add('exec P_BS_Cloth_Out_Distribution ');
Sql.Add(' @GrossWeight=' + quotedstr(Trim(FloatToStr(MGrossWeight))));
Sql.Add(' ,@Tare=' + quotedstr(Trim(FloatToStr(MTare))));
Sql.Add(' ,@NetWeight=' + quotedstr(Trim(FloatToStr(MNetWeight))));
Sql.Add(' ,@Meter=' + quotedstr(Trim(FloatToStr(MMeter))));
Sql.Add(' ,@Yardage=' + quotedstr(Trim(FloatToStr(MYardage))));
Sql.Add(' ,@StkID=' + quotedstr(Trim(FBCIOID)));
Sql.Add(' ,@TMSId =' + quotedstr(MTMSId));
Sql.Add(' ,@Dcode=' + quotedstr(Trim(Dcode)));
Sql.Add(' ,@DName=' + quotedstr(Trim(DName)));
2025-06-20 13:56:26 +08:00
// ShowMessage(sql.Text);
2025-09-29 09:23:46 +08:00
open;
end;
2025-02-20 14:17:49 +08:00
end;
2025-02-20 17:32:25 +08:00
if ADOQueryBaseCmd.fieldbyName('intReturn').AsInteger = -1 then
2025-02-20 14:17:49 +08:00
begin
2025-02-20 17:32:25 +08:00
raise Exception.create(pchar(trim(ADOQueryBaseCmd.fieldbyName('ShowMsg').AsString)));
2025-02-20 14:17:49 +08:00
end;
2025-02-20 17:32:25 +08:00
FCIID := trim(trim(ADOQueryBaseCmd.fieldbyName('MaxIOID2').AsString));
2025-02-20 14:17:49 +08:00
ADOQueryBaseCmd.Connection.CommitTrans;
2025-06-27 17:30:04 +08:00
TradeMarketProgressUpdate(ADOQueryBaseCmd, MTMSId);
2025-02-20 14:17:49 +08:00
Result := true;
except
ADOQueryBaseCmd.Connection.RollbackTrans;
Application.MessageBox(pchar(Exception(ExceptObject).Message), '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
end;
end;
procedure TfrmMachRollMain.PrtData(MCIID: string; againPring: Boolean = false);
var
fPrintFile: string;
Txt, fImagePath, Txt2, fImagePath2: string;
Moudle: Thandle;
Makebar: TMakebar;
Mixtext: TMixtext;
begin
with ADOQueryPrint do
begin
Close;
SQL.Clear;
2025-02-21 15:28:49 +08:00
SQL.Add(' EXEC P_BS_Cloth_Prt2 ');
SQL.Add(' @Filtration=''' + trim(MCIID) + '''');
2025-02-20 14:17:49 +08:00
Open;
end;
if ADOQueryPrint.IsEmpty then
begin
Application.MessageBox('<27><>ǩ<EFBFBD><C7A9><EFBFBD><EFBFBD>δ<EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', MB_ICONERROR);
exit;
end;
2025-02-21 15:28:49 +08:00
// if trim(ADOQueryPrint.fieldbyName('SLabVolume').AsString) <> '' then
// fLabVolume := trim(ADOQueryPrint.fieldbyName('SLabVolume').AsString)
// else
// fLabVolume := trim(ADOQueryPrint.fieldbyName('LabVolume').AsString);
2026-02-05 17:10:07 +08:00
// if fLabVolume = '' then
// begin
// Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>δ<EFBFBD><CEB4><EFBFBD>ñ<EFBFBD>ǩ<EFBFBD><C7A9>', '<27><>ʾ<EFBFBD><CABE>Ϣ', MB_ICONERROR);
// exit;
// end;
//
// ExportFtErpFile(fLabVolume + '.fr3', ADOQueryBaseTemp);
// fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\' + fLabVolume + '.fr3';
ExportFtErpFile('<27>ͻ<EFBFBD><CDBB><EFBFBD>ǩ.fr3', ADOQueryBaseTemp);
fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\<5C>ͻ<EFBFBD><CDBB><EFBFBD>ǩ.fr3';
2025-02-20 14:17:49 +08:00
if FileExists(fPrintFile) then
begin
2025-02-21 15:28:49 +08:00
frxReport1.LoadFromFile(fPrintFile);
frxReport1.PrintOptions.Copies := cds_params.fieldbyName('labNumber').AsInteger;
frxReport1.PrintOptions.ShowDialog := false;
frxReport1.PrepareReport(True);
frxReport1.Print();
2025-02-20 14:17:49 +08:00
end
else
begin
2025-02-21 15:28:49 +08:00
Application.MessageBox(PChar(<><C3BB><EFBFBD>ҵ<EFBFBD>' + fPrintFile), '<27><>ʾ', 0);
2025-02-20 14:17:49 +08:00
end;
end;
procedure TfrmMachRollMain.BadSpeedButtonClick(Sender: TObject);
begin
end;
procedure TfrmMachRollMain.On1301(var Message: Tmessage);
var
i1, i2: Integer;
unitname: string;
fdata: double;
begin
i1 := Message.WParam;
i2 := Message.LParam;
if (trim(cds_params.fieldbyName('mabiao').AsString) = '1') then
begin
InputLen.Text := format('%.2f', [i1 / 100000]);
if trim(cds_params.fieldbyName('mbunit').AsString) = '1' then
begin
if i2 = 0 then
begin
SetUnit('M');
end
else
begin
SetUnit('Y');
end;
end;
end;
end;
procedure TfrmMachRollMain.On1201(var Message: Tmessage);
var
i1, i2: Integer;
unitname: string;
fdata: double;
begin
i1 := Message.WParam;
i2 := Message.LParam;
if trim(cds_params.fieldbyName('chen').AsString) = '1' then
begin
InputWeight.Text := format('%.2f', [i1 / 100000]);
end;
end;
/////////////////////////////////////
function TfrmMachRollMain.deletePack(packId: string): boolean;
var
ccids: string;
packNo: integer;
begin
try
ccids := '';
packNo := strtointdef(Trim(cds_3.FieldByName('packetNo').AsString), 0);
ADOQueryBaseCmd.Connection.BeginTrans;
cds_3.First;
while not cds_3.eof do
begin
if Trim(cds_3.FieldByName('packetid').AsString) = packId then
begin
ccids := ccids + ',' + Trim(cds_3.FieldByName('CIID').AsString);
end;
with ADOQueryBaseCmd do
begin
Close;
SQL.Clear;
SQL.Add('insert into Trade_Need_Up(UType,UOperation,UDataId,uoperator) values(''<27><><EFBFBD><EFBFBD>'',''<27><><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE>'',' + QuotedStr(Trim(cds_3.FieldByName('CIID').AsString)) + ',' + QuotedStr(DName) + ') ');
ExecSQL;
end;
cds_3.Next;
end;
with ADOQueryBaseCmd do
begin
Close;
SQL.Clear;
SQL.Add('exec P_Trade_Insp_Del ');
SQL.Add('@CIIDS=' + QuotedStr(ccids));
SQL.Add(',@DCode=' + QuotedStr(DCode));
SQL.Add(',@DName=' + QuotedStr(DName));
Open;
end;
if ADOQueryBaseCmd.fieldbyName('intReturn').AsInteger = -1 then
begin
raise Exception.create(pchar(trim(ADOQueryBaseCmd.fieldbyName('ShowMsg').AsString)));
end;
ADOQueryBaseCmd.Connection.CommitTrans;
InitJYGrid();
Application.MessageBox(<><C9BE><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ');
except
ADOQueryBaseCmd.Connection.RollbackTrans;
Application.MessageBox(pchar(Exception(ExceptObject).Message), '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
end;
end;
end.