This commit is contained in:
funa 2026-10-21 17:26:11 +08:00
parent 673a3c47b3
commit 735af91a7c
5 changed files with 41 additions and 43 deletions

View File

@ -127,7 +127,6 @@ inherited frmTatClothInspList: TfrmTatClothInspList
ParentFont = False ParentFont = False
PopupMenu = PM_1 PopupMenu = PM_1
TabOrder = 2 TabOrder = 2
ExplicitTop = 133
object Tv1: TcxGridDBTableView object Tv1: TcxGridDBTableView
OnMouseUp = Tv1MouseUp OnMouseUp = Tv1MouseUp
Navigator.Buttons.CustomButtons = <> Navigator.Buttons.CustomButtons = <>

View File

@ -124,6 +124,7 @@ object frmTatInspEdit: TfrmTatInspEdit
Width = 24 Width = 24
Height = 12 Height = 12
Caption = #27611#37325 Caption = #27611#37325
Visible = False
end end
object Label6: TLabel object Label6: TLabel
Left = 343 Left = 343
@ -159,6 +160,7 @@ object frmTatInspEdit: TfrmTatInspEdit
Width = 12 Width = 12
Height = 12 Height = 12
Caption = 'Kg' Caption = 'Kg'
Visible = False
end end
object Label12: TLabel object Label12: TLabel
Left = 459 Left = 459
@ -222,7 +224,7 @@ object frmTatInspEdit: TfrmTatInspEdit
Width = 54 Width = 54
Height = 20 Height = 20
TabOrder = 4 TabOrder = 4
OnChange = GrossWeightChange Visible = False
end end
object Meter: TEdit object Meter: TEdit
Left = 373 Left = 373
@ -257,6 +259,7 @@ object frmTatInspEdit: TfrmTatInspEdit
Width = 54 Width = 54
Height = 20 Height = 20
TabOrder = 5 TabOrder = 5
OnChange = NetWeightChange
end end
object PieceNo: TEdit object PieceNo: TEdit
Left = 261 Left = 261

View File

@ -72,15 +72,16 @@ type
procedure ToolButton4Click(Sender: TObject); procedure ToolButton4Click(Sender: TObject);
procedure cxGridDBColumn3PropertiesEditValueChanged(Sender: TObject); procedure cxGridDBColumn3PropertiesEditValueChanged(Sender: TObject);
procedure TV1Column1PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); procedure TV1Column1PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
procedure GrossWeightChange(Sender: TObject); procedure NetWeightChange(Sender: TObject);
private private
{ Private declarations } { Private declarations }
FGramW: Double; FGramW: Double;
FAddW: Double; //加载时的加重快照,保存时从界面毛净重中扣回 FAddW: Double; //加载时的加重快照,保存时从界面毛净重中扣回
FAddL: Double; //加载时的加长快照,保存时从界面米数中扣回
FSyncing: Boolean; //加载赋值时防止OnChange重入
function SaveData(): Boolean; function SaveData(): Boolean;
procedure GetJYXK(FJYIP: string); procedure GetJYXK(FJYIP: string);
procedure UpdateCalcMeter(); procedure UpdateCalcMeter();
function RoundUpToHalf(AValue: Double): Double; //decimal 0.1-0.4 -> 0.5, 0.6-0.9 -> next integer
public public
{ Public declarations } { Public declarations }
end; end;
@ -114,15 +115,23 @@ begin
end; end;
PieceNo.Text := Trim(ADOTmp.fieldbyname('PieceNo').AsString); PieceNo.Text := Trim(ADOTmp.fieldbyname('PieceNo').AsString);
//gram weight snapshot first, GrossWeight OnChange recalcs CalcMeter with it //gram weight snapshot first, NetWeight OnChange recalcs CalcMeter with it
FGramW := StrToFloatdef(Trim(ADOTmp.fieldbyname('C_GramWeight').AsString), 0); FGramW := StrToFloatdef(Trim(ADOTmp.fieldbyname('C_GramWeight').AsString), 0);
//加重快照:界面显示含加重的毛净重,保存时再扣回,保证数据库基础字段口径不变 //加重快照:界面显示含加重的毛净重,保存时再扣回,保证数据库基础字段口径不变
FAddW := StrToFloatdef(Trim(ADOTmp.fieldbyname('add_weight').AsString), 0); FAddW := StrToFloatdef(Trim(ADOTmp.fieldbyname('add_weight').AsString), 0);
//加长快照:界面米数含加长显示,保存时再扣回,与检验页 Meter+add_length 口径一致
FAddL := StrToFloatdef(Trim(ADOTmp.fieldbyname('add_length').AsString), 0);
FSyncing := True;
try
GrossWeight.Text := FormatFloat('0.##', StrToFloatdef(Trim(ADOTmp.fieldbyname('GrossWeight').AsString), 0) + FAddW); GrossWeight.Text := FormatFloat('0.##', StrToFloatdef(Trim(ADOTmp.fieldbyname('GrossWeight').AsString), 0) + FAddW);
NetWeight.Text := FormatFloat('0.##', StrToFloatdef(Trim(ADOTmp.fieldbyname('NetWeight').AsString), 0) + FAddW); NetWeight.Text := FormatFloat('0.##', StrToFloatdef(Trim(ADOTmp.fieldbyname('NetWeight').AsString), 0) + FAddW);
Meter.Text := Trim(ADOTmp.fieldbyname('Meter').AsString); //毛重框已隐藏:毛重与净重保持一致,净重为唯一录入位
GrossWeight.Text := NetWeight.Text;
Meter.Text := FormatFloat('0.##', StrToFloatdef(Trim(ADOTmp.fieldbyname('Meter').AsString), 0) + FAddL);
Yardage.Text := Trim(ADOTmp.fieldbyname('Yardage').AsString); Yardage.Text := Trim(ADOTmp.fieldbyname('Yardage').AsString);
finally
FSyncing := False;
end;
UpdateCalcMeter(); UpdateCalcMeter();
CodeTableLen.Text := Trim(ADOTmp.fieldbyname('code_table_length').AsString); CodeTableLen.Text := Trim(ADOTmp.fieldbyname('code_table_length').AsString);
@ -348,7 +357,7 @@ begin
sql.Add(' PieceNo=''' + Trim(PieceNo.Text) + ''' '); sql.Add(' PieceNo=''' + Trim(PieceNo.Text) + ''' ');
sql.Add(',GrossWeight=' + FloatToStr(Strtofloatdef(GrossWeight.Text, 0) - FAddW)); sql.Add(',GrossWeight=' + FloatToStr(Strtofloatdef(GrossWeight.Text, 0) - FAddW));
sql.Add(',NetWeight=' + FloatToStr(Strtofloatdef(NetWeight.Text, 0) - FAddW)); sql.Add(',NetWeight=' + FloatToStr(Strtofloatdef(NetWeight.Text, 0) - FAddW));
sql.Add(',Meter=' + FloatToStr(Strtofloatdef(Meter.Text, 0))); sql.Add(',Meter=' + FloatToStr(Strtofloatdef(Meter.Text, 0) - FAddL));
sql.Add(',Yardage=' + FloatToStr(Strtofloatdef(Yardage.Text, 0))); sql.Add(',Yardage=' + FloatToStr(Strtofloatdef(Yardage.Text, 0)));
sql.Add(',code_table_length=' + FloatToStr(Strtofloatdef(CodeTableLen.Text, 0))); sql.Add(',code_table_length=' + FloatToStr(Strtofloatdef(CodeTableLen.Text, 0)));
@ -414,34 +423,25 @@ end;
procedure TfrmTatInspEdit.UpdateCalcMeter(); procedure TfrmTatInspEdit.UpdateCalcMeter();
var var
MGrossW: Double; MNetW: Double;
begin begin
//CalcMeter = (GrossWeight含加重) / C_GramWeight,先取1位小数再按0.05/0.5规则进位(与TV3的CM2一致) //CalcMeter = (净重含加重) / 克重,四舍五入保留1位小数,不按0.05/0.5规则进位
MGrossW := StrToFloatdef(Trim(GrossWeight.Text), 0); //(与检验页 CalcInputLenByWeightKZ 的 InputLen = RoundFloat((净重+加重)/克重,1) 一致)
if Trim(NetWeight.Text) = '' then
Exit;
MNetW := StrToFloatdef(Trim(NetWeight.Text), 0);
if FGramW > 0 then if FGramW > 0 then
CalcMeter.Text := FormatFloat('0.#', RoundUpToHalf(RoundFloat(MGrossW / FGramW, 1))) CalcMeter.Text := FormatFloat('0.#', RoundFloat(MNetW / FGramW, 1))
else else
CalcMeter.Text := ''; CalcMeter.Text := '';
end; end;
function TfrmTatInspEdit.RoundUpToHalf(AValue: Double): Double; procedure TfrmTatInspEdit.NetWeightChange(Sender: TObject);
var
MIntPart: Double;
begin begin
Result := AValue; //毛重框已隐藏:净重为唯一录入位,毛重与净重保持一致(毛重无OnChange,赋值不会递归)
if AValue <= 0 then if FSyncing then
Exit; Exit;
MIntPart := Int(AValue); GrossWeight.Text := NetWeight.Text;
if Frac(AValue) < 0.05 then
Result := MIntPart //integer, keep as is
else if Frac(AValue) <= 0.5 then
Result := MIntPart + 0.5 //decimal 0.1-0.4 -> 0.5
else
Result := MIntPart + 1; //decimal 0.6-0.9 -> next integer
end;
procedure TfrmTatInspEdit.GrossWeightChange(Sender: TObject);
begin
UpdateCalcMeter(); UpdateCalcMeter();
end; end;

View File

@ -396,8 +396,8 @@
Font.Name = #23435#20307 Font.Name = #23435#20307
Font.Style = [fsBold] Font.Style = [fsBold]
ParentFont = False ParentFont = False
ReadOnly = True
TabOrder = 0 TabOrder = 0
OnClick = CIFBegClick
OnKeyPress = MJstr3KeyPress OnKeyPress = MJstr3KeyPress
end end
object BTPrint: TButton object BTPrint: TButton
@ -2933,10 +2933,6 @@
object 查看: TcxTabSheet object 查看: TcxTabSheet
Caption = #26597#30475 Caption = #26597#30475
ImageIndex = 1 ImageIndex = 1
ExplicitLeft = 0
ExplicitTop = 0
ExplicitWidth = 0
ExplicitHeight = 0
object cxGrid1: TcxGrid object cxGrid1: TcxGrid
Left = 0 Left = 0
Top = 0 Top = 0

View File

@ -816,8 +816,8 @@ begin
Loom.Text := FLoom; Loom.Text := FLoom;
// Repairer.Text := Trim(ADOTmp.fieldbyname('Repairer').AsString); // Repairer.Text := Trim(ADOTmp.fieldbyname('Repairer').AsString);
SetDdetails(); SetDdetails();
InputLen.SetFocus; InputWeight.SetFocus;
CIFBegClick(InputLen); CIFBegClick(InputWeight);
end; end;
end end
else else
@ -1899,8 +1899,8 @@ begin
PrtData(FCIID); PrtData(FCIID);
end; end;
end; end;
InputLen.SetFocus; InputWeight.SetFocus;
CIFBegClick(InputLen); CIFBegClick(InputWeight);
FOperationStatus := '²¼Æ±'; FOperationStatus := '²¼Æ±';
InitJYGrid(); InitJYGrid();
InitCDGrid(''); InitCDGrid('');
@ -2167,8 +2167,8 @@ begin
SetDdetails(); SetDdetails();
InitJYGrid(); InitJYGrid();
InitCDGrid(''); InitCDGrid('');
InputLen.SetFocus; InputWeight.SetFocus;
CIFBegClick(InputLen); CIFBegClick(InputWeight);
end; end;
end; end;
finally finally
@ -2253,7 +2253,7 @@ begin
FOperationStatus := '²¼Æ±'; FOperationStatus := '²¼Æ±';
InitLCK(edtScan.Text); InitLCK(edtScan.Text);
InitJYGrid(); InitJYGrid();
InputLen.SetFocus; InputWeight.SetFocus;
end; end;
end; end;
procedure TfrmTatMachInsp.CIFBegClick(Sender: TObject); procedure TfrmTatMachInsp.CIFBegClick(Sender: TObject);