国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 學(xué)院 > 開(kāi)發(fā)設(shè)計(jì) > 正文

通用查詢(xún)組件設(shè)計(jì)(續(xù))

2019-11-18 18:25:08
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

 

通用查詢(xún)組件設(shè)計(jì)(續(xù))

作者:nxyc_twz@163.com

 

  前段時(shí)間由于工作較忙,無(wú)暇整理本組件的相關(guān)文檔,請(qǐng)大家諒解!以后我會(huì)陸續(xù)整理公布該組件的所有相關(guān)文檔及源碼!

 

設(shè)置默認(rèn)的匹配類(lèi)型

PRocedure TDBFilterDialog.SetDefaultMatchType(const Value: TDBFilterMatchType);

begin

//設(shè)置默認(rèn)的匹配類(lèi)型

  FDefaultMatchType := Value;

  if Assigned(FDialog) and not (csDesigning in ComponentState) then

    case FDefaultMatchType of

      fdMatchNone :

      begin

        FDialog.grpSearchType.ItemIndex := 0;

        FDialog.cbxNonMatching.Checked := true;

      end;

      fdMatchRange:

        FDialog.pgeCriteria.ActivePage := FDialog.tabByRange;

      else

        FDialog.grpSearchType.ItemIndex := Integer(FDefaultMatchType);

    end;

end;

 

設(shè)置字段

procedure TDBFilterDialog.SetFields;

var

  i, j, p : Integer;

  field, display : String;

begin

//設(shè)置字段

  FDialog.lstAllFields.Clear;//清除所有字段

  if FFields.Count = 0 then

  begin

    for i := 0 to FDataSet.FieldList.Count - 1 do

     if FDataSet.Fields[i].Visible then //定義查詢(xún)字段

       FDialog.lstAllFields.Items.AddObject(FDataSet.Fields[i].DisplayName,FDataSet.FieldList.Fields[i]);

  end

  else

    for j := 0 to FFields.Count - 1 do

    begin

      p := Pos(';', FFields.Strings[j]);

      field := Copy(FFields.Strings[j], 1, p - 1);

      if p = Length(FFields.Strings[j]) then

        display := field

      else

        display := Copy(FFields.Strings[j], p+1, Length(FFields.Strings[j]));

      for i := 0 to FDataSet.FieldList.Count - 1 do

        if FDataSet.FieldList.Fields[i].FieldName = field then

        FDialog.lstAllFields.Items.AddObject(display, FDataSet.FieldList.Fields[i]);

    end;

  if FDialog.lstAllFields.Items.Count > 0 then

  begin

    FDialog.lstAllFields.ItemIndex := 0;

    FDialog.FieldsListBoxClick(nil);//單擊字段列表框

  end;

end;

 

設(shè)置字段列表

procedure TDBFilterDialog.SetFieldsList(const Value: TStringList);

begin

//設(shè)置字段列表

  FFields.Assign(Value);

end;

 

設(shè)置SQL

procedure TDBFilterDialog.SetOriginalSQL(const Value: TStrings);

var

  i : Integer;

begin

//設(shè)置SQL語(yǔ)句

  if FOriginalSQL.Text <> Value.Text then

  begin

    FOriginalSQL.Clear;

    FOriginalSQL.AddStrings(Value);

    if not (csLoading in ComponentState) then

      FFields.Clear;

    FDialog.NewSQL;//新建SQL查詢(xún)

  end;

  for i := 0 to FOriginalVariables.Count - 1 do

    TDBVariable(FOriginalVariables[i]).Free;//定義參數(shù)數(shù)據(jù)變量類(lèi)

  FOriginalVariables.Clear;

  if TStrings(GetOrdProp(FDataSet, SQLProp)).Text = '' then

    exit;

 

for i := 0 to TQuery(FDataSet).Params.Count - 1 do

FOriginalVariables.Add(TDBVariable.Create(TQuery(FDataSet).Params[i].Name, TQuery(FDataSet).Params[i].Value)); //定義參數(shù)數(shù)據(jù)變量類(lèi)

  SetFields;//設(shè)置字段

end;

 

恢復(fù)SQL

procedure TDBFilterDialog.RestoreSQL;

var

  i : Integer;

begin

//恢復(fù)SQL語(yǔ)句

  // Disable the controls while we are working

  FDataSet.DisableControls;

  FDataSet.Close;

  // clear the existing SQL and variable declarations

  // restore the original SQL and variables

  SetOrdProp(FDataSet, SQLProp, Integer(FOriginalSQL));

  if FDataSet is TDataSet then

    for i := 0 to FOriginalVariables.Count - 1 do

      TQuery(FDataSet).ParamByName(TDBVariable(FOriginalVariables[i]).VariableName).Value :=

         TDBVariable(FOriginalVariables[i]).VariableValue

  else

    for i := 0 to FOriginalVariables.Count - 1 do

      TQuery(FDataSet).ParamByName(TdBVariable(FOriginalVariables[i]).VariableName).Value :=

         TDBVariable(FOriginalVariables[i]).VariableValue;

  FDataSet.Open;

  SetFields;

  FDataSet.EnableControls;

  FModifiedSQL.Assign(TStrings(GetOrdProp(FDataSet, SQLProp)));

end;

 

保存參數(shù)值

procedure TDBFilterDialog.SaveParamValues;

var

  i : Integer;

begin

//保存參數(shù)值

   if FDataSet is TDataSet then

    for i := 0 to FOriginalVariables.Count - 1 do

      TDBVariable(FOriginalVariables[i]).VariableValue :=

        TQuery(FDataSet).ParamByName(TDBVariable(FOriginalVariables[i]).VariableName).Value

  else

    for i := 0 to FOriginalVariables.Count - 1 do

      TDBVariable(FOriginalVariables[i]).VariableValue :=

        TQuery(FDataSet).ParamByName(TDBVariable(FOriginalVariables[i]).VariableName).Value;

end;

 

裝載過(guò)濾對(duì)話(huà)框

procedure TDBFilterDialog.Loaded;

var

  i : Integer;

begin

  inherited;

  if Assigned(FDataSet) and not (csDesigning in ComponentState) then

  begin

    SetFields;

    OriginalSQL.Assign(TStrings(GetOrdProp(FDataSet, SQLProp)));

    for i := 0 to TQuery(FDataSet).Params.Count - 1 do

        FOriginalVariables.Add(TDBVariable.Create(TQuery(FDataSet).Params[i].Name,

          TQuery(FDataSet).Params[i].Value));

  end;

end;

 

傳送消息

procedure TDBFilterDialog.Notification(AComponent: TComponent;

  Operation: TOperation);

begin

  inherited;

  if (AComponent = FDataset) and (Operation = opRemove) then

    FDataset := nil;

end;

 

構(gòu)造函數(shù)

constructor TDBFilterDialog.Create(AOwner: TComponent);

begin

//構(gòu)造函數(shù)

  inherited Create(AOwner);

  FDialog := TMyDBFilterDialog.Create(self);

  FOptions := [fdShowCaseSensitive, fdShowNonMatching];

  FDefaultMatchType := fdMatchStart;

  Caption := SDBFilterCaption;

  FFields := TStringList.Create;

  FOriginalSQL := TStringList.Create;

  FModifiedSQL := TStringList.Create;

  FOriginalVariables := TList.Create;

end;

析構(gòu)函數(shù)

destructor TDBFilterDialog.Destroy;

var

  i : Integer;

begin

  FDialog.Free;

  FFields.Free;

  FOriginalSQL.Free;

  FModifiedSQL.Free;

  for i := 0 to FOriginalVariables.Count - 1 do

    TDBVariable(FOriginalVariables[i]).Free;

  FOriginalVariables.Free;

  inherited Destroy;

end;

 

執(zhí)行查詢(xún)

function TDBFilterDialog.Execute : Boolean;

var

  CurrentSQL : TStrings;

begin

//執(zhí)行數(shù)據(jù)查詢(xún)

  CurrentSQL := TStrings(GetOrdProp(FDataSet, SQLProp));

  // 檢查SQL語(yǔ)句是否已經(jīng)改變了

  if not FModifiedSQL.Equals(CurrentSQL) then

    OriginalSQL := CurrentSQL;

  if FDialog.lstAllFields.Items.Count = 0 then

    SetFields;

  FDialog.grpSearchType.ItemIndex := Integer(FDefaultMatchType);

  if fdShowCaseSensitive in Options then

    FDialog.cbxCaseSensitive.Visible := true

  else

    FDialog.cbxCaseSensitive.Visible := false;

  if fdShowNonMatching in Options then

    FDialog.cbxNonMatching.Visible := true

  else

    FDialog.cbxNonMatching.Visible := false;

  if fdCaseSensitive in Options then

    FDialog.cbxCaseSensitive.Checked := true

  else

    FDialog.cbxCaseSensitive.Checked := false;

  SaveParamValues;//保存參數(shù)值

  Result := FDialog.ShowModal = mrOK; //點(diǎn)擊確定按鈕

  if Result then

    ReBuildSQL;//重建SQL語(yǔ)句

end;

 


上一篇:區(qū)分保留字跟關(guān)鍵字

下一篇:獲得遠(yuǎn)程或本地機(jī)器的網(wǎng)卡的MAC

發(fā)表評(píng)論 共有條評(píng)論
用戶(hù)名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
學(xué)習(xí)交流
熱門(mén)圖片

新聞熱點(diǎn)

疑難解答

圖片精選

網(wǎng)友關(guān)注

主站蜘蛛池模板: 祥云县| 修文县| 吐鲁番市| 新龙县| 靖安县| 成都市| 体育| 杭州市| 马龙县| 阳曲县| 子长县| 枝江市| 蒲城县| 东乌珠穆沁旗| 勃利县| 荥阳市| 黄梅县| 安岳县| 施甸县| 七台河市| 积石山| 张家川| 深圳市| 百色市| 秦安县| 龙南县| 镇江市| 绩溪县| 巴林右旗| 清涧县| 渑池县| 本溪| 汤阴县| 安宁市| 五台县| 修水县| 宜阳县| 昌乐县| 安泽县| 镇安县| 安仁县|