MaiXinRong hace 6 años
padre
commit
27005c52c4
Se han modificado 2 ficheros con 129 adiciones y 0 borrados
  1. 32 0
      DataModules/AttachmentInfoDm.dfm
  2. 97 0
      DataModules/AttachmentInfoDm.pas

+ 32 - 0
DataModules/AttachmentInfoDm.dfm

@@ -0,0 +1,32 @@
+object AttachmentInfoData: TAttachmentInfoData
+  OldCreateOrder = False
+  Left = 581
+  Top = 330
+  Height = 175
+  Width = 215
+  object sdpAttachmentInfo: TsdADOProvider
+    TableName = 'AttachmentInfo'
+    Left = 56
+    Top = 24
+  end
+  object sddAttachmentInfo: TsdDataSet
+    Active = False
+    Filtered = False
+    Provider = sdpAttachmentInfo
+    Left = 56
+    Top = 80
+    FieldListData = {
+      0101044E616D6506024944094669656C644E616D650602494408446174615479
+      70650203084461746153697A6502040549734B6579080F4E65656450726F6365
+      73734E616D650809507265636973696F6E02000453697A6502000001044E616D
+      650606557365724944094669656C644E616D6506065573657249440844617461
+      547970650203084461746153697A6502040549734B6579080F4E65656450726F
+      636573734E616D650909507265636973696F6E02000453697A6502000001044E
+      616D6506034D6163094669656C644E616D6506034D6163084461746154797065
+      0218084461746153697A6503FF000549734B6579080F4E65656450726F636573
+      734E616D650909507265636973696F6E02000453697A6502000001044E616D65
+      060450617468094669656C644E616D6506045061746808446174615479706502
+      18084461746153697A6503FF000549734B6579080F4E65656450726F63657373
+      4E616D650909507265636973696F6E02000453697A6502000000}
+  end
+end

+ 97 - 0
DataModules/AttachmentInfoDm.pas

@@ -0,0 +1,97 @@
+unit AttachmentInfoDm;
+
+interface
+
+uses
+  SysUtils, Classes, sdDB, sdProvider, ADODB, Variants;
+
+type
+  TAttachmentInfoData = class(TDataModule)
+    sdpAttachmentInfo: TsdADOProvider;
+    sddAttachmentInfo: TsdDataSet;
+  private
+    FProjectData: TObject;
+    FMacAddr: string;
+
+    function GetAttachmentInfoRec(AID: Integer): TsdDataRecord;
+  public
+    constructor Create(AProjectData: TObject);
+    destructor Destroy; override;
+
+    procedure Open(AConnection: TADOConnection);
+    procedure Close;
+    procedure Save;
+
+    function GetAttachmentPath(AID: Integer): string;
+    procedure SaveAttachmentPath(AID: Integer; APath: string);
+  end;
+
+implementation
+
+uses UtilMethods, PHPWebDM;
+
+{$R *.dfm}
+
+{ TAttachmentInfoData }
+
+procedure TAttachmentInfoData.Close;
+begin
+  sddAttachmentInfo.Close;
+end;
+
+constructor TAttachmentInfoData.Create(AProjectData: TObject);
+begin
+  inherited Create(nil);
+  FProjectData := AProjectData;
+  FMacAddr := GetMacAddr;
+end;
+
+destructor TAttachmentInfoData.Destroy;
+begin
+  inherited;
+end;
+
+function TAttachmentInfoData.GetAttachmentInfoRec(AID: Integer): TsdDataRecord;
+begin
+  Result := sddAttachmentInfo.Locate('ID;Mac', VarArrayOf([AID, FMacAddr]));
+end;
+
+function TAttachmentInfoData.GetAttachmentPath(AID: Integer): string;
+var
+  Rec: TsdDataRecord;
+begin
+  Result := '';
+  Rec := GetAttachmentInfoRec(AID);
+  if Assigned(Rec) then
+    Result := Rec.ValueByName('Path').AsString;
+end;
+
+procedure TAttachmentInfoData.Open(AConnection: TADOConnection);
+begin
+  sdpAttachmentInfo.Connection := AConnection;
+  sddAttachmentInfo.Open;
+end;
+
+procedure TAttachmentInfoData.Save;
+begin
+  sddAttachmentInfo.Save;
+end;
+
+procedure TAttachmentInfoData.SaveAttachmentPath(AID: Integer;
+  APath: string);
+var
+  Rec: TsdDataRecord;
+begin
+  Rec := GetAttachmentInfoRec(AID);
+  if not Assigned(Rec) then
+  begin
+    Rec := sddAttachmentInfo.Add;
+    Rec.ValueByName('ID').AsInteger := AID;
+    Rec.ValueByName('UserID').AsInteger := PHPWeb.UserID;
+    Rec.ValueByName('Mac').AsString := FMacAddr;
+  end;
+  Rec.ValueByName('Path').AsString := APath;
+  sddAttachmentInfo.Save;
+end;
+
+end.