unit U_JTSJY; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, ComCtrls, ToolWin, DB, ADODB, Buttons, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit, cxDBData, cxGridLevel, cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxClasses, cxControls, cxGridCustomView, cxGrid, DBClient, RM_Dataset, RM_System, RM_Common, RM_Class, RM_GridReport, IniFiles, cxLookAndFeels, cxLookAndFeelPainters, cxNavigator, dxSkinsCore, 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, dxSkinsDefaultPainters, dxSkinValentine, dxSkinVS2010, dxSkinWhiteprint, dxSkinXmas2008Blue, dxSkinscxPCPainter; type TfrmJTSJY = class(TForm) CPInfo: TRichEdit; ADOQueryTemp: TADOQuery; Panel3: TPanel; Panel4: TPanel; Panel2: TPanel; SQty: TEdit; Label4: TLabel; Button3: TButton; Panel8: TPanel; Panel9: TPanel; Label1: TLabel; ZG1: TEdit; ZG2: TEdit; Panel6: TPanel; btnSampleSel: TButton; Button1: TButton; Panel10: TPanel; cxGrid3: TcxGrid; Tv3: TcxGridDBTableView; cxGridDBColumn1: TcxGridDBColumn; v3Column1: TcxGridDBColumn; v3Column2: TcxGridDBColumn; cxGridLevel2: TcxGridLevel; Panel7: 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; v3Column4: TcxGridDBColumn; ADOCmd: TADOQuery; ClientDataSet1: TClientDataSet; DataSource1: TDataSource; ZG5: TEdit; ZG5C1: TLabel; ZG5C2: TLabel; v3Column3: TcxGridDBColumn; RM2: TRMGridReport; RMDB_Main: TRMDBDataSet; ADOQueryPrint: TADOQuery; Panel1: TPanel; Label14: TLabel; ComboBox1: TComboBox; Edit13: TEdit; Label15: TLabel; Button2: TButton; Panel5: TPanel; Label2: TLabel; MachNO: TComboBox; Tv3Column1: TcxGridDBColumn; Label7: TLabel; Label9: TLabel; ZGQty: TEdit; Label3: TLabel; Y_Type: TComboBox; ZG4: TEdit; ZG4C2: TLabel; ZG4C1: TLabel; ZG6C2: TLabel; ZG6C1: TLabel; ZG3: TEdit; ZG6: TEdit; JTNote: TEdit; Label5: TLabel; ZG1C1: TLabel; ZG1C2: TLabel; ZG2C1: TLabel; ZG2C2: TLabel; ZG3C1: TLabel; ZG3C2: TLabel; ClientDataSetYS: TClientDataSet; procedure FormDestroy(Sender: TObject); procedure btnSampleSelClick(Sender: TObject); procedure TBCloseClick(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure Button1Click(Sender: TObject); procedure ZG1Click(Sender: TObject); procedure SQtyClick(Sender: TObject); procedure SpeedButton1Click(Sender: TObject); procedure SpeedButton12Click(Sender: TObject); procedure Button3Click(Sender: TObject); procedure FormShow(Sender: TObject); procedure Edit13Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure ZGQtyClick(Sender: TObject); procedure cxGridDBColumn1CustomDrawCell(Sender: TcxCustomGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean); private ZGKS, SJKS, ZGZL, ZXZL, FactoryName, Y_CodeName, Y_Spec, Y_CodeNameCP, BatchNo, FFFMJID, DZCDYDllName, FTSStr,FZGColor: string; FCK, OKInt: Integer; function SaveData(DataType: string): Boolean; procedure InitGrid(); procedure InitJP(FName: string); procedure PrtData(FMJID: string); procedure OpenCom(DllName: string); procedure CloseCom(DllName: string); procedure On1201(var Message: Tmessage); message 1201; procedure TSInfo(TSStr: string); { Private declarations } public { Public declarations } end; var frmJTSJY: TfrmJTSJY; newh, newh1: hwnd; IniFile: TIniFile; implementation uses U_DataLink, U_RTFun, U_Fun, U_CPSel, U_iniParam, U_SCPerson, U_TSOKNO; {$R *.dfm} procedure TfrmJTSJY.FormDestroy(Sender: TObject); begin frmJTSJY := nil; end; procedure TfrmJTSJY.On1201(var Message: Tmessage); var i1, i2: integer; FMJMaoZ: Double; begin i1 := Message.WParam; i2 := Message.LParam; FMJMaoZ := RoundFloat(i1 * i2 / 100000, 2); SQty.Text := floattostr(FMJMaoZ); end; procedure TfrmJTSJY.btnSampleSelClick(Sender: TObject); var i: Integer; ZGName,ZGColor1,ZGColor2:string; begin FZGColor:=''; try frmCPSel := TfrmCPSel.Create(Self); with frmCPSel do begin if ShowModal = 1 then begin CPInfo.Hint := FHMainId; end; end; finally frmCPSel.Close; end; with ADOQueryTemp do begin Close; sql.Clear; sql.Add('select * from YT_Plan_Main where Mainid=''' + Trim(CPInfo.Hint) + ''''); Open; end; with ADOQueryTemp do begin Y_CodeName := Trim(fieldbyname('Y_CodeName').AsString); Y_Spec := Trim(fieldbyname('Y_Spec').AsString); BatchNo := Trim(fieldbyname('BatchNo').AsString); Y_CodeNameCP := Trim(fieldbyname('Y_CodeNameCP').AsString); ZGKS := Trim(fieldbyname('ZGKS').AsString); SJKS := Trim(fieldbyname('SJKS').AsString); ZGZL := Trim(fieldbyname('ZGZL').AsString); ZXZL := Trim(fieldbyname('ZXZL').AsString); FactoryName := Trim(fieldbyname('FactoryName').AsString); end; ADOQueryTemp.Close; CPInfo.Text := ' ' + #13 + '原丝品名:' + Trim(Y_CodeName) + #13 + #13 + '规格:' + Trim(Y_Spec) + #13 + #13 + '批号:' + Trim(BatchNo) + #13 + #13 + '成品品名:' + Trim(Y_CodeNameCP) + #13 + #13 + '纸管重量:' + Trim(ZGZL) + #13 + #13 + '纸箱重量:' + Trim(ZXZL) + #13 + #13 + '纸管颗数:' + Trim(ZGKS); //+ #13 + #13 //+'板颗数:'+Trim(SJKS); ZGQty.Text := ZGKS; with Panel8 do begin for i := 0 to Panel8.ControlCount - 1 do begin if Controls[i].Tag = 2 then begin Controls[i].Visible := False; end; if Controls[i] is TEdit then begin TEdit(Controls[i]).Text := ''; end; end; end; //1122 with ADOQueryTemp do begin Close; sql.Clear; sql.Add('select * from YT_Plan_Rule A inner join ZGColor B on A.RName=B.ColorName '); sql.Add(' where Mainid=''' + Trim(CPInfo.Hint) + ''' and RType=''颜色'' and isnull(RName,'''')<>'''''); Open; end; i:=ADOQueryTemp.RecordCount; SCreateCDS20(ADOQueryTemp,ClientDataSetYS); SInitCDSData20(ADOQueryTemp,ClientDataSetYS); with ClientDataSetYS do begin First; while not Eof do begin if FieldByName('Sindex').AsInteger=1 then begin ZG1.Visible:=True;ZG1C1.Visible:=True;ZG1C2.Visible:=True; ZG1.Hint:=Trim(ClientDataSetYS.fieldbyname('RName').AsString); if Trim(ZG1.Hint)<>'任意色' then begin ZG1C1.Caption:=''; ZG1C1.Color:=StringToColor(ClientDataSetYS.fieldbyname('ColorData1').AsString); ZG1C2.Color:=StringToColor(ClientDataSetYS.fieldbyname('ColorData2').AsString); end else begin ZG1C1.Color:=clWindow;ZG1C2.Color:=clWindow; ZG1C1.Caption:='任'+#13+'意'+#13+'色';//ZG1C2.Caption:='任'+#13+'意'+#13+'色'; end; if i = 1 then begin ZG1.Text := '√'; FZGColor:=ZG1.Hint; end; end else if FieldByName('Sindex').AsInteger=2 then begin ZG2.Visible:=True;ZG2C1.Visible:=True;ZG2C2.Visible:=True; ZG2.Hint:=Trim(ClientDataSetYS.fieldbyname('RName').AsString); if Trim(ZG2.Hint)<>'任意色' then begin ZG2C1.Caption:=''; ZG2C1.Color:=StringToColor(ClientDataSetYS.fieldbyname('ColorData1').AsString); ZG2C2.Color:=StringToColor(ClientDataSetYS.fieldbyname('ColorData2').AsString); end else begin ZG2C1.Color:=clWindow;ZG2C2.Color:=clWindow; ZG2C1.Caption:='任'+#13+'意'+#13+'色';//ZG2C2.Caption:='任'+#13+'意'+#13+'色'; end; end else if FieldByName('Sindex').AsInteger=3 then begin ZG3.Visible:=True;ZG3C1.Visible:=True;ZG3C2.Visible:=True; ZG3.Hint:=Trim(ClientDataSetYS.fieldbyname('RName').AsString); if Trim(ZG3.Hint)<>'任意色' then begin ZG3C1.Caption:=''; ZG3C1.Color:=StringToColor(ClientDataSetYS.fieldbyname('ColorData1').AsString); ZG3C2.Color:=StringToColor(ClientDataSetYS.fieldbyname('ColorData2').AsString); end else begin ZG3C1.Color:=clWindow;ZG3C2.Color:=clWindow; ZG3C1.Caption:='任'+#13+'意'+#13+'色';//ZG3C2.Caption:='任'+#13+'意'+#13+'色'; end; end else if FieldByName('Sindex').AsInteger=4 then begin ZG4.Visible:=True;ZG4C1.Visible:=True;ZG4C2.Visible:=True; ZG4.Hint:=Trim(ClientDataSetYS.fieldbyname('RName').AsString); if Trim(ZG4.Hint)<>'任意色' then begin ZG4C1.Caption:=''; ZG4C1.Color:=StringToColor(ClientDataSetYS.fieldbyname('ColorData1').AsString); ZG4C2.Color:=StringToColor(ClientDataSetYS.fieldbyname('ColorData2').AsString); end else begin ZG4C1.Color:=clWindow;ZG4C2.Color:=clWindow; ZG4C1.Caption:='任'+#13+'意'+#13+'色';//ZG4C2.Caption:='任'+#13+'意'+#13+'色'; end; end else if FieldByName('Sindex').AsInteger=5 then begin ZG5.Visible:=True;ZG5C1.Visible:=True;ZG5C2.Visible:=True; ZG5.Hint:=Trim(ClientDataSetYS.fieldbyname('RName').AsString); if Trim(ZG5.Hint)<>'任意色' then begin ZG5C1.Caption:=''; ZG5C1.Color:=StringToColor(ClientDataSetYS.fieldbyname('ColorData1').AsString); ZG5C2.Color:=StringToColor(ClientDataSetYS.fieldbyname('ColorData2').AsString); end else begin ZG5C1.Color:=clWindow;ZG5C2.Color:=clWindow; ZG5C1.Caption:='任'+#13+'意'+#13+'色';//ZG5C2.Caption:='任'+#13+'意'+#13+'色'; end; end else if FieldByName('Sindex').AsInteger=6 then begin ZG6.Visible:=True;ZG6C1.Visible:=True;ZG6C2.Visible:=True; ZG6.Hint:=Trim(ClientDataSetYS.fieldbyname('RName').AsString); if Trim(ZG6.Hint)<>'任意色' then begin ZG6C1.Caption:=''; ZG6C1.Color:=StringToColor(ClientDataSetYS.fieldbyname('ColorData1').AsString); ZG6C2.Color:=StringToColor(ClientDataSetYS.fieldbyname('ColorData2').AsString); end else begin ZG6C1.Color:=clWindow;ZG6C2.Color:=clWindow; ZG6C1.Caption:='任'+#13+'意'+#13+'色';//ZG6C2.Caption:='任'+#13+'意'+#13+'色'; end; end; Next; end; end; {with ClientDataSetYS do begin First; while not Eof do begin ZGName:='ZG'+Trim(ClientDataSetYS.fieldbyname('Sindex').AsString); ZGColor1:=ZGName+'C1';ZGColor2:=ZGName+'C2'; TEdit(FindComponent('ZG1')).Visible:=True; if FindComponent(ZGName) is TEdit then begin TEdit(FindComponent(Trim(ZGName))).Visible:=True; TEdit(FindComponent(Trim(ZGName))).Hint:=Trim(ClientDataSetYS.fieldbyname('RName').AsString); end; if i = 1 then begin TEdit(FindComponent(Trim(ZGName))).Text := '√'; end; if Trim(ClientDataSetYS.fieldbyname('ColorData1').AsString)<>'任意色' then begin TLabel(FindComponent(Trim(ZGColor1))).Visible:=True; TLabel(FindComponent(Trim(ZGColor1))).Color:=StringToColor(ClientDataSetYS.fieldbyname('ColorData1').AsString); end else begin TLabel(FindComponent(Trim(ZGColor1))).Color:=null; TLabel(FindComponent(Trim(ZGColor1))).Caption:='任'+#13+'意'+#13+'色' end; if Trim(ClientDataSetYS.fieldbyname('ColorData2').AsString)<>'任意色' then begin TLabel(FindComponent(Trim(ZGColor2))).Visible:=True; TLabel(FindComponent(Trim(ZGColor2))).Color:=StringToColor(ClientDataSetYS.fieldbyname('ColorData2').AsString); end else begin TLabel(FindComponent(Trim(ZGColor2))).Color:=null; TLabel(FindComponent(Trim(ZGColor2))).Caption:='任'+#13+'意'+#13+'色' end; Next; end; end; } with ADOQueryTemp do begin Close; sql.Clear; sql.Add('select * from YT_Plan_Rule where Mainid=''' + Trim(CPInfo.Hint) + ''' and RType=''机台'' and isnull(RName,'''')<>'''' '); Open; end; i := ADOQueryTemp.RecordCount; if i = 1 then begin MachNO.ItemIndex := MachNO.Items.IndexOf(ADOQueryTemp.fieldbyname('RName').AsString); MachNO.Enabled := False; end else begin MachNO.Enabled := True; MachNO.ItemIndex := -1; end; ADOQueryTemp.Close; end; procedure TfrmJTSJY.TBCloseClick(Sender: TObject); begin Close; end; procedure TfrmJTSJY.FormClose(Sender: TObject; var Action: TCloseAction); begin if FCK = 9 then begin CloseCom(DZCDYDllName) end; Action := caFree; end; procedure TfrmJTSJY.Button1Click(Sender: TObject); begin Close; end; procedure TfrmJTSJY.ZG1Click(Sender: TObject); var Fint, i: Integer; begin TEdit(Sender).Text := '√'; FZGColor:=TEdit(Sender).Hint; Fint := TEdit(Sender).TabOrder; for i := 0 to Panel8.ControlCount - 1 do begin with Panel8 do begin if Controls[i] is TEdit then begin if TEdit(Controls[i]).TabOrder <> Fint then begin TEdit(Controls[i]).Text := ''; end; end; end; end; end; procedure TfrmJTSJY.SQtyClick(Sender: TObject); var i: Integer; begin with Panel7 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 TfrmJTSJY.InitJP(FName: string); var i: Integer; begin with Panel7 do begin for i := 0 to ControlCount - 1 do begin if Controls[i] is TSpeedButton then begin TSpeedButton(Controls[i]).Hint := Trim(FName); end; end; end; end; procedure TfrmJTSJY.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 TfrmJTSJY.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; function TfrmJTSJY.SaveData(DataType: string): Boolean; var maxno, FMJID: string; begin FMJID := ''; try ADOCmd.Connection.BeginTrans; ///保存主表 if GetLSNo(ADOCmd, maxno, 'T' + Trim(SCXFlag), 'JY_YT', 4, 1) = False then begin ADOCmd.Connection.RollbackTrans; Application.MessageBox('生成流水号异常!', '提示', 0); exit; end; with ADOCmd do begin Close; sql.Clear; SQL.Add('select * from JY_YT where JYId=''' + Trim(FMJID) + ''''); Open; end; with ADOCmd do begin Append; FieldByName('JYID').Value := Trim(maxno); FieldByName('FactoryName').value := FactoryName; FieldByName('Y_CodeName').value := Trim(Y_CodeName); FieldByName('Y_CodeNameCP').value := Trim(Y_CodeNameCP); FieldByName('Y_Spec').value := Trim(Y_Spec); FieldByName('BatchNo').value := Trim(BatchNo); FieldByName('MachNO').value := Trim(MachNO.Text); FieldByName('Y_Type').value := Trim(Y_Type.Text); FieldByName('JTNote').value := Trim(JTNote.Text); FieldByName('ZGColor').value :=Trim(FZGColor); FieldByName('CRType').Value := '已入库'; FieldByName('Valie').Value := 'Y'; FieldByName('ZGZL').Value := StrToFloatdef(trim(ZGZL), 0); FieldByName('ZGKS').Value := StrToFloatdef(trim(ZGQty.Text), 0); FieldByName('ZXZL').Value := StrToFloatdef(trim(ZXZL), 0); FieldByName('BZType').Value := '箱'; FieldByName('JYGW').Value := StrToFloatdef(trim(SQty.Text), 0); if Trim(FMJID) = '' then begin FieldByName('Filler').Value := Trim(DName); FieldByName('FillTime').Value := SGetServerDateTime(ADOQueryTemp); FieldByName('FillCode').Value := Trim(DCode); end else begin FieldByName('Editer').Value := Trim(DName); FieldByName('EditCode').Value := Trim(DCode); FieldByName('EditTime').Value := SGetServerDateTime(ADOQueryTemp); end; FieldByName('JTType').Value := Trim(SCXFlag); Post; end; FMJID := trim(maxno); FFFMJID := FMJID; ////////////////////////净重、出入库及库存///////////////////////////////////// with ADOCmd do begin Close; sql.Clear; sql.Add('exec P_JY_Insert_JTS @JYID=''' + trim(FMJID) + ''''); execsql; end; ////////////////////////净重、出入库及库存///////////////////////////////////// with ADOQueryTemp do begin Close; sql.Clear; SQL.Add('select * from JY_YT where JYID=''' + Trim(maxno) + ''''); Open; end; with ClientDataSet1 do begin Append; FieldByName('JYID').Value := Trim(maxno); FieldByName('ZGKS').Value := trim(ZGQty.Text); FieldByName('ZGColor').value :=FZGColor; FieldByName('JYGW').Value := trim(SQty.Text); FieldByName('MachNO').Value := trim(MachNO.Text); FieldByName('JYNW').Value := ADOQueryTemp.fieldbyname('JYNW').Value; Post; end; ADOCmd.Connection.CommitTrans; Result := True; except Result := False; ADOCmd.Connection.RollbackTrans; Application.MessageBox('保存失败!', '提示', 0); end; end; procedure TfrmJTSJY.PrtData(FMJID: string); var fPrintFile: string; Txt, fImagePath: string; Moudle: THandle; Makebar: TMakebar; Mixtext: TMixtext; begin ExportFtErpFile('加弹丝标签.rmf', ADOQueryTemp); fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\加弹丝标签.rmf'; with ADOQueryPrint do begin Close; SQL.Clear; sql.Add(' EXEC P_JY_Print_YTLab ''' + Trim(FMJID) + ''''); Open; end; if ADOQueryPrint.IsEmpty then begin application.MessageBox('标签内容未找到!', '提示信息', MB_ICONERROR); 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); exit; 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 TfrmJTSJY.Button3Click(Sender: TObject); var FReal: Double; FStr: string; begin if Trim(CPInfo.Text) = '' then begin TSInfo('没有选择品种!'); exit; end; //1211 if Trim(FZGColor) = '' then begin TSInfo('没有选择纸管颜色!'); exit; end; if Trim(ZGQty.Text) = '' then begin InitJP('ZGQty'); ZGQty.SetFocus; TSInfo('颗数不能为空!'); Exit; end; if TryStrToFloat(ZGQty.Text, FReal) = False then begin TSInfo('颗数非法数字!'); Exit; end; if Trim(SQty.Text) = '' then begin InitJP('SQty'); SQty.SetFocus; TSInfo('重量不能为空!'); Exit; end; if TryStrToFloat(SQty.Text, FReal) = False then begin TSInfo('重量非法数字!'); Exit; end; FStr := '1'; if StrToFloat(SQty.Text) < 20 then begin FStr := ''; try frmTSOKNO := TfrmTSOKNO.Create(Application); with frmTSOKNO do begin TSStr := '重量小于20,确定要继续操作吗?'; OKNOFlag := '选择'; if ShowModal = 1 then begin FStr := '1'; end; end; finally frmTSOKNO.Free; end; end; if StrToFloat(SQty.Text) > 45 then begin FStr := ''; try frmTSOKNO := TfrmTSOKNO.Create(Application); with frmTSOKNO do begin TSStr := '重量大于45,确定要继续操作吗?'; OKNOFlag := '选择'; if ShowModal = 1 then begin FStr := '1'; end; end; finally frmTSOKNO.Free; end; end; if StrToInt(ZGQty.Text) <> 6 then begin FStr := ''; try frmTSOKNO := TfrmTSOKNO.Create(Application); with frmTSOKNO do begin TSStr := '纸管颗数不等于6,确定要继续操作吗?'; OKNOFlag := '选择'; if ShowModal = 1 then begin FStr := '1'; end; end; finally frmTSOKNO.Free; end; end; if FStr = '1' then begin try frmTSOKNO := TfrmTSOKNO.Create(Application); with frmTSOKNO do begin TSStr := '确定要打印数据吗?数据打印后数据将不能修改!'; OKNOFlag := '选择'; if ShowModal = 1 then begin if SaveData('手输') then begin PrtData(Trim(FFFMJID)); SQty.Text := ''; end; end; end; finally frmTSOKNO.Free; end; end; end; procedure TfrmJTSJY.TSInfo(TSStr: string); var TSStr10: string; begin FTSStr := TSStr; try frmTSOKNO := TfrmTSOKNO.Create(Application); with frmTSOKNO do begin frmTSOKNO.TSStr := Self.FTSStr; frmTSOKNO.OKNOFlag := '提示'; if ShowModal = 1 then begin end; end; finally frmTSOKNO.Free; end; end; procedure TfrmJTSJY.InitGrid(); begin with ADOQueryTemp do begin Close; sql.Clear; sql.Add('select * from JY_YT where Convert(varchar(10),FillTime,120)=Convert(varchar(10),Getdate(),120)'); sql.Add(' and Filler=''' + Trim(DName) + ''' order by FillTime desc '); Open; end; SCreateCDS20(ADOQueryTemp, ClientDataSet1); SInitCDSData20(ADOQueryTemp, ClientDataSet1); end; procedure TfrmJTSJY.FormShow(Sender: TObject); begin try IniFile := TIniFile.Create(ExtractFilePath(Application.ExeName) + 'FileKPZ.INI'); DZCDYDllName := IniFile.ReadString('生产车间配置', '电子秤调用Dll文件', ''); finally IniFile.Free; end; FZGColor:=''; InitGrid(); if DZCDYDllName <> '' then begin OpenCom(DZCDYDllName); end; end; procedure TfrmJTSJY.Edit13Click(Sender: TObject); begin if Trim(Edit13.Text) = '' then begin Edit13.Text := '√'; OpenCom(DZCDYDllName); end else begin Edit13.Text := ''; if FCK = 9 then CloseCom(DZCDYDllName) else begin Exit; end; end; end; procedure TfrmJTSJY.OpenCom(DllName: string); type TMyFunc = function(fhandle: hwnd; sCommName: PAnsiChar; IntTime: integer; IsMessage: integer): HWND; stdcall; var Tf: TMyFunc; Tp: TFarProc; Th: Thandle; begin Th := LoadLibrary(Pchar(trim(DllName))); if Th > 0 then begin try Tp := GetProcAddress(Th, 'CommOpen'); if Tp <> nil then begin Tf := TMyFunc(Tp); newh := Tf(self.Handle, 'Comm1', 500, 1); if newh < 1 then begin FCK := 1; showmessage('串口打开失败!'); Exit; end else begin FCK := 9; end; end else begin end; finally end; end else begin application.MessageBox(Pchar('找不到 ' + trim(DllName) + '串口文件!'), '提示'); end; end; procedure TfrmJTSJY.CloseCom(DllName: string); type TMyFunc = function(sCommName: PAnsiChar): HWND; stdcall; var Tf1: TMyFunc; Tp1: TFarProc; Th1: Thandle; //newh1:hwnd; 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 TfrmJTSJY.Button2Click(Sender: TObject); begin if ClientDataSet1.IsEmpty then Exit; try frmTSOKNO := TfrmTSOKNO.Create(Application); with frmTSOKNO do begin TSStr := '确定要重打标签吗?'; OKNOFlag := '选择'; if ShowModal = 1 then begin Self.PrtData(Trim(ClientDataSet1.fieldbyname('JYId').AsString)); end; end; finally frmTSOKNO.Free; end; end; procedure TfrmJTSJY.ZGQtyClick(Sender: TObject); var i: Integer; begin with Panel7 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 TfrmJTSJY.cxGridDBColumn1CustomDrawCell(Sender: TcxCustomGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean); var id, id10: Integer; begin id := TV3.GetColumnByFieldName('JYNW').Index; //;-TV1.GroupedItemCount; id10 := TV3.GetColumnByFieldName('ZGKS').Index; //;-TV1.GroupedItemCount; if id < 0 then Exit; if AViewInfo.GridRecord.Values[id] < 20 then begin ACanvas.Brush.Color := clRed; end; if AViewInfo.GridRecord.Values[id] > 45 then begin ACanvas.Brush.Color := clRed; end; if AViewInfo.GridRecord.Values[id10] <> 6 then begin ACanvas.Brush.Color := clRed; end; end; end.