⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 datapersistentunit.pas

📁 Delphi最新三层源码(1.0),对delphi有帮助
💻 PAS
字号:
unit DataPersistentUnit;

interface
  uses Windows, Messages, Classes, SysUtils, Forms, DB, ADODB, DBClient, MConnect,
       IDataPersistentUnit, DataStructureUnit;
      
type

  TLDMDataSet = class(TPersistent)
    private
      IDataPer: IDataPersistent;
    published
      function BeginTrans: Integer; safecall;
      function CommitTrans: Integer; safecall;
      function RollBackTrans: Integer; safecall;
      function SelectLDMDS(const wsSQL: WideString; out wsPrv :WideString): TDataSet; Stdcall;
      function InsertLDMDS(const wsSQL: WideString): Integer; safecall;
      function UpdateLDMDS(const wsSQL: WideString): Integer; safecall;
      function DeleteLDMDS(const wsSQL: WideString): Integer; safecall;
      Procedure CloseLDMDS(const wsDSName: WideString); safecall;
  public
    constructor Create(pIDataPer: IDataPersistent);
  end;



implementation
  uses ServerFrm, ResourceStrUnit;

constructor TLDMDataSet.Create(pIDataPer: IDataPersistent);
begin
  inherited Create;
  IDataPer := pIDataPer;
end;


function TLDMDataSet.BeginTrans: Integer; safecall;
begin
  try
    Result := IDataPer.BeginTrans;
  except
    Result := -1;
    MessageBox(Application.handle, PChar(GloRs_IDsBTranErr), PChar(GloRs_Title), MB_ICONINFORMATION);
  end;
end;

function TLDMDataSet.CommitTrans: Integer; safecall;
begin
  try
    Result := IDataPer.CommitTrans;
  except
    Result := -1;
    MessageBox(Application.handle, PChar(GloRs_IDsCTranErr), PChar(GloRs_Title), MB_ICONINFORMATION);
  end;
end;

function TLDMDataSet.RollBackTrans: Integer; safecall;
begin
  try
    Result := IDataPer.RollBackTrans;
  except
    Result := -1;
    MessageBox(Application.handle, PChar(GloRs_IDsRTranErr), PChar(GloRs_Title), MB_ICONINFORMATION);
  end;
end;

function TLDMDataSet.SelectLDMDS(const wsSQL: WideString; out wsPrv :WideString): TDataSet; Stdcall;
begin
  try
    Result := IDataPer.SelectData(wsSQL, wsPrv);
  except
    Result := nil;
    MessageBox(Application.handle, PChar(GloRs_IDsGetData), PChar(GloRs_Title), MB_ICONINFORMATION);
  end;
end;

function TLDMDataSet.InsertLDMDS(const wsSQL: WideString): Integer; safecall;
begin
  try
    Result := IDataPer.InsertDataSet(wsSQL);
  except
    Result := -1;
    MessageBox(Application.handle, PChar(GloRs_IDsExeData), PChar(GloRs_Title), MB_ICONINFORMATION);
  end;
end;

function TLDMDataSet.UpdateLDMDS(const wsSQL: WideString): Integer; safecall;
begin
  try
    Result := IDataPer.UpdateDataSet(wsSQL);
  except
    Result := -1;
    MessageBox(Application.handle, PChar(GloRs_IDsExeData), PChar(GloRs_Title), MB_ICONINFORMATION);
  end;
end;

function TLDMDataSet.DeleteLDMDS(const wsSQL: WideString): Integer; safecall;
begin
  try
    Result := IDataPer.DeleteDataSet(wsSQL);
  except
    Result := -1;
    MessageBox(Application.handle, PChar(GloRs_IDsExeData), PChar(GloRs_Title), MB_ICONINFORMATION);
  end;
end;

Procedure TLDMDataSet.CloseLDMDS(const wsDSName: WideString); safecall;
begin
  try
    IDataPer.CloseDataSet(wsDSName);
  except
  end;
end;


end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -