浏览代码

接入变更令系统,需求调整,兼容相关

MaiXinRong 7 年之前
父节点
当前提交
e443d699b9
共有 4 个文件被更改,包括 75 次插入1 次删除
  1. 6 0
      DataModules/BGLDm.dfm
  2. 36 1
      DataModules/BGLDm.pas
  3. 3 0
      Frames/BGLFme.dfm
  4. 30 0
      Frames/BGLFme.pas

+ 6 - 0
DataModules/BGLDm.dfm

@@ -117,6 +117,12 @@ object BGLData: TBGLData
       FieldName = 'BGLType'
       Size = 10
     end
+    object cdsBGLViewIsCloud: TBooleanField
+      FieldName = 'IsCloud'
+    end
+    object cdsBGLViewWebID: TIntegerField
+      FieldName = 'WebID'
+    end
   end
   object dsBGL: TDataSource
     DataSet = cdsBGLView

+ 36 - 1
DataModules/BGLDm.pas

@@ -98,6 +98,8 @@ type
     cdsBGBillsViewUsedQuantity: TFloatField;
     cdsBGLIsCloud: TBooleanField;
     cdsBGLWebID: TIntegerField;
+    cdsBGLViewIsCloud: TBooleanField;
+    cdsBGLViewWebID: TIntegerField;
     procedure cdsBGBillsViewAfterInsert(DataSet: TDataSet);
     procedure cdsBGBillsViewAfterPost(DataSet: TDataSet);
     procedure cdsBGBillsViewQuantityChange(Sender: TField);
@@ -136,6 +138,8 @@ type
     procedure Close;
     procedure Save;
 
+    function GetBGLCanEdit(ASerialNo: Integer): Boolean;
+
     function AllBGLTotalPrice: Double;
 
     function AllCloudBGLWebID: string;
@@ -431,6 +435,14 @@ var
   iIncrement: Integer;
   sNewCode: string;
 begin
+  if cdsBGLViewIsCloud.AsBoolean then
+  begin
+    cdsBGLViewCode.Tag := 0;
+    WarningMessage('当前变更令不允许编辑。');
+    DataSet.Cancel;
+    Abort;
+  end;
+
   // 变更令号不可为空
   if cdsBGLViewCode.AsString = '' then
   begin
@@ -713,7 +725,7 @@ procedure TBGLData.LoadCloudBGL(const ABGLs: string);
     cdsBGLPos_Reason.AsString := ABGL.S['description'];
     cdsBGLDirection.AsString := ABGL.S['basis'];
     cdsBGLDrawingCode.AsString := ABGL.S['cnum'];
-    cdsBGLApprovalCode.AsString := '';
+    cdsBGLApprovalCode.AsString := ABGL.S['bnum'];
     cdsBGLCreatePhaseID.AsInteger := iCreatePhaseID;
     cdsBGLBGLType.AsString := ABGL.S['changeNature'];
     cdsBGLIsCloud.AsBoolean := True;
@@ -736,4 +748,27 @@ begin
   end;
 end;
 
+function TBGLData.GetBGLCanEdit(ASerialNo: Integer): Boolean;
+var
+  i: Integer;
+  bk: TBookmark;
+begin
+  cdsBGLView.DisableControls;
+  bk := cdsBGLView.GetBookmark;
+  cdsBGLView.First;
+  i := 0;
+  while (i < ASerialNo) and not cdsBGLView.Eof do
+  begin
+    cdsBGLView.Next;
+    Inc(i);
+  end;
+  if i = ASerialNo then
+    Result := not cdsBGLViewIsCloud.AsBoolean
+  else
+    Result := False;
+  cdsBGLView.GotoBookmark(bk);
+  cdsBGLView.FreeBookmark(bk);
+  cdsBGLView.EnableControls;
+end;
+
 end.

+ 3 - 0
Frames/BGLFme.dfm

@@ -336,6 +336,8 @@ object BGLFrame: TBGLFrame
       end>
     Grid = zgBGL
     ExtendRowCount = 1
+    Options = [aoAllowEdit, aoAllowDelete, aoAllowUpMove, aoAllowDownMove]
+    OnGridCellCanEdit = zaBGLGridCellCanEdit
     Left = 96
     Top = 88
   end
@@ -470,6 +472,7 @@ object BGLFrame: TBGLFrame
     Grid = zgBGBills
     ExtendRowCount = 1
     OnGridSetCellText = zaBGBillsGridSetCellText
+    OnGridCellCanEdit = zaBGBillsGridCellCanEdit
     Left = 96
     Top = 456
   end

+ 30 - 0
Frames/BGLFme.pas

@@ -57,6 +57,10 @@ type
     procedure zgBGLEditorLoadCell(Sender: TObject; ACoord: TPoint;
       AControl: TWinControl);
     procedure zgBGLCellTextChanged(Sender: TObject; Col, Row: Integer);
+    procedure zaBGLGridCellCanEdit(Sender: TObject; const ACoord: TPoint;
+      var Allow: Boolean);
+    procedure zaBGBillsGridCellCanEdit(Sender: TObject;
+      const ACoord: TPoint; var Allow: Boolean);
   private
     FBGLData: TBGLData;
 
@@ -93,6 +97,14 @@ begin
   dbmDirection.DataSource := FBGLData.dsBGL;
   zaBGBills.DataSet := FBGLData.cdsBGBillsView;
   SetDxBtnAction(actnNew, tobtnNew);
+
+  if _IsCloud then
+  begin
+    zaBGL.Options := [aoAllowEdit, aoAllowDelete, aoAllowUpMove, aoAllowDownMove];
+    zaBGL.ExtendRowCount := 0;
+  end
+  else
+    zaBGL.Options := [aoAllowInsert, aoAllowEdit, aoAllowDelete, aoAutoInsert, aoAllowUpMove, aoAllowDownMove];
 end;
 
 procedure TBGLFrame.actnNewExecute(Sender: TObject);
@@ -269,4 +281,22 @@ begin
   end;
 end;
 
+procedure TBGLFrame.zaBGLGridCellCanEdit(Sender: TObject;
+  const ACoord: TPoint; var Allow: Boolean);
+begin
+  if _IsCloud then
+    Allow := FBGLData.GetBGLCanEdit(ACoord.Y)
+  else
+    Allow := True;
+end;
+
+procedure TBGLFrame.zaBGBillsGridCellCanEdit(Sender: TObject;
+  const ACoord: TPoint; var Allow: Boolean);
+begin
+  if _IsCloud then
+    Allow := not FBGLData.cdsBGLViewIsCloud.AsBoolean
+  else
+    Allow := True;
+end;
+
 end.