Browse Source

Merge branch 'master' of http://192.168.1.12:3000/maixinrong/measure

builder 8 years ago
parent
commit
9ff1f80ab4
5 changed files with 71 additions and 20 deletions
  1. 2 2
      Dprs/CSL/Measure_Cloud.dpr
  2. 1 1
      Forms/ReportsFrm.dfm
  3. 2 2
      Forms/ReportsFrm.pas
  4. 2 2
      Units/CalcDecimal.pas
  5. 64 13
      Units/UtilMethods.pas

+ 2 - 2
Dprs/CSL/Measure_Cloud.dpr

@@ -254,8 +254,6 @@ begin
 
 
       {$IFDEF _mLoginNoPW}
       {$IFDEF _mLoginNoPW}
       sName := PHPWeb.GetNameFromURLProtocol(ParamStr(1));
       sName := PHPWeb.GetNameFromURLProtocol(ParamStr(1));
-      if sName[1] = '%' then
-        sName := UTF8Decode(HttpDecode(sName));
 
 
       if sName = '' then         // 表示手工运行的
       if sName = '' then         // 表示手工运行的
       begin
       begin
@@ -267,6 +265,8 @@ begin
         // For Test only!
         // For Test only!
 //        Application.MessageBox(PChar(ParamStr(1) + #10#13 + sName), '系统提示', MB_OK + MB_ICONINFORMATION);
 //        Application.MessageBox(PChar(ParamStr(1) + #10#13 + sName), '系统提示', MB_OK + MB_ICONINFORMATION);
 //        Application.Terminate;
 //        Application.Terminate;
+        if sName[1] = '%' then
+          sName := UTF8Decode(HttpDecode(sName));
 
 
         case PHPWeb.Login(sName, '', 2, sInfo, sURL) of
         case PHPWeb.Login(sName, '', 2, sInfo, sURL) of
           ltLoginFail:
           ltLoginFail:

+ 1 - 1
Forms/ReportsFrm.dfm

@@ -216,7 +216,7 @@ object ReportsForm: TReportsForm
     Font.Charset = DEFAULT_CHARSET
     Font.Charset = DEFAULT_CHARSET
     Font.Color = clWindowText
     Font.Color = clWindowText
     Font.Height = -12
     Font.Height = -12
-    Font.Name = 'Microsoft YaHei UI'
+    Font.Name = #24494#36719#38597#40657
     Font.Style = []
     Font.Style = []
     Bars = <
     Bars = <
       item
       item

+ 2 - 2
Forms/ReportsFrm.pas

@@ -327,9 +327,9 @@ end;
 procedure TReportsForm.PreviewReportCurPage;
 procedure TReportsForm.PreviewReportCurPage;
 begin
 begin
   if FbNormal then
   if FbNormal then
-    PreviewComXML.PrintPreviewCanvas(-1, PrecededCount, PreviewBox.Canvas)
+    PreviewComXML.PrintPreviewCanvas(-1, PrecededCount, PreviewBox.Canvas, True)
   else //Ç¿ÖÆ1:1ÏÔʾ
   else //Ç¿ÖÆ1:1ÏÔʾ
-    PreviewComXML.PrintPreviewCanvas(CurPage, 0, PreviewBox.Canvas);
+    PreviewComXML.PrintPreviewCanvas(CurPage, 0, PreviewBox.Canvas, True);
 end;
 end;
 
 
 procedure TReportsForm.ResizePreviewBox;
 procedure TReportsForm.ResizePreviewBox;

+ 2 - 2
Units/CalcDecimal.pas

@@ -76,7 +76,7 @@ type
 implementation
 implementation
 
 
 uses
 uses
-  ProjectData, ScUtils, SysUtils;
+  ProjectData, UtilMethods, SysUtils;
 
 
 { TDecimal }
 { TDecimal }
 
 
@@ -147,7 +147,7 @@ begin
   if Assigned(RelaDecimal) then
   if Assigned(RelaDecimal) then
     Result := FRelaDecimal.RoundTo(AValue)
     Result := FRelaDecimal.RoundTo(AValue)
   else
   else
-    Result := ScRoundTo(AValue, -Digit);
+    Result := CommonRoundTo(AValue, -Digit);
 end;
 end;
 
 
 procedure TDecimal.SetDigit(const Value: Integer);
 procedure TDecimal.SetDigit(const Value: Integer);

+ 64 - 13
Units/UtilMethods.pas

@@ -7,14 +7,15 @@ uses
   sdDB, VCLZip, VCLUnZip, Dialogs, Forms, ShlObj, Classes, StrUtils, Math, ADODB,
   sdDB, VCLZip, VCLUnZip, Dialogs, Forms, ShlObj, Classes, StrUtils, Math, ADODB,
   IdGlobal;
   IdGlobal;
 
 
-type
+type 
+  TRoundMode = (rmNearest, rmUp, rmDown);
   TBookmarkRefreshEvent = procedure (AExpandFrame: Boolean) of object;
   TBookmarkRefreshEvent = procedure (AExpandFrame: Boolean) of object;
 
 
   {RoundTo}
   {RoundTo}
   function QuantityRoundTo(AValue: Double): Double;
   function QuantityRoundTo(AValue: Double): Double;
   function PriceRoundTo(AValue: Double): Double;
   function PriceRoundTo(AValue: Double): Double;
   function TotalPriceRoundTo(AValue: Double): Double;
   function TotalPriceRoundTo(AValue: Double): Double;
-  function CommonRoundTo(AValue: Double; ADigit: Integer): Double;
+  function CommonRoundTo(AValue: Double; ADigit: Integer; RoundMode: TRoundMode = rmNearest): Double;
 
 
   {Interface Control}
   {Interface Control}
   procedure AlignControl(AControl, AParent: TWinControl; AAlign: TAlign);
   procedure AlignControl(AControl, AParent: TWinControl; AAlign: TAlign);
@@ -117,40 +118,90 @@ type
 implementation
 implementation
 
 
 uses
 uses
-  SysUtils, dxBar, MainFrm, ConstUnit, Globals, StdCtrls, ShellAPI,
-  ScUtils;
+  SysUtils, dxBar, MainFrm, ConstUnit, Globals, StdCtrls, ShellAPI;
 
 
 var
 var
   SysProgressDisabled: Boolean;
   SysProgressDisabled: Boolean;
 
 
 {RoundTo}
 {RoundTo}
+function InnerRoundTo(const AValue: Extended; const ADigit: Integer; RoundMode: TRoundMode): Extended;
+var
+  LFactor, Offset: Extended;
+  HFactor: Integer;
+begin
+  LFactor := IntPower(10, ADigit);
+  HFactor := Trunc(IntPower(10, abs(ADigit)));
+  Result := AValue;
+  case RoundMode of
+    rmNearest:
+    begin
+      if AValue >= 0 then
+        Offset := 0.5
+      else
+        Offset := -0.5;
+      Result := Trunc((AValue * HFactor) + Offset) * LFactor;
+    end;
+    rmUP:
+    begin
+      if Frac(AValue / LFactor) > 0 then
+        Result := Trunc(AValue * HFactor + 1) * LFactor
+      else
+        Result := Trunc(AValue * HFactor) * LFactor;
+    end;
+    rmDown:
+    begin
+      Result := Trunc(AValue * HFactor) * LFactor;
+    end;
+  end;
+end;
+
 function QuantityRoundTo(AValue: Double): Double;
 function QuantityRoundTo(AValue: Double): Double;
 begin
 begin
   if Assigned(OpenProjectManager.CurProjectData) then
   if Assigned(OpenProjectManager.CurProjectData) then
-    Result := ScRoundTo(AValue, -OpenProjectManager.CurProjectData.ProjProperties.QuantityDigit)
+    Result := CommonRoundTo(AValue, -OpenProjectManager.CurProjectData.ProjProperties.QuantityDigit)
   else
   else
-    Result := ScRoundTo(AValue, iQuantityDigit);
+    Result := CommonRoundTo(AValue, iQuantityDigit);
 end;
 end;
 
 
 function PriceRoundTo(AValue: Double): Double;
 function PriceRoundTo(AValue: Double): Double;
 begin
 begin
   if Assigned(OpenProjectManager.CurProjectData) then
   if Assigned(OpenProjectManager.CurProjectData) then
-    Result := ScRoundTo(AValue, -OpenProjectManager.CurProjectData.ProjProperties.PriceDigit)
+    Result := CommonRoundTo(AValue, -OpenProjectManager.CurProjectData.ProjProperties.PriceDigit)
   else
   else
-    Result := ScRoundTo(AValue, iPriceDigit);
+    Result := CommonRoundTo(AValue, iPriceDigit);
 end;
 end;
 
 
 function TotalPriceRoundTo(AValue: Double): Double;
 function TotalPriceRoundTo(AValue: Double): Double;
 begin
 begin
   if Assigned(OpenProjectManager.CurProjectData) then
   if Assigned(OpenProjectManager.CurProjectData) then
-    Result := ScRoundTo(AValue, -OpenProjectManager.CurProjectData.ProjProperties.TotalPriceDigit)
+    Result := CommonRoundTo(AValue, -OpenProjectManager.CurProjectData.ProjProperties.TotalPriceDigit)
   else
   else
-    Result := ScRoundTo(AValue, iTotalPriceDigit);
+    Result := CommonRoundTo(AValue, iTotalPriceDigit);
 end;
 end;
 
 
-function CommonRoundTo(AValue: Double; ADigit: Integer): Double;
-begin
-  Result := ScRoundTo(AValue, ADigit);
+function CommonRoundTo(AValue: Double; ADigit: Integer; RoundMode: TRoundMode = rmNearest): Double;
+var
+  X: Double;
+  P: Pointer;
+  I: Integer;
+  Buf: array [0..7] of Byte;
+begin
+  P := @AValue;
+  CopyMemory(@Buf[0], P, SizeOf(AValue));
+  // 进位处理,从后往前,如果当前byte为$FF,则往前一byte进1
+  // 注意到尾数开始的位置停止
+  // 这里说的前后是二进制串,实际存储前后相反
+  for I := 0 to 6 do
+    if (I < 6) and (Buf[I] = $FF) then
+      Buf[I] := 0
+    else
+    begin
+      Buf[I] := Buf[I] + 1;
+      Break;
+    end;
+  P := @X;
+  CopyMemory(P, @Buf[0], SizeOf(X));
+  Result := InnerRoundTo(X, ADigit, RoundMode);
 end;
 end;
 
 
 {Interface Control}
 {Interface Control}