瀏覽代碼

合同支付项,名称不允许为空

MaiXinRong 9 年之前
父節點
當前提交
c03f4f5c47
共有 2 個文件被更改,包括 19 次插入0 次删除
  1. 1 0
      DataModules/DealPaymentDm.dfm
  2. 18 0
      DataModules/DealPaymentDm.pas

+ 1 - 0
DataModules/DealPaymentDm.dfm

@@ -110,6 +110,7 @@ object DealPaymentData: TDealPaymentData
       item
         FieldName = 'RangePrice'
       end>
+    BeforeAddRecord = sdvDealPaymentBeforeAddRecord
     OnGetText = sdvDealPaymentGetText
     OnSetText = sdvDealPaymentSetText
     OnNeedLookupRecord = sdvDealPaymentNeedLookupRecord

+ 18 - 0
DataModules/DealPaymentDm.pas

@@ -24,6 +24,8 @@ type
     procedure sddDealPaymentAfterValueChanged(AValue: TsdValue);
     procedure sddDealPaymentBeforeDeleteRecord(ARecord: TsdDataRecord;
       var Allow: Boolean);
+    procedure sdvDealPaymentBeforeAddRecord(ARecord: TsdDataRecord;
+      var Allow: Boolean);
   private
     FProjectData: TObject;
     FPayFormula: TPayFormula;
@@ -476,8 +478,18 @@ procedure TDealPaymentData.sdvDealPaymentSetText(var Text: string;
 
 begin
   if not Assigned(AValue) then Exit;
+
+  Text := Trim(Text);
+  if SameText('Name', AValue.FieldName) and (Text = '') then
+  begin
+    ErrorMessage('合同支付项名称不允许为空,如需删除,请点击右键进行删除');
+    Allow := False;
+    Exit;
+  end;
+
   CheckLockedData;
   if not Allow then Exit;
+
   if SameText('StartedPrice', AValue.FieldName) then
     DoStartedPriceChanged;
   if SameText('RangePrice', AValue.FieldName) then
@@ -735,4 +747,10 @@ begin
   end;
 end;
 
+procedure TDealPaymentData.sdvDealPaymentBeforeAddRecord(
+  ARecord: TsdDataRecord; var Allow: Boolean);
+begin
+  Allow := ARecord.ValueByName('Name').AsString <> '';
+end;
+
 end.