unit uFrame_18K; interface uses System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants, FMX.Types, FMX.Graphics, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.StdCtrls, FMX.Controls.Presentation, FMX.Edit, FMX.Objects, FMX.ImgList, System.ImageList,uFrameBase,uShowInfo,uKsoap,uPucFun; type TFrame_18K = class(TFrameBase) Rectangle88: TRectangle; Option1: TRectangle; Glyph9: TGlyph; OptionLabel1: TText; Text19: TText; OptionValue1: TEdit; Option3: TRectangle; Glyph2: TGlyph; OptionLabel3: TText; Text6: TText; OptionValue3: TEdit; Option5: TRectangle; Glyph3: TGlyph; OptionLabel5: TText; Text23: TText; OptionValue5: TEdit; Option7: TRectangle; Glyph12: TGlyph; OptionLabel7: TText; Text28: TText; OptionValue7: TEdit; Option9: TRectangle; Glyph13: TGlyph; OptionLabel9: TText; Text30: TText; OptionValue9: TEdit; ImageList1: TImageList; Rectangle1: TRectangle; Glyph1: TGlyph; Text1: TText; Text2: TText; Edit1: TEdit; Rectangle2: TRectangle; Glyph4: TGlyph; Text3: TText; Text4: TText; Edit2: TEdit; TxtError: TText; procedure Edit_CaiZhiClick(Sender: TObject); private procedure FillDefaultValue(sPartnumValue,sDefaultTxt:string);override; //填写默认值 function DoExec():boolean;override; //判断输入是否有效,执行插入主表,或打开窗体 function CheckValid(var sTxt:string):boolean;override; { Private declarations } public { Public declarations } end; implementation {$R *.fmx} uses uDM; function TFrame_18K.CheckValid(var sTxt:string):boolean; //返回面次数据 var aa:Extended; begin Result:=false; if not GetRadioTxt(sTxt) then //没有选择,提示出错信息 begin ErrorLayout(GridLayout,TxtError,'请选择TOP面/BOT面'); Exit; end; if Trim(OptionValue1.Text)='' then begin Error(OptionValue1,TxtError,'第一段溫度輸入不能為空');Exit;end; if Trim(OptionValue3.Text)='' then begin Error(OptionValue3,TxtError,'第一段時間輸入不能為空');Exit;end; if Trim(OptionValue5.Text)='' then begin Error(OptionValue5,TxtError,'第二段溫度輸入不能為空');Exit;end; if Trim(OptionValue7.Text)='' then begin Error(OptionValue7,TxtError,'第二段時間輸入不能為空');Exit;end; if Trim(Edit1.Text)='' then begin Error(Edit1,TxtError,'第三段溫度輸入不能為空');Exit;end; if Trim(Edit2.Text)='' then begin Error(Edit2,TxtError,'第三段時間輸入不能為空');Exit;end; if Trim(OptionValue9.Text)='' then begin Error(OptionValue9,TxtError,'烤架編號輸入不能為空');Exit;end; if not TryStrToFloat(OptionValue1.Text,aa) then begin Error(OptionValue1,TxtError,'第一段溫度輸入類型錯誤,請重新輸入。');Exit;end; // if not TryStrToFloat(OptionValue3.Text,aa) then begin Error(OptionValue3,TxtError,'第一段時間輸入類型錯誤,請重新輸入。');Exit;end; if not TryStrToFloat(OptionValue5.Text,aa) then begin Error(OptionValue5,TxtError,'第二段溫度輸入類型錯誤,請重新輸入。');Exit;end; // if not TryStrToFloat(OptionValue7.Text,aa) then begin Error(OptionValue7,TxtError,'第二段時間輸入類型錯誤,請重新輸入。');Exit;end; if not TryStrToFloat(Edit1.Text,aa) then begin Error(Edit1,TxtError,'第三段溫度輸入類型錯誤,請重新輸入。');Exit;end; // if not TryStrToFloat(Edit2.Text,aa) then begin Error(Edit2,TxtError,'第三段時間輸入類型錯誤,請重新輸入。');Exit;end; Result:=true; if Result then Error(OptionValue1,TxtError,''); end; procedure TFrame_18K.FillDefaultValue(sPartnumValue,sDefaultTxt:string); var tmpList:TStrings; begin if sDefaultTxt='' then Exit; tmpList:=TStringList.Create; try tmpList.DelimitedText:=sDefaultTxt; if tmpList.Count>32 then begin OptionValue1.Text:=tmpList.Strings[32]; OptionValue3.Text:=tmpList.Strings[0]; OptionValue5.Text:=tmpList.Strings[3]; OptionValue7.Text:=tmpList.Strings[4]; Edit1.Text:=tmpList.Strings[5]; Edit2.Text:=tmpList.Strings[20]; OptionValue9.Text:=tmpList.Strings[21]; end; {tmpList.DelimitedText:=sPartnumValue; if tmpList.Count>5 then //这里根据料号返回信息填写缺省值 Edit_banhou.Text:=tmpList.Strings[5];} finally tmpList.Free; end; end; function TFrame_18K.DoExec():boolean; var LotNoRecord:TLotNoRecord; vId:Integer; sTxt:string; sError:string; vP_ID:Double; begin Result:=false; if CheckValid(sTxt) then //上传数据 begin LotNoRecord:=TLotNoRecord.Create('-1'); //初始化记录 LotNoRecord.P_LOT:=ksoap.P_Lot; LotNoRecord.P_LOT_TYPE:='正常板'; 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_DIE_NAME:=OptionValue1.Text; //材質 LotNoRecord.P_LINE_SPEED:=StrToFloat(OptionValue3.Text); //板厚 LotNoRecord.P_ELE_CUR_DENSITY:=StrToFloat(OptionValue5.Text); //解析度 LotNoRecord.P_ELE_AREA1:=StrToFloat(OptionValue7.Text); //最小線寬 // LotNoRecord.P_SIDE:=sTxt; //面次 LotNoRecord.P_PRODUCT_PRESSURE:=StrToFloat(Edit1.Text); //線寬容差最大值 LotNoRecord.P_COM_TEMPERATURE:=StrToFloat(Edit2.Text); //線寬容差最小值 LotNoRecord.P_ELE_AREA2:=StrToFloat(OptionValue9.Text); //最小間距 LotNoRecord.P_CREATION_DATE:=FormatDateTime('yyyymmdd hh:mm:ss',Now); sError:=''; vP_ID:=Ksoap.Thread_cf_traceability_seq_f(ksoap.P_ORG_CODE,sError); LotNoRecord.P_ID:=vP_ID; if vP_ID=0 then BEGIN dm.InsertMain(vId,LotNoRecord,true); ShowInfoOK('連接數據庫服務器失敗數據暫存本地,正在生產中...'); Result:=true; END ELSE BEGIN //直接调用API,出错再保存本地 if not Ksoap.Thread_Insert_CM_WIP_PROCESS_LINE_HISTORY_NEW(LotNoRecord,sError) then //提交主表不成功 begin if sError='連接數據庫服務器失败' then begin dm.InsertMain(vId,LotNoRecord,true); ShowInfoOK('連接數據庫服務器失敗數據暫存本地,正在生產中...'); Result:=true; end else ShowError(sError); end else begin ShowInfoOK('上傳成功,正在生產中...'); Result:=true; end; END; end; end; procedure TFrame_18K.Edit_CaiZhiClick(Sender: TObject); begin inherited; ShowTouchKeyBoard(); end; end.