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

📄 frm_mainbase.pas

📁 用Delhpi和mapx开发的警务管理系统
💻 PAS
📖 第 1 页 / 共 3 页
字号:
    sForeignId:=adoQue.fieldbyname('ForeignFieldId').AsString;
    sForeignName:=adoQue.fieldbyname('ForeignFieldName').AsString;
    sForeignTableName:=adoQue.fieldbyname('ForeignTable').AsString;
    sForeignFieldType:=adoQue.fieldbyname('ForeignFieldType').AsString;
  adoQue.Free;
  cDataPub:=TDataPub.create(systemDM.Glb_BasicDataOperate,cMapInfo^.TableName,10);
  strSql:='select ';
  for iLoop:=0 to high(cDataPub.msArrColumnName) do
  begin
    strSql:=strSql + cMapInfo^.TableName + '.' + cDataPub.msArrColumnName[iLoop] + ',';
  end;
  strSql:=copy(strSql,1,length(strsql)-1);
  if iForeign=0 then
    strSql:=strSql + ' from ' + cMapInfo^.TableName
  else
    strSql:=strSql + ' from ' + cMapInfo^.TableName + ',' + sForeignTableName;
  if iForeign=0 then
  begin
    if sFieldType='VARCHAR2' then
      strSql:=strSql + ' where ' + sFieldName + ' like''%' + trim(txt_Condition.Text) + '%'''
    else if sFieldType='NUMBER' then
      strSql:=strSql + ' where ' + sFieldName + '=' + trim(txt_Condition.Text);
  end
  else
  begin
    if sForeignFieldType='VARCHAR2' then
      strSql:= strSql + ' where ' + cMapInfo^.TableName + '.'  + sFieldName + '=' +
      sForeignTableName + '.' + sForeignId + ' and ' + sForeignTableName + '.' +  sForeignName + ' like''%' + trim(txt_Condition.Text) + '%'''
    else if sForeignFieldType='NUMBER' then
      strSql:= strSql + ' where ' + cMapInfo^.TableName + '.' + sFieldName + '=' +
      sForeignTableName + '.' + sForeignId + ' and ' + sForeignTableName + '.' + sForeignName + '=' + trim(txt_Condition.Text);
  end;
  adoQue:=systemDM.Glb_BasicDataOperate.adoGetAdoQuery(strSql);
  cDataGrid:=TGridListView.create(systemDM.Glb_BasicDataOperate);
  cDataGrid.AddDatatoListView(cDataPub.msArrColumnComments,adoQue,lv_Result,true);
  cDataPub.sChangeListCaption(TBase_ListView(lv_Result));
  cDataPub.sChangeListData(TBase_ListView(lv_Result));
  cDataGrid.Free;
  cDataPub.Free;
end;

procedure TForm_MainBase.Action_EditExecute(Sender: TObject);
var
  msTableName:string;
begin
  if lv_Result.SelCount=0 then
  begin
    Application.MessageBox('请选择记录!','提示',MB_OK + MB_ICONINFORMATION);
    exit;
  end;
  msTableName:=MapControl.sGetTvSelectTableName;
  with TForm_Basic.create(systemDM.Glb_BasicDataOperate,msTableName,'',4,lv_Result) do
  begin
    try
      ShowModal;
    finally
      free;
    end;
  end;
end;


procedure TForm_MainBase.Action_LocateExecute(Sender: TObject);
var
  strSql:string;
  TableInf:pTable;
  MapInf:pMapInfo;
  ftrs:Features;
begin
  if lv_Result.SelCount=0 then
  begin
    Application.MessageBox('请选择记录!','提示',MB_OK + MB_ICONINFORMATION);
    exit;
  end;
  TableInf:=lv_Result.Selected.Data;
  strSql:='FEATUREID=' + TableInf^.DataValue[0];
  MapInf:=tv_Layer.Selected.Data;
  ftrs:=Map_main.Layers[MapInf^.SpaceTableName].Search(strSql,EmptyParam);
  if ftrs.Count<>0 then
  begin
    Map_main.Layers[MapInf^.SpaceTableName].Selection.ClearSelection;
    Map_main.Layers[MapInf^.SpaceTableName].Selection.Add(ftrs[1]);
    Map_main.CenterX:=ftrs[1].CenterX;
    Map_main.CenterY:=ftrs[1].CenterY;
  end;
end;

procedure TForm_MainBase.Timer1Timer(Sender: TObject);
var
  strSql:string;
  adoTempQue:TADOQuery;
  iLoop:integer;
  ftrs:Features;
  ftrId:array of integer;
begin
  if adoCriminalQue<>nil then
    adoCriminalQue.Free;
  tempFtrs:=Map_main.Layers['DOORPLATE_S'].NoFeatures;
  strSql:='select * from StayEscaNo';
  adoCriminalQue:=systemDM.Glb_BasicDataOperate.adoGetAdoQuery(strSql);
  for iLoop:=0 to adoCriminalQue.RecordCount -1 do
  begin
    strSql:='select * from DOORPLATE,StayEscaNo where DOORPLATE.Street=StayEscaNo.StayAddStreet and  StayEscaNo.StayAddDetail = DOORPLATE.DOORPLATE';
    adoTempQue:=systemDM.Glb_BasicDataOperate.adoGetAdoQuery(strSql);
    SetLength(ftrId,length(ftrId)+1);
    if adoTempQue.RecordCount<>0 then
      ftrId[iLoop]:=adoTempQue.fieldbyname('FEATUREID').AsInteger;
    adoTempQue.Free;
    adoCriminalQue.Next;
  end;
  //adoQue.Free;
  for iLoop:=0 to length(ftrid)-1 do
  begin
    strSql:='FEATUREID=' + inttostr(ftrid[iLoop]);
    ftrs:=Map_main.Layers['DOORPLATE_S'].Search(strSql,EmptyParam);
    if ftrs.Count<>0 then
    begin
      Map_main.Layers['DOORPLATE_S'].Selection.Add(ftrs[1]);
      tempFtrs.Add(ftrs);
    end;
  end;
end;

procedure TForm_MainBase.lv_ResultClick(Sender: TObject);
var
  msTableName:string;
  cDataPub:TDataPub;
begin
  if lv_Result.SelCount=0 then
    exit;
  msTableName:=MapControl.sGetTvSelectTableName;
  cDataPub:=TDataPub.create(systemDM.Glb_BasicDataOperate,msTableName,pan_Detail,11,lv_Result);
  cDataPub.Free;
end;

procedure TForm_MainBase.tv_LayerClick(Sender: TObject);
var
  MaInfo:pMapInfo;
  iLoop:integer;
  cDataPub:TDataPub;
begin
  lv_Result.Items.Clear;
  lv_Result.Columns.Clear;
  if tv_Layer.SelectionCount=0 then
    exit;
  MaInfo:=tv_Layer.Selected.Data;
  if MaInfo^.ParentID=0 then
    exit;
  m_ShowTableName:=MaInfo^.TableName;
  if MaInfo^.TableName='CASERECORD' then
  begin
    CASERECORD.Enabled:=False;

    COMPANY.Enabled:=true;
    DOORPLATE.Enabled:=true;
    WORKOBJECT.Enabled:=true;
    PermanentPopu.Enabled:=true;
    StayPopu.Enabled:=true;
  end
  else if MaInfo^.TableName='DOORPLATE' then
  begin
    DOORPLATE.Enabled:=false;

    COMPANY.Enabled:=true;
    WORKOBJECT.Enabled:=true;
    CASERECORD.Enabled:=true;
    PermanentPopu.Enabled:=true;
    StayPopu.Enabled:=true;
  end
  else if MaInfo^.TableName='POLICEHOUSE' then
  begin
    DOORPLATE.Enabled:=true;

    COMPANY.Enabled:=true;
    WORKOBJECT.Enabled:=true;
    CASERECORD.Enabled:=true;
    PermanentPopu.Enabled:=true;
    StayPopu.Enabled:=true;
  end
  else
  begin
    COMPANY.Enabled:=false;
    DOORPLATE.Enabled:=false;
    WORKOBJECT.Enabled:=false;
    CASERECORD.Enabled:=false;
    PermanentPopu.Enabled:=false;
    StayPopu.Enabled:=false;
  end;
  //初始化查询字段名
  cDataPub:=TDataPub.create(systemDM.Glb_BasicDataOperate,MaInfo^.TableName);
  cb_Condition.Clear;
  SetLength(msArrType,length(cDataPub.msArrColumnName));
  for iLoop:=0 to high(cDataPub.msArrColumnName) do
  begin
    msArrType[iLoop]:= cDataPub.msArrColumnType[iLoop];
  end;
  for iLoop:=0 to high(cDataPub.msArrColumnName) do
  begin
    cb_Condition.Items.Add(cDataPub.msArrColumnComments[iLoop]);
    cb_Condition.itemsvalue.Add(cDataPub.msArrColumnName[iLoop]);
  end;
  cb_Condition.ItemIndex:=0;
  cDataPub.Free;
end;


//***************************************//
//           显示关联资源Click事件       //
//***************************************//
procedure TForm_MainBase.bitShowClick(Sender: TObject);
var
  strMessage:string;
  strSqlString:string;
  cDataPubMain,cDataPubRel:TDataPub;
  sRelTableName:string;
  sConditonValue:array of string;
  iRelColumnCount:integer;
  pTableInfo:pTable;
  iLoop,jLoop:integer;
  iPos:integer;
  iIndex:integer;
begin
  //取得主表关联字段的值
  cDataPubMain:=TDataPub.create(systemDM.Glb_BasicDataOperate,m_ShowTableName);

  for iLoop:=0 to high(cDataPubMain.msSpecialRelTableNames) do
  begin
    if UpperCase(cDataPubMain.msSpecialRelTableNames[iLoop])=UpperCase(TBUtton(Sender).Name) then
      iIndex:=iLoop;
  end;


  iRelColumnCount:=length(cDataPubMain.msOriginalField[iIndex]);
  if lv_Result.SelCount=0 then
  begin
    Application.MessageBox('请选择记录!','提示',MB_OK + MB_ICONINFORMATION);
    exit;
  end;
  pTableInfo:=lv_Result.Selected.Data;
  SetLength(sConditonValue,iRelColumnCount);
  for iLoop:=0 to iRelColumnCount-1 do
  begin
    sConditonValue[iLoop]:=pTableInfo^.DataValue[cDataPubMain.iGetColumnIndex(cDataPubMain.msOriginalField[iIndex][iLoop])];
  end;

  //根据选择的关联资源形成SQl语句
  cDataPubRel:=TDataPub.create(systemDM.Glb_BasicDataOperate,TButton(sender).Name);
  strSqlString:='select ';
  for iLoop:= 0 to high(cDataPubRel.msArrColumnName) do
  begin
    strSqlString:=strSqlString + cDataPubRel.msArrColumnName[iLoop] + ',';
  end;
  strSqlString:=copy(strSqlString,1,length(strSqlString)-1);
  strSqlString:= strSqlString + ' from ' + TButton(sender).Name;
  strSqlString:=strSqlString + ' where ';
  //where 条件
  //for iLoop:=0 to m_lvResult.Items.Count -1 do
  //begin
    for jLoop:=0 to iRelColumnCount-1 do
    begin
    if cDataPubMain.msRelType[iIndex][jLoop]= 0 then
    begin
      strSqlString:=strSqlString + cDataPubMain.msRelField[iIndex][jLoop] + '=' + sConditonValue[jLoop] + ' and   ';
    end
    else if cDataPubMain.msRelType[iIndex][jLoop]= 1 then
    begin
      strSqlString:=strSqlString + cDataPubMain.msRelField[iIndex][jLoop] + '=''' + sConditonValue[jLoop] + ''' and   ';
    end
    else if cDataPubMain.msRelType[iIndex][jLoop]= 2 then
    begin
      if (pos('甲',sConditonValue[jLoop])<>0) or (pos('乙',sConditonValue[jLoop])<>0) or
        (pos('丙',sConditonValue[jLoop])<>0) or (pos('丁',sConditonValue[jLoop])<>0) or
        (pos('戊',sConditonValue[jLoop])<>0) then
      begin
        strSqlString:=strSqlString + cDataPubMain.msRelField[iIndex][jLoop] + ' like ''' + sConditonValue[jLoop] + '%'' and   ';
      end
      else
      begin
        strSqlString:=strSqlString + cDataPubMain.msRelField[iIndex][jLoop] + ' like ''' + sConditonValue[jLoop] + '%'' and   ';
        strSqlString:=strSqlString + cDataPubMain.msRelField[iIndex][jLoop] + ' not like ''%甲%''' + ' and   ';
        strSqlString:=strSqlString + cDataPubMain.msRelField[iIndex][jLoop] + ' not like ''%乙%''' + ' and   ';
        strSqlString:=strSqlString + cDataPubMain.msRelField[iIndex][jLoop] + ' not like ''%丙%''' + ' and   ';
        strSqlString:=strSqlString + cDataPubMain.msRelField[iIndex][jLoop] + ' not like ''%丁%''' + ' and   ';
        strSqlString:=strSqlString + cDataPubMain.msRelField[iIndex][jLoop] + ' not like ''%戊%''' + ' and   ';
      end;
    end;
    end;
    strSqlString:=copy(strSqlString,1,length(strSqlString)-6);
    //strSqlString:=strSqlString + ' or ';
  //end;
  //strSqlString:=copy(strSqlString,1,length(strSqlString)-3);
  cDataPubMain.Free;
  cDataPubRel.Free;
  with TForm_Basic.create(systemDM.Glb_BasicDataOperate,TButton(sender).Name,strSqlString,1) do
  try
    ShowModal;
  finally
    free;
  end;
end;




procedure TForm_MainBase.cb_ConditionChange(Sender: TObject);
begin
  if msArrType[cb_Condition.ItemIndex]='DATE' then
    dp_Condition.Visible:=true
  else
    dp_Condition.Visible:=false;
end;

procedure TForm_MainBase.dp_ConditionChange(Sender: TObject);
begin
  txt_Condition.Text:=DateToStr(dp_Condition.Date);
end;

end.

⌨️ 快捷键说明

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