Initial commit - Delphi MES client project
This commit is contained in:
@@ -0,0 +1,259 @@
|
||||
unit uFrame_Dyp_Setup;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
|
||||
FMX.Types, FMX.Graphics, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.StdCtrls,
|
||||
System.ImageList, FMX.ImgList, FMX.Controls.Presentation, FMX.Edit,
|
||||
FMX.Objects,uFrameBase,uShowInfo,uKsoap,uPucFun, FMX.Memo.Types,
|
||||
FMX.ScrollBox, FMX.Memo, DateUtils, FMX.ListBox;
|
||||
|
||||
type
|
||||
TFrame_Dyp_Setup = class(TFrameBase)
|
||||
Rectangle88: TRectangle;
|
||||
Option1: TRectangle;
|
||||
Glyph9: TGlyph;
|
||||
OptionLabel1: TText;
|
||||
Text19: TText;
|
||||
Edit_CaiZhi: TEdit;
|
||||
Option2: TRectangle;
|
||||
Glyph2: TGlyph;
|
||||
OptionLabel3: TText;
|
||||
Text6: TText;
|
||||
Edit_banhou: TEdit;
|
||||
Option3: TRectangle;
|
||||
Glyph3: TGlyph;
|
||||
OptionLabel5: TText;
|
||||
Text23: TText;
|
||||
Edit_jiexi: TEdit;
|
||||
Option4: TRectangle;
|
||||
Glyph12: TGlyph;
|
||||
OptionLabel7: TText;
|
||||
Text28: TText;
|
||||
Edit_xiankuang: TEdit;
|
||||
Option7: TRectangle;
|
||||
Glyph13: TGlyph;
|
||||
OptionLabel9: TText;
|
||||
Text30: TText;
|
||||
Edit_rongchadada: TEdit;
|
||||
ImageList1: TImageList;
|
||||
Option6: TRectangle;
|
||||
Glyph1: TGlyph;
|
||||
Text1: TText;
|
||||
Text2: TText;
|
||||
Edit_rongchaxiao: TEdit;
|
||||
Option5: TRectangle;
|
||||
Glyph4: TGlyph;
|
||||
Text3: TText;
|
||||
Text4: TText;
|
||||
TxtError: TText;
|
||||
Timer1: TTimer;
|
||||
OpenDialog1: TOpenDialog;
|
||||
Memo1: TMemo;
|
||||
ComboBoxP_PC: TComboBox;
|
||||
ComboBox_jianju: TComboBox;
|
||||
procedure Edit_CaiZhiClick(Sender: TObject);
|
||||
private
|
||||
iLine: integer;
|
||||
{ Private declarations }
|
||||
public
|
||||
procedure FillDefaultValue(sPartnumValue,sDefaultTxt:string);override; //填写默认值
|
||||
function DoExec():boolean;override; //判断输入是否有效,执行插入主表,或打开窗体
|
||||
function CheckValid(var sTxt:string):boolean;override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.fmx}
|
||||
|
||||
uses uDM, json_dypSave, uSafeLog;
|
||||
|
||||
function TFrame_Dyp_Setup.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 ComboBoxP_PC.ItemIndex<0 then begin Error(ComboBoxP_PC,TxtError,'返回工序不能为空');Exit;end;
|
||||
if Trim(Edit_xiankuang.Text)='' then begin Error(Edit_xiankuang,TxtError,'备注输入不能为空');Exit;end;
|
||||
// if Trim(Edit_jiexi.Text)='' then begin Error(Edit_jiexi,TxtError,'解析度输入不能为空');Exit;end;
|
||||
if ComboBox_jianju.ItemIndex<0 then begin Error(ComboBox_jianju,TxtError,'是否合格不能为空');Exit;end;
|
||||
// if ComboBox_jianju.Items[ComboBox_jianju.ItemIndex] = '' then begin Error(ComboBox_jianju,TxtError,'请选择最小间距是否合格');Exit;end;
|
||||
// if Trim(Edit_rongchaxiao.Text)='' then begin Error(Edit_rongchaxiao,TxtError,'线宽容差最小值输入不能为空');Exit;end;
|
||||
// if Trim(Edit_rongchadada.Text)='' then begin Error(Edit_rongchadada,TxtError,'线宽容差最大值输入不能为空');Exit;end;
|
||||
|
||||
// if not TryStrToFloat(Edit_banhou.Text,aa) then begin Error(Edit_banhou,TxtError,'板厚输入类型错误,请重新输入。');Exit;end;
|
||||
// if not TryStrToFloat(Edit_jiexi.Text,aa) then begin Error(Edit_jiexi,TxtError,'解析度输入类型错误,请重新输入。');Exit;end;
|
||||
// if not TryStrToFloat(Edit_xiankuang.Text,aa) then begin Error(Edit_xiankuang,TxtError,'最小线宽输入类型错误,请重新输入。');Exit;end;
|
||||
// if not TryStrToFloat(Edit_rongchaxiao.Text,aa) then begin Error(Edit_rongchaxiao,TxtError,'线宽容差最小值输入类型错误,请重新输入。');Exit;end;
|
||||
// if not TryStrToFloat(Edit_rongchadada.Text,aa) then begin Error(Edit_rongchadada,TxtError,'线宽容差最大值输入类型错误,请重新输入。');Exit;end;
|
||||
Result:=true;
|
||||
if Result then Error(Edit_CaiZhi,TxtError,'');
|
||||
end;
|
||||
|
||||
procedure TFrame_Dyp_Setup.FillDefaultValue(sPartnumValue,sDefaultTxt:string);
|
||||
var
|
||||
tmpList:TStrings;
|
||||
i: integer;
|
||||
sError: string;
|
||||
begin
|
||||
// ComboBoxP_PC.Items.Clear;
|
||||
// 添加:初始化ComboBox_jianju选项
|
||||
ComboBox_jianju.Items.Clear;
|
||||
ComboBox_jianju.Items.Add('合格');
|
||||
ComboBox_jianju.Items.Add('不合格');
|
||||
WorkLog.MessageInfo('FillDefaultValue:%s',[self.Name]);
|
||||
|
||||
// KJSon.REST_pro_List('', 9, sDefaultTxt);
|
||||
// KJSon.REST_pro_List('', 9, sError); //查工序
|
||||
//
|
||||
// if KJSon. FList_pro_process.Count>0 then
|
||||
// begin
|
||||
// for I := 0 to KJSon. FList_pro_process.Count - 1 do
|
||||
// begin
|
||||
// ComboBoxP_PC.Items.Add(KJSon. REST_Value(KJSon. FList_pro_process.Strings[i], 'name'));
|
||||
// end;
|
||||
// end;
|
||||
|
||||
if sDefaultTxt='' then Exit;
|
||||
tmpList:=TStringList.Create;
|
||||
try
|
||||
tmpList.DelimitedText:=sDefaultTxt;
|
||||
if tmpList.Count>32 then
|
||||
begin
|
||||
Edit_CaiZhi.Text:=tmpList.Strings[32];
|
||||
Edit_banhou.Text:=tmpList.Strings[0];
|
||||
Edit_jiexi.Text:=tmpList.Strings[3];
|
||||
Edit_xiankuang.Text:=tmpList.Strings[4];
|
||||
// ComboBox_jianju.Text:=tmpList.Strings[5]; // 修改:设置ComboBox的值
|
||||
// Edit_rongchaxiao.Text:=tmpList.Strings[20];
|
||||
// Edit_rongchadada.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 GetLatestFileInDir(const DirPath: string): string;
|
||||
var
|
||||
SearchRec: TSearchRec;
|
||||
LatestTime: TDateTime;
|
||||
CurrentTime: TDateTime;
|
||||
begin
|
||||
Result := '';
|
||||
LatestTime := MinDateTime; // 初始化为最小日期
|
||||
if FindFirst(IncludeTrailingPathDelimiter(DirPath) + 'bx-*.txt', faAnyFile, SearchRec) = 0 then
|
||||
begin
|
||||
repeat
|
||||
if (SearchRec.Name <> '.') and (SearchRec.Name <> '..') then
|
||||
begin
|
||||
CurrentTime := FileDateToDateTime(SearchRec.Time);
|
||||
if CompareDateTime(CurrentTime, LatestTime) > 0 then
|
||||
begin
|
||||
LatestTime := CurrentTime;
|
||||
Result := IncludeTrailingPathDelimiter(DirPath) + SearchRec.Name;
|
||||
end;
|
||||
end;
|
||||
until FindNext(SearchRec) <> 0;
|
||||
FindClose(SearchRec);
|
||||
end;
|
||||
end;
|
||||
|
||||
function TFrame_Dyp_Setup.DoExec():boolean;
|
||||
var
|
||||
LotNoRecord:TLotNoRecord;
|
||||
vId:Integer;
|
||||
sTxt:string;
|
||||
sError:string;
|
||||
vP_ID:Double;
|
||||
begin
|
||||
Result:=false;
|
||||
if CheckValid(sTxt) then //上传数据
|
||||
begin
|
||||
WorkLog.MessageInfo('TFrame_Dyp_Setup:%s',[sTxt]);
|
||||
|
||||
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; //线别编号
|
||||
// if ComboBoxP_PC.ItemIndex>-1 then
|
||||
// begin
|
||||
// fDevRecord.P_Line_name:= ComboBoxP_PC.Items[ComboBoxP_PC.ItemIndex]; //线别
|
||||
// fDevRecord.P_Line_id:= (KJson.REST_Value(KJson.FList_pro_process.Strings[ComboBoxP_PC.ItemIndex],'id')); //线别编号;
|
||||
// end;
|
||||
|
||||
// LotNoRecord.P_LINE_SPEED:=StrToFloat(Edit_banhou.Text); //板厚
|
||||
// LotNoRecord.P_ELE_CUR_DENSITY:=StrToFloat(Edit_jiexi.Text); //解析度
|
||||
// LotNoRecord.P_ELE_AREA1:=StrToFloat(Edit_xiankuang.Text); //最小线宽
|
||||
LotNoRecord.P_MESH:= Edit_xiankuang.Text; //面次
|
||||
// 添加:获取ComboBox选中的值
|
||||
;
|
||||
LotNoRecord.P_DIE_NAME:= ComboBox_jianju.Items[ComboBox_jianju.ItemIndex]; //是否合格
|
||||
LotNoRecord.P_OFF_NET:= 1; //判断是否维修
|
||||
// if ComboBox_jianju.ItemIndex = 0 then
|
||||
// LotNoRecord.P_ELE_AREA2:=1 // 合格
|
||||
// else
|
||||
// LotNoRecord.P_ELE_AREA2:=0; // 不合格
|
||||
// LotNoRecord.P_PRODUCT_PRESSURE:=StrToFloat(Edit_rongchadada.Text); //线宽容差最大值
|
||||
// LotNoRecord.P_COM_TEMPERATURE:=StrToFloat(Edit_rongchaxiao.Text); //线宽容差最小值
|
||||
LotNoRecord.P_CREATION_DATE:= FormatDateTime('yyyymmdd hh:mm:ss',Now);
|
||||
|
||||
sError:='';
|
||||
// vP_ID:=KJSon.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
|
||||
WorkLog.MessageInfo('LotNoRecord.P_SIDE: %s',[LotNoRecord.P_SIDE]);
|
||||
|
||||
//直接调用API,出错再保存本地
|
||||
if not KJSon.Thread_Insert_CM_WIP_PROCESS_LINE_HISTORY_NEW(LotNoRecord,sError) then //提交主表不成功
|
||||
begin
|
||||
if sError='连接数据库服务器失败' then
|
||||
begin
|
||||
dm.InsertMain(vId,LotNoRecord,true);
|
||||
ShowInfoOK('连接数据库服务器失败数据暂存本地,正在生产中...', False);
|
||||
Result:=true;
|
||||
end
|
||||
else
|
||||
ShowError(sError);
|
||||
end
|
||||
else
|
||||
begin
|
||||
ShowInfoOK('上传成功!', True);
|
||||
Result:=true;
|
||||
end;
|
||||
// END;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
procedure TFrame_Dyp_Setup.Edit_CaiZhiClick(Sender: TObject);
|
||||
begin
|
||||
inherited;
|
||||
ShowTouchKeyBoard();
|
||||
end;
|
||||
|
||||
end.
|
||||
Reference in New Issue
Block a user