From 35406177d1cff43870f9da1aedb55f3c4f281e66 Mon Sep 17 00:00:00 2001
From: doom4ster <doom4ster@gmail.com>
Date: 星期一, 11 九月 2017 11:21:36 +0800
Subject: [PATCH] CB_IMGPSScan.cab ver2.0.1.38  有未歸類文件都不能上傳

---
 CB_IMGPSScanImp.pas |   95 +++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 83 insertions(+), 12 deletions(-)

diff --git a/CB_IMGPSScanImp.pas b/CB_IMGPSScanImp.pas
index 9f74e74..8f64685 100644
--- a/CB_IMGPSScanImp.pas
+++ b/CB_IMGPSScanImp.pas
@@ -839,7 +839,8 @@
     function LoadFileGetMD5(const filename:string):string; //20170809 取的檔案的MD5
     function ISExistImg(const filename:string):boolean;  //20170809 確認是否存在原有影像
     procedure _DelTreeForExistImg(ASourceDir:String);   //2017 刪除前確認 有舊影像嗎
-    function DocNoIsExistImg(DocNopath: String): boolean;     //2017 刪除前確認 有舊影像嗎
+    function DocNoIsExistImg(DocNopath: String): boolean; //2017 刪除前確認 有舊影像嗎
+    function CheckCaseAttach_OK: Boolean;     //2017 確認是否有未歸類文件
   protected
     { Protected declarations }
     procedure DefinePropertyPages(DefinePropertyPage: TDefinePropertyPage); override;
@@ -2203,6 +2204,7 @@
       DeleteImageFile(ExtractFilePath(iISB.FileName),ExtractFileName(iISB.FileName),NowCaseNo);
     end;
   end;
+//ShowMessage('iISB.FileName='+iISB.FileName);
   ReSortFileName(ExtractFilePath(iISB.FileName));
   DrawDocItem2(MytreeNode1,NowCaseno);
   MyTreeNode1.Text := Format('%s-%d'+_Msg('頁'),[NowCaseno,GetCasePage(ImageSavePath,NowCaseNo)]);
@@ -5469,6 +5471,7 @@
 
   DeleteFile(Path+FileName);
   DocDir := Path2DocDir(Path,CaseID);
+//ShowMessage('DocDir='+DocDir);
   SetContextList('D',-1,CaseID,DocDir,FileName);
   {FileList:=TStringlist.Create;
   try
@@ -5615,7 +5618,7 @@
       for n := 0 to S.Count - 1 do
       begin
 
-        if FWH_category='N' then
+        if (FWH_category='N') and (FIs_In_Wh='Y') then
         begin
           if ISExistImg(ImageSavePath+CaseID+'\upload\'+S.Strings[n]) then
           begin
@@ -6749,6 +6752,7 @@
   //DocNo:String;
 begin
   //DocNo := FormCode2DocNo(FileName2FormCode(FileName));
+//ShowMessage('FileName='+FileName);
   if DocDir = '' then
     DocDir := AttName ; //附件
   ContextList.Clear;
@@ -6838,6 +6842,24 @@
     begin
       Result := False;
       Break;
+    end;
+  end;
+end;
+
+Function TCB_IMGPSScanX.CheckCaseAttach_OK:Boolean;  //檢查是否有未歸類的案件
+var
+  i,j : Integer;
+begin
+  Result := True;
+  for i := 0 to NewTreeNode.Count - 1 do
+  begin
+    for j := 0 to NewTreeNode.Item[i].Count - 1 do
+    begin
+      if Pos(_msg('未歸類'),NewTreeNode.Item[i].Item[j].Text) > 0 then
+      begin
+        Result := False;
+        Break;
+      end;
     end;
   end;
 end;
@@ -7073,7 +7095,7 @@
       begin
         FileList.LoadFromFile(Path+CaseID+'\'+iDocDir+'\Context.dat');
 
-        if FWH_category='N' then
+        if (FWH_category='N') and (FIs_In_Wh='Y') then
         begin
           ST1.Clear;
           for n := 0 to FileList.Count - 1 do
@@ -8042,8 +8064,8 @@
         FileList.LoadFromFile(ImageSavePath+Caseno+'\'+CaseDocNoList.Strings[i]+'\Context.dat');
       iDocNo := DocNoDir2DocNo(CaseDocNoList.Strings[i]);
       ST1.Clear;
-
-      if FWH_category='N' then
+//ShowMessage(FileList.Text);
+      if (FWH_category='N') and (FIs_In_Wh='Y') then
       begin
         for n := 0 to FileList.Count - 1 do
         begin
@@ -8066,7 +8088,7 @@
       if FileList.Count=0 then Continue;
 
 
-      //Showmessage('aaa '+FileList.Text);
+//Showmessage('aaa '+FileList.Text);
       DocNoCopies := Strtoint(CaseDocNo_CopiesList.Strings[i]);
       DocNoPage := FileList.Count;
       iDocNo := DocNoDir2DocNo(CaseDocNoList.Strings[i]);
@@ -8178,6 +8200,7 @@
 
     if DirectoryExists(ImageSavePath+Caseno+'\'+AttName) then
     begin
+
       FileList.Clear;
       if FileExists(ImageSavePath+Caseno+'\'+AttName+'\Context.dat') then
         FileList.LoadFromFile(ImageSavePath+Caseno+'\'+AttName+'\Context.dat')
@@ -8207,6 +8230,42 @@
         end;
       end;
     end;
+
+    if FModeName='件' then  //20170904 先裝死  因為異動 同時存在兩種附件太難寫
+    begin
+      if DirectoryExists(ImageSavePath+Caseno+'\Attach') then
+      begin
+        FileList.Clear;
+        if FileExists(ImageSavePath+Caseno+'\Attach'+'\Context.dat') then
+          FileList.LoadFromFile(ImageSavePath+Caseno+'\Attach'+'\Context.dat')
+        Else
+        begin
+          Rmdir(ImageSavePath+Caseno+'\Attach');
+          Exit;
+        end;
+        DocNoPage := FileList.Count;
+        iDocNo := DocNoDir2DocNo(AttName);
+        //DocNode := TreeView1.Items.AddChild(CaseNode,Format('%s{%s}-%d'+_msg('份'),[AttName,DocNo2DocName(Caseno,iDocNo),1]));
+        DocNode := TreeView1.Items.AddChild(CaseNode,Format('%s{%s}-%d'+_msg('份'),[DocNo2DocName(Caseno,iDocNo),'Attach',1]));
+        DocNode.ImageIndex := 2;
+        DocNode.SelectedIndex := 2;
+        for n := 0 to FileList.Count - 1 do
+        begin
+          FormID := FileName2FormCode(FileList.Strings[n]);
+          if not CheckFormIDExists(DocNode,FormID) then
+          begin
+            FormPage := GetFormIDPage(FileList,FormID);
+            FormName := FormCode2FormName(Caseno,FormID);
+            //FormNode := TreeView1.Items.AddChild(DocNode,FormID+'{'+FormName+'}-'+inttostr(FormPage)+_msg('頁'));
+            FormNode := TreeView1.Items.AddChild(DocNode,FormName+'{'+FormID+'}-'+inttostr(FormPage)+_msg('頁'));
+
+            FormNode.ImageIndex := 4;
+            FormNode.SelectedIndex := 4;
+          end;
+        end;
+      end;
+    end;
+
   Finally
   FileList.Free;
   CaseDocNoList.Free;
@@ -9175,6 +9234,7 @@
   S := TStringlist.Create;
   GraphicPrinter := TDibGraphicPrinter.Create;
   PrtDialog := TPrintDialog.Create(self);
+  //PrtDialog.Copies:=99;
   try
     IF PrtDialog.Execute Then
     begin
@@ -11855,7 +11915,7 @@
      For i := 0 to CaseDocNoList.Count-1 do
      begin
 
-       if FWH_category='N' then
+       if (FWH_category='N') and (FIs_In_Wh='Y') then
        begin
          if FileExists(ImageSavePath+NowCaseno+'\EditedDocDir.dat') then
          begin
@@ -11886,7 +11946,7 @@
        for n := 0 to ContextList.Count - 1 do
        begin
 
-         if FWH_category='N' then
+         if (FWH_category='N') and (FIs_In_Wh='Y') then
          begin
            if ISExistImg(Path+iDocNo+'\'+ContextList.Strings[n]) then
            begin
@@ -11942,22 +12002,24 @@
 
 //ShowMessage('ContextList.Count='+IntToStr(ContextList.Count));
      CreatePreViewISB(ContextList.Count);
-//ShowMessage(IntToStr(ContextList.Count-Ct));
+//ShowMessage(IntToStr(ContextList.Count));
      int1:=0;
+//ShowMessage(BoolToStr(DocNoIs_In_WH(Copy(iDocNo,1,8)),true));
      For i := 0 to ContextList.Count -1 do
      begin
-       if FWH_category='N' then
+       if (FWH_category='N') and (FIs_In_Wh='Y')  then
        begin
          if ISExistImg(Path+iDocNo+'\'+ContextList.Strings[i]) then
          begin
 
-           if not DocNoIs_In_WH(Copy(iDocNo,1,8)) then
+           if not DocNoIs_In_WH(Copy(iDocNo,1,8)) and ( iDocNo<>'Attach') then
            begin
              inc(int1);
              Continue;
            end;
          end;
        end;
+//ShowMessage(Path+iDocNo+'\'+ContextList.Strings[i]);
        ISB := TImageScrollBox(FindComponent(ISBName+intToStr(i+1-int1)));
        ISB.AntiAliased := True;
        if ISB.ZoomPercent > 100  then
@@ -11985,7 +12047,7 @@
        begin
          if FileName2FormCode(ContextList.Strings[i]) = FormID then
          begin
-           if FWH_category='N' then
+           if (FWH_category='N') and (FIs_In_Wh='Y') then
            begin
 //ShowMessage(Path+iDocNo+'\'+ContextList.Strings[i]);
 //ShowMessage(BoolToStr(ISExistImg(Path+iDocNo+'\'+ContextList.Strings[i]),true));
@@ -13057,6 +13119,7 @@
         OldName := Filelist.Strings[i];
         //NewName := Add_Zoo(i+1,3)+Copy(OldName,4,length(OldName)-3);
         NewName := Add_Zoo(i+1,3)+FileName2NoQuene_Filename(OldName);
+//ShowMessage(OldName+#10#13+NewName);
         ReNameFile(Path+OldName,Path+NewName);
         Filelist.Strings[i] := NewName;
       end;
@@ -13919,6 +13982,14 @@
     Showmessage(_Msg('尚有未配號案件,無法上傳'));
     Exit;
   end;
+
+  if not CheckCaseAttach_OK then  //20170911檢查是否有未歸類的案件
+  begin
+    Showmessage(_Msg('尚有未歸類文件,無法上傳'));
+    Exit;
+  end;
+
+
   if NewTreeNode.Count = 0  then
   begin
     Showmessage(_Msg('無影像需傳送'));

--
Gitblit v1.8.0