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

📄 rmd_bde.pas

📁 中小企业管理系统------ ERP系统原代码
💻 PAS
📖 第 1 页 / 共 2 页
字号:
  begin
    FTable.Close;
    FTable.DatabaseName := Value;
  end;
end;

function TRMDBDETable.GetPropValue(Index: string): Variant;
begin
  Index := AnsiUpperCase(Index);
  Result := inherited GetPropValue(Index);
  if Result <> Null then Exit;
  if Index = 'INDEXNAME' then
    Result := FTable.IndexName
  else if Index = 'MASTERSOURCE' then
    Result := RMGetDataSetName(FTable.Owner, FTable.MasterSource)
  else if Index = 'MASTERFIELDS' then
    Result := FTable.MasterFields
  else if Index = 'TABLENAME' then
    Result := FTable.TableName
  else if Index = 'DATABASE' then
    Result := FTable.DatabaseName
end;


{------------------------------------------------------------------------------}
{------------------------------------------------------------------------------}
{TRMDBDEQuery}

constructor TRMDBDEQuery.Create;
begin
  inherited Create;
  FQuery := TQuery.Create(RMDialogForm);
  DataSet := FQuery;

  Component := FQuery;
  BaseName := 'Query';
  BmpRes := 'RMD_BDEQUERY';
end;

procedure TRMDBDEQuery.LoadFromStream(Stream: TStream);
begin
  inherited LoadFromStream(Stream);
end;

procedure TRMDBDEQuery.SaveToStream(Stream: TStream);
begin
  LVersion := 0;
  inherited SaveToStream(Stream);
end;

procedure TRMDBDEQuery.GetDatabases(sl: TStrings);
var
  liStringList: TStringList;
begin
  liStringList := TStringList.Create;
  try
    Session.GetAliasNames(liStringList);
    liStringList.Sort;
    sl.Assign(liStringList);
  finally
    liStringList.Free;
  end;
end;

procedure TRMDBDEQuery.GetTableNames(DB: string; Strings: TStrings);
var
  sl: TStringList;
begin
  sl := TStringList.Create;
  try
    try
      Session.GetTableNames(DB, '', True, False, sl);
      sl.Sort;
      Strings.Assign(sl);
    except;
    end;
  finally
    sl.Free;
  end;
end;

procedure TRMDBDEQuery.GetTableFieldNames(const DB, TName: string; sl: TStrings);
var
  i: Integer;
  lStrings: TStringList;
  t: TTable;
begin
  lStrings := TStringList.Create;
  t := TTable.Create(RMDialogForm);
  try
    t.DatabaseName := DB;
    t.TableName := tName;
    try
      t.FieldDefs.UpDate;
      for i := 0 to t.FieldDefs.Count - 1 do
        lStrings.Add(t.FieldDefs.Items[i].Name);
      lStrings.Sort;
      sl.Assign(lStrings);
    except;
    end;
  finally
    lStrings.Free;
    t.Free;
  end;
end;

procedure TRMDBDEQuery.SetPropValue(Index: string; Value: Variant);
var
  d: TComponent;
begin
  inherited SetPropValue(Index, Value);
  Index := AnsiUpperCase(Index);
  if index = 'DATABASE' then
  begin
    FQuery.Close;
    FQuery.DatabaseName := Value;
  end
  else if Index = 'DATASOURCE' then
  begin
    d := RMFindComponent(FQuery.Owner, Value);
    FQuery.DataSource := RMGetDataSource(FQuery.Owner, TDataSet(d));
  end
  else if index = 'PARAMS.COUNT' then
  begin
  end
  else if Index = 'SQL' then
  begin
    FQuery.Close;
    FQuery.SQL.Text := Value;
  end
end;

function TRMDBDEQuery.GetPropValue(Index: string): Variant;
begin
  Index := AnsiUpperCase(Index);
  Result := inherited GetPropValue(Index);
  if Result <> Null then Exit;
  if Index = 'DATABASE' then
    Result := FQuery.DatabaseName
  else if Index = 'DATASOURCE' then
    Result := RMGetDataSetName(FQuery.Owner, FQuery.DataSource)
  else if Index = 'PARAMS.COUNT' then
    Result := FQuery.Params.Count
  else if Index = 'SQL' then
    Result := FQuery.SQL.Text
  else if Index = 'SQL.COUNT' then
    Result := FQuery.SQL.Count
end;

function TRMDBDEQuery.DoMethod(const MethodName: string; Pars: array of Variant): Variant;
begin
  Result := inherited DoMethod(MethodName, Pars);
  if Result = Null then
    Result := LinesMethod(FQuery.SQL, MethodName, 'SQL', Pars[0], Pars[1], Pars[2]);
  if MethodName = 'EXECSQL' then
  begin
    OnBeforeOpenQueryEvent(FQuery);
    FQuery.ExecSQL;
  end;
end;

function TRMDBDEQuery.GetParamName(Index: Integer): string;
begin
  Result := FQuery.Params[Index].Name;
end;

function TRMDBDEQuery.GetParamType(Index: Integer): TFieldType;
begin
  Result := FQuery.Params[Index].DataType;
end;

procedure TRMDBDEQuery.SetParamType(Index: Integer; Value: TFieldType);
begin
  FQuery.Params[Index].DataType := Value;
end;

function TRMDBDEQuery.GetParamKind(Index: Integer): TRMParamKind;
begin
  Result := rmpkValue;
  if not FQuery.Params[Index].Bound then
    Result := rmpkAssignFromMaster;
end;

procedure TRMDBDEQuery.SetParamKind(Index: Integer; Value: TRMParamKind);
begin
  if Value = rmpkAssignFromMaster then
  begin
    FQuery.Params[Index].Bound := False;
    FParams.Delete(FParams.IndexOf(FQuery.Params[Index].Name));
  end
  else
  begin
    FQuery.Params[Index].Clear;
    FQuery.Params[Index].Bound := True;
    FParams[FQuery.Params[Index].Name] := '';
  end;
end;

function TRMDBDEQuery.GetParamText(Index: Integer): string;
begin
  Result := '';
  if ParamKind[Index] = rmpkValue then
    Result := FParams[FQuery.Params[Index].Name];
end;

procedure TRMDBDEQuery.SetParamText(Index: Integer; Value: string);
begin
  if ParamKind[Index] = rmpkValue then
    FParams[FQuery.Params[Index].Name] := Value;
end;

function TRMDBDEQuery.GetParamValue(Index: Integer): Variant;
begin
  Result := FQuery.Params[Index].Value;
end;

procedure TRMDBDEQuery.SetParamValue(Index: Integer; Value: Variant);
begin
  FQuery.Params[Index].Value := Value;
end;

{------------------------------------------------------------------------------}
{------------------------------------------------------------------------------}
{TDBEditForm}

procedure TRMDFormBDEDBProp.Localize;
begin
  Font.Name := RMLoadStr(SRMDefaultFontName);
  Font.Size := StrToInt(RMLoadStr(SRMDefaultFontSize));
  Font.Charset := StrToInt(RMLoadStr(SCharset));

  RMSetStrProp(GroupBox1, 'Caption', rmRes + 3233);
  RMSetStrProp(Label4, 'Caption', rmRes + 3234);
  RMSetStrProp(Label1, 'Caption', rmRes + 3235);
  RMSetStrProp(Label2, 'Caption', rmRes + 3236);
  RMSetStrProp(Label3, 'Caption', rmres + 3237);
  RMSetStrProp(btnDefaultsParam, 'Caption', rmRes + 3238);
  RMSetStrProp(btnClearParam, 'Caption', rmRes + 3239);
  RMSetStrProp(btnPath, 'Caption', rmRes + 3240);

  btnOK.Caption := RMLoadStr(SOK);
  btnCancel.Caption := RMLoadStr(SCancel);
end;

function TRMDFormBDEDBProp.Edit: Boolean;
begin
  edtDBName.Text := FDatabase.DatabaseName;
  cmbAliasName.Text := FDatabase.AliasName;
  cmbDriverName.Text := FDatabase.DriverName;
  memDatabaseParams.Lines := FDatabase.Params;
  Result := False;
  if ShowModal = mrOk then
  begin
    FDatabase.DatabaseName := edtDBName.Text;
    if cmbDriverName.Text <> '' then
      FDatabase.DriverName := cmbDriverName.Text
    else
      FDatabase.AliasName := cmbAliasName.Text;
    FDatabase.Params := memDatabaseParams.Lines;
    Result := True;
  end;
end;

procedure TRMDFormBDEDBProp.cmbAliasNameChange(Sender: TObject);
begin
  cmbDriverName.Text := '';
end;

procedure TRMDFormBDEDBProp.cmbAliasNameDropDown(Sender: TObject);
begin
  cmbAliasName.Items.Clear;
  FDatabase.Session.GetAliasNames(cmbAliasName.Items);
end;

procedure TRMDFormBDEDBProp.cmbDriverNameChange(Sender: TObject);
begin
  cmbAliasName.Text := '';
end;

procedure TRMDFormBDEDBProp.cmbDriverNameDropDown(Sender: TObject);
begin
  cmbDriverName.Items.Clear;
  FDatabase.Session.GetDriverNames(cmbDriverName.Items);
end;

procedure TRMDFormBDEDBProp.btnDefaultsParamClick(Sender: TObject);
var
  AddPassword: Boolean;
begin
  memDatabaseParams.Clear;
  AddPassword := False;
  if cmbDriverName.Text <> '' then
  begin
    FDatabase.Session.GetDriverParams(cmbDriverName.Text, memDatabaseParams.Lines);
    AddPassword := cmbDriverName.Text <> szCFGDBSTANDARD;
  end
  else if cmbAliasName.Text <> '' then
  begin
    FDatabase.Session.GetAliasParams(cmbAliasName.Text, memDatabaseParams.Lines);
    AddPassword := FDatabase.Session.GetAliasDriverName(cmbAliasName.Text) <> szCFGDBSTANDARD;
  end;

  if AddPassword then memDatabaseParams.Lines.Add('PASSWORD=');
end;

procedure TRMDFormBDEDBProp.btnClearParamClick(Sender: TObject);
begin
  memDatabaseParams.Clear;
end;

procedure TRMDFormBDEDBProp.btnPathClick(Sender: TObject);
var
  str: string;
begin
  if RMSelectDirectory(RMLoadStr(rmRes + 3252), '', str) then
    memDatabaseParams.Lines.Values['PATH'] := str;
//  if SelectDirectory(str, [], 0) then
//    memDatabaseParams.Lines.Values['PATH'] := str;
end;

procedure TRMDFormBDEDBProp.btnOKClick(Sender: TObject);
begin
  ModalResult := mrNone;
  try
    FDatabase.ValidateName(edtDBName.Text);
  except
    edtDBName.SetFocus;
    raise;
  end;
  if FDatabase.Connected then
  begin
    if MessageDlg(SDisconnectDatabase, mtConfirmation,
      mbOkCancel, 0) <> mrOk then Exit;
    FDatabase.Close;
  end;
  ModalResult := mrOk;
end;

procedure TRMDFormBDEDBProp.FormCreate(Sender: TObject);
begin
  Localize;
end;

initialization
  RMRegisterControl(TRMDBDEDatabase, 'RMD_BDEDBCONTROL', RMLoadStr(SInsertDB) + '(BDE)');
  RMRegisterControl(TRMDBDETable, 'RMD_BDETABLECONTROL', RMLoadStr(SInsertTable) + '(BDE)');
  RMRegisterControl(TRMDBDEQuery, 'RMD_BDEQUERYCONTROL', RMLoadStr(SInsertQuery) + '(BDE)');

finalization

{$ENDIF}
end.



//此源码由程序太平洋收集整理发布,任何人都可自由转载,但需保留本站信息
//╭⌒╮┅~ ¤ 欢迎光临程序太平洋╭⌒╮
//╭⌒╭⌒╮╭⌒╮~╭⌒╮  ︶  ,︶︶
//,︶︶︶︶,''︶~~ ,''~︶︶  ,''
//╔ ╱◥███◣═╬╬╬╬╬╬╬╬╬╗
//╬ ︱田︱田 田 ︱          ╬
//╬       http://www.5ivb.net ╬
//╬  ╭○╮●                     ╬
//╬  /■\/■\                    ╬
//╬   <| ||    有希望,就有成功! ╬
//╬                 ╬
//╚╬╬╬╬╬╬╬╬╬╬╗  ╔╬╬╬╬╝
//
//说明:
//专业提供VB、.NET、Delphi、ASP、PB源码下载
//包括:程序源码,控件,商业源码,系统方案,开发工具,书籍教程,技术文档

⌨️ 快捷键说明

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