Parcourir la source

WeiWu ZJJL Gather: ReNumber Code

MaiXinRong il y a 8 ans
Parent
commit
fbc6d00e8a

+ 33 - 2
DataModules/ReportMemoryDm/rmWeiWuZjjlGatherDm.pas

@@ -100,6 +100,8 @@ type
     cdsZjjlDanWeiName: TWideStringField;
   private
     FZjjlList: TList;
+    FPreText: string;
+    FPhaseIndex: Integer;
     function FindZjjl(ARec: TsdDataRecord; ANode: TBillsIDTreeNode): TZjjl;
 
     procedure GatherZjjl(AProjectData: TProjectData);
@@ -314,6 +316,8 @@ begin
   try
     if AProjectData.PhaseData.Active then
     begin
+      FPreText := AProjectData.PhaseData.PhaseProperty.ZJJLPreText;
+      FPhaseIndex := AProjectData.PhaseIndex;
       GatherZjjl(AProjectData);
       WriteData;
     end;
@@ -378,18 +382,45 @@ begin
 end;
 
 procedure TrmWeiWuZjjlGatherData.WriteData;
+
+  function GetCodeFormat(ACount: Integer): string;
+  begin
+    if ACount < 10 then
+      Result := '-%d'
+    else if ACount < 100 then
+      REsult := '-%2d'
+    else if ACount < 1000 then
+      Result := '-%3d'
+    else if ACount < 10000 then
+      Result := '-%4d'
+    else if ACount < 100000 then
+      Result := '-%5d';
+  end;
+
+  function GetFormatStr(AIndex: Integer; const sFormat: string): string;
+  begin
+    Result := Format(sFormat, [AIndex]);
+    Result := StringReplace(Result, ' ', '0', [rfReplaceAll]);
+  end;
+
 var
   i: Integer;
   vZ: TZjjl;
-begin       
+  sPre, sCode, sFormat: String;
+begin
   cdsZjjl.Active := True;
   cdsZjjl.EmptyDataSet;
+  if FPreText <> '' then
+    sPre := FPreText + GetFormatStr(FPhaseIndex, '-%02d')
+  else
+    sPre := FPreText + GetFormatStr(FPhaseIndex, '%02d');
+  sFormat := GetCodeFormat(FZjjlList.Count);
   for i := 0 to FZjjlList.Count - 1 do
   begin
     vZ := TZjjl(FZjjlList.Items[i]);
 
     cdsZjjl.Append;
-    cdsZjjlCode.AsString := vZ.FCode;
+    cdsZjjlCode.AsString := sPre + GetFormatStr(i+1, sFormat);
     cdsZjjlCertificateCode.AsString := vZ.FCertificateCode;
     cdsZjjlBGLCode.AsString := vZ.FBGLCode;
     cdsZjjlPegName.AsString := vZ.FPegName;

+ 1 - 0
DataModules/ZJJLDm.pas

@@ -540,6 +540,7 @@ procedure TZJJLData.CheckZjjlVerison;
 begin
   if TPhaseData(PhaseData).PhaseProperty.ZjjlVersion = 0 then
   begin
+    TPhaseData(PhaseData).PhaseProperty.ZJJLPreText := TProjectData(TPhaseData(PhaseData).ProjectData).ProjProperties.ZJJLPreText;
     LoadVersion0Info;
     LoadVersion0History;
   end;

+ 8 - 2
Frames/ZJJLFme.pas

@@ -92,8 +92,10 @@ constructor TZJJLFrame.Create(AParent: TFrame; AZJJLData: TZJJLData);
 begin
   inherited Create(AParent);
   ResetFrameLink(AZJJLData);
-  with TProjectData(TPhaseData(FZJJLData.PhaseData).ProjectData) do
-    lePreText.Text := ProjProperties.ZJJLPreText;
+  with TPhaseData(FZJJLData.PhaseData).PhaseProperty do
+  begin
+    lePreText.Text := ZJJLPreText;
+  end;
   RefreshTitle;
 end;
 
@@ -131,7 +133,10 @@ end;
 procedure TZJJLFrame.lePreTextExit(Sender: TObject);
 begin
   with TProjectData(TPhaseData(FZJJLData.PhaseData).ProjectData) do
+  begin
     ProjProperties.ZJJLPreText := lePreText.Text;
+    PhaseData.PhaseProperty.ZJJLPreText := lePreText.Text;
+  end;
 end;
 
 procedure TZJJLFrame.SetDataReadOnly(const Value: Boolean);
@@ -141,6 +146,7 @@ begin
   lePreText.Enabled := not FDataReadOnly;
   saZJJL.Columns.ColumnByName('Code').ReadOnly := FDataReadOnly;
   saZJJL.Columns.ColumnByName('CertificateCode').ReadOnly := FDataReadOnly;
+  lePreText.Enabled := not Value;
 end;
 
 procedure TZJJLFrame.zgZJJLMouseDown(Sender: TObject; Button: TMouseButton;

+ 13 - 0
Units/PhaseProperty.pas

@@ -27,6 +27,8 @@ type
     procedure SetZJJLType(const Value: Integer);
     procedure SetZjjlVersion(const Value: Integer);
     function GetZjjlVersion: Integer;
+    function GetZJJLPreText: string;
+    procedure SetZJJLPreText(const Value: string);
   public
     constructor Create(AConnection: TADOConnection);
     destructor Destroy; override;
@@ -38,6 +40,7 @@ type
     property FinalAudit: Boolean read FFinalAudit write SetFinalAudit;
 
     property ZJJLType: Integer read GetZJJLType write SetZJJLType;
+    property ZJJLPreText: string read GetZJJLPreText write SetZJJLPreText;
     property ZjjlVersion: Integer read GetZjjlVersion write SetZjjlVersion;
   end;
 
@@ -101,6 +104,11 @@ begin
   Result := VarToStrDef(vProperty, ADef);
 end;
 
+function TPhaseProperties.GetZJJLPreText: string;
+begin
+  Result := GetStrPropertyDef('ZJJLPreText', '');
+end;
+
 function TPhaseProperties.GetZJJLType: Integer;
 begin
   Result := GetIntPropertyDef('ZJJLType', 0);
@@ -139,6 +147,11 @@ begin
   FPropertyInqurity.Value['FinalAudit'] := FFinalAudit;
 end;
 
+procedure TPhaseProperties.SetZJJLPreText(const Value: string);
+begin
+  FPropertyInqurity.Value['ZJJLPreText'] := Value;
+end;
+
 procedure TPhaseProperties.SetZJJLType(const Value: Integer);
 begin
   FPropertyInqurity.Value['ZJJLType'] := Value;