📄 frm_basic.pas
字号:
unit frm_Basic;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, Base_Panel,cls_DataPub, StdCtrls, Buttons, Base_BitBtn,
Base_Edit, Base_ComboBox, Base_StaticText,Base_LabeledEdit,cls_BaseClass,
ComCtrls,MapXLib_TLB,Base_ListView;
type
TForm_Basic = class(TForm)
pan_Container: TBase_Panel;
pan_Relation: TBase_Panel;
Base_StaticText1: TBase_StaticText;
cb_RelateSource: TBase_ComboBox;
bbtn_Show: TBase_BitBtn;
Base_Panel4: TBase_Panel;
pan_Add: TBase_Panel;
bbtn_Add: TBase_BitBtn;
bbtn_Save: TBase_BitBtn;
bbtn_Locate: TBase_BitBtn;
bbtn_Close1: TBase_BitBtn;
pan_SelectCondition: TBase_Panel;
bbtn_Select: TBase_BitBtn;
Base_BitBtn1: TBase_BitBtn;
pan_select: TBase_Panel;
bbtn_Edit: TBase_BitBtn;
bbtn_Delete: TBase_BitBtn;
Base_BitBtn4: TBase_BitBtn;
pan_Loacate: TBase_Panel;
btn_Locate: TBase_BitBtn;
procedure FormCreate(Sender: TObject);
procedure bbtn_UpdateClick(Sender: TObject);
procedure bbtn_DeleteClick(Sender: TObject);
procedure bbtn_ShowClick(Sender: TObject);
procedure bbtn_AddClick(Sender: TObject);
procedure bbtn_SaveClick(Sender: TObject);
procedure bbtn_Close1Click(Sender: TObject);
procedure bbtn_SelectClick(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure btn_LocateClick(Sender: TObject);
private
{ Private declarations }
msSql:string;
msTableName:string;
mDataOperate:TDataOperate;
miState:integer; // 0:添加 1:查询;2:嵌套表添加;3:生成查询条件窗体;4:生成不包含ListView的修改窗体
msFieldName:TStringList;
mAttribute:TListView;
mMap:TMap;
mspaceTableName:string;
mVisible:integer;
public
{ Public declarations }
cDataPub:TDataPub;
constructor create(DataOperate:TDataOperate;sTableName:string;sSql:string;iState:integer);reintroduce;overload;
constructor create(DataOperate:TdataOperate;sTableName:string;sSql:string;iState:integer;sFieldName:TStringList);reintroduce;overload;//嵌套表添加时的构造函数;需要传入主键字段名
constructor create(DataOperate:TDataOperate;sTableName:string;sSql:string;iState:integer;lv_Attribute:TListView);reintroduce;overload;
constructor create(DataOperate:TDataOperate;sTableName:string;sSql:string;iState:integer;aspaceTableName:string;aMap:TMap;iVisible:integer);reintroduce;overload;
end;
var
Form_Basic: TForm_Basic;
implementation
uses frmSystemDM;
{$R *.dfm}
constructor TForm_Basic.create(DataOperate:TDataOperate;sTableName:string;sSql:string;iState:integer);
begin
inherited create(Application);
mDataOperate:=DataOperate;
msTableName:=sTableName;
msSql:=sSql;
miState:=iState;
end;
constructor TForm_Basic.create(DataOperate:TdataOperate;sTableName:string;sSql:string;iState:integer;sFieldName:TStringList);
begin
inherited create(Application);
mDataOperate:=DataOperate;
msTableName:=sTableName;
msSql:=sSql;
miState:=iState;
msFieldName:=sFieldName;
end;
constructor TForm_Basic.create(DataOperate:TDataOperate;sTableName:string;sSql:string;iState:integer;lv_Attribute:TListView);
begin
inherited create(Application);
mDataOperate:=DataOperate;
msTableName:=sTableName;
msSql:=sSql;
miState:=iState;
mAttribute:=lv_Attribute;
end;
constructor TForm_Basic.create(DataOperate:TDataOperate;sTableName:string;sSql:string;iState:integer;aspaceTableName:string;aMap:TMap;ivisible:integer);
begin
inherited create(Application);
mDataOperate:=DataOperate;
msTableName:=sTableName;
msSql:=sSql;
miState:=iState;
mMap:=aMap;
mspaceTableName:=aspaceTableName;
mVisible:=iVisible;
end;
procedure TForm_Basic.FormCreate(Sender: TObject);
begin
if miState<>4 then
cDataPub:=TDataPub.create(mDataOperate,msTableName,self,pan_Container,cb_RelateSource,miState,msSql,msFieldName)
else
cDataPub:=TDataPub.create(mDataOperate,msTableName,self,pan_Container,miState,mAttribute);
if (miState=0) or (miState=2) then
pan_Add.Visible:=true
else if (miState=1) or (mistate=4) then
pan_Select.Visible:=true
else If miState =3 then
pan_SelectCondition.Visible:=true;
if (miState=1) or (miState=2) then
pan_Relation.Visible:=false;
if mVisible=1 then
pan_Loacate.Visible:=true;
end;
procedure TForm_Basic.bbtn_UpdateClick(Sender: TObject);
begin
cDataPub.blnUpdateRecord;
end;
procedure TForm_Basic.bbtn_DeleteClick(Sender: TObject);
begin
cDataPub.blnDeleteRecord;
end;
procedure TForm_Basic.bbtn_ShowClick(Sender: TObject);
var
iLoop:integer;
iIndex:integer;
begin
if cDataPub.lv_Temp.SelCount= 0 then
begin
Application.MessageBox('请选择关联资源!','提示',MB_OK + MB_ICONINFORMATION);
exit;
end;
for iLoop:= 0 to cDataPub.lv_Temp.Items.Count -1 do
begin
if cDataPub.lv_Temp.Items[iLoop].Selected=true then
iIndex:=iLoop;
end;
msTableName:=cb_RelateSource.itemsvalue[cb_RelateSource.ItemIndex];
msSql:='select * from ' + cb_RelateSource.itemsvalue[cb_RelateSource.ItemIndex] + ' where ';
for iLoop:=0 to cDataPub.lv_Temp.Columns.Count -1 do
begin
if (cDataPub.miArrColumnPri[iLoop]= 1) and (cDataPub.msArrColumnType[iLoop]='VARCHAR2') then
msSql:= msSql + cDataPub.msArrRelColNames[cb_RelateSource.ItemIndex][iLoop] + '=''' + cDataPub.msArrRelColData[cb_RelateSource.ItemIndex][iLoop] + ''' and '
else if (cDataPub.miArrColumnPri[iLoop]= 1) and (cDataPub.msArrColumnType[iLoop]='NUMBER') then
msSql:= msSql + cDataPub.msArrRelColNames[cb_RelateSource.ItemIndex][iLoop] + '=' + cDataPub.msArrRelColData[cb_RelateSource.ItemIndex][iLoop] + ' and ';
end;
msSql:=copy(msSql,1,length(msSql)- 6);
with TForm_Basic.Create(mDataOperate,msTableName,msSql,1) do
try
ShowModal;
finally
free;
end;
end;
procedure TForm_Basic.bbtn_AddClick(Sender: TObject);
var
iLoop:integer;
begin
for iLoop:=0 to pan_Container.ControlCount -1 do
begin
if pan_Container.Controls[iLoop] is TBase_BitBtn then
pan_Container.Controls[iLoop].Enabled:=false
else if pan_Container.Controls[iLoop] is TBase_LabeledEdit then
TBase_LabeledEdit(pan_Container.Controls[iLoop]).Text:='';
end;
bbtn_Save.Enabled:=True;
end;
procedure TForm_Basic.bbtn_SaveClick(Sender: TObject);
var
iLoop:integer;
begin
cDataPub.blnAddRecord;
for iLoop:=0 to pan_Container.ControlCount -1 do
begin
if pan_Container.Controls[iLoop] is TBase_BitBtn then
pan_Container.Controls[iLoop].Enabled:=True;
end;
bbtn_Save.Enabled:=False;
end;
procedure TForm_Basic.bbtn_Close1Click(Sender: TObject);
begin
self.Close;
end;
procedure TForm_Basic.bbtn_SelectClick(Sender: TObject);
var
SelectSql:string;
tempSql:string;
tempCdataPub:TDataPub;
begin
tempCdataPub:=TDataPub.create(mDataOperate,msTableName);
SelectSql:=tempCdataPub.sFormSelectSql;
tempSql:=cDataPub.sFormWhereSql;
tempSql:=SelectSql + tempSql;
tempCdataPub.Free;
With TForm_Basic.create(systemDM.Glb_BasicDataOperate,msTableName,tempSql,1,mspaceTableName,mMap,1) do
begin
try
ShowModal;
finally
free;
end;
end;
self.Close;
end;
procedure TForm_Basic.FormClose(Sender: TObject; var Action: TCloseAction);
begin
cDataPub.Free;
end;
procedure TForm_Basic.btn_LocateClick(Sender: TObject);
var
TableInfo:pTable;
strSql:string;
ftrs:Features;
tempList:TBase_ListView;
iLoop:integer;
tempvalue:string;
begin
for iLoop:=0 to pan_Container.ComponentCount-1 do
begin
if pan_Container.Components[iLoop] is Tbase_ListView then
begin
tempList:=TBase_ListView(pan_Container.Components[iLoop]);
break;
end;
end;
if tempList.SelCount=0 then
begin
Application.MessageBox('请选择记录!','提示',MB_OK + MB_ICONINFORMATION);
exit;
end;
TableInfo:=tempList.Selected.Data;
if (mspaceTableName='CASE_S') or (mspaceTableName='DOORPLATE_S') or (mspaceTableName='POLICEHOUSE_S') then
begin
if mspaceTableName='POLICEHOUSE_S' then
tempvalue:=inttostr(strtoint(TableInfo^.DataValue[0])-1200+1)
else
tempvalue:= TableInfo^.DataValue[0];
strSql:='FEATUREID=' + tempvalue;
ftrs:=mMap.Layers[mspaceTableName].Search(strSql,EmptyParam);
if ftrs.Count<>0 then
begin
mMap.Layers[mspaceTableName].Selection.ClearSelection;
mMap.Layers[mspaceTableName].Selection.Add(ftrs[1]);
mMap.CenterX:=ftrs[1].CenterX;
mMap.CenterY:=ftrs[1].CenterY;
end;
end
else if (mspaceTableName='StayPopu') or (mspaceTableName='PermanentPopu') then
begin
end;
self.Close;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -