Просмотр исходного кода

Task #1301 变更台账,需求变更

MaiXinRong 10 лет назад
Родитель
Сommit
e92646cab1
5 измененных файлов с 92 добавлено и 6 удалено
  1. 3 3
      DataModules/BGLDm.dfm
  2. 64 0
      DataModules/BGLDm.pas
  3. 1 1
      Frames/BGLFme.dfm
  4. 13 1
      SiChuanJiaoTou/ScjtBGLFme.dfm
  5. 11 1
      SiChuanJiaoTou/ScjtBGLFme.pas

+ 3 - 3
DataModules/BGLDm.dfm

@@ -268,9 +268,9 @@ object BGLData: TBGLData
   object cdsScjtBGlView: TClientDataSet
     Aggregates = <>
     Params = <>
-    BeforePost = cdsBGLViewBeforePost
-    BeforeDelete = cdsBGLViewBeforeDelete
-    OnNewRecord = cdsBGLViewNewRecord
+    BeforePost = cdsScjtBGlViewBeforePost
+    BeforeDelete = cdsScjtBGlViewBeforeDelete
+    OnNewRecord = cdsScjtBGlViewNewRecord
     Left = 95
     Top = 188
     object cdsScjtBGLViewID: TIntegerField

+ 64 - 0
DataModules/BGLDm.pas

@@ -144,6 +144,9 @@ type
     procedure cdsBGBillsViewPriceSetText(Sender: TField;
       const Text: String);
     procedure cdsBGLViewCodeChange(Sender: TField);
+    procedure cdsScjtBGlViewBeforePost(DataSet: TDataSet);
+    procedure cdsScjtBGlViewBeforeDelete(DataSet: TDataSet);
+    procedure cdsScjtBGlViewNewRecord(DataSet: TDataSet);
   private
     FProjectData: TObject;
 
@@ -687,4 +690,65 @@ begin
   end;
 end;
 
+procedure TBGLData.cdsScjtBGlViewBeforePost(DataSet: TDataSet);
+var
+  iIncrement: Integer;
+  sNewCode: string;
+begin
+  // 变更令号不可为空
+  if cdsScjtBGLViewCode.AsString = '' then
+  begin
+    cdsBGLViewCode.Tag := 0;
+    if cdsBGL.FindKey([cdsScjtBGLViewID.AsInteger]) then
+      if cdsBGLCode.AsString <> '' then
+        WarningMessage('变更令号不允许为空,如需删除,请点击右键进行删除。');
+    DataSet.Cancel;
+    Abort;
+  end;
+
+  if cdsScjtBGLViewCode.Tag = 1 then
+  begin
+    cdsScjtBGLViewCode.Tag := 0;
+
+    if CheckBGLUsed(cdsScjtBGLViewID.AsInteger) then
+    begin
+      ErrorMessage('当前变更令下变更清单已被应用到清单,不可修改!');
+      Abort;
+    end;
+
+    sNewCode := cdsScjtBGLViewCode.AsString;
+    if Pos(';', sNewCode) > 0 then
+    begin
+      ErrorMessage('变更令号不可输入'';'',请使用其他符号代替!');
+      Abort;
+    end;
+
+    // 相同变更令号应递增[1],[2]...
+    iIncrement := 1;
+    while LocateBGL(sNewCode) and (cdsBGLID.AsInteger <> cdsScjtBGLViewID.AsInteger) do
+    begin
+      sNewCode := Format('%s[%d]', [cdsScjtBGLViewCode.AsString, iIncrement]);
+      Inc(iIncrement);
+    end;
+    if cdsScjtBGLViewCode.AsString <> sNewCode then
+    begin
+      cdsScjtBGLViewCode.AsString := sNewCode;
+      cdsScjtBGLViewCode.Tag := 0;
+    end;
+  end;
+end;
+
+procedure TBGLData.cdsScjtBGlViewBeforeDelete(DataSet: TDataSet);
+begin
+  if CheckBGLUsed(cdsScjtBGLViewID.AsInteger) then
+    raise Exception.Create('变更令下变更清单已被应用到清单,不可删除!');
+  DeleteBGBills(cdsScjtBGLViewID.AsInteger);
+end;
+
+procedure TBGLData.cdsScjtBGlViewNewRecord(DataSet: TDataSet);
+begin
+  cdsScjtBGLViewID.AsInteger := GetNewIDOfIndex(cdsBGL);
+  cdsScjtBGLViewCreatePhaseID.AsInteger := TProjectData(FProjectData).PhaseIndex;
+end;
+
 end.

+ 1 - 1
Frames/BGLFme.dfm

@@ -299,7 +299,7 @@ object BGLFrame: TBGLFrame
         ReadOnly = False
       end
       item
-        Title.Caption = #21464#26356#24615#36136
+        Title.Caption = #21464#26356#31867#22411
         Title.CaptionAcrossCols = '1'
         Title.Font.Charset = GB2312_CHARSET
         Title.Font.Color = clWindowText

+ 13 - 1
SiChuanJiaoTou/ScjtBGLFme.dfm

@@ -20,6 +20,7 @@ object ScjtBGLFrame: TScjtBGLFrame
     Selection.TransparentColor = False
     FrozenCol = 0
     FrozenRow = 0
+    OnMouseDown = zgBGLMouseDown
     Align = alClient
   end
   object zaBGL: TZjGridDBA
@@ -237,8 +238,19 @@ object ScjtBGLFrame: TScjtBGLFrame
       end>
     Grid = zgBGL
     ExtendRowCount = 3
-    Options = [aoAllowEdit]
+    Options = [aoAllowInsert, aoAllowEdit, aoAllowDelete, aoAutoInsert]
     Left = 120
     Top = 120
   end
+  object dxpmBGL: TdxBarPopupMenu
+    BarManager = MainForm.dxBarManager
+    ItemLinks = <
+      item
+        Item = MainForm.dxbtnDelete
+        Visible = True
+      end>
+    UseOwnFont = False
+    Left = 184
+    Top = 120
+  end
 end

+ 11 - 1
SiChuanJiaoTou/ScjtBGLFme.pas

@@ -5,12 +5,15 @@ interface
 uses
   ProjectData,
   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
-  Dialogs, ZjGridDBA, ZJGrid;
+  Dialogs, ZjGridDBA, ZJGrid, dxBar;
 
 type
   TScjtBGLFrame = class(TFrame)
     zgBGL: TZJGrid;
     zaBGL: TZjGridDBA;
+    dxpmBGL: TdxBarPopupMenu;
+    procedure zgBGLMouseDown(Sender: TObject; Button: TMouseButton;
+      Shift: TShiftState; X, Y: Integer);
   private
   public
     constructor Create(AProjectData: TProjectData);
@@ -37,4 +40,11 @@ begin
   inherited;
 end;
 
+procedure TScjtBGLFrame.zgBGLMouseDown(Sender: TObject;
+  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
+begin
+  if Button = mbRight then
+    dxpmBGL.PopupFromCursorPos;
+end;
+
 end.