| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 | unit AttachmentInfoDm;interfaceuses  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;implementationuses 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.
 |