Browse Source

Bug #1258 其他台账,控制用户新增、改动数据

MaiXinRong 8 years ago
parent
commit
d72a930455

+ 9 - 1
DataModules/OtherMeasureOnceDm.dfm

@@ -40,7 +40,11 @@ object OtherMeasureOnceData: TOtherMeasureOnceData
       636573734E616D650909507265636973696F6E02000453697A6502000001044E
       616D6506054D54797065094669656C644E616D6506054D547970650844617461
       547970650218084461746153697A6502140549734B6579080F4E65656450726F
-      636573734E616D650909507265636973696F6E02000453697A6502000000}
+      636573734E616D650909507265636973696F6E02000453697A6502000001044E
+      616D65060A4F6D4461746554696D65094669656C644E616D65060A4F6D446174
+      6554696D650844617461547970650218084461746153697A6502320549734B65
+      79080F4E65656450726F636573734E616D650909507265636973696F6E020004
+      53697A6502000000}
   end
   object sdvOnce: TsdDataView
     Active = False
@@ -61,7 +65,11 @@ object OtherMeasureOnceData: TOtherMeasureOnceData
       end
       item
         FieldName = 'MemoStr'
+      end
+      item
+        FieldName = 'OmDateTime'
       end>
+    OnSetText = sdvOnceSetText
     Left = 48
     Top = 152
   end

+ 37 - 1
DataModules/OtherMeasureOnceDm.pas

@@ -11,6 +11,8 @@ type
     sddOnce: TsdDataSet;
     sdvOnce: TsdDataView;
     procedure sddOnceAfterAddRecord(ARecord: TsdDataRecord);
+    procedure sdvOnceSetText(var Text: String; ARecord: TsdDataRecord;
+      AValue: TsdValue; AColumn: TsdViewColumn; var Allow: Boolean);
   private
     FProjectData: TObject;
 
@@ -28,7 +30,7 @@ type
 implementation
 
 uses
-  ProjectData;
+  ProjectData, UtilMethods, Variants;
 
 {$R *.dfm}
 
@@ -97,4 +99,38 @@ begin
   ARecord.ValueByName('CreatePhaseID').AsInteger := TProjectData(FProjectData).PhaseIndex;
 end;
 
+procedure TOtherMeasureOnceData.sdvOnceSetText(var Text: String;
+  ARecord: TsdDataRecord; AValue: TsdValue; AColumn: TsdViewColumn;
+  var Allow: Boolean);
+begin
+  if SameText(AColumn.FieldName, 'Code') then
+  begin
+    if (Text = '') then
+    begin
+      if (ARecord.ValueByName('Name').AsString = '') then
+        DataSetErrorMessage(Allow, '编号和名称不可同时为空。');
+      if (ARecord.ValueByName('Code').AsString = '') and (ARecord.ValueByName('Name').AsString = '') then
+        sddOnce.Remove(ARecord);
+    end;
+  end
+  else if SameText(AColumn.FieldName, 'Name') then
+  begin
+    if (Text = '') then
+    begin
+      if (ARecord.ValueByName('Code').AsString = '') then
+        DataSetErrorMessage(Allow, '编号和名称不可同时为空。');
+      if(ARecord.ValueByName('Code').AsString = '') and (ARecord.ValueByName('Name').AsString = '') then
+        sddOnce.Remove(ARecord);
+    end;
+  end
+  else
+  begin
+    if (ARecord.ValueByName('Code').AsString = '') and (ARecord.ValueByName('Name').AsString = '') then
+    begin
+      DataSetErrorMessage(Allow, '编号、名称不可同时为空,请先填写编号或名称,再填写其他信息。');
+      sddOnce.Remove(AValue.Owner);
+    end;
+  end;
+end;
+
 end.

+ 1 - 0
DataModules/OtherMeasurePhaseDm.dfm

@@ -93,6 +93,7 @@ object OtherMeasurePhaseData: TOtherMeasurePhaseData
         FieldName = 'AddTotalPrice'
       end>
     BeforeAddRecord = sdvPhaseBeforeAddRecord
+    OnSetText = sdvPhaseSetText
     Left = 56
     Top = 160
   end

+ 36 - 0
DataModules/OtherMeasurePhaseDm.pas

@@ -15,6 +15,8 @@ type
     procedure sdvPhaseAfterValueChanged(AValue: TsdValue);
     procedure sddPhaseGetRecordClass(var ARecordClass: TsdRecordClass);
     procedure sddPhaseAfterValueChanged(AValue: TsdValue);
+    procedure sdvPhaseSetText(var Text: String; ARecord: TsdDataRecord;
+      AValue: TsdValue; AColumn: TsdViewColumn; var Allow: Boolean);
   private
     FProjectData: TObject;
 
@@ -216,4 +218,38 @@ begin
   end;
 end;
 
+procedure TOtherMeasurePhaseData.sdvPhaseSetText(var Text: String;
+  ARecord: TsdDataRecord; AValue: TsdValue; AColumn: TsdViewColumn;
+  var Allow: Boolean);
+begin
+  if SameText(AColumn.FieldName, 'Code') then
+  begin
+    if (Text = '') then
+    begin
+      if (ARecord.ValueByName('Name').AsString = '') then
+        DataSetErrorMessage(Allow, '编号和名称不可同时为空。');
+      if (ARecord.ValueByName('Code').AsString = '') and (ARecord.ValueByName('Name').AsString = '') then
+        sddPhase.Remove(ARecord);
+    end;
+  end
+  else if SameText(AColumn.FieldName, 'Name') then
+  begin
+    if (Text = '') then
+    begin
+      if (ARecord.ValueByName('Code').AsString = '') then
+        DataSetErrorMessage(Allow, '编号和名称不可同时为空。');
+      if(ARecord.ValueByName('Code').AsString = '') and (ARecord.ValueByName('Name').AsString = '') then
+        sddPhase.Remove(ARecord);
+    end;
+  end
+  else
+  begin
+    if (ARecord.ValueByName('Code').AsString = '') and (ARecord.ValueByName('Name').AsString = '') then
+    begin
+      DataSetErrorMessage(Allow, '编号、名称不可同时为空,请先填写编号或名称,再填写其他信息。');
+      sddPhase.Remove(AValue.Owner);
+    end;
+  end;
+end;
+
 end.

+ 18 - 1
Frames/OtherMeasureFme.dfm

@@ -102,7 +102,7 @@ object OtherMeasureFrame: TOtherMeasureFrame
           Height = 682
           Options = [goRangeSelect, goRowSizing, goColSizing, goCellNotMaintainData, goFixedRowShowNo, goFixedColShowNo, goAlwaysShowSelection]
           OptionsEx = []
-          ColCount = 6
+          ColCount = 7
           ShowGridLine = False
           DefaultColWidth = 73
           DefaultFixedColWidth = 35
@@ -232,6 +232,23 @@ object OtherMeasureFrame: TOtherMeasureFrame
         ReadOnly = False
       end
       item
+        Title.Caption = #26085#26399
+        Title.CaptionAcrossCols = '1'
+        Title.Font.Charset = GB2312_CHARSET
+        Title.Font.Color = clWindowText
+        Title.Font.Height = -12
+        Title.Font.Name = #23435#20307
+        Title.Font.Style = []
+        Alignment = taLeftJustify
+        Font.Charset = GB2312_CHARSET
+        Font.Color = clWindowText
+        Font.Height = -12
+        Font.Name = #23435#20307
+        Font.Style = []
+        FieldName = 'OmDateTime'
+        ReadOnly = False
+      end
+      item
         Title.Caption = #22791#27880
         Title.CaptionAcrossCols = '1'
         Title.Font.Charset = GB2312_CHARSET

+ 1 - 1
Units/Connections.pas

@@ -8,7 +8,7 @@ uses
 const
   ProductName = 'Measure';
   EmptyFileVersion = '1.0.0.0';
-  FileVersion = '1.0.1.7';
+  FileVersion = '1.0.1.8';
   EncryptVersion = 'Auto1.0';
   SAdoConnectStr = 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=%s;' +
                    'User ID=Admin;Password='''';Persist Security Info=True';

+ 9 - 7
Units/DataBaseTables.pas

@@ -693,12 +693,12 @@ const
 
   {其他台账 -- 全额计量}
   SOtherMeasureOnce = 'OtherMeasureOnce';
-  tdOtherMeasureOnce: array [0..7] of TScFieldDef = (
+  tdOtherMeasureOnce: array [0..8] of TScFieldDef = (
     (FieldName: 'ID'; FieldType: ftInteger; Size: 0; Precision: 0; NotNull: True; PrimaryKey: True; ForceUpdate: False),
     // 排序
     (FieldName: 'SerialNo'; FieldType: ftInteger; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
     // 编号
-    (FieldName: 'Code'; FieldType: ftInteger; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'Code'; FieldType: ftString; Size: 50; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
     // 名称
     (FieldName: 'Name'; FieldType: ftString; Size: 200; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
     // 台账类型
@@ -707,8 +707,10 @@ const
     (FieldName: 'TotalPrice'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
     // 备注
     (FieldName: 'MemoStr'; FieldType: ftString; Size: 255; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
-    // 创建日期
-    (FieldName: 'CreatePhaseID'; FieldType: ftInteger; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False)
+    // 创建期数
+    (FieldName: 'CreatePhaseID'; FieldType: ftInteger; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 日期
+    (FieldName: 'OmDateTime'; FieldType: ftString; Size: 50; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False)
   );
 
   {其他台账 -- 分期计量}
@@ -718,7 +720,7 @@ const
     // 排序
     (FieldName: 'SerialNo'; FieldType: ftInteger; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
     // 编号
-    (FieldName: 'Code'; FieldType: ftInteger; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    (FieldName: 'Code'; FieldType: ftString; Size: 50; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
     // 名称
     (FieldName: 'Name'; FieldType: ftString; Size: 200; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
     // 台账类型
@@ -727,8 +729,8 @@ const
     (FieldName: 'TotalPrice'; FieldType: ftString; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
     // 备注
     (FieldName: 'MemoStr'; FieldType: ftString; Size: 255; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
-    // 创建
-    (FieldName: 'CreatePhaseID'; FieldType: ftInteger; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 创建期
+    (FieldName: 'CreatePhaseID'; FieldType: ftInteger; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False)
     // 以下为根据期数缓存DetailMeasure中数据
     // 本期计量
     (FieldName: 'CurTotalPrice'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),