unit U_GreyInspection; interface uses Windows, Messages, SysUtils, 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, IniFiles, cxLookAndFeels, cxLookAndFeelPainters, cxNavigator, StrUtils, dxSkinsCore, dxSkinsDefaultPainters, dxSkinscxPCPainter, 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, dxSkinPumpkin, dxSkinSeven, dxSkinSevenClassic, dxSkinSharp, dxSkinSharpPlus, dxSkinSilver, dxSkinSpringTime, dxSkinStardust, dxSkinSummer2008, dxSkinTheAsphaltWorld, dxSkinValentine, dxSkinVS2010, dxSkinWhiteprint, dxSkinXmas2008Blue; type TfrmGreyInspection = class(TForm) cxGridPopupMenu1: TcxGridPopupMenu; DataSource1: TDataSource; Order_MJ: TClientDataSet; ADOCmd: TADOQuery; RMDB_Main: TRMDBDataSet; RM2: TRMGridReport; DS_MJCD: TDataSource; CDS_MJCD: TClientDataSet; DS_MJID: TDataSource; CDS_MJID: TClientDataSet; ADOQueryPrint: TADOQuery; cxGridPopupMenu2: TcxGridPopupMenu; ADOQueryMainDSC: TADOQuery; Panel2: TPanel; Label9: TLabel; JYLen1: TEdit; Label4: TLabel; Label5: TLabel; Label11: TLabel; BTPrint: TButton; Button5: TButton; Edit3: TEdit; Label10: TLabel; Edit4: TEdit; Label12: TLabel; Label30: TLabel; JYTare: TEdit; Label31: TLabel; Label32: TLabel; JYNW: TEdit; Label33: TLabel; Panel7: TPanel; OrdNote: TRichEdit; Label36: TLabel; RM3: TRMGridReport; JYxh: TEdit; ADOTmp: TADOQuery; Panel5: TPanel; Panel6: TPanel; Label1: TLabel; Label35: TLabel; Label39: TLabel; Scan: TEdit; Edit7: TEdit; Edit8: TEdit; ToolBar1: TToolBar; ToolButton1: TToolButton; TBCD: TToolButton; TBClose: TToolButton; cxGrid3: TcxGrid; Tv3: TcxGridDBTableView; cxGridDBColumn1: TcxGridDBColumn; v3Column1: TcxGridDBColumn; v3Column2: TcxGridDBColumn; v3Column3: TcxGridDBColumn; cxGridLevel2: TcxGridLevel; Label13: TLabel; JYXS: TEdit; ToolButton2: TToolButton; Label3: TLabel; person1: TEdit; person2: TEdit; Label14: TLabel; Label6: TLabel; Label15: TLabel; JYLen2: TEdit; ToolButton3: TToolButton; Label16: TLabel; Label19: TLabel; Label21: TLabel; Label22: TLabel; Label23: TLabel; Label24: TLabel; JYLen3: TEdit; person3: TEdit; person4: TEdit; JYLen4: TEdit; Label25: TLabel; Label27: TLabel; Label28: TLabel; person5: TEdit; JYLen5: TEdit; QryCheckNet: TADOQuery; Label29: TLabel; edtDel: TEdit; ToolButton4: TToolButton; ToolButton5: TToolButton; lbl1: TLabel; lbl2: TLabel; JYGW: TEdit; Tv3Column1: TcxGridDBColumn; Label40: TLabel; Edit1: TEdit; Tv3Column2: TcxGridDBColumn; Panel1: TPanel; Label26: TLabel; Label34: TLabel; Edit6: TEdit; ComboBox1: TComboBox; Label46: TLabel; kaijian: TEdit; 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; SpeedButton49: TSpeedButton; SpeedButton84: TSpeedButton; SpeedButton43: TSpeedButton; lblJYPS: TLabel; lblJYLen: TLabel; Label2: TLabel; Label7: TLabel; jylen: TEdit; cxStyleRepository1: TcxStyleRepository; cxStyle1: TcxStyle; Tv3Column3: TcxGridDBColumn; Tv3Column4: TcxGridDBColumn; ToolButton6: TToolButton; Tv3Column5: TcxGridDBColumn; procedure FormDestroy(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure TBCloseClick(Sender: TObject); procedure TBCDClick(Sender: TObject); procedure FormShow(Sender: TObject); procedure BTPrintClick(Sender: TObject); procedure SpeedButton1Click(Sender: TObject); procedure SpeedButton12Click(Sender: TObject); procedure cxGridDBColumn2PropertiesChange(Sender: TObject); procedure Button5Click(Sender: TObject); procedure SpeedButton49Click(Sender: TObject); procedure ScanKeyPress(Sender: TObject; var Key: Char); procedure Edit3Click(Sender: TObject); procedure Edit4Click(Sender: TObject); procedure Edit6Click(Sender: TObject); procedure MJstr3KeyPress(Sender: TObject; var Key: Char); procedure JYGWChange(Sender: TObject); procedure ScanClick(Sender: TObject); procedure Edit7Click(Sender: TObject); procedure JYNWKeyPress(Sender: TObject; var Key: Char); procedure FormCreate(Sender: TObject); procedure Edit8Click(Sender: TObject); procedure JYLen1Change(Sender: TObject); procedure Tv2CellDblClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean); procedure ToolButton2Click(Sender: TObject); procedure person1Click(Sender: TObject); procedure person2Click(Sender: TObject); procedure ToolButton3Click(Sender: TObject); procedure person5Click(Sender: TObject); procedure person4Click(Sender: TObject); procedure person3Click(Sender: TObject); procedure edtDelClick(Sender: TObject); procedure ToolButton4Click(Sender: TObject); procedure ToolButton5Click(Sender: TObject); procedure Label9Click(Sender: TObject); procedure Label6Click(Sender: TObject); procedure Label16Click(Sender: TObject); procedure Label23Click(Sender: TObject); procedure Label27Click(Sender: TObject); procedure Edit1Click(Sender: TObject); procedure SpeedButton43Click(Sender: TObject); procedure JYLen1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure JYLen2MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure JYLen3MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure JYLen4MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure JYLen5MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure Label2Click(Sender: TObject); procedure ToolButton6Click(Sender: TObject); private { Private declarations } FColumn, FFFMJID, FOperationStatus: string; FAPID, FSPID, FMainId, FSubId, FMJCode, FPCID, FMJName, FMJSpec, FMJMF, FMJKZ, FMJColor, FAPBatchNo, FCarNo, FISJSKZ: string; // 产品信息 FMF_Wai, FJSKZ, FKONGJIA, fkongjiawei: Double; FCDName: string; //疵点名称 isCommopen, IsJsMessage: boolean; fxsType, fRollType: string; procedure InitBatchNo(); //刷新批号选项 procedure InitCDGrid(); //刷新疵点信息 procedure InitInspectionRecord(); //刷新检验信息 function CheckData(CKType: string): Boolean; //校验数据 function SaveData(): Boolean; //保存数据 function SelfConnData(): Boolean; //检测网络链接 procedure ScanOrder(); //扫描订单 procedure ScanSample(); //扫描样品 procedure ScanAnPai(); //扫描布票 procedure ScanbpAnPai(); //扫描布票安排 procedure ClearGlobal(MStatus: string); //清除全局ID procedure PrintCKMDG(MRKOrdID: string); //打印入库单 procedure PrtData(FMJID: string); //打印卷标签 procedure QuantityConversion(); //数量换算 procedure OpenCom(DllName: string); procedure CloseCom(DllName: string); procedure clearCom(DllName: string); procedure DelDate(FMJID: string); //删除标签 procedure On1201(var Message: Tmessage); message 1201; procedure On1301(var Message: Tmessage); message 1301; public fmanage: string; I3: Double; { Public declarations } end; var frmGreyInspection: TfrmGreyInspection; newh, newh1, newh2: hwnd; IniFile: TIniFile; implementation uses U_DataLink, U_Fun, U_ZDYHelp, U_iniParam, U_SCPerson, U_FinishedClothStatistical; {$R *.dfm} procedure TfrmGreyInspection.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); newh2 := Tf1('Comm1'); end else begin end; finally // FreeLibrary(Th1); end; end else begin application.MessageBox(Pchar('找不到 ' + trim(DllName) + ' 文件!'), '提示'); end; end; procedure TfrmGreyInspection.DelDate(FMJID: string); var FJYID: string; begin with ADOTmp do begin Close; sql.Clear; sql.Add('select * from CK_Cloth_CR where APID=''' + Trim(FMJID) + ''''); sql.Add('and CRFlag=''出库'' '); Open; end; if ADOTmp.RecordCount >= 1 then begin Application.MessageBox('已出库不能扫描删除!', '提示', 0); Exit; end; with ADOTmp do begin Close; sql.Clear; sql.Add('select top 1 * from CK_Cloth_CR where APID=''' + Trim(FMJID) + ''''); Open; end; FJYID := Trim(ADOTmp.fieldbyname('JYID').AsString); try ADOCmd.Connection.BeginTrans; with ADOCmd do begin Close; sql.Clear; sql.Add('UPDATE CK_Cloth_CR Set CRTime=NULL,CRType=NULL,CRFlag=''待入库'' ,RKNo=NULL where CK_Cloth_CR.CRFlag=''入库'' and CK_Cloth_CR.JYID=''' + Trim(FJYID) + ''''); sql.Add('UPDATE CK_Cloth_KC Set Valid=''N'' where CK_Cloth_KC.JYID=''' + Trim(FJYID) + ''''); sql.Add('UPDATE JY_Cloth Set JYCRType=''未入库'',RKNo=null where JY_Cloth.JYID=''' + Trim(FJYID) + ''''); sql.Add('delete JY_Cloth where JYID=''' + Trim(FJYID) + ''''); sql.Add('delete CK_Cloth_CR where JYID=''' + Trim(FJYID) + ''''); sql.Add('delete CK_Cloth_KC where JYID=''' + Trim(FJYID) + ''''); sql.Add('delete JY_Cloth_CD where JYID=''' + Trim(FJYID) + ''''); sql.Add('update PD_Plan_AnPai set jyflag=(case when isnull((select count(*) from JY_Cloth where apid=''' + trim(FMJID) + '''),0)>0 then 1 else 0 end)'); sql.Add('where apid =''' + trim(FMJID) + ''' '); sql.Add('insert into SY_SysLog(operor,opertime,Model,acction,opevent,result) values( '); sql.Add(' ' + quotedstr(trim(DName))); sql.Add(',getdate() '); sql.Add(',' + quotedstr(trim(self.Caption))); sql.Add(',' + quotedstr(trim('作废成品检验数据'))); sql.Add(',' + quotedstr('卷条码:' + trim(FMJID))); sql.Add(',' + quotedstr(trim('成功'))); sql.Add(')'); ExecSQL; end; if not CDS_MJID.IsEmpty then begin if CDS_MJID.Locate('JYID', FJYID, []) then CDS_MJID.Delete; end; FAPID := FMJID; FFFMJID := FJYID; InitInspectionRecord(); InitCDGrid(); ADOCmd.Connection.CommitTrans; Application.MessageBox('删除成功!', '提示', 0); except ADOCmd.Connection.RollbackTrans; Application.MessageBox('删除失败!', '提示', 0); end; edtDel.Text := ''; end; function TfrmGreyInspection.SelfConnData(): Boolean; begin try with QryCheckNet do begin Close; sql.Clear; //查询一个小表检测网络 SQL.Add('select getdate()'); Open; end; Result := true; except // if Application.MessageBox('是否重新连接网络!','提示',32+4)<>IDYES then Exit; if not Assigned(DataLink_FabricInspection) then DataLink_FabricInspection := DataLink_FabricInspection.Create(Application); try with DataLink_FabricInspection.ADOLink do begin //if not Connected then begin Connected := false; ConnectionString := DConString; LoginPrompt := false; Connected := true; end; end; Result := true; except Result := false; end; end; end; procedure TfrmGreyInspection.InitBatchNo(); var fsj: string; begin // fsj := 'select distinct(ZdyName) name from KH_ZDY A where A.Type=''GreyBatchNo'' '; // SInitComBoxBySql(ADOTmp, BatchNo, False, fsj); end; procedure TfrmGreyInspection.QuantityConversion(); var MLen, MNWet, MGWet, MPWet, MCC, XiShu, MGreyLen: Double; begin // MLen := StrToFloatdef(trim(JYLen.Text), 0); // MNWet := StrToFloatdef(trim(JYNW.Text), 0); // MPWet := StrToFloatdef(trim(JYTare.Text), 0); // MGWet := StrToFloatdef(trim(JYGW.Text), 0); // MCC := StrToFloatdef(trim(JYXS.Text), 0); // if MCC > 0 then // begin // MGWet := StrToFloat(format('%.1f', [MLen * MCC])); // MNWet := MGWet - MPWet; // JYGW.Text := FloatToStr(MGWet); // JYNW.Text := FloatToStr(MNWet); // end; // // MNWet := MGWet - MPWet; // JYNW.Text := FloatToStr(MNWet); end; function TfrmGreyInspection.CheckData(CKType: string): Boolean; var mvalue, i4, FCD: Double; begin try if Trim(CKType) = '提交' then begin FCD := (strtofloatdef(trim(JYLen2.Text), 0) + strtofloatdef(trim(JYLen1.Text), 0) + strtofloatdef(trim(JYLen3.Text), 0) + strtofloatdef(trim(JYLen4.Text), 0) + strtofloatdef(trim(JYLen5.Text), 0)); if RoundFloat(FCD, 2) <> RoundFloat(StrToFloatDef(JYLen.Text, 0), 2) then raise Exception.Create('产量和需等于检验长度!!,当前长度和为' + FloatToStr(FCD) + '实际长度为' + trim(JYLen.Text)); if (FPCID = '') and (FapID = '') then raise Exception.Create('请先刷卡或扫描布票!'); // if (strtofloatdef(trim(JYLen1.Text), 0) < 0.00) or (strtofloatdef(trim(JYLen2.Text), 0) < 0.00) or (strtofloatdef(trim(JYLen3.Text), 0) < 0.00) or (strtofloatdef(trim(JYLen4.Text), 0) < 0.00) or (strtofloatdef(trim(JYLen5.Text), 0) < 0.00) then // raise Exception.Create('长度不能小于0!'); if (strtofloatdef(trim(JYLen1.Text), 0) + strtofloatdef(trim(JYLen2.Text), 0) + strtofloatdef(trim(JYLen3.Text), 0) + strtofloatdef(trim(JYLen4.Text), 0) + strtofloatdef(trim(JYLen5.Text), 0)) <= 0.00 then raise Exception.Create('总长度不能小于等于0!'); if (Trim(JYLen1.Text) <> '') or (Trim(JYLen2.Text) <> '') or (Trim(JYLen3.Text) <> '') or (Trim(JYLen4.Text) <> '') or (Trim(JYLen5.Text) <> '') then begin if (strtofloatdef(trim(JYLen1.Text), 0) > 400) or (strtofloatdef(trim(JYLen2.Text), 0) > 400) or (strtofloatdef(trim(JYLen3.Text), 0) > 400) or (strtofloatdef(trim(JYLen4.Text), 0) > 400) or (strtofloatdef(trim(JYLen5.Text), 0) > 400) then raise Exception.Create('长度不能大于400!'); end; if (person1.Text <> '') and (JYLen1.Text = '') then begin raise Exception.Create('选了挡车工1长度不能为0!'); end; if (person2.Text <> '') and (JYLen2.Text = '') then begin raise Exception.Create('选了挡车工2长度不能为0!'); end; if (person3.Text <> '') and (JYLen3.Text = '') then begin raise Exception.Create('选了挡车工3长度不能为0!'); end; if (person4.Text <> '') and (JYLen4.Text = '') then begin raise Exception.Create('选了挡车工4长度不能为0!'); end; if (person5.Text <> '') and (JYLen5.Text = '') then begin raise Exception.Create('选了挡车工5长度不能为0!'); end; if (strtofloatdef(trim(JYGW.Text), 0) > 100) then raise Exception.Create('重量不能大于100!!'); if (strtofloatdef(trim(JYLen.Text), 0) <= 0.00) then raise Exception.Create('长度不能小于等于0!!'); // if Edit7.Text <> '' then // begin // if I3 <> 0 then // begin // i4 := RoundFloat(I3 + 0.1, 0); // end // else // begin // i4 := StrToFloatDEF(JYLen1.TEXT, 0); // end; // // if (JYLen5.Text <> '') and (JYLen4.Text <> '') and (JYLen3.Text <> '') and (JYLen2.Text <> '') and (JYLen1.Text <> '') then // begin // JYLen5.Text := FloatToStr(i4 - strtofloat(jylen4.Text) - strtofloat(jylen3.Text) - strtofloat(jylen2.Text) - strtofloat(jylen1.Text)); // end // else if (JYLen4.Text <> '') and (JYLen3.Text <> '') and (JYLen2.Text <> '') and (JYLen1.Text <> '') then // begin // JYLen4.Text := FloatToStr(i4 - strtofloat(jylen3.Text) - strtofloat(jylen2.Text) - strtofloat(jylen1.Text)); // end // else if (JYLen3.Text <> '') and (JYLen2.Text <> '') and (JYLen1.Text <> '') then // begin // JYLen3.Text := FloatToStr(i4 - strtofloat(jylen2.Text) - strtofloat(jylen1.Text)); // end // else if (JYLen2.Text <> '') and (JYLen1.Text <> '') then // begin // JYLen2.Text := FloatToStr(i4 - strtofloat(jylen1.Text)); // end // else if (JYLen1.Text <> '') then // begin // JYLen1.Text := FloatToStr(i4); // end; // end; end; //ShowMessage(JYLen2.Text); Result := True; except Result := false; application.MessageBox(PChar(Exception(ExceptObject).Message), '提示信息', 0); end; end; procedure TfrmGreyInspection.ClearGlobal(MStatus: string); begin if MStatus = '扫描' then begin FAPID := ''; FSPID := ''; FMainId := ''; FSubId := ''; FFFMJID := ''; FMJCode := ''; FMJName := ''; FMJSpec := ''; FMJMF := ''; FMJKZ := ''; FMJColor := ''; FAPBatchNo := ''; FCarNo := ''; FMF_Wai := 0; FJSKZ := 0; FISJSKZ := ''; JYxh.Text := ''; JYXS.Text := ''; JYGW.Text := ''; JYNW.Text := ''; JYLen1.Text := ''; JYLen2.Text := ''; JYLen3.Text := ''; person1.Text := ''; person2.Text := ''; person3.Text := ''; person4.Text := ''; person5.Text := ''; person1.hint := ''; person2.hint := ''; person3.hint := ''; person4.hint := ''; person5.hint := ''; end; if MStatus = '提交' then begin JYLen1.Text := ''; JYLen2.Text := ''; JYGW.Text := ''; JYNW.Text := ''; // FOperationStatus := ''; FFFMJID := ''; FAPID := ''; if FOperationStatus = '扫描布票' then begin FOperationStatus := ''; FPCID := ''; end; end; end; procedure TfrmGreyInspection.PrintCKMDG(MRKOrdID: string); var fPrintFile: string; Txt, fImagePath: string; Moudle: THandle; Makebar: TMakebar; Mixtext: TMixtext; begin with ADOQueryPrint do begin Close; SQL.Clear; sql.Add(' exec P_Print_RKMDGangNo '); SQL.Add(' @RKOrdID=''' + Trim(MRKOrdID) + ''''); Open; end; try Moudle := LoadLibrary('MakeQRBarcode.dll'); @Makebar := GetProcAddress(Moudle, 'Make'); @Mixtext := GetProcAddress(Moudle, 'MixText'); Txt := Trim(ADOQueryPrint.fieldbyname('RKOrdID').AsString); fImagePath := ExtractFilePath(Application.ExeName) + 'image\temp.bmp'; if not DirectoryExists(pchar(ExtractFilePath(Application.ExeName) + 'image')) then CreateDirectory(pchar(ExtractFilePath(Application.ExeName) + 'image'), nil); if FileExists(fImagePath) then DeleteFile(fImagePath); Makebar(pchar(Txt), Length(Txt), 3, 3, 0, PChar(fImagePath), 3); except application.MessageBox('条形码生成失败!', '提示信息', MB_ICONERROR); exit; end; ExportFtErpFile('验布工仓库码单.rmf', ADOTmp); fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\验布工仓库码单.rmf'; if FileExists(fPrintFile) then begin RMVariables['QRBARCODE'] := fImagePath; RM2.LoadFromFile(fPrintFile); Rm2.DefaultCopies := 1; RM2.ShowReport; end else begin Application.MessageBox(PChar('没有找' + fPrintFile), '提示', 0); Exit; end; end; procedure TfrmGreyInspection.ScanSample(); var MFromMJLen: Double; begin with ADOTmp do begin Close; sql.Clear; sql.Add('select * from CP_YDang '); sql.Add('where CYID=''' + Trim(Scan.Text) + ''''); Open; end; if not ADOTmp.IsEmpty then begin FMainId := Trim(ADOTmp.fieldbyname('MainId').AsString); FSubId := Trim(ADOTmp.fieldbyname('SubId').AsString); FMJCode := Trim(ADOTmp.fieldbyname('SPCode').AsString); FMJName := Trim(ADOTmp.fieldbyname('SPName').AsString); FMJSpec := Trim(ADOTmp.fieldbyname('SPSpec').AsString); FMJMF := Trim(ADOTmp.fieldbyname('SPMF').AsString); FMJKZ := Trim(ADOTmp.fieldbyname('SPKZ').AsString); FMJColor := trim(ADOTmp.fieldbyname('SPColor').AsString); JYxh.Text := '1'; OrdNote.Text := '编号:' + FMJCode + #13; OrdNote.Text := OrdNote.Text + '品名:' + FMJName + #13; OrdNote.Text := OrdNote.Text + '门幅:' + FMJMF + #13; OrdNote.Text := OrdNote.Text + '克重:' + FMJKZ + #13; OrdNote.Text := OrdNote.Text + '颜色:' + FMJColor + #13; end else begin ClearGlobal('扫描'); end; InitInspectionRecord(); InitCDGrid(); Scan.Text := ''; end; procedure TfrmGreyInspection.ScanOrder(); begin with ADOTmp do begin Close; sql.Clear; sql.Add('select A.*,B.* '); sql.Add(',maxRoll=1+isnull((select cast (max(mjxh) as int) from FinishedCloth_Inspect X where X.subid=B.subid and X.MJType =''正品'' ),0)'); sql.Add('from Cloth_Main A '); sql.Add('inner join Cloth_Sub B on A.MainId=B.MainId'); sql.Add('where A.MainID=''' + Trim(Scan.Text) + ''''); sql.Add(' and A.OrderType=''梭织织造单'''); //ShowMessage(SQL.Text); Open; end; if not ADOTmp.IsEmpty then begin FAPID := ''; // FSPID := Trim(ADOTmp.fieldbyname('SPID').AsString); FMainId := Trim(ADOTmp.fieldbyname('MainId').AsString); FSubId := Trim(ADOTmp.fieldbyname('SubId').AsString); FMJCode := Trim(ADOTmp.fieldbyname('C_Code').AsString); FMJName := Trim(ADOTmp.fieldbyname('C_CodeName').AsString); FMJSpec := Trim(ADOTmp.fieldbyname('C_Spec').AsString); FMJMF := Trim(ADOTmp.fieldbyname('MF').AsString); FMJKZ := Trim(ADOTmp.fieldbyname('KZ').AsString); FMJColor := trim(ADOTmp.fieldbyname('C_Color').AsString); JYxh.Text := Trim(ADOTmp.fieldbyname('maxRoll').AsString); OrdNote.Text := '订单号:' + Trim(ADOTmp.fieldbyname('ConNo').AsString) + #13; OrdNote.Text := OrdNote.Text + '编号:' + FMJCode + #13; OrdNote.Text := OrdNote.Text + '品名:' + FMJName + #13; OrdNote.Text := OrdNote.Text + '门幅:' + FMJMF + #13; OrdNote.Text := OrdNote.Text + '克重:' + FMJKZ + #13; OrdNote.Text := OrdNote.Text + '颜色:' + FMJColor + #13; OrdNote.Text := OrdNote.Text + '特别提示:' + Trim(ADOTmp.fieldbyname('Note').AsString); end else begin ClearGlobal('扫描生产计划单'); end; InitInspectionRecord(); InitCDGrid(); Scan.Text := ''; end; procedure TfrmGreyInspection.ScanAnPai(); var FAPXH, FCAPXH: string; begin with ADOTmp do begin Close; sql.Clear; sql.Add('exec P_Get_ScanAnPai ''' + Trim(Scan.Text) + ''''); Open; end; if not ADOTmp.IsEmpty then begin // FAPID := Trim(ADOTmp.fieldbyname('apid').AsString); FMainId := Trim(ADOTmp.fieldbyname('MainId').AsString); FSubId := Trim(ADOTmp.fieldbyname('SubId').AsString); FMJCode := Trim(ADOTmp.fieldbyname('P_Code').AsString); FMJName := Trim(ADOTmp.fieldbyname('P_CodeName').AsString); FMJSpec := Trim(ADOTmp.fieldbyname('P_Spec').AsString); FMJMF := Trim(ADOTmp.fieldbyname('P_MF').AsString); FJSKZ := ADOTmp.fieldbyname('JSKZ').AsFloat; FISJSKZ := Trim(ADOTmp.fieldbyname('ISJSKZ').AsString); FMJKZ := Trim(ADOTmp.fieldbyname('P_KZ').AsString); FMJColor := trim(ADOTmp.fieldbyname('P_Color').AsString); JYxh.Text := Trim(ADOTmp.fieldbyname('maxRoll').AsString); FPCID := trim(ADOTmp.fieldbyname('PCID2').AsString); FKONGJIA := StrToFloatDEF(ADOTmp.fieldbyname('KONGJIA').AsString, 0); fkongjiawei := StrToFloatDEF(ADOTmp.fieldbyname('kongjiawei').AsString, 0); OrdNote.Text := '订单号:' + Trim(ADOTmp.fieldbyname('orderno').AsString) + #13; OrdNote.Text := OrdNote.Text + '轴卡号:' + FPCID + #13; OrdNote.Text := OrdNote.Text + '编号:' + FMJCode + #13; OrdNote.Text := OrdNote.Text + '品名:' + FMJName + #13; OrdNote.Text := OrdNote.Text + '门幅:' + FMJMF + #13; OrdNote.Text := OrdNote.Text + '克重:' + FMJKZ + #13; OrdNote.Text := OrdNote.Text + '颜色:' + FMJColor + #13; OrdNote.Text := OrdNote.Text + '特别提示:' + Trim(ADOTmp.fieldbyname('P_Note').AsString); end else begin ClearGlobal('扫描生产计划单'); end; InitInspectionRecord(); InitCDGrid(); Scan.Text := ''; end; procedure TfrmGreyInspection.ScanBPAnPai(); var FAPXH, FCAPXH: string; begin with ADOTmp do begin Close; sql.Clear; sql.Add('select * from CK_YgCl where mjid=(select pcid from PD_Plan_AnPai e where e.APID= ''' + Trim(Scan.Text) + ''''); sql.Add(')and cltype=''上轴'''); // ShowMessage(SQL.Text); Open; end; if ADOTmp.IsEmpty then begin application.MessageBox(Pchar('该卡还未上轴刷卡!'), '提示'); FPCID := ''; Scan.Text := ''; Exit; end; with ADOCmd do begin Close; sql.Clear; sql.Add('select * from JY_Cloth where APID = ''' + Trim(Scan.Text) + ''''); Open; end; if not ADOCmd.IsEmpty then begin application.MessageBox('重复扫描布票!', '提示', 0); Exit; end; with ADOCmd do begin Close; sql.Clear; sql.Add('select PCID,APXH from PD_Plan_AnPai where APID = ''' + Trim(Scan.Text) + ''''); Open; end; // if not ADOCmd.IsEmpty then // begin // if ADOCmd.fieldbyname('APXH').AsInteger - 1 <> 0 then // begin // FAPXH := IntToStr(ADOCmd.fieldbyname('APXH').AsInteger - 1); // FCAPXH := ADOCmd.fieldbyname('APXH').AsString; // with ADOTmp do // begin // Close; // sql.Clear; // sql.Add('select JYFlag from PD_Plan_AnPai where PCID = ''' + Trim(ADOCmd.fieldbyname('PCID').AsString) + ''''); // SQL.Add(' and APXH=' + QuotedStr(Trim(FAPXH))); // Open; // end; // if Trim(ADOTmp.fieldbyname('JYFlag').AsString) <> 'True' then // begin // FAPXH := '当前布号: ' + FCAPXH + #13 + FAPXH + '号布还未检验,是否跳过?'; // if MessageBox(self.Handle, PChar(FAPXH), '提示', MB_OKCANCEL or MB_ICONINFORMATION) = IDOK then // begin // Next; // end // else // begin // Exit; // end; // end; // end; // // end; with ADOTmp do begin Close; sql.Clear; sql.Add('exec P_Get_ScanBPAnPai ''' + Trim(Scan.Text) + ''''); Open; end; if not ADOTmp.IsEmpty then begin FAPID := Trim(ADOTmp.fieldbyname('APID').AsString); FpcID := Trim(ADOTmp.fieldbyname('PCID').AsString); // FSPID := Trim(ADOTmp.fieldbyname('SPID').AsString); FMainId := Trim(ADOTmp.fieldbyname('MainId').AsString); FSubId := Trim(ADOTmp.fieldbyname('SubId').AsString); FMJCode := Trim(ADOTmp.fieldbyname('P_Code').AsString); FMJName := Trim(ADOTmp.fieldbyname('P_CodeName').AsString); FMJSpec := Trim(ADOTmp.fieldbyname('P_Spec').AsString); FMJMF := Trim(ADOTmp.fieldbyname('P_MF').AsString); FMF_Wai := ADOTmp.fieldbyname('MF_Wai').AsFloat; FJSKZ := ADOTmp.fieldbyname('JSKZ').AsFloat; FISJSKZ := Trim(ADOTmp.fieldbyname('ISJSKZ').AsString); FMJKZ := Trim(ADOTmp.fieldbyname('P_KZ').AsString); FMJColor := trim(ADOTmp.fieldbyname('P_Color').AsString); JYxh.Text := Trim(ADOTmp.fieldbyname('maxRoll').AsString); // BatchNo.Text := Trim(ADOTmp.fieldbyname('APBatchNo').AsString); FKONGJIA := StrToFloatDEF(ADOTmp.fieldbyname('KONGJIA').AsString, 0); fkongjiawei := StrToFloatDEF(ADOTmp.fieldbyname('kongjiawei').AsString, 0); OrdNote.Text := '订单号:' + Trim(ADOTmp.fieldbyname('orderno').AsString) + #13; OrdNote.Text := OrdNote.Text + '轴卡号:' + FPCID + #13; OrdNote.Text := OrdNote.Text + '编号:' + FMJCode + #13; OrdNote.Text := OrdNote.Text + '品名:' + FMJName + #13; OrdNote.Text := OrdNote.Text + '门幅:' + FMJMF + #13; OrdNote.Text := OrdNote.Text + '克重:' + FMJKZ + #13; OrdNote.Text := OrdNote.Text + '颜色:' + FMJColor + #13; OrdNote.Text := OrdNote.Text + '特别提示:' + Trim(ADOTmp.fieldbyname('P_Note').AsString); end else begin ClearGlobal('扫描生产计划单'); end; InitInspectionRecord(); InitCDGrid(); Scan.Text := ''; end; procedure TfrmGreyInspection.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 TfrmGreyInspection.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 TfrmGreyInspection.FormDestroy(Sender: TObject); begin frmGreyInspection := nil; end; procedure TfrmGreyInspection.On1301(var Message: Tmessage); var i1, i2: Double; unitname: string; fdata: double; begin i1 := Message.WParam; I3 := strtofloat(format('%.3f', [i1 / 100000])); i2 := Message.LParam; if IsJsMessage then begin if (trim(Edit7.Text) = '√') then begin jylen.Text := format('%.1f', [i1 / 100000]); // if person2.Text = '' then // begin // if StrToFloat(format('%.1f', [i1 / 100000])) >= 0 then // begin // JYLen1.Text := format('%.1f', [i1 / 100000]); // end // else // JYLen1.Text := '0'; // // end // else // begin // if person3.Text = '' then // begin // if JYLen1.Text <> '' then // begin // if (strtofloat(format('%.1f', [i1 / 100000])) - strtofloat(jylen1.Text)) >= 0 then // begin // JYLen2.Text := FloatToStr(strtofloat(format('%.1f', [i1 / 100000])) - strtofloat(jylen1.Text)); // end // else // JYLen2.Text := '0'; // // end // else // begin // JYLen2.Text := format('%.1f', [i1 / 100000]); // end; // end // else // begin // if person4.Text = '' then // begin // if (JYLen2.Text <> '') and (JYLen1.Text <> '') then // begin // if (strtofloat(format('%.1f', [i1 / 100000])) - strtofloat(jylen2.Text) - strtofloat(jylen1.Text)) >= 0 then // begin // JYLen3.Text := FloatToStr(strtofloat(format('%.1f', [i1 / 100000])) - strtofloat(jylen2.Text) - strtofloat(jylen1.Text)); // end // else // JYLen3.Text := '0'; // // end // else // begin // JYLen3.Text := format('%.1f', [i1 / 100000]); // end; // end // else // begin // if person5.Text = '' then // begin // if (JYLen3.Text <> '') and (JYLen2.Text <> '') and (JYLen1.Text <> '') then // begin // if (strtofloat(format('%.1f', [i1 / 100000])) - strtofloat(jylen3.Text) - strtofloat(jylen2.Text) - strtofloat(jylen1.Text)) >= 0 then // begin // JYLen4.Text := FloatToStr(strtofloat(format('%.1f', [i1 / 100000])) - strtofloat(jylen3.Text) - strtofloat(jylen2.Text) - strtofloat(jylen1.Text)); // end // else // JYLen4.Text := '0'; // // end // else // begin // JYLen4.Text := format('%.1f', [i1 / 100000]); // end; // end // else // begin // if (JYLen4.Text <> '') and (JYLen3.Text <> '') and (JYLen2.Text <> '') and (JYLen1.Text <> '') then // begin // if (strtofloat(format('%.1f', [i1 / 100000])) - strtofloat(jylen4.Text) - strtofloat(jylen3.Text) - strtofloat(jylen2.Text) - strtofloat(jylen1.Text)) >= 0 then // begin // JYLen5.Text := FloatToStr(strtofloat(format('%.1f', [i1 / 100000])) - strtofloat(jylen4.Text) - strtofloat(jylen3.Text) - strtofloat(jylen2.Text) - strtofloat(jylen1.Text)); // end // else // JYLen5.Text := '0'; // // end // else // begin // JYLen5.Text := format('%.1f', [i1 / 100000]); // end; // end; // end; // end; // // end; // if i2 = 0 then // begin // Label9.Caption := 'M'; // Label6.Caption := 'M'; // Label16.Caption := 'M'; // Label23.Caption := 'M'; // Label27.Caption := 'M'; // end // else // begin // Label9.Caption := 'Y'; // Label6.Caption := 'Y'; // Label16.Caption := 'Y'; // Label23.Caption := 'Y'; // Label27.Caption := 'Y'; // end; end; end; end; procedure TfrmGreyInspection.On1201(var Message: Tmessage); var i1, i2: integer; unitname: string; fdata: double; begin i1 := Message.WParam; i2 := Message.LParam; if IsJsMessage then begin if trim(Edit1.Text) = '√' then begin JYGW.Text := format('%.1f', [i1 / 100000]); end; end; end; procedure TfrmGreyInspection.FormClose(Sender: TObject; var Action: TCloseAction); begin //DataLink_WFBProducttion.ADOLink.Connected:=False; if isCommopen then begin closeCom(DZCDYDllName); closeCom(MBDYDllName); end; Action := caFree; end; procedure TfrmGreyInspection.InitCDGrid(); begin with ADOTmp do begin Close; SQL.Clear; sql.Add('select * from JY_Cloth_CD where JYID=' + quotedstr(Trim(FFFMJID))); //ShowMessage(SQL.Text); Open; end; SCreateCDS20(ADOTmp, CDS_MJCD); SInitCDSData20(ADOTmp, CDS_MJCD); end; procedure TfrmGreyInspection.InitInspectionRecord(); begin with ADOTmp do begin Close; SQL.Clear; sql.Add('select JYPS=count(JYId),JYLen=isnull(sum(JYLen),0) from JY_Cloth where Filler=''' + Trim(DName) + ''' '); sql.Add(' and DateDiff(dd,FillTime,getdate())=0 '); // ShowMessage(SQL.Text); Open; end; lblJYPS.Caption := '日检验:' + trim(ADOTmp.fieldbyname('JYPS').AsString) + '匹'; lblJYLen.Caption := '日检验:' + trim(ADOTmp.fieldbyname('JYLen').AsString) + '米'; with ADOTmp do begin Close; SQL.Clear; sql.Add('select JYPS=count(JYId),JYLen=isnull(sum(JYLen),0) from JY_Cloth where Filler=''' + Trim(DName) + ''' '); sql.Add(' and datediff(month,FillTime,getdate())=0 '); //ShowMessage(SQL.Text); Open; end; lblJYPS.Caption := lblJYPS.Caption + ' 月检验:' + trim(ADOTmp.fieldbyname('JYPS').AsString) + '匹'; lblJYLen.Caption := lblJYLen.Caption + ' 月检验:' + trim(ADOTmp.fieldbyname('JYLen').AsString) + '米'; with ADOTmp do begin Close; SQL.Clear; sql.Add('select A.*'); // SQL.Add(',p_name=(select P_CodeName from pd_plan_sub B WHERE B.SUBID=A.SUBID)'); sql.Add(',JTH=(SELECT MACHNO FROM BS_Machine k where k.machid= (SELECT top 1 e.CarNo FROM CK_YgCl E where a.PCID =E.MJID and E.ClType'); sql.Add('IN (''上轴'',''接头'') and isnull(CarNo,'''')<>'''' order by e.Filltime desc))'); SQL.Add(',APXH=(SELECT APXH FROM PD_Plan_AnPai E WHERE E.APID=A.APID)'); sql.Add('from JY_Cloth A where A.JYCRType in (''已入库'',''未入库'') '); sql.Add(' and A.Filler=''' + Trim(DName) + ''''); sql.Add(' and CONVERT(VARCHAR(10),FILLTIME,120)=CONVERT(VARCHAR(10),GETDATE(),120)'); sql.Add('order by filltime desc'); //ShowMessage(SQL.Text); Open; end; SCreateCDS20(ADOTmp, CDS_MJID); SInitCDSData20(ADOTmp, CDS_MJID); end; procedure TfrmGreyInspection.TBCloseClick(Sender: TObject); begin Close; end; procedure TfrmGreyInspection.TBCDClick(Sender: TObject); begin try frmZDYHelp := TfrmZDYHelp.Create(Application); with frmZDYHelp do begin flag := 'GreyCD'; flagname := '疵点'; fnote := True; V1Note.Caption := '英文名称'; if ShowModal = 1 then begin end; end; finally frmZDYHelp.Free; end; end; procedure TfrmGreyInspection.FormShow(Sender: TObject); begin InitCDGrid(); InitBatchNo(); if IsINIFile() then ReadINIFile() else WriteINIFile; if trim(Edit7.Text) = '√' then IsJsMessage := true; if trim(fmanage) <> '高权限' then begin if trim(DZCDYDllName) <> '' then OpenCom(DZCDYDllName); if trim(MBDYDllName) <> '' then OpenCom(MBDYDllName); Edit7.Visible := true; Label35.Visible := true; end; end; function TfrmGreyInspection.SaveData(): Boolean; var maxno, FMJID, BZID, strsql: string; FMJLen: Double; FJYLEN, FJSLEN: Double; begin FMJID := ''; try ADOCmd.Connection.BeginTrans; ///保存主表 with ADOCmd do begin Close; sql.Clear; SQL.Add('select * from JY_Cloth where JYId=''' + Trim(FMJID) + ''''); Open; end; with ADOCmd do begin if FAPID <> '' then begin maxno := FAPID; Append; end else begin if Trim(FMJID) = '' then begin Append; if GetLSNo(ADOTmp, maxno, 'G' + Trim(SCXFlag), 'JY_Cloth', 4, 1) = False then begin ADOCmd.Connection.RollbackTrans; Application.MessageBox('生成流水号异常!', '提示', 0); BTPrint.Enabled := True; exit; end; end else begin maxno := Trim(FMJID); Edit; end; end; FieldByName('MainId').value := Trim(FMainId); FieldByName('SubId').value := Trim(FSubId); FieldByName('APId').value := Trim(FAPID); FieldByName('pcid').value := Trim(FPCID); FieldByName('P_Code').value := Trim(FMJCode); FieldByName('P_CodeName').value := Trim(FMJName); FieldByName('P_Spec').value := Trim(FMJSpec); FieldByName('P_Color').value := Trim(FMJColor); FieldByName('P_MF').value := Trim(FMJMF); FieldByName('P_KZ').value := Trim(FMJKZ); FieldByName('MachNo').value := Trim(FCarNo) + ''; FieldByName('JYID').Value := Trim(maxno); FieldByName('JYCRType').Value := '未入库'; FieldByName('Valie').Value := 'Y'; FieldByName('kaijian').Value := StrToFloatDef(kaijian.Text, 0); FieldByName('JYXH').Value := strtointdef(trim(JYxh.Text), 0); //挡车工 FieldByName('Person1').Value := trim(Person1.Text); FieldByName('Person2').Value := trim(Person2.Text); FieldByName('Person3').Value := trim(Person3.Text); FieldByName('group1').Value := trim(Person1.hint); FieldByName('group2').Value := trim(Person2.hint); FieldByName('group3').Value := trim(Person3.hint); FieldByName('group4').Value := trim(Person4.hint); FieldByName('group5').Value := trim(Person5.hint); FieldByName('Person4').Value := trim(Person4.Text); FieldByName('Person5').Value := trim(Person5.Text); //挡车工长度 FieldByName('JYLen1').Value := StrToFloatdef(trim(JYLen1.Text), 0); FieldByName('JYLen2').Value := StrToFloatdef(trim(JYLen2.Text), 0); FieldByName('JYLen3').Value := StrToFloatdef(trim(JYLen3.Text), 0); FieldByName('JYLen4').Value := StrToFloatdef(trim(JYLen4.Text), 0); FieldByName('JYLen5').Value := StrToFloatdef(trim(JYLen5.Text), 0); //长度 FieldByName('JYLen').Value := StrToFloatdef(trim(JYLen.Text), 0) + FKONGJIA; // StrToFloatdef(trim(JYLen1.Text), 0) + StrToFloatdef(trim(JYLen2.Text), 0) + StrToFloatdef(trim(JYLen3.Text), 0) + StrToFloatdef(trim(JYLen4.Text), 0) + StrToFloatdef(trim(JYLen5.Text), 0) + FKONGJIA; //皮重 FieldByName('JYTare').Value := 0; //StrToFloatdef(trim(JYTare.Text), 0) // 毛重 FieldByName('JYGW').Value := StrToFloatdef(trim(JYGW.Text), 0) + fkongjiawei; // 净重 FieldByName('JYNW').Value := StrToFloatdef(trim(JYGW.Text), 0); //- StrToFloatdef(trim(JYTare.Text), 0); //系数 FieldByName('JYXS').Value := StrToFloatdef(trim(JYXS.Text), 0); FieldByName('kongjia').Value := FKONGJIA; FieldByName('kongjiaWEI').Value := FKONGJIAWEI; FieldByName('JSKZ').Value := FJSKZ; //计算米数 if (FJSKZ > 0) then begin FieldByName('JSLen').Value := RoundFloat(((StrToFloatdef(trim(JYGW.Text), 0)) * 1000 / FJSKZ + FKONGJIA), 1); end else begin FieldByName('JSLen').Value := RoundFloat((StrToFloatdef(trim(JYLen1.Text), 0) + StrToFloatdef(trim(JYLen2.Text), 0) + StrToFloatdef(trim(JYLen3.Text), 0) + StrToFloatdef(trim(JYLen4.Text), 0) + StrToFloatdef(trim(JYLen5.Text), 0)), 1) + FKONGJIA; end; if Trim(Edit3.Text) <> '' then begin FieldByName('JYType').Value := '正品'; end; if Trim(Edit4.Text) <> '' then begin FieldByName('JYType').Value := '次品'; end; if Trim(FMJID) = '' then begin FieldByName('Filler').Value := Trim(DName); FieldByName('FillCode').Value := Trim(DCode); FieldByName('FillTime').Value := SGetServerDateTime(ADOTmp); end else begin FieldByName('Editer').Value := Trim(DName); FieldByName('EditCode').Value := Trim(DCode); FieldByName('EditTime').Value := SGetServerDateTime(ADOTmp); end; FieldByName('JTType').Value := Trim(SCXFlag); Post; end; /////////////////////////更新卷号///////////////////////////////////// if FAPID = '' then begin with ADOCmd do begin close; sql.Clear; sql.Add('update JY_Cloth SET '); sql.Add('JYXH= (select isnull(MAX(JYXH),0)+1 from JY_Cloth X where X.JYID<>JY_Cloth.JYID and X.PCID=JY_Cloth.PCID )'); sql.Add('where JYID=''' + Trim(maxno) + ''' '); execsql; end; end; //查询卷号修改界面 with ADOCmd do begin Close; sql.Clear; sql.Add('select JYXH from JY_Cloth'); sql.Add('where JYID=''' + Trim(maxno) + ''''); open; if not IsEmpty then begin JYxh.Text := fieldbyname('JYxh').AsString; end; end; //////////////////////////更新卷号//////////////////////////////////// FMJID := Trim(maxno); FFFMJID := Trim(maxno); with ADOCmd do begin close; sql.Clear; sql.Add('update JY_Cloth SET '); sql.Add('CDList=cast((select CDName+CAST(CDQty as varchar)+''M;'' from JY_Cloth_CD where JY_Cloth_CD.JYID=JY_Cloth.JYID for xml path('''')) as varchar(200))'); sql.Add('where JYID=''' + Trim(FMJID) + ''' '); execsql; end; with ADOCmd do begin close; sql.Clear; sql.Add('update JY_Cloth SET '); sql.Add('jslen=jylen'); sql.Add('where JYID=''' + Trim(FMJID) + ''' '); sql.Add('and jslen= ADOCmd.FieldByName('c_pie').AsFloat then begin if Application.MessageBox('已检匹数已经超出经轴匹数,是否确定提交?', '提示', 32 + 4) <> IDYES then begin BTPrint.Enabled := True; Exit; end; end; end; if SaveData() then begin if StrToFloatDef(kaijian.Text, 0) <> 0 then begin with ADOCmd do begin close; sql.Clear; sql.Add('exec P_JY_ChaiPi '); sql.Add(' @OrgJYID=' + quotedstr(FFFMJID)); sql.Add(',@KJLen=' + kaijian.text); open; end; if ADOCmd.FieldByName('intReturn').AsInteger = -1 then begin application.MessageBox(PChar(trim(ADOCmd.FieldByName('ShowMsg').AsString)), '提示信息', 0); ADOCmd.Connection.RollbackTrans; end; end; JYxh.Text := inttostr(strTointdef(trim(JYXH.Text), 0) + 1); if Trim(Edit6.Text) = '√' then begin PrtData(FFFMJID); end; if trim(MBDYDllName) <> '' then begin if Edit7.Text <> '' then begin clearCom(MBDYDllName); end; end; end else begin BTPrint.Enabled := True; end; InitInspectionRecord(); InitCDGrid(); ClearGlobal('提交'); JYLen1.SetFocus; jylen1.Text := ''; jylen2.Text := ''; jylen3.Text := ''; jylen4.Text := ''; jylen5.Text := ''; person1.Text := ''; person2.Text := ''; person3.Text := ''; person1.hint := ''; person2.hint := ''; person3.hint := ''; person4.hint := ''; person5.hint := ''; person4.Text := ''; person5.Text := ''; // FMainId := ''; BTPrint.Enabled := True; end; procedure TfrmGreyInspection.PrtData(FMJID: string); var fPrintFile: string; Txt, fImagePath: string; Moudle: THandle; Makebar: TMakebar; Mixtext: TMixtext; begin with ADOQueryPrint do begin Close; SQL.Clear; sql.Add(' EXEC P_JY_Print_Lab '); SQL.Add(' @JYID=''' + Trim(FMJID) + ''''); Open; end; if ADOQueryPrint.IsEmpty then begin application.MessageBox('标签内容未找到!', '提示信息', MB_ICONERROR); BTPrint.Enabled := True; exit; end; try Moudle := LoadLibrary('MakeQRBarcode.dll'); @Makebar := GetProcAddress(Moudle, 'Make'); @Mixtext := GetProcAddress(Moudle, 'MixText'); Txt := Trim(ADOQueryPrint.fieldbyname('JYID').AsString); fImagePath := ExtractFilePath(Application.ExeName) + 'image\temp.bmp'; if not DirectoryExists(pchar(ExtractFilePath(Application.ExeName) + 'image')) then CreateDirectory(pchar(ExtractFilePath(Application.ExeName) + 'image'), nil); if FileExists(fImagePath) then DeleteFile(fImagePath); Makebar(pchar(Txt), Length(Txt), 3, 3, 0, PChar(fImagePath), 3); except application.MessageBox('条形码生成失败!', '提示信息', MB_ICONERROR); BTPrint.Enabled := True; exit; end; ExportFtErpFile(Trim(ADOQueryPrint.fieldbyname('LabName').AsString), ADOTmp); if Trim(ADOQueryPrint.fieldbyname('LabName').AsString) <> '' then begin fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\' + Trim(ADOQueryPrint.fieldbyname('LabName').AsString) + '.rmf'; end else begin ExportFtErpFile('通用坯布标签.rmf', ADOTmp); fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\通用坯布标签.rmf'; end; if FileExists(fPrintFile) then begin RMVariables['QRBARCODE'] := fImagePath; RM2.LoadFromFile(fPrintFile); Rm2.DefaultCopies := strtointdef(trim(ComboBox1.Text), 1); RM2.PrintReport; end else begin Application.MessageBox(PChar('没有找' + fPrintFile), '提示', 0); end; end; procedure TfrmGreyInspection.SpeedButton1Click(Sender: TObject); var fsj: string; begin fsj := Trim(TSpeedButton(Sender).Hint); if Trim(fsj) = '' 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 TfrmGreyInspection.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 TfrmGreyInspection.cxGridDBColumn2PropertiesChange(Sender: TObject); var fsj: string; begin fsj := Trim(Order_MJ.fieldbyname('SubId').AsString); Order_MJ.DisableControls; with Order_MJ do begin First; while not Eof do begin if Trim(Order_MJ.fieldbyname('SubId').AsString) <> fsj then begin Edit; FieldByName('SSel').Value := False; end; Next; end; end; Order_MJ.EnableControls; Order_MJ.Locate('SubId', fsj, []); end; procedure TfrmGreyInspection.Button5Click(Sender: TObject); var fPrintFile: string; i: Integer; mvalue: Double; begin if CDS_MJID.IsEmpty then Exit; PrtData(CDS_MJID.fieldbyname('JYID').AsString); end; procedure TfrmGreyInspection.SpeedButton49Click(Sender: TObject); begin Panel3.Visible := False; end; procedure TfrmGreyInspection.ScanKeyPress(Sender: TObject; var Key: Char); begin if Key = #13 then begin if Scan.Text = '' then Exit; // if Pos('CM', Trim(Scan.Text)) > 0 then // begin // FOperationStatus := '扫描生产计划单'; // ClearGlobal('扫描'); // ScanOrder(); // end // else // begin // FOperationStatus := '扫描产品信息'; // ClearGlobal('扫描'); // ScanSample(); // end; if Pos('PC', Trim(Scan.Text)) > 0 then begin with ADOTmp do begin Close; sql.Clear; sql.Add('select * from pd_plan_Card where pcid= ''' + Trim(Scan.Text) + ''''); Open; end; if ADOTmp.IsEmpty then begin application.MessageBox(Pchar('卡号错误!'), '提示'); FPCID := ''; Scan.Text := ''; Exit; end; with ADOTmp do begin Close; sql.Clear; sql.Add('select * from CK_YgCl where mjid= ''' + Trim(Scan.Text) + ''''); sql.Add('and cltype=''上轴'''); Open; end; if ADOTmp.IsEmpty then begin application.MessageBox(Pchar('该卡还未上轴刷卡!'), '提示'); FPCID := ''; Scan.Text := ''; Exit; end; FOperationStatus := '扫描流程卡'; ClearGlobal('扫描'); ScanAnpai(); end else begin FOperationStatus := '扫描布票'; ClearGlobal('扫描'); ScanbpAnpai(); end; JYLen.SetFocus; Scan.Text := ''; end; end; procedure TfrmGreyInspection.Edit3Click(Sender: TObject); begin if Trim(Edit3.Text) = '' then begin Edit3.Text := '√'; Edit4.Text := ''; end else begin Edit3.Text := ''; Edit4.Text := '√'; end; end; procedure TfrmGreyInspection.Edit4Click(Sender: TObject); begin if Trim(Edit4.Text) = '' then begin Edit4.Text := '√'; Edit3.Text := ''; end else begin Edit4.Text := ''; Edit3.Text := '√'; end; end; procedure TfrmGreyInspection.Edit6Click(Sender: TObject); begin if Trim(Edit6.Text) = '' then begin Edit6.Text := '√'; end else begin Edit6.Text := ''; end; end; procedure TfrmGreyInspection.MJstr3KeyPress(Sender: TObject; var Key: Char); begin if Key = #13 then begin Key := #0; SelectNext(ActiveControl as TWinControl, True, True); end; end; procedure TfrmGreyInspection.JYGWChange(Sender: TObject); begin QuantityConversion(); end; procedure TfrmGreyInspection.ScanClick(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 TfrmGreyInspection.Edit7Click(Sender: TObject); begin if Trim(Edit7.Text) = '' then begin Edit7.Text := '√'; end else begin Edit7.Text := ''; end; end; procedure TfrmGreyInspection.JYNWKeyPress(Sender: TObject; var Key: Char); begin if Key = #13 then begin BTPrint.Click; end; end; procedure TfrmGreyInspection.FormCreate(Sender: TObject); begin IsCommopen := false; IsJsMessage := false; end; procedure TfrmGreyInspection.Edit8Click(Sender: TObject); begin if Trim(Edit8.Text) = '' then begin Edit8.Text := '√'; Button5.Visible := true; end else begin Edit8.Text := ''; Button5.Visible := false; end; end; procedure TfrmGreyInspection.JYLen1Change(Sender: TObject); var XiShu, FMJLen, FMJMaShu: Double; begin QuantityConversion(); end; procedure TfrmGreyInspection.Tv2CellDblClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean); begin if CDS_MJCD.IsEmpty then Exit; if Trim(CDS_MJCD.fieldbyname('MCID').AsString) = '' then begin if Application.MessageBox('确定要删除数据吗?', '提示', 32 + 4) <> IDYES then Exit; CDS_MJCD.Delete; end; end; procedure TfrmGreyInspection.ToolButton2Click(Sender: TObject); begin try frmZDYHelp := TfrmZDYHelp.Create(Application); with frmZDYHelp do begin flag := 'GreyBatchNo'; flagname := '批号'; if ShowModal = 1 then begin InitBatchNo(); end; end; finally frmZDYHelp.Free; end; end; procedure TfrmGreyInspection.person1Click(Sender: TObject); var i: Integer; begin Panel3.Visible := false; // 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; try frmSCPerson := TfrmSCPerson.Create(Application); with frmSCPerson do begin FlagStr := 'SCPerson'; if ShowModal = 1 then begin Person1.Text := frmSCPerson.FSDPerson; Person1.Hint := frmSCPerson.CDS_ZB.FieldByName('note').AsString; end; end; finally frmSCPerson.Free; end; end; procedure TfrmGreyInspection.person2Click(Sender: TObject); var i: Integer; begin Panel3.Visible := false; // 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; try frmSCPerson := TfrmSCPerson.Create(self); with frmSCPerson do begin FlagStr := 'SCPerson'; if ShowModal = 1 then begin Person2.Text := frmSCPerson.FSDPerson; Person2.Hint := frmSCPerson.CDS_ZB.FieldByName('note').AsString; end; end; finally frmSCPerson.Free; end; end; procedure TfrmGreyInspection.ToolButton3Click(Sender: TObject); begin try frmZDYHelp := TfrmZDYHelp.Create(Application); with frmZDYHelp do begin flag := 'SCPerson'; flagname := '挡车工'; V1Note.Caption := '组别'; fnote := True; if ShowModal = 1 then begin end; end; finally frmZDYHelp.free; end; end; procedure TfrmGreyInspection.person5Click(Sender: TObject); var i: Integer; begin Panel3.Visible := false; // 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; try frmSCPerson := TfrmSCPerson.Create(self); with frmSCPerson do begin FlagStr := 'SCPerson'; if ShowModal = 1 then begin Person5.Text := frmSCPerson.FSDPerson; Person5.Hint := frmSCPerson.CDS_ZB.FieldByName('note').AsString; end; end; finally frmSCPerson.Free; end; end; procedure TfrmGreyInspection.person4Click(Sender: TObject); var i: Integer; begin Panel3.Visible := false; // 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; try frmSCPerson := TfrmSCPerson.Create(self); with frmSCPerson do begin FlagStr := 'SCPerson'; if ShowModal = 1 then begin Person4.Text := frmSCPerson.FSDPerson; Person4.Hint := frmSCPerson.CDS_ZB.FieldByName('note').AsString; end; end; finally frmSCPerson.Free; end; end; procedure TfrmGreyInspection.person3Click(Sender: TObject); var i: Integer; begin Panel3.Visible := false; // 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; try frmSCPerson := TfrmSCPerson.Create(self); with frmSCPerson do begin FlagStr := 'SCPerson'; if ShowModal = 1 then begin Person3.Text := frmSCPerson.FSDPerson; Person3.Hint := frmSCPerson.CDS_ZB.FieldByName('note').AsString; end; end; finally frmSCPerson.Free; end; end; procedure TfrmGreyInspection.edtDelClick(Sender: TObject); begin if Trim(TEdit(Sender).Text) = '' then begin TEdit(Sender).Text := '√'; Edit7.Text := ''; end else begin TEdit(Sender).Text := ''; Edit7.Text := '√'; end; end; procedure TfrmGreyInspection.ToolButton4Click(Sender: TObject); begin try frmFinishedClothStatistical := TfrmFinishedClothStatistical.Create(self); with frmFinishedClothStatistical do begin if ShowModal = 1 then begin end; end; finally frmFinishedClothStatistical.Free; end; end; procedure TfrmGreyInspection.ToolButton5Click(Sender: TObject); begin try frmZDYHelp := TfrmZDYHelp.Create(Application); with frmZDYHelp do begin flag := 'JXiuG'; flagname := '机修工'; V1Note.Caption := '组别'; fnote := True; if ShowModal = 1 then begin end; end; finally frmZDYHelp.free; end; end; procedure TfrmGreyInspection.Label9Click(Sender: TObject); begin if Label9.Caption = 'Y' then begin Label2.Caption := 'M'; Label9.Caption := 'M'; Label6.Caption := 'M'; Label16.Caption := 'M'; Label23.Caption := 'M'; Label27.Caption := 'M'; end else begin Label2.Caption := 'Y'; Label9.Caption := 'Y'; Label6.Caption := 'Y'; Label16.Caption := 'Y'; Label23.Caption := 'Y'; Label27.Caption := 'Y'; end; end; procedure TfrmGreyInspection.Label6Click(Sender: TObject); begin if Label6.Caption = 'Y' then begin Label2.Caption := 'M'; Label9.Caption := 'M'; Label6.Caption := 'M'; Label16.Caption := 'M'; Label23.Caption := 'M'; Label27.Caption := 'M'; end else begin Label2.Caption := 'Y'; Label9.Caption := 'Y'; Label6.Caption := 'Y'; Label16.Caption := 'Y'; Label23.Caption := 'Y'; Label27.Caption := 'Y'; end; end; procedure TfrmGreyInspection.Label16Click(Sender: TObject); begin if Label16.Caption = 'Y' then begin Label2.Caption := 'M'; Label9.Caption := 'M'; Label6.Caption := 'M'; Label16.Caption := 'M'; Label23.Caption := 'M'; Label27.Caption := 'M'; end else begin Label2.Caption := 'Y'; Label9.Caption := 'Y'; Label6.Caption := 'Y'; Label16.Caption := 'Y'; Label23.Caption := 'Y'; Label27.Caption := 'Y'; end; end; procedure TfrmGreyInspection.Label23Click(Sender: TObject); begin if Label23.Caption = 'Y' then begin Label9.Caption := 'M'; Label6.Caption := 'M'; Label16.Caption := 'M'; Label23.Caption := 'M'; Label27.Caption := 'M'; end else begin Label9.Caption := 'Y'; Label6.Caption := 'Y'; Label16.Caption := 'Y'; Label23.Caption := 'Y'; Label27.Caption := 'Y'; end; end; procedure TfrmGreyInspection.Label27Click(Sender: TObject); begin if Label27.Caption = 'Y' then begin Label9.Caption := 'M'; Label6.Caption := 'M'; Label16.Caption := 'M'; Label23.Caption := 'M'; Label27.Caption := 'M'; end else begin Label9.Caption := 'Y'; Label6.Caption := 'Y'; Label16.Caption := 'Y'; Label23.Caption := 'Y'; Label27.Caption := 'Y'; end; end; procedure TfrmGreyInspection.Edit1Click(Sender: TObject); begin if Trim(Edit1.Text) = '' then begin Edit1.Text := '√'; end else begin Edit1.Text := ''; end; end; procedure TfrmGreyInspection.SpeedButton43Click(Sender: TObject); begin if edtDel.Text = '√' then begin DelDate(Trim(Scan.Text)); end else begin FOperationStatus := '扫描布票'; ClearGlobal('扫描'); ScanAnpai(); end; JYLen1.SetFocus; Scan.Text := ''; end; procedure TfrmGreyInspection.JYLen1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin if Trim(person1.Text) = '' then begin raise Exception.Create('先输入挡车工1!'); end; end; procedure TfrmGreyInspection.JYLen2MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin if Trim(person2.Text) = '' then begin raise Exception.Create('先输入挡车工2!'); end; end; procedure TfrmGreyInspection.JYLen3MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin if Trim(person3.Text) = '' then begin raise Exception.Create('先输入挡车工3!'); end; end; procedure TfrmGreyInspection.JYLen4MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin if Trim(person4.Text) = '' then begin raise Exception.Create('先输入挡车工4!'); end; end; procedure TfrmGreyInspection.JYLen5MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin if Trim(person5.Text) = '' then begin raise Exception.Create('先输入挡车工5!'); end; end; procedure TfrmGreyInspection.Label2Click(Sender: TObject); begin if Label2.Caption = 'Y' then begin Label2.Caption := 'M'; Label9.Caption := 'M'; Label6.Caption := 'M'; Label16.Caption := 'M'; Label23.Caption := 'M'; Label27.Caption := 'M'; end else begin Label2.Caption := 'Y'; Label9.Caption := 'Y'; Label6.Caption := 'Y'; Label16.Caption := 'Y'; Label23.Caption := 'Y'; Label27.Caption := 'Y'; end; end; procedure TfrmGreyInspection.ToolButton6Click(Sender: TObject); begin if CDS_MJID.IsEmpty then Exit; if Application.MessageBox('确定要删除数据吗?', '提示', 32 + 4) <> IDYES then Exit; ADOCmd.Connection.BeginTrans; try with ADOTmp do begin Close; sql.Clear; SQL.Add('select * from JY_CLOTH A WHERE A.JYID=' + QuotedStr(trim(CDS_MJID.fieldbyName('JYID').AsString))); OPEN; end; if ADOTmp.FieldByName('JYCRType').AsString = '已出库' then begin application.MessageBox('该条码已发货,禁止删除!', '提示信息', 0); exit; end; // if ADOTmp.FieldByName('JYCRType').AsString = '已入库' then // begin // application.MessageBox('该条码已入库,禁止删除!', '提示信息', 0); // exit; // end; with ADOTmp do begin Close; sql.Clear; SQL.Add(' update JY_CLOTH set Deler= ' + QuotedStr(Trim(dname))); sql.Add(',Deltime=GETDATE() where jyid=' + QuotedStr(trim(CDS_MJID.fieldbyName('JYID').AsString))); sql.Add(' insert into JY_CLOTH_del select * from JY_CLOTH where jyid=' + QuotedStr(trim(CDS_MJID.fieldbyName('JYID').AsString))); sql.Add('delete JY_Cloth where JYID=''' + Trim(CDS_MJID.fieldbyname('JYID').AsString) + ''''); sql.Add('delete CK_Cloth_CR where JYID=''' + Trim(CDS_MJID.fieldbyname('JYID').AsString) + ''''); sql.Add('delete CK_Cloth_KC where JYID=''' + Trim(CDS_MJID.fieldbyname('JYID').AsString) + ''''); sql.Add('delete JY_Cloth_CD where JYID=''' + Trim(CDS_MJID.fieldbyname('JYID').AsString) + ''''); sql.Add('update PD_Plan_AnPai SET jyflag=''0'' '); sql.Add('where APID=''' + trim(CDS_MJID.fieldbyname('apid').AsString) + ''' '); sql.Add('insert into SY_SysLog(operor,opertime,Model,acction,opevent,result) values( '); sql.Add(' ' + quotedstr(trim(DName))); sql.Add(',getdate() '); sql.Add(',' + quotedstr(trim(self.Caption))); sql.Add(',' + quotedstr(trim('作废成品检验数据'))); sql.Add(',' + quotedstr('卷条码:' + trim(CDS_MJID.fieldbyname('JYID').AsString) + ' 卷号:' + trim(CDS_MJID.fieldbyname('JYXH').AsString) + ' 卡号:' + trim(CDS_MJID.fieldbyname('pcid').AsString))); sql.Add(',' + quotedstr(trim('成功'))); sql.Add(')'); ExecSQL; end; ADOCmd.Connection.CommitTrans; CDS_MJID.Delete; application.MessageBox('删除成功!', '提示信息'); except ADOCmd.Connection.RollbackTrans; application.MessageBox(PChar(Exception(ExceptObject).Message), '提示信息', 0); end; end; end.