unit U_TradeMachInsp; interface uses Windows, Messages, SysUtils, StrUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit, DB, cxDBData, cxCalendar, cxGridLevel, cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxClasses, cxControls, cxGridCustomView, cxGrid, RM_Common, RM_Class, RM_GridReport, RM_System, RM_Dataset, ADODB, DBClient, cxGridCustomPopupMenu, cxGridPopupMenu, ExtCtrls, ComCtrls, ToolWin, cxTextEdit, Buttons, cxSplitter, cxCheckBox, MovePanel, cxLookAndFeels, cxLookAndFeelPainters, cxNavigator, Menus, U_BaseList, dxSkinsCore, dxSkinsDefaultPainters, dxDateRanges, dxBarBuiltInMenu, cxContainer, cxImage, cxDBEdit, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient, IdExplicitTLSClientServerBase, ShellAPI, IdFTP, FireDAC.Stan.StorageXML, cxPC, 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, MMSystem; type TfrmTradeMachInsp = class(TfrmBaseList) cxStyleRepository1: TcxStyleRepository; cxStyle1: TcxStyle; cxStyle2: TcxStyle; GPM_1: TcxGridPopupMenu; ADOQueryMain: TADOQuery; ADOCmd: TADOQuery; RMDB_1: TRMDBDataSet; DS_2: TDataSource; CDS_2: TClientDataSet; ADOQueryPrint: TADOQuery; GPM_2: TcxGridPopupMenu; ADOQueryMainDSC: TADOQuery; Panel7: TPanel; AOrdDefNote1: TRichEdit; RM1: TRMGridReport; ADOTmp: TADOQuery; ScrollBox1: TScrollBox; SpeedButton13: TSpeedButton; SpeedButton14: TSpeedButton; SpeedButton15: TSpeedButton; SpeedButton16: TSpeedButton; SpeedButton17: TSpeedButton; SpeedButton18: TSpeedButton; SpeedButton21: TSpeedButton; SpeedButton22: TSpeedButton; SpeedButton23: TSpeedButton; SpeedButton24: TSpeedButton; SpeedButton25: TSpeedButton; SpeedButton26: TSpeedButton; SpeedButton29: TSpeedButton; SpeedButton30: TSpeedButton; SpeedButton31: TSpeedButton; SpeedButton32: TSpeedButton; SpeedButton33: TSpeedButton; SpeedButton34: TSpeedButton; SpeedButton37: TSpeedButton; SpeedButton38: TSpeedButton; SpeedButton39: TSpeedButton; SpeedButton40: TSpeedButton; SpeedButton41: TSpeedButton; SpeedButton42: TSpeedButton; SpeedButton45: TSpeedButton; SpeedButton46: TSpeedButton; SpeedButton47: TSpeedButton; SpeedButton48: TSpeedButton; SpeedButton50: TSpeedButton; SpeedButton51: TSpeedButton; SpeedButton54: TSpeedButton; SpeedButton55: TSpeedButton; SpeedButton56: TSpeedButton; SpeedButton57: TSpeedButton; SpeedButton58: TSpeedButton; SpeedButton59: TSpeedButton; SpeedButton62: TSpeedButton; SpeedButton63: TSpeedButton; SpeedButton64: TSpeedButton; SpeedButton65: TSpeedButton; SpeedButton66: TSpeedButton; SpeedButton67: TSpeedButton; SpeedButton70: TSpeedButton; SpeedButton71: TSpeedButton; SpeedButton72: TSpeedButton; SpeedButton73: TSpeedButton; SpeedButton74: TSpeedButton; SpeedButton75: TSpeedButton; SpeedButton19: TSpeedButton; SpeedButton20: TSpeedButton; SpeedButton27: TSpeedButton; SpeedButton28: TSpeedButton; SpeedButton35: TSpeedButton; SpeedButton36: TSpeedButton; SpeedButton43: TSpeedButton; SpeedButton44: TSpeedButton; SpeedButton52: TSpeedButton; SpeedButton53: TSpeedButton; SpeedButton60: TSpeedButton; SpeedButton61: TSpeedButton; SpeedButton68: TSpeedButton; SpeedButton69: TSpeedButton; SpeedButton76: TSpeedButton; SpeedButton77: TSpeedButton; SpeedButton78: TSpeedButton; SpeedButton79: TSpeedButton; SpeedButton80: TSpeedButton; SpeedButton81: TSpeedButton; SpeedButton82: TSpeedButton; SpeedButton83: TSpeedButton; CDS_3: TClientDataSet; DS_3: TDataSource; ADOQueryImage: TADOQuery; DataSource2: TDataSource; IdFTP1: TIdFTP; Panel4: TPanel; cxGrid3: TcxGrid; Tv3: TcxGridDBTableView; cxGridDBColumn1: TcxGridDBColumn; v3Column1: TcxGridDBColumn; v3Column4: TcxGridDBColumn; v3Column5: TcxGridDBColumn; cxGridLevel2: TcxGridLevel; Panel3: TPanel; SpeedButton1: TSpeedButton; SpeedButton2: TSpeedButton; SpeedButton3: TSpeedButton; SpeedButton4: TSpeedButton; SpeedButton5: TSpeedButton; SpeedButton6: TSpeedButton; SpeedButton7: TSpeedButton; SpeedButton8: TSpeedButton; SpeedButton9: TSpeedButton; SpeedButton10: TSpeedButton; SpeedButton11: TSpeedButton; SpeedButton12: TSpeedButton; Panel1: TPanel; Pic_Image1: TcxDBImage; Tv3Column1: TcxGridDBColumn; MovePanel1: TMovePanel; Label17: TLabel; Label18: TLabel; lblLenUnit1: TLabel; CIFBeg: TEdit; Button1: TButton; Button4: TButton; CIFEnd: TEdit; CIFQty: TEdit; RadioGroup1: TRadioGroup; Button2: TButton; Panel8: TPanel; cxDBImage1: TcxDBImage; DS_ImgHX: TDataSource; Qry_ImgHX: TADOQuery; Tv3Column3: TcxGridDBColumn; Tv3Column4: TcxGridDBColumn; cxStyle4: TcxStyle; cxPageControl1: TcxPageControl; cxTabSheet1: TcxTabSheet; �鿴: TcxTabSheet; cxGrid2: TcxGrid; Tv2: TcxGridDBTableView; tv2CDType: TcxGridDBColumn; tv2CDWZ: TcxGridDBColumn; v2Column2: TcxGridDBColumn; Tv2CDQty: TcxGridDBColumn; Tv2CDReason: TcxGridDBColumn; v2Column1: TcxGridDBColumn; v2Column3: TcxGridDBColumn; v2Column4: TcxGridDBColumn; cxGridLevel1: TcxGridLevel; cxGrid1: TcxGrid; TV1: TcxGridDBTableView; cxGridDBColumn2: TcxGridDBColumn; cxGridDBColumn3: TcxGridDBColumn; cxGridDBColumn4: TcxGridDBColumn; cxGridDBColumn5: TcxGridDBColumn; cxGridDBColumn6: TcxGridDBColumn; cxGridDBColumn7: TcxGridDBColumn; cxGridDBColumn8: TcxGridDBColumn; cxGridDBColumn9: TcxGridDBColumn; cxGridLevel3: TcxGridLevel; DS_1: TDataSource; CDS_1: TClientDataSet; lblCIFName: TLabel; Label2: TLabel; Label8: TLabel; CIFNumber: TEdit; Panel9: TPanel; Panel10: TPanel; Label22: TLabel; Label13: TLabel; Label23: TLabel; Label25: TLabel; Label27: TLabel; GramWeight: TEdit; Width: TEdit; Color: TEdit; CodeName: TEdit; OrderNo: TEdit; Panel2: TPanel; lblLenUnit: TLabel; Label4: TLabel; Label5: TLabel; Label11: TLabel; InputLen: TEdit; BTPrint: TButton; Button6: TButton; Button8: TButton; ToolBar2: TToolBar; ToolButton3: TToolButton; ToolButton5: TToolButton; ToolButton6: TToolButton; Label10: TLabel; Edit3: TEdit; Label12: TLabel; Edit4: TEdit; GPM_3: TcxGridPopupMenu; pnlSet: TPanel; Label35: TLabel; Label16: TLabel; Label26: TLabel; Label6: TLabel; Label7: TLabel; Label9: TLabel; Label15: TLabel; Label19: TLabel; Label20: TLabel; Label21: TLabel; Label3: TLabel; Label30: TLabel; Label33: TLabel; edtChen: TEdit; edtMaBiao: TEdit; ComboBox1: TComboBox; Edit6: TEdit; edtMBDW: TEdit; MinLen: TEdit; MinWeight: TEdit; MaxLen: TEdit; MaxWeight: TEdit; MPlace: TEdit; YPlace: TEdit; KgPlace: TEdit; lblRuleConversion: TLabel; Tare: TEdit; Coefficient: TEdit; Label1: TLabel; edtScan: TEdit; Button3: TButton; ToolButton4: TToolButton; ToolButton7: TToolButton; ToolButton8: TToolButton; InputWeight: TEdit; Label36: TLabel; Label28: TLabel; BCIOID: TEdit; ToolBar1: TToolBar; btnRK: TToolButton; btnCXRK: TToolButton; ToolButton2: TToolButton; Tv3Column2: TcxGridDBColumn; Label31: TLabel; ComboBox2: TComboBox; Label32: TLabel; PieceNo: TEdit; Label34: TLabel; FtyPCId: TEdit; Label14: TLabel; Label24: TLabel; Composition: TEdit; Label37: TLabel; Edit5: TEdit; Button5: TButton; MaxQty: TLabel; Label39: TLabel; DelQty: TEdit; Tv3Column5: TcxGridDBColumn; ADOQuery1: TADOQuery; ADOQuery2: TADOQuery; lbl1: TLabel; edt1: TEdit; PCID: TEdit; lbl2: TLabel; Edit1: TEdit; lbl3: TLabel; SpeedButton49: TSpeedButton; SpeedButton84: TSpeedButton; SpeedButton85: TSpeedButton; SpeedButton86: TSpeedButton; SpeedButton87: TSpeedButton; Edit2: TEdit; Timer1: TTimer; procedure FormDestroy(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure FormShow(Sender: TObject); procedure Tv2CellDblClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean); procedure BTPrintClick(Sender: TObject); procedure SpeedButton1Click(Sender: TObject); procedure SpeedButton12Click(Sender: TObject); procedure SpeedButton13Click(Sender: TObject); procedure Button1Click(Sender: TObject); procedure edtScanKeyPress(Sender: TObject; var Key: Char); procedure CIFBegClick(Sender: TObject); procedure CIFEndChange(Sender: TObject); procedure Edit3Click(Sender: TObject); procedure Edit4Click(Sender: TObject); procedure Edit6Click(Sender: TObject); procedure MJstr3KeyPress(Sender: TObject; var Key: Char); procedure Button2Click(Sender: TObject); procedure GrossWeightChange(Sender: TObject); procedure edtScanClick(Sender: TObject); procedure NetWeightKeyPress(Sender: TObject; var Key: Char); procedure FormCreate(Sender: TObject); procedure Button4Click(Sender: TObject); procedure edtChenClick(Sender: TObject); procedure Button6Click(Sender: TObject); procedure edtScanDblClick(Sender: TObject); procedure Button8Click(Sender: TObject); procedure Tv3MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure edtYJClick(Sender: TObject); procedure cxDBImage1DblClick(Sender: TObject); procedure Pic_Image1DblClick(Sender: TObject); procedure Tv3CustomDrawCell(Sender: TcxCustomGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean); procedure lblLenUnitClick(Sender: TObject); procedure ToolButton3Click(Sender: TObject); procedure ToolButton6Click(Sender: TObject); procedure ToolButton5Click(Sender: TObject); procedure Button3Click(Sender: TObject); procedure ToolButton4Click(Sender: TObject); procedure ToolButton7Click(Sender: TObject); procedure ToolButton8Click(Sender: TObject); procedure MPlaceExit(Sender: TObject); procedure InputLenChange(Sender: TObject); procedure InputWeightChange(Sender: TObject); procedure btnRKClick(Sender: TObject); procedure btnCXRKClick(Sender: TObject); procedure ToolButton2Click(Sender: TObject); procedure ComboBox2Change(Sender: TObject); procedure Edit5Click(Sender: TObject); procedure Button5Click(Sender: TObject); procedure edt1Click(Sender: TObject); procedure Edit1Click(Sender: TObject); procedure SpeedButton87Click(Sender: TObject); private { Private declarations } FCIID, FOperationStatus, FCIFName, FWorkshop: string; FBCIOID, FOrderNo, FMainId, FSubId, FPCId, FConNo, FConMId, FConSId, FDRMID, FDRSID, FLCKID: string; FBatchNO, FLenUnit, FC_Code, FC_Name, FC_Spec, FC_Width, FC_GramWeight, FC_KnitGramWeight, FDyeNo: string; FC_Color, FC_ColorNo, FC_StyleNo, FC_Composition, FC_Pattern, FC_CustPattern, FC_ColorDepth, FLoom: string; FFtyPCId, FCUSTNAME, FGangNo, FRulePieceNo, FRuleBeforeTare, FRuleLaterTare, FC_Figure, FC_Yarn, FYWY: string; FPieceNo: Integer; IsCommopen: boolean; procedure SetINIFile(); procedure GetINIFile(); procedure SetUnit(MUnit: string); procedure InitCDPanel(); //ˢ�´õ�ѡ�� procedure InitCDGrid(MCIID: string); //ˢ�´õ�Ǽ���Ϣ procedure InitCDGridCX(MCIID: string); //ˢ�´õ��ѯ��Ϣ procedure InitJYGrid(); //ˢ�¼�����Ϣ function CheckData(CKType: string): Boolean; //У������ function SaveData(): Boolean; //�������� procedure InitLCK(MBCIOID: string); //ɨ�����̿� procedure InitBP(MBCIOID: string); //ɨ�貼Ʊ procedure InitHXK(MBCIOID: string); //ɨ����� procedure InitDyePlan(MBCIOID: string); //ɨ��Ⱦ���� procedure InitJTM(MCIID: string); //ɨ������� procedure SetDdetails(); procedure ClearGlobal(); //���ȫ��ID procedure PrtData(MCIID: string); //��ӡ����ǩ procedure PrtData2(MCIID: string); //��ӡ�����ǩ procedure QuantityConversion(); //�������� procedure InitImage(YFTPName: string); //ͼƬ procedure InitImageHX(HXSID: string); procedure LookImage(FileName: string); procedure OpenCom(DllName: string); //���� procedure CloseCom(DllName: string); //�رմ��� procedure On1201(var Message: Tmessage); message 1201; //���ӳ� procedure On1301(var Message: Tmessage); message 1301; //��� procedure Delay(msecs: integer); procedure PrtMD(MInNo: string); //��ӡ��ⵥ procedure PlayWav(MWav: string); public fmanage: string; fFlileFlag: string; TFLAG: Double; { Public declarations } end; var frmTradeMachInsp: TfrmTradeMachInsp; newh, newh1: hwnd; implementation uses U_DataLink, U_RTFun, U_ZDYHelp, U_iniParam; {$R *.dfm} procedure TfrmTradeMachInsp.PlayWav(MWav: string); begin if FileExists(PChar(ExtractFilePath(Application.ExeName) + 'wav\' + MWav + '.wav')) then PlaySound(PChar(ExtractFilePath(Application.ExeName) + 'wav\' + MWav + '.wav'), 0, SND_ASYNC); end; procedure TfrmTradeMachInsp.SetDdetails(); begin AOrdDefNote1.Text := ''; AOrdDefNote1.Text := AOrdDefNote1.Text + '���̿�:' + FBCIOID + #13; AOrdDefNote1.Text := AOrdDefNote1.Text + 'Ʒ��:' + FC_Name + #13; AOrdDefNote1.Text := AOrdDefNote1.Text + '�ŷ�:' + FC_Width + #13; AOrdDefNote1.Text := AOrdDefNote1.Text + '��������:' + FC_KnitGramWeight + #13; AOrdDefNote1.Text := AOrdDefNote1.Text + '��Ʒ����:' + FC_GramWeight + #13; AOrdDefNote1.Text := AOrdDefNote1.Text + '��ɫ:' + FC_Color + #13; AOrdDefNote1.Text := AOrdDefNote1.Text + '�ɷ�:' + FC_Composition + #13; AOrdDefNote1.Text := AOrdDefNote1.Text + '�Ứ:' + FC_Figure + #13; AOrdDefNote1.Text := AOrdDefNote1.Text + '��ɴ:' + FC_Yarn + #13; AOrdDefNote1.Text := AOrdDefNote1.Text + '�ϳ�ë��:' + FRuleBeforeTare + #13; AOrdDefNote1.Text := AOrdDefNote1.Text + '���ϳ�Ƥ��:' + FRuleLaterTare + #13; AOrdDefNote1.Text := AOrdDefNote1.Text + 'ҵ��Ա:' + FYWY + #13; AOrdDefNote1.Text := AOrdDefNote1.Text + '�ͻ�:' + FCUSTNAME + #13; end; procedure TfrmTradeMachInsp.Delay(msecs: integer); var FirstTickCount: longint; begin FirstTickCount := GetTickCount; repeat Application.ProcessMessages; until ((GetTickCount - FirstTickCount) >= Longint(msecs)); end; procedure TfrmTradeMachInsp.PrtMD(MInNo: string); var fPrintFile, FLBName: string; begin with ADOQueryPrint do begin Close; SQL.Clear; sql.Add(' EXEC P_Trade_Cloth_In_Prt11 '); SQL.Add(' @Filtration=''' + Trim(MInNo) + ''''); Open; end; FLBName := '��̨������ⵥ'; ExportFtErpFile(FLBName + '.rmf', ADOTmp); fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\' + FLBName + '.rmf'; if FileExists(fPrintFile) then begin RM1.LoadFromFile(fPrintFile); RM1.DefaultCopies := strtointdef(trim(ComboBox1.Text), 1); RM1.PrintReport; end else begin Application.MessageBox(PChar('û����' + fPrintFile), '��ʾ', 0); end; end; procedure TfrmTradeMachInsp.SetINIFile(); begin if edtChen.Text = '��' then IsDZCDYDll := '1' else IsDZCDYDll := '0'; if edtMaBiao.Text = '��' then IsMBDYDll := '1' else IsMBDYDll := '0'; if edtMBDW.Text = '��' then IsMBDYDllUnit := '1' else IsMBDYDllUnit := '0'; LabQty := ComboBox1.Text; FMinLen := MinLen.Text; FMaxLen := MaxLen.Text; FMinWeight := MinWeight.Text; FMaxWeight := MaxWeight.Text; FMPlace := MPlace.Text; FYPlace := YPlace.Text; FKgPlace := KgPlace.Text; WriteINIFile(); end; procedure TfrmTradeMachInsp.GetINIFile(); begin if IsDZCDYDll = '1' then edtChen.Text := '��' else edtChen.Text := ''; if IsMBDYDll = '1' then edtMaBiao.Text := '��' else edtMaBiao.Text := ''; if IsMBDYDllUnit = '1' then edtMBDW.Text := '��' else edtMBDW.Text := ''; ComboBox1.ItemIndex := ComboBox1.Items.IndexOf(trim(LabQty)); MinLen.Text := FMinLen; MaxLen.Text := FMaxLen; MinWeight.Text := FMinWeight; MaxWeight.Text := FMaxWeight; MPlace.Text := FMPlace; YPlace.Text := FYPlace; KgPlace.Text := FKgPlace; end; procedure TfrmTradeMachInsp.SetUnit(MUnit: string); begin lblLenUnit.Caption := MUnit; lblLenUnit1.Caption := MUnit; end; procedure TfrmTradeMachInsp.InitImage(YFTPName: string); begin // with ADOQueryImage do // begin // close; // sql.Clear; // sql.Add('select * from TC_File A'); // sql.Add('where isnull(WBID,'''')<>'''' and WBID=' + quotedstr(YFTPName)); //// showmessage(sql.text); // open; // end; end; procedure TfrmTradeMachInsp.InitImageHX(HXSID: string); begin // with Qry_ImgHX do // begin // close; // sql.Clear; // sql.Add('select * from TC_File A'); // sql.Add('where isnull(WBID,'''')<>'''' and WBID=' + quotedstr(HXSID)); //// ShowMessage(SQL.Text); // open; // end; end; procedure TfrmTradeMachInsp.QuantityConversion(); begin if lblRuleConversion.Caption = '��ת����' then begin InputWeight.Text := floattostr(StrToFloatdef(trim(InputLen.Text), 0) * StrToFloatdef(trim(Coefficient.Text), 0) + StrToFloatdef(FRuleBeforeTare, 0)); end; if lblRuleConversion.Caption = 'ë��ת��' then begin InputLen.Text := floattostr((StrToFloatdef(trim(InputWeight.Text), 0) + StrToFloatdef(FRuleLaterTare, 0)) * StrToFloatdef(trim(Coefficient.Text), 0)); end; if lblRuleConversion.Caption = '����ת��' then begin InputLen.Text := floattostr((RoundFloat(StrToFloatdef(trim(InputWeight.Text), 0), 1) - StrToFloatdef(FRuleBeforeTare, 0)) * StrToFloatdef(trim(Coefficient.Text), 0)); end; if (InputLen.text <> '0') and (InputLen.text <> '0.0') and (InputLen.text <> '0.00') and (InputLen.text <> '') and (StrToFloatdef(InputLen.text, 0) > 10) then begin MaxQty.Caption := InputLen.text; end; end; function TfrmTradeMachInsp.CheckData(CKType: string): Boolean; var mvalue: Double; begin try if Trim(FBCIOID) = '' then raise Exception.Create('�����ظ��ύ��'); if Trim(CKType) = '�ύ' then begin with ADOTmp do begin Close; sql.Clear; SQL.Add('select * from Trade_Cloth_Inspect where BCIOID not like ''%MR%'' and BCIOID=''' + Trim(FBCIOID) + ''''); Open; end; // if ADOTmp.IsEmpty = false then // begin // if Application.MessageBox('�ò�Ʊ�ѱ�������Ƿ�Ҫ�ٴα��棿', '��ʾ', 32 + 4) <> IDYES then // begin // Result := false; // exit; // end; // end; if (StrToIntDef(PieceNo.Text, 0) = 0) and (ComboBox2.Text = '�ֶ�') then raise Exception.Create('���Ų���Ϊ��!'); if trim(lblLenUnit.Caption) = '' then raise Exception.Create('���ȵ�λ����Ϊ��!'); if Trim(InputWeight.Text) <> '' then begin if TryStrToFloat(InputWeight.Text, mvalue) = False then raise Exception.Create('����¼�����!'); if strtofloatdef(trim(InputWeight.Text), 0) < Strtofloatdef(MinWeight.Text, 0) then raise Exception.Create('��������С��' + MinWeight.Text + '!'); if strtofloatdef(trim(InputWeight.Text), 0) > Strtofloatdef(MaxWeight.Text, 0) then raise Exception.Create('�������ܴ���' + MaxWeight.Text + '!'); end; if Trim(MaxQty.Caption) <> '' then begin if TryStrToFloat(MaxQty.Caption, mvalue) = False then raise Exception.Create('����¼�����!'); if strtofloatdef(trim(MaxQty.Caption), 0) < Strtofloatdef(MinLen.Text, 0) then raise Exception.Create('���Ȳ���С��' + MinLen.Text + '��!'); if strtofloatdef(trim(MaxQty.Caption), 0) > Strtofloatdef(MaxLen.Text, 0) then raise Exception.Create('���Ȳ��ܴ���' + MaxLen.Text + '��!'); end; if (strtofloatdef(trim(InputLen.Text), 0) = 0) and (strtofloatdef(trim(InputWeight.Text), 0) = 0) then raise Exception.Create('���Ⱥ��������ܶ�Ϊ0!!'); end; Result := True; except Result := false; application.MessageBox(PChar(Exception(ExceptObject).Message), '��ʾ��Ϣ', 0); end; end; procedure TfrmTradeMachInsp.ClearGlobal(); begin FBCIOID := ''; FOrderNo := ''; FConNo := ''; FConMId := ''; FConSId := ''; FMainId := ''; FSubId := ''; FDyeNo := ''; FDRMID := ''; FDRSID := ''; FPCId := ''; FC_CustPattern := ''; FC_ColorDepth := ''; FFtyPCId := ''; FGangNo := ''; FC_Code := ''; FC_Name := ''; FBatchNO := ''; FC_Spec := ''; FLoom := ''; FC_Color := ''; FC_ColorNo := ''; FC_StyleNo := ''; FC_Composition := ''; FC_Width := ''; FC_KnitGramWeight := ''; FC_Figure := ''; FC_Yarn := ''; FC_GramWeight := ''; FC_Pattern := ''; FCIID := ''; FWorkshop := ''; InputLen.Text := ''; // MaxQty.Caption := ''; Coefficient.Text := ''; AOrdDefNote1.Text := ''; Tare.Text := ''; InputWeight.Text := ''; FLenUnit := ''; FRuleBeforeTare := ''; FRuleLaterTare := ''; end; procedure TfrmTradeMachInsp.LookImage(FileName: string); var sFieldName: string; begin sFieldName := leftbstr(ExtractFilePath(Application.ExeName), 1) + ':\ͼƬ�鿴'; if not DirectoryExists(pchar(sFieldName)) then CreateDirectory(pchar(sFieldName), nil); sFieldName := sFieldName + '\' + trim(FileName); try IdFTP1.Host := ReadINIFileStr('SYSTEMSET.INI', 'SERVER', '��������ַ', '127.0.0.1'); IdFTP1.Username := 'three'; IdFTP1.Password := '641010'; IdFTP1.Connect(); except ; end; if IdFTP1.Connected then begin try IdFTP1.Get(fFlileFlag + '\' + Trim(FileName), sFieldName, true, false); except Application.MessageBox('�ͻ�ͼ���ļ�������', '��ʾ', MB_ICONWARNING); IdFTP1.Quit; Exit; end; end else begin Application.MessageBox('�������ļ�������', '��ʾ', MB_ICONWARNING); IdFTP1.Quit; Exit; end; if IdFTP1.Connected then IdFTP1.Quit; ShellExecute(Handle, 'open', PChar(sFieldName), '', '', SW_SHOWNORMAL); end; procedure TfrmTradeMachInsp.Pic_Image1DblClick(Sender: TObject); begin if TcxDBImage(Sender).Picture.Height = 0 then exit; LookImage(ADOQueryImage.fieldbyname(TcxDBImage(Sender).Hint).asstring); end; procedure TfrmTradeMachInsp.InitDyePlan(MBCIOID: string); begin end; procedure TfrmTradeMachInsp.InitLCK(MBCIOID: string); begin with ADOTmp do begin Close; sql.Clear; sql.Add(' select G.LCKID,isnull(F.LabName,''�κƱ�ǩ'') AS LabVolume, isnull(RuleConversion,''����ת��'') AS RuleConversion, Isnull(RulePieceNo,''������������'') AS RulePieceNo,isnull(RuleLenUnit,''M'') AS RuleLenUnit '); sql.Add(' ,YWY=(select Saleser from BS_Contract_Main X where X.ConNo=C.ConNo) '); sql.Add(' ,A.*,B.*,C.*,E.*,F.* from PB_LCK A '); sql.Add(' inner JOIN Knit_Plan_Main B on A.MainId = B.MainId '); sql.Add(' INNER JOIN Knit_Plan_Sub C on B.MainId = C.MainId '); sql.Add(' left JOIN Trade_Cloth_Inspect_Rule E on B.MainId =E.RuleID '); sql.Add(' left JOIN BS_Contract_Sub F on C.ConSID =F.ConSID '); sql.add(' INNER JOIN PB_CK_LCK G on G.LCKID = A.LCKID '); sql.Add(' where A.LCKID = ''' + Trim(MBCIOID) + ''''); // ShowMessage(sql.Text); Open; end; if ADOTmp.IsEmpty then begin Application.MessageBox('���̿������ڣ�', '��ʾ', 0); edtScan.Text := ''; end else begin // if Trim(ADOTmp.fieldbyname('status').AsString) = '0' then // begin // if Application.MessageBox('����δ���飬�Ƿ�Ҫֱ�ӽ��г�Ʒ���飿', '��ʾ', 32 + 4) <> IDYES then // begin // edtScan.Text := ''; // Exit; // end; // end; FBCIOID := Trim(MBCIOID); FLCKID := Trim(MBCIOID); FLenUnit := Trim(ADOTmp.fieldbyname('RuleLenUnit').AsString); FCUSTNAME := Trim(ADOTmp.fieldbyname('CUSTNAME').AsString); // SetUnit(FLenUnit); FConMId := Trim(ADOTmp.fieldbyname('ConMId').AsString); FConSId := Trim(ADOTmp.fieldbyname('ConSId').AsString); FConNo := Trim(ADOTmp.fieldbyname('ConNo').AsString); FOrderNo := Trim(ADOTmp.fieldbyname('OrderNo').AsString); FMainId := Trim(ADOTmp.fieldbyname('MainId').AsString); FSubId := Trim(ADOTmp.fieldbyname('SubId').AsString); //FPCId := Trim(ADOTmp.fieldbyname('PCID').AsString); FC_Code := Trim(ADOTmp.fieldbyname('C_Code').AsString); FC_Name := Trim(ADOTmp.fieldbyname('C_Name').AsString); //FBatchNO := Trim(ADOTmp.fieldbyname('BatchNO').AsString); FC_Spec := Trim(ADOTmp.fieldbyname('C_Spec').AsString); FC_Color := Trim(ADOTmp.fieldbyname('C_Color').AsString); FC_KnitGramWeight := Trim(ADOTmp.fieldbyname('C_KnitGramWeight').AsString); FC_Figure := Trim(ADOTmp.fieldbyname('C_Figure').AsString); FC_Yarn := Trim(ADOTmp.fieldbyname('C_Yarn').AsString); FC_Composition := Trim(ADOTmp.fieldbyname('C_Composition').AsString); // FLoom := Trim(ADOTmp.fieldbyname('Loom').AsString); FC_Width := Trim(ADOTmp.fieldbyname('C_Width').AsString); FC_GramWeight := Trim(ADOTmp.fieldbyname('C_GramWeight').AsString); FRulePieceNo := Trim(ADOTmp.fieldbyname('RulePieceNo').AsString); //�������ɹ��� FYWY := Trim(ADOTmp.fieldbyname('YWY').AsString); //ҵ��Ա if FRulePieceNo = '�ֶ�����' then begin ComboBox2.ItemIndex := 1; Label32.Visible := True; PieceNo.Visible := True; end; Coefficient.Text := Trim(ADOTmp.fieldbyname('Coefficient').AsString); //ϵ�� lblRuleConversion.Caption := Trim(ADOTmp.fieldbyname('RuleConversion').AsString); //ת������ OrderNo.Text := FOrderNo; BCIOID.Text := MBCIOID; //BatchNO.text := FBatchNO; Width.text := FC_Width; GramWeight.text := FC_GramWeight; Composition.text := FC_Composition; CodeName.text := FC_Name; Color.text := FC_Color; PCID.Text := ''; Tare.Text := ADOTmp.fieldbyname('RuleLaterTare').AsString; // Ƥ�أ����ϳƣ� FRuleBeforeTare := ADOTmp.fieldbyname('RuleBeforeTare').AsString; // Ƥ�أ��ϳƣ� FRuleLaterTare := ADOTmp.fieldbyname('RuleLaterTare').AsString; // Ƥ�أ����ϳƣ� InputLen.SetFocus; CIFBegClick(InputLen); SetDdetails(); FRulePieceNo := '��������'; end; InitJYGrid(); InitCDGrid(FCIID); edtScan.Text := ''; edtScan.SetFocus; edtScan.OnClick(edtScan); end; procedure TfrmTradeMachInsp.InitHXK(MBCIOID: string); begin with ADOTmp do begin Close; sql.Clear; sql.Add(' select isnull(B.LabName,''�κƱ�ǩ'') AS LabVolume, RuleConversion=''����ת��'', RulePieceNo=''����������'' , RuleLenUnit =''M'' '); sql.Add(' ,YWY=(select Saleser from BS_Contract_Main X where X.ConNo=A.ConNo) '); sql.Add(' ,A.* from BS_Cloth_IO A '); sql.Add(' INNER JOIN BS_Contract_Sub B on A.ConSID=B.ConSId '); sql.Add(' where A.BCIOID = ''' + Trim(MBCIOID) + ''''); // ShowMessage(sql.Text); Open; end; if ADOTmp.IsEmpty then begin Application.MessageBox('����������', '��ʾ', 0); edtScan.Text := ''; end else begin FBCIOID := Trim(MBCIOID); FLenUnit := Trim(ADOTmp.fieldbyname('RuleLenUnit').AsString); SetUnit(FLenUnit); FConMId := Trim(ADOTmp.fieldbyname('ConMId').AsString); FConSId := Trim(ADOTmp.fieldbyname('ConSId').AsString); FConNo := Trim(ADOTmp.fieldbyname('ConNo').AsString); FOrderNo := ''; FMainId := ''; FSubId := ''; FPCId := Trim(ADOTmp.fieldbyname('BCIOID').AsString); FC_Code := Trim(ADOTmp.fieldbyname('C_Code').AsString); FC_Name := Trim(ADOTmp.fieldbyname('C_Name').AsString); FBatchNO := ''; FC_Spec := Trim(ADOTmp.fieldbyname('C_Spec').AsString); FC_Color := Trim(ADOTmp.fieldbyname('C_Color').AsString); FC_KnitGramWeight := Trim(ADOTmp.fieldbyname('C_KnitGramWeight').AsString); FC_Figure := Trim(ADOTmp.fieldbyname('C_Figure').AsString); FC_Yarn := Trim(ADOTmp.fieldbyname('C_Yarn').AsString); FC_Composition := Trim(ADOTmp.fieldbyname('C_Composition').AsString); FLoom := ''; FC_Width := Trim(ADOTmp.fieldbyname('C_Width').AsString); FC_GramWeight := Trim(ADOTmp.fieldbyname('C_GramWeight').AsString); FRulePieceNo := Trim(ADOTmp.fieldbyname('RulePieceNo').AsString); //�������ɹ��� FYWY := Trim(ADOTmp.fieldbyname('YWY').AsString); //ҵ��Ա if FRulePieceNo = '�ֶ�����' then begin ComboBox2.ItemIndex := 1; Label32.Visible := True; PieceNo.Visible := True; end; Coefficient.Text := ''; //ϵ�� lblRuleConversion.Caption := Trim(ADOTmp.fieldbyname('RuleConversion').AsString); //ת������ OrderNo.Text := FOrderNo; BCIOID.Text := FBCIOID; //BatchNO.text := FBatchNO; Width.text := FC_Width; GramWeight.text := FC_GramWeight; Composition.text := FC_Composition; CodeName.text := FC_Name; Color.text := FC_Color; Tare.Text := ''; // Ƥ�أ����ϳƣ� FRuleBeforeTare := ''; // Ƥ�أ��ϳƣ� FRuleLaterTare := ''; // Ƥ�أ����ϳƣ� InputLen.SetFocus; CIFBegClick(InputLen); SetDdetails(); end; InitJYGrid(); InitCDGrid(FCIID); edtScan.Text := ''; edtScan.SetFocus; edtScan.OnClick(edtScan); end; procedure TfrmTradeMachInsp.InitBP(MBCIOID: string); begin with ADOTmp do begin Close; sql.Clear; sql.Add(' select * from Trade_Cloth_Inspect A '); sql.Add(' where A.PCID = ''' + Trim(MBCIOID) + ''''); Open; end; if ADOTmp.IsEmpty = false then begin // if Application.MessageBox('�ò�Ʊ�Ѽ���,�Ƿ����', '��ʾ', 32 + 4) <> IDYES then // begin // edtScan.Text := ''; // ClearGlobal(); // Exit; // end; Application.MessageBox('�Ѽ���', '��ʾ', 0); edtScan.Text := ''; ClearGlobal(); exit; end; with ADOTmp do begin Close; sql.Clear; sql.Add(' select isnull(E.LabVolume,''Ĭ�ϱ�ǩ'') AS LabVolume, isnull(RuleConversion,''����ת��'') AS RuleConversion, Isnull(RulePieceNo,''������������'') AS RulePieceNo,isnull(RuleLenUnit,''M'') AS RuleLenUnit '); sql.Add(' ,YWY=(select Saleser from BS_Contract_Main X where X.ConNo=D.ConNo) '); sql.Add(' ,A.status, LengthNumber=1,C.*,D.*,E.* ,A.*,B.* from Knit_Plan_Card A '); sql.Add(' left JOIN Knit_Cloth_Stock B on A.PCID =B.StkID '); sql.Add(' INNER JOIN Knit_Plan_Main C on A.MainId =C.MainId '); sql.Add(' INNER JOIN Knit_Plan_Sub D on C.MainId =D.MainId '); sql.Add(' left JOIN Trade_Cloth_Inspect_Rule E on C.MainId =E.RuleID '); // sql.Add(' INNER JOIN BS_Contract_Sub F on D.ConSID =F.ConSID '); sql.Add(' where A.PCID = ''' + Trim(MBCIOID) + ''''); //ShowMessage(sql.Text); Open; end; if Trim(ADOTmp.fieldbyname('status').AsString) = '-1' then begin Application.MessageBox('��Ʊ��ɾ��', '��ʾ', 0); edtScan.Text := ''; end else begin if Trim(ADOTmp.fieldbyname('status').AsString) = '0' then begin if Application.MessageBox('����δ���飬�Ƿ�Ҫֱ�ӽ��г�Ʒ���飿', '��ʾ', 32 + 4) <> IDYES then begin edtScan.Text := ''; Exit; end; end; FBCIOID := Trim(MBCIOID); FLenUnit := 'M'; //Trim(ADOTmp.fieldbyname('RuleLenUnit').AsString); SetUnit(FLenUnit); //FLCKID := Trim(ADOTmp.fieldbyname('LCKID').AsString); FConMId := Trim(ADOTmp.fieldbyname('ConMId').AsString); FConSId := Trim(ADOTmp.fieldbyname('ConSId').AsString); FConNo := Trim(ADOTmp.fieldbyname('ConNo').AsString); FOrderNo := Trim(ADOTmp.fieldbyname('OrderNo').AsString); FMainId := Trim(ADOTmp.fieldbyname('MainId').AsString); FSubId := Trim(ADOTmp.fieldbyname('SubId').AsString); FPCId := Trim(ADOTmp.fieldbyname('PCID').AsString); FC_Code := Trim(ADOTmp.fieldbyname('C_Code').AsString); FC_Name := Trim(ADOTmp.fieldbyname('C_Name').AsString); FBatchNO := Trim(ADOTmp.fieldbyname('BatchNO').AsString); FC_Spec := Trim(ADOTmp.fieldbyname('C_Spec').AsString); FC_Color := Trim(ADOTmp.fieldbyname('C_Color').AsString); FC_KnitGramWeight := Trim(ADOTmp.fieldbyname('C_KnitGramWeight').AsString); FC_Figure := Trim(ADOTmp.fieldbyname('C_Figure').AsString); FC_Yarn := Trim(ADOTmp.fieldbyname('C_Yarn').AsString); FC_Composition := Trim(ADOTmp.fieldbyname('C_Composition').AsString); FLoom := Trim(ADOTmp.fieldbyname('Loom').AsString); FC_Width := Trim(ADOTmp.fieldbyname('C_Width').AsString); FC_GramWeight := Trim(ADOTmp.fieldbyname('C_GramWeight').AsString); FRulePieceNo := Trim(ADOTmp.fieldbyname('RulePieceNo').AsString); //�������ɹ��� FYWY := Trim(ADOTmp.fieldbyname('YWY').AsString); //ҵ��Ա if FRulePieceNo = '�ֶ�����' then begin ComboBox2.ItemIndex := 1; Label32.Visible := True; PieceNo.Visible := True; end; Coefficient.Text := Trim(ADOTmp.fieldbyname('Coefficient').AsString); //ϵ�� lblRuleConversion.Caption := Trim(ADOTmp.fieldbyname('RuleConversion').AsString); //ת������ OrderNo.Text := FOrderNo; BCIOID.Text := FLCKID; PCID.Text := MBCIOID; //BatchNO.text := FBatchNO; Width.text := FC_Width; GramWeight.text := FC_GramWeight; Composition.text := FC_Composition; CodeName.text := FC_Name; Color.text := FC_Color; // DelQty.text := Trim(ADOTmp.fieldbyname('DelMeter').AsString); MPlace.Text := Trim(ADOTmp.fieldbyname('LengthNumber').AsString); Tare.Text := ADOTmp.fieldbyname('RuleLaterTare').AsString; // Ƥ�أ����ϳƣ� FRuleBeforeTare := ADOTmp.fieldbyname('RuleBeforeTare').AsString; // Ƥ�أ��ϳƣ� FRuleLaterTare := ADOTmp.fieldbyname('RuleLaterTare').AsString; // Ƥ�أ����ϳƣ� InputLen.SetFocus; CIFBegClick(InputLen); SetDdetails(); FRulePieceNo := '��������'; end; PlayWav('ɨ��ɹ�'); InitJYGrid(); InitCDGrid(FCIID); edtScan.Text := ''; edtScan.SetFocus; edtScan.OnClick(edtScan); end; procedure TfrmTradeMachInsp.InputLenChange(Sender: TObject); begin QuantityConversion(); // if StrToFloatDef(InputLen.Text, 0) > 5 then // begin // TFLAG := 1; // end; end; procedure TfrmTradeMachInsp.InputWeightChange(Sender: TObject); begin QuantityConversion(); end; procedure TfrmTradeMachInsp.InitJTM(MCIID: string); begin with ADOTmp do begin Close; sql.Clear; sql.Add('select * from Trade_Cloth_IO where StkId=''' + Trim(MCIID) + ''' and IOFlag=''���'''); Open; end; if not ADOTmp.IsEmpty then begin Application.MessageBox('�Ѳ���������ݲ��ܲ���!', '��ʾ', 0); Exit; end; with ADOTmp do begin Close; sql.Clear; sql.Add('select * from Trade_Cloth_IO where StkId=''' + Trim(MCIID) + ''' and IOFlag=''����'''); Open; end; if not ADOTmp.IsEmpty then begin Application.MessageBox('�Ѳ����������ݲ��ܲ���!', '��ʾ', 0); Exit; end; with ADOTmp do begin Close; sql.Clear; sql.Add('select * from Trade_Cloth_Inspect where CIID=''' + Trim(MCIID) + ''''); Open; end; if not ADOTmp.IsEmpty then begin FOperationStatus := '������'; FCIID := MCIID; InitCDGrid(MCIID); end; end; procedure TfrmTradeMachInsp.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('�Ҳ��� ' + trim(DllName) + ' �ļ���'), '��ʾ'); end; end; procedure TfrmTradeMachInsp.ComboBox2Change(Sender: TObject); begin if ComboBox2.ItemIndex = 0 then begin PieceNo.Text := ''; Label32.Visible := False; PieceNo.Visible := False; end; if ComboBox2.ItemIndex = 1 then begin Label32.Visible := True; PieceNo.Visible := True; end; end; procedure TfrmTradeMachInsp.OpenCom(DllName: string); type TMyFunc = function(fhandle: hwnd; sCommName: PAnsiChar; IntTime: integer; IsMessage: integer): HWND; stdcall; var Tf: TMyFunc; Tp: TFarProc; Th: Thandle; begin // closeCom(FComFile); 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('����ʧ�ܣ�'), '��ʾ'); end else IsCommOpen := true; end else begin IsCommOpen := false; end; finally // FreeLibrary(Th); end; end else begin IsCommOpen := false; application.MessageBox(Pchar('�Ҳ��� ' + trim(DllName) + ' �ļ���'), '��ʾ'); end; end; procedure TfrmTradeMachInsp.FormDestroy(Sender: TObject); begin inherited; frmTradeMachInsp := nil; end; procedure TfrmTradeMachInsp.On1301(var Message: Tmessage); var i1, i2: integer; unitname: string; fdata: double; begin i1 := Message.WParam; i2 := Message.LParam; if (trim(edtMaBiao.Text) = '��') then begin if (i1 = 0) and (strToFloatdef(InputLen.Text, 0) > 10) then begin edit2.Text := InputLen.Text; // exit; end; InputLen.Text := format('%.2f', [i1 / 100000]); if edtMBDW.Text = '��' then begin if i2 = 0 then begin SetUnit('M'); end else begin SetUnit('Y'); end; end; end; end; procedure TfrmTradeMachInsp.On1201(var Message: Tmessage); var i1, i2: integer; unitname: string; fdata: double; begin i1 := Message.WParam; i2 := Message.LParam; if trim(edtChen.Text) = '��' then begin InputWeight.Text := format('%.2f', [i1 / 100000]); end; end; procedure TfrmTradeMachInsp.FormClose(Sender: TObject; var Action: TCloseAction); begin inherited; if isCommopen then begin closeCom(DZCDYDllName); closeCom(MBDYDllName); end; Action := caFree; end; procedure TfrmTradeMachInsp.InitCDGrid(MCIID: string); begin cxPageControl1.ActivePageIndex := 0; with ADOTmp do begin Close; SQL.Clear; sql.Add('select * from Trade_Cloth_Inspect_Flaw where CIID=' + quotedstr(Trim(MCIID))); Open; end; SCreateCDS(ADOTmp, CDS_2); SInitCDSData(ADOTmp, CDS_2); end; procedure TfrmTradeMachInsp.InitCDGridCX(MCIID: string); begin cxPageControl1.ActivePageIndex := 1; with ADOTmp do begin Close; SQL.Clear; sql.Add('select * from Trade_Cloth_Inspect_Flaw where CIID=' + quotedstr(Trim(MCIID))); Open; end; SCreateCDS(ADOTmp, CDS_1); SInitCDSData(ADOTmp, CDS_1); end; procedure TfrmTradeMachInsp.InitJYGrid(); var MNetWeight, MJYLen: double; begin with ADOQueryMain do begin Close; SQL.Clear; sql.Add('select A.*'); sql.Add('from Trade_Cloth_Inspect A where Filler=''' + Trim(DName) + ''''); sql.Add('and CONVERT(VARCHAR(10),A.FillTime,120) =CONVERT(VARCHAR(10),getdate(),120) '); // sql.Add('from Trade_Cloth_Inspect A where BCIOID=''' + Trim(FBCIOID) + ''''); sql.Add('order by A.filltime desc'); Open; end; SCreateCDS(ADOQueryMain, CDS_3); SInitCDSData(ADOQueryMain, CDS_3); end; procedure TfrmTradeMachInsp.FormShow(Sender: TObject); begin inherited; ReadCxGrid(trim(Self.Caption) + 'Tv1', Tv1, 'ó�������'); ReadCxGrid(trim(Self.Caption) + 'Tv2', Tv2, 'ó�������'); ReadCxGrid(trim(Self.Caption) + 'Tv3', Tv3, 'ó�������'); fFlileFlag := UserDataFlag + 'HX'; InitCDPanel(); InitCDGrid(FCIID); TFLAG := 0; if IsINIFile() then ReadINIFile() else WriteINIFile; GetINIFile(); if trim(fmanage) <> '��Ȩ��' then begin if trim(DZCDYDllName) <> '' then OpenCom(DZCDYDllName); if trim(MBDYDllName) <> '' then OpenCom(MBDYDllName); edtScan.SetFocus; end; end; procedure TfrmTradeMachInsp.InitCDPanel(); var AA: array[0..100] of string; i, j: Integer; begin with ADOTmp do begin Close; sql.Clear; sql.Add('select ZDYName from KH_Zdy where Type=''WFBCD2'' order by ZDYNO '); Open; end; if ADOTmp.IsEmpty then begin Application.MessageBox('û�ж���õ㣡', '��ʾ', 0); Exit; end; with ADOTmp do begin First; i := 0; while not Eof do begin AA[i] := Trim(fieldbyname('ZDYName').AsString); i := i + 1; Next; end; end; i := i - 1; if i > 69 then begin i := 69; end; for j := 0 to i do begin with ScrollBox1 do begin TSpeedButton(Controls[j]).Visible := True; TSpeedButton(Controls[j]).Hint := AA[j]; if Length(AA[j]) > 2 then begin TSpeedButton(Controls[j]).Caption := Copy(Trim(AA[j]), 1, 2) + #13 + Copy(Trim(AA[j]), 3, Length(AA[j]) - 2); end else TSpeedButton(Controls[j]).Caption := AA[j]; end; end; end; procedure TfrmTradeMachInsp.Tv2CellDblClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean); begin if CDS_2.IsEmpty then Exit; // if FOperationStatus = '������' then // Exit; if Application.MessageBox('ȷ��Ҫɾ��������', '��ʾ', 32 + 4) <> IDYES then Exit; if Trim(CDS_2.fieldbyname('CIFID').AsString) = '' then begin CDS_2.Delete; end else begin with ADOCmd do begin Close; SQL.Clear; // sql.Add('insert ZDel_Trade_Cloth_Inspect_Flaw into select * from Trade_Cloth_Inspect_Flaw where CIFID=''' + Trim(CDS_2.fieldbyname('CIFID').AsString) + ''''); sql.Add('delete Trade_Cloth_Inspect_Flaw where CIFID=''' + Trim(CDS_2.fieldbyname('CIFID').AsString) + ''''); ExecSQL; end; //���´õ���Ϣ with ADOCmd do begin Close; sql.Clear; sql.Add('exec C_JY_UC_CDList @CIID=''' + Trim(CDS_2.fieldbyname('CIID').AsString) + ''''); execsql; end; CDS_2.Delete; end; end; procedure TfrmTradeMachInsp.Tv3CustomDrawCell(Sender: TcxCustomGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean); begin if AViewInfo.GridRecord.Values[TcxGridDBTableView(Sender).GetColumnByFieldName('Grade').Index] = '��Ʒ' then ACanvas.Brush.Color := clRed; end; procedure TfrmTradeMachInsp.Tv3MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin if CDS_3.isEmpty then exit; InitCDGridCX(CDS_3.FieldByName('CIID').AsString); end; function TfrmTradeMachInsp.SaveData(): Boolean; var maxno, MCIID, BZID, strsql: string; MInputLen, MMeter, MYardage, MDelQty: Double; MInputWeight, MGrossWeight, MNetWeight, MTare, MRuleBeforeTare, MRuleLaterTare: Double; begin if FOperationStatus = '������' then begin MCIID := FCIID; end else begin MCIID := ''; end; try ADOCmd.Connection.BeginTrans; ///�������� with ADOCmd do begin Close; sql.Clear; SQL.Add('select * from Trade_Cloth_Inspect where CIID=''' + Trim(MCIID) + ''''); Open; end; with ADOCmd do begin if Trim(MCIID) = '' then begin if not GetLSNo(ADOTmp, maxno, Trim(SCXFlag), 'Trade_Cloth_Inspect', 4, 1) then raise Exception.Create('��ȡ����ʧ�ܣ�'); Append; FieldByName('Filler').Value := Trim(DName); FieldByName('CIID').Value := Trim(maxno); end else begin maxno := Trim(MCIID); Edit; FieldByName('Editer').Value := Trim(DName); FieldByName('EditTime').Value := SGetServerDateTime(ADOTmp); end; FieldByName('Coefficient').Value := StrToFloatdef(trim(Coefficient.Text), 0); //ϵ�� ///////////////////////// �������� ///////////////////////// MRuleBeforeTare := StrToFloatdef(FRuleBeforeTare, 0); MRuleLaterTare := StrToFloatdef(FRuleLaterTare, 0); MTare := MRuleBeforeTare + MRuleLaterTare; //Ƥ�� MInputWeight := RoundFloat(StrToFloatdef(trim(InputWeight.Text), 0), StrTointdef(KgPlace.Text, 0)); //ë�� MGrossWeight := MInputWeight + MRuleLaterTare; //ë�� MNetWeight := MInputWeight - MRuleBeforeTare; //���� FieldByName('InputWeight').Value := MInputWeight; FieldByName('GrossWeight').Value := MGrossWeight; FieldByName('NetWeight').Value := MNetWeight; FieldByName('Tare').Value := MTare; ///////////////////////// �������� ///////////////////////// /// ///////////////////////// ���泤�� ///////////////////////// MInputLen := RoundFloat(StrToFloatdef(trim(InputLen.text), 0), 2); MDelQty := RoundFloat(StrToFloatdef(trim(DelQty.text), 0), 2); if lblLenUnit.Caption = 'M' then begin MMeter := RoundFloat(StrToFloatdef(trim(MaxQty.Caption), 0) - MDelQty, StrTointdef(MPlace.Text, 0)); MYardage := RoundFloat(MMeter / 0.9144, StrTointdef(YPlace.Text, 0)); end else begin MYardage := RoundFloat(StrToFloatdef(trim(MaxQty.Caption), 0) - MDelQty, StrTointdef(YPlace.Text, 0)); MMeter := RoundFloat(MYardage * 0.9144, StrTointdef(MPlace.Text, 0)); end; FieldByName('InputLen').Value := MInputLen; FieldByName('Meter').Value := MMeter; FieldByName('Yardage').Value := MYardage; FieldByName('DelQty').Value := MDelQty; FieldByName('LenUnit').Value := TRIM(lblLenUnit.Caption); ///////////////////////// ���泤�� ///////////////////////// if Trim(Edit3.Text) <> '' then begin FieldByName('Grade').Value := '��Ʒ'; end; if Trim(Edit4.Text) <> '' then begin FieldByName('Grade').Value := '����'; end; if Trim(Edit5.Text) <> '' then begin FieldByName('Grade').Value := '����'; end; if FOperationStatus <> '������' then begin FieldByName('PieceNo').Value := 0; end; //�ֶ����� if FRulePieceNo = '�ֶ�����' then begin FieldByName('PieceNo').Value := StrToInt(PieceNo.Text); end; FieldByName('OrderNo').value := Trim(FOrderNo); FieldByName('MainId').value := Trim(FMainId); FieldByName('SubId').value := Trim(FSubId); FieldByName('ConNo').value := Trim(FConNo); FieldByName('ConMId').value := Trim(FConMId); FieldByName('ConSId').value := Trim(FConSId); FieldByName('FromDRMID').value := Trim(FDRMID); FieldByName('FromDRSID').value := Trim(FDRSID); FieldByName('DyeNo').value := Trim(FDyeNo); FieldByName('BCIOID').value := Trim(BCIOID.Text); FieldByName('PCID').value := Trim(PCID.Text); if (trim(Edit4.Text) = '��') or (trim(edt1.Text) = '��') then begin FieldByName('CIIOFlag').Value := 'δ���'; end else begin FieldByName('CIIOFlag').Value := '�����'; end; FieldByName('FtyPCId').value := FtyPCId.text; FieldByName('C_Code').value := FC_Code; FieldByName('C_Name').value := FC_Name; //FieldByName('BatchNO').value := BatchNO.text; FieldByName('C_Spec').value := FC_Spec; FieldByName('C_Color').value := FC_Color; FieldByName('C_Composition').value := FC_Composition; //FieldByName('Loom').value := FLoom; FieldByName('C_Width').value := FC_Width; FieldByName('C_KnitGramWeight').value := FC_KnitGramWeight; FieldByName('C_Figure').value := FC_Figure; FieldByName('C_Yarn').value := FC_Yarn; FieldByName('C_GramWeight').value := FC_GramWeight; FieldByName('CIMachNo').Value := Trim(SCXFlag); Post; end; MCIID := Trim(maxno); FCIID := Trim(maxno); ////////////////// ����õ���Ϣ ////////////////// with CDS_2 do begin First; while not Eof do begin if Trim(CDS_2.fieldbyname('CIFID').AsString) = '' then begin if not GetLSNo(ADOTmp, maxno, 'JC', 'Trade_Cloth_Inspect_Flaw', 5, 1) then raise Exception.Create('��ȡ�õ�ʧ�ܣ�'); end else begin maxno := Trim(CDS_2.fieldbyname('CIFID').AsString); end; with ADOCmd do begin Close; SQL.Clear; sql.Add('select * from Trade_Cloth_Inspect_Flaw '); sql.Add(' where CIFID=''' + Trim(maxno) + ''''); Open; end; with ADOCmd do begin if Trim(CDS_2.fieldbyname('CIFID').AsString) = '' then Append else Edit; RTSetSaveDataCDS(ADOCmd, Tv2, CDS_2, 'Trade_Cloth_Inspect_Flaw', 0); FieldByName('CIID').Value := Trim(MCIID); FieldByName('CIFID').Value := Trim(maxno); Post; end; CDS_2.Edit; CDS_2.FieldByName('CIID').Value := Trim(MCIID); CDS_2.FieldByName('CIFID').Value := Trim(maxno); Next; end; end; ////////////////// ����õ���Ϣ ////////////////// /// ////////////////// ���¾��Ŵõ���Ϣ ////////////////// with ADOCmd do begin Close; sql.Clear; sql.Add('exec P_Trade_Insp_Up @CIID=''' + trim(MCIID) + ''''); if FOperationStatus = '������' then sql.Add(',@InspType=' + QuotedStr(FRulePieceNo)) else sql.Add(',@InspType=' + QuotedStr('������')); // ShowMessage(sql.text); execsql; end; ////////////////// ���¾��Ŵõ���Ϣ ////////////////// ////////////////// ���¿��� ////////////////// with ADOCmd do begin Close; sql.Clear; sql.Add('insert into Trade_Need_Up(UOperation,UType,UDataId) values(''����'',''��̨����'',' + quotedstr(maxno) + ') '); // ShowMessage(sql.text); execsql; end; ////////////////// ���¿��� ////////////////// ADOCmd.Connection.CommitTrans; ////////////////////// �����Զ����� /////////////////// // with ADOTmp do // begin // Close; // SQL.Clear; // sql.Add('select * from Knit_Cloth_Inspect '); // sql.Add(' where PCID=''' + Trim(FBCIOID) + ''''); // Open; // end; // if Trim(ADOTmp.fieldbyname('CIIOFlag').AsString) <> '�ѳ���' then // begin // with ADOCmd do // begin // Close; // sql.Clear; // Sql.Add('exec P_Knit_Cloth_AutoOut '); // Sql.Add(' @StkIds=' + quotedstr(trim(FBCIOID))); // Sql.Add(',@IOTime=' + Quotedstr('')); // Sql.Add(',@IOType=' + Quotedstr('�Զ�����')); // Sql.Add(',@IONO=' + Quotedstr('')); // Sql.Add(',@FillID=' + Quotedstr(DCode)); // Sql.Add(',@Filler=' + Quotedstr(DName)); //// ShowMessage(sql.text); // Open; // end; // if ADOCmd.FieldByName('intReturn').AsInteger = -1 then // begin // edtScan.text := ''; // raise Exception.Create(pchar(trim(ADOCmd.FieldByName('ShowMsg').AsString))); // end; // end; ////////////////////// �����Զ����� /////////////////// ////////////////// ��Ʒ����⼰��� ////////////////// if (trim(edt1.Text) = '��') then exit; if Trim(Edit4.Text) = '' then begin with ADOCmd do begin Close; sql.Clear; sql.Add('exec P_Trade_Insp_In_Stk @CIID=''' + trim(MCIID) + ''''); Open; end; if ADOCmd.FieldByName('intReturn').AsInteger = -1 then begin application.MessageBox(PChar(trim(ADOCmd.FieldByName('ShowMsg').AsString)), '��ʾ��Ϣ', 0); Result := False; end else begin Result := True; end; end else begin Result := True; end; ////////////////// ��Ʒ����⼰��� ////////////////// except ADOCmd.Connection.RollbackTrans; application.MessageBox(PChar(Exception(ExceptObject).Message), '��ʾ��Ϣ', 0); Result := False; end; end; procedure TfrmTradeMachInsp.btnCXRKClick(Sender: TObject); var MStkIds: string; begin if CDS_3.IsEmpty then exit; btnCXRK.Enabled := False; with CDS_3 do begin DisableControls; First; while not eof do begin MStkIds := MStkIds + Trim(CDS_3.FieldByName('CIID').AsString) + ','; next; end; EnableControls; end; MStkIds := copy(MStkIds, 1, Length(MStkIds) - 1); try ADOCmd.Connection.BeginTrans; with ADOCmd do begin Close; Sql.Clear; Sql.Add('exec P_Trade_Cloth_ReIn '); Sql.Add('@StkIds=' + quotedstr(trim(MStkIds))); Sql.Add(',@IOIDS='''' '); Open; end; if ADOCmd.FieldByName('intReturn').AsInteger = -1 then begin raise Exception.Create(pchar(trim(ADOCmd.FieldByName('ShowMsg').AsString))); end; application.MessageBox('�������ɹ���', '��ʾ��Ϣ'); ADOCmd.Connection.CommitTrans; btnCXRK.Enabled := True; except ADOCmd.Connection.RollbackTrans; btnCXRK.Enabled := True; application.MessageBox(PChar(Exception(ExceptObject).Message), '��ʾ��Ϣ', 0); end; end; procedure TfrmTradeMachInsp.btnRKClick(Sender: TObject); var MINo, MStkIds: string; begin if CDS_3.IsEmpty then exit; btnRK.Enabled := False; with CDS_3 do begin DisableControls; First; while not eof do begin MStkIds := MStkIds + Trim(CDS_3.FieldByName('CIID').AsString) + ','; next; end; EnableControls; end; MStkIds := copy(MStkIds, 1, Length(MStkIds) - 1); if GetLSNo(ADOCmd, MINo, '9', 'Trade_Cloth_IO', 4, 1) = False then begin Application.MessageBox('ȡ��ⵥ��ʧ��!', '��ʾ', 0); Exit; end; ADOCmd.Connection.BeginTrans; try with ADOCmd do begin Close; Sql.Clear; Sql.Add('exec P_Trade_Cloth_In '); Sql.Add('@StkIds=' + quotedstr(trim(MStkIds))); Sql.Add(',@IOTime=' + Quotedstr(FormatDateTime('yyyy-MM-dd', SGetServerDate(ADOTmp)))); Sql.Add(',@IOType=' + Quotedstr('�������')); Sql.Add(',@IONO=' + Quotedstr(MINo)); Open; end; if ADOCmd.FieldByName('intReturn').AsInteger = -1 then begin raise Exception.Create(pchar(trim(ADOCmd.FieldByName('ShowMsg').AsString))); end; ADOCmd.Connection.CommitTrans; application.MessageBox('�������ɹ���', '��ʾ��Ϣ'); btnRK.Enabled := True; except btnRK.Enabled := True; ADOCmd.Connection.RollbackTrans; application.MessageBox(PChar(Exception(ExceptObject).Message), '��ʾ��Ϣ', 0); end; end; procedure TfrmTradeMachInsp.BTPrintClick(Sender: TObject); var fPrintFile: string; mvalue: Double; i: Integer; begin edtScan.SetFocus; BTPrint.Enabled := False; // edtMaBiao.text := '��'; SetINIFile(); if StrToFloatdef(edit2.Text, 0) <> 0 then begin edtMaBiao.Text := ''; InputLen.Text := edit2.Text; edit2.text := ''; end; if CheckData('�ύ') = False then begin BTPrint.Enabled := True; exit; end; //�жϼ���ƥ���Ƿ�����̿�ƥ���� // with ADOCmd do // begin // Close; // sql.Clear; // SQL.Add('select count(*) Total,KKPS=(select count(LCKBID) KKPS from PB_CK_LCK where LCKID =''' + Trim(FLCKID) + ''''); // sql.Add(' ) from Trade_Cloth_Inspect where BCIOID=''' + Trim(FLCKID) + ''''); // showmessage(sql.Text); // Open; // end; // if (Copy(FLCKID, 1, 3) = 'LCK') and (ADOCmd.fieldbyname('Total').AsInteger >= ADOCmd.fieldbyname('KKPS').AsInteger) then // begin // Application.MessageBox('�ѳ������̿�ƥ����', '��ʾ', 0); // BTPrint.Enabled := True; // exit; // end; if SaveData() then begin if Trim(Edit6.Text) = '��' then begin PrtData(FCIID); end; if trim(Edit1.Text) = '��' then begin prtData2(FCIID); end; PlayWav('��ȷ'); edtMaBiao.Text := '��'; InputLen.Text := ''; InputWeight.Text := ''; DelQty.Text := ''; // MaxQty.Caption := ''; Edit3.Text := '��'; Edit4.Text := ''; Edit5.Text := ''; // PieceNo.Text := inttostr(strtointdef(PieceNo.Text, 0) + 1); //�������� PieceNo.Text := ''; Delay(500); BTPrint.Enabled := True; end else begin BTPrint.Enabled := True; end; InputLen.SetFocus; CIFBegClick(InputLen); FOperationStatus := '������'; InitJYGrid(); InitCDGrid(''); FCIID := ''; // FBCIOID := ''; edtScan.Text := ''; edtScan.SetFocus; edtScan.OnClick(edtScan); end; procedure TfrmTradeMachInsp.PrtData(MCIID: string); var fPrintFile, FLabVolume: string; Txt, fImagePath, Txt2, fImagePath2: string; Moudle: THandle; Makebar: TMakebar; Mixtext: TMixtext; begin with ADOQueryPrint do begin Close; SQL.Clear; sql.Add(' EXEC P_Trade_Insp_Prt_Lab '); SQL.Add(' @CIID=''' + Trim(MCIID) + ''''); // ShowMessage(sql.Text); Open; end; if ADOQueryPrint.IsEmpty then begin application.MessageBox('��ǩ����δ�ҵ���', '��ʾ��Ϣ', MB_ICONERROR); exit; end; if Trim(ADOQueryPrint.fieldbyname('Grade').AsString) = '��Ʒ' then FLabVolume := Trim(ADOQueryPrint.fieldbyname('LabVolume').AsString) else FLabVolume := '��Ʒ��ǩ'; ExportFtErpFile(FLabVolume + '.rmf', ADOTmp); fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\' + FLabVolume + '.rmf'; if FileExists(fPrintFile) then begin RM1.LoadFromFile(fPrintFile); if Trim(ADOQueryPrint.fieldbyname('LabVolume').AsString) <> '��Ʒ��ǩ' then RM1.DefaultCopies := strtointdef(trim(ComboBox1.Text), 1) else RM1.DefaultCopies := 1; RM1.PrintReport; end else begin Application.MessageBox(PChar('û����' + fPrintFile), '��ʾ', 0); end; end; procedure TfrmTradeMachInsp.PrtData2(MCIID: string); var fPrintFile, FLabVolume: string; Txt, fImagePath, Txt2, fImagePath2: string; Moudle: THandle; Makebar: TMakebar; Mixtext: TMixtext; begin with ADOQueryPrint do begin Close; SQL.Clear; sql.Add(' EXEC P_Trade_Insp_Prt_Lab2 '); SQL.Add(' @CIID=''' + Trim(MCIID) + ''''); // ShowMessage(sql.Text); Open; end; if ADOQueryPrint.IsEmpty then begin application.MessageBox('��ǩ����δ�ҵ���', '��ʾ��Ϣ', MB_ICONERROR); exit; end; FLabVolume := '�����ǩ'; ExportFtErpFile(FLabVolume + '.rmf', ADOTmp); fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\' + FLabVolume + '.rmf'; if FileExists(fPrintFile) then begin RM1.LoadFromFile(fPrintFile); RM1.DefaultCopies := 1; RM1.PrintReport; end else begin Application.MessageBox(PChar('û����' + fPrintFile), '��ʾ', 0); end; end; procedure TfrmTradeMachInsp.SpeedButton1Click(Sender: TObject); var fsj: string; begin fsj := Trim(TSpeedButton(Sender).Hint); if Trim(fsj) = '' then Exit; if TEdit(FindComponent(Trim(TSpeedButton(Sender).Hint))).Name = 'KuangHao' then Exit; fsj := Trim(TEdit(FindComponent(Trim(TSpeedButton(Sender).Hint))).Text); TEdit(FindComponent(Trim(TSpeedButton(Sender).Hint))).Text := fsj + Trim(TSpeedButton(Sender).Caption); TEdit(FindComponent(Trim(TSpeedButton(Sender).Hint))).SelectAll; end; procedure TfrmTradeMachInsp.SpeedButton87Click(Sender: TObject); var Key: Char; begin Key := #13; edtScanKeyPress(Sender, Key); end; procedure TfrmTradeMachInsp.SpeedButton12Click(Sender: TObject); var fsj: string; begin fsj := Trim(TEdit(FindComponent(Trim(TSpeedButton(Sender).Hint))).Text); if Trim(fsj) = '' then Exit; TEdit(FindComponent(Trim(TSpeedButton(Sender).Hint))).Text := Copy(fsj, 1, Length(fsj) - 1); TEdit(FindComponent(Trim(TSpeedButton(Sender).Hint))).SelectAll; end; procedure TfrmTradeMachInsp.SpeedButton13Click(Sender: TObject); var i: Integer; begin // if CheckData('�õ�') = False then // exit; // // FCIFName := Trim(TSpeedButton(Sender).Hint); // MovePanel1.Visible := True; // lblCIFName.Caption := Trim(FCIFName); // // // // //��ʾ���ּ��� //// CIFBeg.Text := InputLen.Text; // with Panel3 do // begin // for i := 0 to ControlCount - 1 do // begin // if Controls[i] is TSpeedButton then // begin // TSpeedButton(Controls[i]).Hint := Trim(CIFBeg.Name); // end; // end; // end; // // CIFNumber.OnClick(CIFNumber); // CIFNumber.SetFocus; with CDS_2 do begin Append; // if RadioGroup1.ItemIndex = 5 then // FieldByName('CIFName').Value := '������' + Trim(FCIFName) // else if RadioGroup1.ItemIndex = 4 then // FieldByName('CIFName').Value := '��ƥ' + Trim(FCIFName) // else FieldByName('CIFName').Value := Trim(TSpeedButton(Sender).Hint); FieldByName('CIFbeg').Value := Trim(InputLen.Text); FieldByName('CIFEnd').Value := Trim(InputLen.Text); FieldByName('CIFNumber').Value := 1; FieldByName('CIFPoints').Value := 0; if RadioGroup1.ItemIndex > -1 then begin if RadioGroup1.ItemIndex < 3 then begin FieldByName('CIFPoints').Value := RadioGroup1.ItemIndex + 1; end else begin FieldByName('CIFPoints').Value := 4; end; end; FieldByName('CIFQty').Value := 0; Post; end; end; procedure TfrmTradeMachInsp.cxDBImage1DblClick(Sender: TObject); begin if TcxDBImage(Sender).Picture.Height = 0 then exit; LookImage(Qry_ImgHX.fieldbyname(TcxDBImage(Sender).Hint).asstring); end; procedure TfrmTradeMachInsp.Button1Click(Sender: TObject); var mvalue: Double; begin if Trim(CIFNumber.Text) = '' then begin Application.MessageBox('��������Ϊ��!', '��ʾ', 0); Exit; end; if Trim(CIFBeg.Text) <> '' then begin if Trim(CIFEnd.Text) <> '' then begin if StrToFloat(CIFEnd.Text) < StrToFloat(CIFBeg.Text) then begin Application.MessageBox('�õ�λ��¼�����!', '��ʾ', 0); Exit; end; end; end; if CIFQty.Text <> '' then begin if TryStrToFloat(CIFQty.Text, mvalue) = False then begin Application.MessageBox('�Ƿ�����!', '��ʾ', 0); Exit; end; end; with CDS_2 do begin Append; // if RadioGroup1.ItemIndex = 5 then // FieldByName('CIFName').Value := '������' + Trim(FCIFName) // else if RadioGroup1.ItemIndex = 4 then // FieldByName('CIFName').Value := '��ƥ' + Trim(FCIFName) // else FieldByName('CIFName').Value := Trim(FCIFName); FieldByName('CIFbeg').Value := Trim(CIFBeg.Text); FieldByName('CIFEnd').Value := Trim(CIFEnd.Text); FieldByName('CIFNumber').Value := Trim(CIFNumber.Text); FieldByName('CIFPoints').Value := 0; if RadioGroup1.ItemIndex > -1 then begin if RadioGroup1.ItemIndex < 3 then begin FieldByName('CIFPoints').Value := RadioGroup1.ItemIndex + 1; end else begin FieldByName('CIFPoints').Value := 4; end; end; FieldByName('CIFQty').Value := StrToFloatdef(trim(CIFQty.Text), 0); Post; end; CIFBeg.Text := ''; CIFEnd.Text := ''; CIFQty.Text := ''; CIFNumber.Text := ''; MovePanel1.Visible := False; cxPageControl1.ActivePageIndex := 0; end; procedure TfrmTradeMachInsp.edtScanDblClick(Sender: TObject); begin edtScan.Text := ''; end; procedure TfrmTradeMachInsp.edtScanKeyPress(Sender: TObject; var Key: Char); begin if Key = #13 then begin if trim(edtScan.Text) = '' then exit; if trim(edtScan.Text) = FBCIOID then begin edtScan.Text := ''; PlayWav('�ظ�ɨ��'); exit; end; FOperationStatus := '������'; // InitLCK(edtScan.Text); if Copy(edtScan.Text, 1, 2) = 'PC' then begin InitBP(edtScan.Text); end else //if Copy(edtScan.Text, 1, 3) = 'LCK' then begin InitLCK(edtScan.Text); end; // else if Copy(edtScan.Text, 1, 2) = 'MR' then // begin // InitHXK(edtScan.Text); // end // else // begin // Application.MessageBox('��Ʊ�������', '��ʾ', 0); // Exit; // end; edtScan.SetFocus; edtScan.OnClick(edtScan); end; end; procedure TfrmTradeMachInsp.CIFBegClick(Sender: TObject); var i: Integer; begin with Panel3 do begin for i := 0 to ControlCount - 1 do begin if Controls[i] is TSpeedButton then begin TSpeedButton(Controls[i]).Hint := Trim(TEdit(Sender).Name); end; end; end; end; procedure TfrmTradeMachInsp.CIFEndChange(Sender: TObject); var mvalue: Double; begin if Trim(CIFBeg.Text) <> '' then begin if TryStrToFloat(CIFBeg.Text, mvalue) = False then begin Application.MessageBox('�Ƿ�����!', '��ʾ', 0); Exit; end; end else begin Exit; end; if Trim(CIFEnd.Text) <> '' then begin if TryStrToFloat(CIFEnd.Text, mvalue) = False then begin Application.MessageBox('�Ƿ�����!', '��ʾ', 0); Exit; end; end else begin Exit; end; CIFQty.Text := FloatToStr(StrToFloat(CIFEnd.Text) - StrToFloat(CIFBeg.Text)); end; procedure TfrmTradeMachInsp.Edit1Click(Sender: TObject); begin if Trim(Edit1.Text) = '' then begin Edit1.Text := '��'; end else begin Edit1.Text := ''; end; end; procedure TfrmTradeMachInsp.Edit3Click(Sender: TObject); begin if Trim(Edit3.Text) = '' then begin Edit3.Text := '��'; Edit4.Text := ''; Edit5.Text := ''; end else begin Edit3.Text := ''; Edit4.Text := ''; Edit5.Text := ''; end; end; procedure TfrmTradeMachInsp.Edit4Click(Sender: TObject); begin if Trim(Edit4.Text) = '' then begin Edit3.Text := ''; Edit4.Text := '��'; Edit5.Text := ''; end else begin Edit3.Text := ''; Edit4.Text := ''; Edit5.Text := ''; end; end; procedure TfrmTradeMachInsp.Edit5Click(Sender: TObject); begin if Trim(Edit5.Text) = '' then begin Edit3.Text := ''; Edit4.Text := ''; Edit5.Text := '��'; end else begin Edit3.Text := ''; Edit4.Text := ''; Edit5.Text := ''; end; end; procedure TfrmTradeMachInsp.Edit6Click(Sender: TObject); begin if Trim(Edit6.Text) = '' then begin Edit6.Text := '��'; end else begin Edit6.Text := ''; end; end; procedure TfrmTradeMachInsp.MJstr3KeyPress(Sender: TObject; var Key: Char); begin if Key = #13 then begin Key := #0; SelectNext(ActiveControl as TWinControl, True, True); end; end; procedure TfrmTradeMachInsp.MPlaceExit(Sender: TObject); begin SetINIFile(); end; procedure TfrmTradeMachInsp.Button2Click(Sender: TObject); begin RadioGroup1.ItemIndex := -1; end; procedure TfrmTradeMachInsp.Button3Click(Sender: TObject); begin if pnlSet.Visible then pnlSet.Visible := False else pnlSet.Visible := True; end; procedure TfrmTradeMachInsp.GrossWeightChange(Sender: TObject); begin QuantityConversion(); end; procedure TfrmTradeMachInsp.edtScanClick(Sender: TObject); var i: Integer; begin Panel3.Visible := True; with Panel3 do begin for i := 0 to ControlCount - 1 do begin if Controls[i] is TSpeedButton then begin TSpeedButton(Controls[i]).Hint := Trim(TEdit(Sender).Name); end; end; end; end; procedure TfrmTradeMachInsp.NetWeightKeyPress(Sender: TObject; var Key: Char); begin if Key = #13 then begin BTPrint.Click; end; end; procedure TfrmTradeMachInsp.FormCreate(Sender: TObject); begin inherited; IsCommopen := false; end; procedure TfrmTradeMachInsp.lblLenUnitClick(Sender: TObject); begin // if Trim(lblLenUnit.Caption) = 'M' then // SetUnit('Y') // else // SetUnit('M'); end; procedure TfrmTradeMachInsp.Button4Click(Sender: TObject); begin MovePanel1.Visible := false; CIFBeg.Text := ''; CIFEnd.Text := ''; CIFQty.Text := ''; CIFNumber.Text := ''; end; procedure TfrmTradeMachInsp.Button5Click(Sender: TObject); var FInputLen: string; begin FInputLen := InputLen.text; edtMaBiao.text := ''; SetINIFile(); InputLen.text := FInputLen; end; procedure TfrmTradeMachInsp.ToolButton2Click(Sender: TObject); begin if CDS_3.IsEmpty then exit; if Application.MessageBox('ȷ��Ҫ���´�ӡ��', '��ʾ', 32 + 4) <> IDYES then Exit; try with ADOTmp do begin Close; SQL.Clear; sql.Add(' select * from Trade_Cloth_IO A where IOFlag=''���'' '); SQL.Add(' and A.StkId=''' + trim(CDS_3.fieldbyName('CIID').AsString) + ''''); Open; end; PrtMD(ADOTmp.fieldbyName('IONo').AsString); except application.MessageBox('���´�ӡʧ��!', '��ʾ��Ϣ', MB_ICONERROR); end; end; procedure TfrmTradeMachInsp.ToolButton3Click(Sender: TObject); begin if CDS_3.IsEmpty then Exit; PrtData(CDS_3.fieldbyname('CIID').AsString); end; procedure TfrmTradeMachInsp.ToolButton4Click(Sender: TObject); begin try frmZDYHelp := TfrmZDYHelp.Create(Application); with frmZDYHelp do begin flag := 'WFBCD2'; flagname := '��Ʒ�õ�'; fnote := True; V1Note.Caption := 'Ӣ������'; if ShowModal = 1 then begin Self.InitCDPanel(); end; end; finally frmZDYHelp.Free; end; end; procedure TfrmTradeMachInsp.ToolButton5Click(Sender: TObject); begin if CDS_3.IsEmpty then Exit; if Application.MessageBox('ȷ��Ҫɾ��������', '��ʾ', 32 + 4) <> IDYES then Exit; ADOCmd.Connection.BeginTrans; try with ADOCmd do begin Close; sql.Clear; sql.Add('insert into Trade_Need_Up(UType,UOperation,UDataId) values(''����'',''����ɾ��'',' + quotedstr(Trim(CDS_3.fieldbyname('CIID').AsString)) + ') '); ExecSQL; end; with ADOCmd do begin Close; Sql.Clear; Sql.Add('exec P_Trade_Insp_Del '); Sql.Add('@CIIDS=' + quotedstr(Trim(CDS_3.fieldbyname('CIID').AsString))); Sql.Add(',@DCode=' + Quotedstr(DCode)); Sql.Add(',@DName=' + Quotedstr(DName)); Open; end; if ADOCmd.FieldByName('intReturn').AsInteger = -1 then begin raise Exception.Create(pchar(trim(ADOCmd.FieldByName('ShowMsg').AsString))); end; with ADOTmp do begin Close; SQL.Clear; sql.Add(' select * from Knit_Cloth_IO'); sql.Add(' where IOFlag = ''����'' and StkId=''' + Trim(CDS_3.fieldbyname('BCIOID').AsString) + ''''); // ShowMessage(sql.text); Open; end; if ADOTmp.IsEmpty = false then begin with ADOCmd do begin Close; Sql.Clear; Sql.Add('exec P_Knit_Cloth_ReOut '); Sql.Add('@StkIds=' + quotedstr(trim(CDS_3.fieldbyname('BCIOID').AsString))); Sql.Add(',@IOIDS=' + quotedstr(trim(''))); Sql.Add(',@FillId=' + quotedstr(trim(DCode))); Sql.Add(',@Filler=' + quotedstr(trim(DName))); // ShowMessage(sql.Text); Open; end; end; ADOCmd.Connection.CommitTrans; CDS_3.Delete; application.MessageBox('ɾ���ɹ���', '��ʾ��Ϣ'); except ADOCmd.Connection.RollbackTrans; application.MessageBox(PChar(Exception(ExceptObject).Message), '��ʾ��Ϣ', 0); end; end; procedure TfrmTradeMachInsp.ToolButton6Click(Sender: TObject); begin if CDS_3.IsEmpty then Exit; InitJTM(CDS_3.fieldbyname('CIID').AsString); end; procedure TfrmTradeMachInsp.ToolButton7Click(Sender: TObject); begin WriteCxGrid(trim(Self.Caption) + 'Tv1', Tv1, 'ó�������'); WriteCxGrid(trim(Self.Caption) + 'Tv2', Tv2, 'ó�������'); WriteCxGrid(trim(Self.Caption) + 'Tv3', Tv3, 'ó�������'); end; procedure TfrmTradeMachInsp.ToolButton8Click(Sender: TObject); begin Close; end; procedure TfrmTradeMachInsp.edt1Click(Sender: TObject); begin if Trim(edt1.Text) = '' then begin edt1.Text := '��'; end else begin edt1.Text := ''; end; end; procedure TfrmTradeMachInsp.edtChenClick(Sender: TObject); begin if Trim(TEdit(Sender).Text) = '' then begin TEdit(Sender).Text := '��'; end else begin TEdit(Sender).Text := ''; end; SetINIFile(); end; procedure TfrmTradeMachInsp.edtYJClick(Sender: TObject); begin if Trim(TEdit(Sender).Text) = '' then begin TEdit(Sender).Text := '��'; end else begin TEdit(Sender).Text := ''; end; end; procedure TfrmTradeMachInsp.Button6Click(Sender: TObject); begin if ScrollBox1.Visible then ScrollBox1.Visible := False else ScrollBox1.Visible := True; end; procedure TfrmTradeMachInsp.Button8Click(Sender: TObject); begin if Panel7.Visible then Panel7.Visible := False else Panel7.Visible := True; end; end.