unit uListConentBland; interface uses System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants, FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.Objects, System.ImageList, FMX.ImgList, FMX.Controls.Presentation, FMX.Edit,uTcpDevice, FMX.Layouts, System.Rtti, FMX.Grid.Style, FMX.Memo, FMX.ScrollBox, FMX.Grid, Winapi.Windows, uDM,uShowInfo, FMX.StdCtrls,uKsoap; type TfrmListConentBland = class(TForm) Rectangle1: TRectangle; Rectangle2: TRectangle; Rectangle3: TRectangle; TxtFactoryCode: TText; Rectangle4: TRectangle; Rectangle6: TRectangle; Text2: TText; ImageList1: TImageList; Rectangle18: TRectangle; Rectangle19: TRectangle; Rectangle20: TRectangle; Rectangle21: TRectangle; Text7: TText; Rectangle26: TRectangle; Rectangle27: TRectangle; Text17: TText; Rectangle33: TRectangle; Text3: TText; Rectangle5: TRectangle; Rectangle7: TRectangle; Rectangle8: TRectangle; Rectangle9: TRectangle; Rectangle10: TRectangle; Rectangle11: TRectangle; Rectangle12: TRectangle; Memo1: TMemo; Text4: TText; Text5: TText; Rectangle001: TRectangle; Glyph1: TGlyph; Text6: TText; TxtPc11: TText; Rectangle13: TRectangle; Glyph2: TGlyph; Text8: TText; Text9: TText; Rectangle15: TRectangle; Rectangle16: TRectangle; Text10: TText; EdtInput1: TEdit; EdtInput2: TEdit; Rectangle17: TRectangle; Rectangle22: TRectangle; Text11: TText; TxtEmpNo: TText; Rectangle25: TRectangle; Text12: TText; TxtLotNo: TText; Rectangle28: TRectangle; Text13: TText; TxtGoodsNo: TText; Rectangle29: TRectangle; Line1: TLine; Rectangle30: TRectangle; Line2: TLine; Text14: TText; TxtPc: TText; Text18: TText; TxtLine: TText; Text20: TText; TxtLineNum: TText; Rectangle31: TRectangle; Text22: TText; TxtLotNum: TText; Rectangle32: TRectangle; Text26: TText; Text29: TText; Line3: TLine; StringGrid1: TStringGrid; Rectangle14: TRectangle; StringGrid2: TStringGrid; StringColumn1: TStringColumn; StringColumn3: TStringColumn; StringColumn6: TStringColumn; StringColumn7: TStringColumn; Timer1: TTimer; Rectangle35: TRectangle; Text21: TText; Text16: TText; Glyph23: TGlyph; TxtVerInfo: TText; TxtInput1Error: TText; TxtInput2Error: TText; procedure Rectangle28Click(Sender: TObject); procedure Rectangle21Click(Sender: TObject); procedure Timer1Timer(Sender: TObject); procedure Text16Click(Sender: TObject); procedure FormCreate(Sender: TObject); procedure FormDestroy(Sender: TObject); procedure Text5Click(Sender: TObject); procedure EdtInput1KeyDown(Sender: TObject; var Key: Word; var KeyChar: Char; Shift: TShiftState); procedure EdtInput2KeyDown(Sender: TObject; var Key: Word; var KeyChar: Char; Shift: TShiftState); procedure Rectangle20Click(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); private procedure F2DCodeWork(Sender: TObject;Avalue: string); procedure NumEnceWork(Avalue: string); procedure AddLog(sLog:string); procedure RfidWork(Avalue: string); procedure F2DCodeShowState(Avalue: string); //显示读头状态 { Private declarations } public iCount:Integer; vP_ID:Double; vId:integer; IsFirst:boolean; F2DCode:T2DCode; Rfid:TRfid; NumEnce:TNumEnce; end; var frmListConentBland: TfrmListConentBland; implementation {$R *.fmx} uses uPucFun, uMain; procedure TfrmListConentBland.NumEnceWork(Avalue: string); begin end; procedure TfrmListConentBland.AddLog(sLog:string); begin Memo1.Lines.Add(FormatDateTime('yyyyddmm hh:mm:ss.zzz ',Now)+sLog); Memo1.SelStart:=Length(Memo1.Text); Memo1.SelLength:=0; end; procedure TfrmListConentBland.EdtInput1KeyDown(Sender: TObject; var Key: Word; var KeyChar: Char; Shift: TShiftState); var sError:string; LotNoRecord:TLotNoRecord; DetailRecord:TDetailRecord; begin if Key = vk_Return then begin with StringGrid1 do begin if Cells[0,RowCount-1]=EdtInput1.Text then //重复 begin TxtShowErrorInfo(TxtInput1Error,'條碼重複輸入'); end else begin // if NumEnce<>nil then // begin // NumEnce.SendStr('#011301'); // NumEnce.SendStr('#011401'); // Sleep(100); // NumEnce.SendStr('#011300'); // NumEnce.SendStr('#011400'); // end; TxtShowErrorInfo(TxtInput1Error,''); BeginUpdate; RowCount:=RowCount+1; Cells[0,RowCount-1]:=EdtInput1.Text; Cells[1,RowCount-1]:=FormatDateTime('yyyyddmm hh:mm:ss',Now); SelectRow(RowCount-1); EndUpdate; inc(iCount); Text29.Text:=iCount.ToString; //Ksoap.Insert_cc_wip_lot_bc_history(TxtLotNo.Text,EdtInput1.Text,'A#','正常板','-1','-1','-1',vP_Id.ToString,'',sError); if IsFirst then //第一次,插入主 begin LotNoRecord:=TLotNoRecord.Create('-1'); //初始化记录 LotNoRecord.P_LOT:=TxtLotNo.Text; LotNoRecord.P_LOT_TYPE:='-1'; LotNoRecord.P_Enable:='Y'; LotNoRecord.P_ID:=0; LotNoRecord.P_ORG_CODE:=ksoap.P_ORG_CODE; //廠區 LotNoRecord.P_NUM:=ksoap.P_WORK_NUM; //工號 LotNoRecord.P_PC:=ksoap.P_PC; //製程 LotNoRecord.P_LINE:=ksoap.P_LINE; //線別 LotNoRecord.P_LINE_NUM:=ksoap.P_LINE_NUM; //線別編號 LotNoRecord.P_CREATION_DATE:=FormatDateTime('yyyyddmm hh:mm:ss',Now); dm.InsertMain(vId,LotNoRecord); IsFirst:=false; end; DetailRecord.P_ORG_CODE:=ksoap.P_ORG_CODE; //廠區 DetailRecord.P_LOT:=TxtLotNo.Text; DetailRecord.P_BC:=EdtInput1.Text; // 條碼(批號10碼+PNL3碼) DetailRecord.P_PC:=ksoap.P_PC; //製程 DetailRecord.P_LINE:=ksoap.P_LINE; //線別 DetailRecord.P_LINE_NUM:=ksoap.P_LINE_NUM; //線別編號 DetailRecord.P_LOT_TYPE:='正常板'; DetailRecord.P_TROLLEY_NUM:='-1'; DetailRecord.P_COPPER_MODEL:='-1'; DetailRecord.P_BUFFER_TYPE:='-1'; DetailRecord.P_CREATION_DATE:=FormatDateTime('yyyyddmm hh:mm:ss',Now); DetailRecord.P_ID:='0'; dm.InsertDetail(vId,DetailRecord); end; end; EdtInput1.Text:=''; EdtInput1.SetFocus; end; end; procedure TfrmListConentBland.EdtInput2KeyDown(Sender: TObject; var Key: Word; var KeyChar: Char; Shift: TShiftState); begin if Key = vk_Return then begin with StringGrid2 do begin if Cells[0,RowCount-1]=EdtInput2.Text then //重复 begin TxtShowErrorInfo(TxtInput2Error,'條碼重複輸入'); end else begin TxtShowErrorInfo(TxtInput2Error,''); BeginUpdate; RowCount:=RowCount+1; Cells[0,RowCount-1]:=EdtInput2.Text; Cells[1,RowCount-1]:=FormatDateTime('yyyyddmm hh:mm:ss',Now); SelectRow(RowCount-1); EndUpdate; //dm.InsertLotNo(); // end; end; EdtInput2.Text:=''; EdtInput2.SetFocus; end; end; procedure TfrmListConentBland.F2DCodeShowState(Avalue: string); begin AddLog(Avalue); end; procedure TfrmListConentBland.F2DCodeWork(Sender: TObject;Avalue:string); begin end; procedure TfrmListConentBland.RfidWork(Avalue: string); begin end; procedure TfrmListConentBland.FormClose(Sender: TObject; var Action: TCloseAction); begin //退出的时候 if iCount>0 then dm.InsertQtyTime(vId.ToString,'0',Text29.Text,'-1','-1','-1','-1'); end; procedure TfrmListConentBland.FormCreate(Sender: TObject); var sDevName,sIp,sPort:string; tmpValue:string; i:integer; begin TxtFactoryCode.Text:=ksoap.P_ORG_CODE+'區'; //厂区 TxtEmpNo.Text:=ksoap.P_WORK_NUM; //工号 TxtLotNo.Text:=ksoap.P_Lot; //批号 TxtGoodsNo.Text:=ksoap.P_Goods_Num; //料号 TxtPc.Text:=ksoap.P_PC; //制程代码 TxtLine.Text:=ksoap.P_LINE; //制程名 TxtLineNum.Text:=ksoap.P_LINE_NUM; //线别 TxtLotNum.Text:=ksoap.P_Lot_Num.tostring; TxtVerInfo.Text:=GetBuildInfo; Memo1.Lines.Clear; iCount:=0; //根据配置加载设备 for i := 1 to 9 do begin tmpValue:=dm.MemTableReadKeyValue('讀頭','tv_line_speed'+i.ToString); if tmpValue<>'' then begin if CheckParameter(tmpValue,sDevName,sIp,sPort) then begin if sameText(sDevName,'keyence') then //2D读头 begin F2DCode:=T2DCode.Create(sIp,sPort.ToInteger); F2DCode.OnWork:=F2DCodeWork; end; if sameText(sDevName,'RFID') then //RFID begin Rfid:=TRfid.Create(sIp,sPort.ToInteger); Rfid.OnWork:=RfidWork; end; if sameText(sDevName,'WJ95') then //采集器 begin NumEnce:=TNumEnce.Create(sIp,sPort.ToInteger); NumEnce.OnWork:=NumEnceWork; end; end; end; end; TxtShowErrorInfo(TxtInput1Error,''); TxtShowErrorInfo(TxtInput2Error,''); //调整网格列宽 StringColumn6.Width:=StringGrid1.Width-StringColumn1.Width-25; StringColumn7.Width:=StringGrid1.Width-StringColumn3.Width-25; IsFirst:=True; end; procedure TfrmListConentBland.FormDestroy(Sender: TObject); begin if F2DCode<>nil then FreeandNil(F2DCode); if Rfid<>nil then FreeandNil(Rfid); if NumEnce<>nil then FreeandNil(NumEnce); end; procedure TfrmListConentBland.Rectangle20Click(Sender: TObject); begin if ShowInfoOKCancel('該批還沒有完成,真的要退出吗?') then Close; end; procedure TfrmListConentBland.Rectangle21Click(Sender: TObject); begin Close; end; procedure TfrmListConentBland.Rectangle28Click(Sender: TObject); begin Close; end; procedure TfrmListConentBland.Text16Click(Sender: TObject); begin ShowTouchKeyBoard(); end; procedure TfrmListConentBland.Text5Click(Sender: TObject); begin MEMO1.Lines.Clear; end; procedure TfrmListConentBland.Timer1Timer(Sender: TObject); begin with StringGrid1 do begin BeginUpdate; RowCount:=RowCount+1; Cells[0,RowCount-1]:=RowCount.ToString; Cells[1,RowCount-1]:=RowCount.ToString; Cells[2,RowCount-1]:=RowCount.ToString; Cells[3,RowCount-1]:=RowCount.ToString; SelectRow(RowCount-1); EndUpdate; end; with StringGrid2 do begin BeginUpdate; RowCount:=RowCount+1; Cells[0,RowCount-1]:=RowCount.ToString; Cells[1,RowCount-1]:=RowCount.ToString; Cells[2,RowCount-1]:=RowCount.ToString; Cells[3,RowCount-1]:=RowCount.ToString; SelectRow(RowCount-1); EndUpdate; end; end; end.