📄 xldz.pas
字号:
unit XLDZ;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, DB, ADODB;
type
TFrm_XLDZ = class(TForm)
CB_XLFZ: TComboBox;
ListBox1: TListBox;
ListBox2: TListBox;
ED_Name: TEdit;
Label1: TLabel;
RG_CZ: TRadioGroup;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
BT_Sure: TButton;
BT_Cancel: TButton;
ADOQuery: TADOQuery;
ListBox3: TListBox;
Label5: TLabel;
Label6: TLabel;
procedure FormCreate(Sender: TObject);
procedure CB_XLFZChange(Sender: TObject);
procedure ListBox1Click(Sender: TObject);
procedure ListBox2Click(Sender: TObject);
procedure ListBox3Click(Sender: TObject);
procedure BT_SureClick(Sender: TObject);
procedure BT_CancelClick(Sender: TObject);
private
{ Private declarations }
procedure AddListBox(ListBox:TListBox;FileName:string);
public
{ Public declarations }
end;
var
Frm_XLDZ: TFrm_XLDZ;
implementation
uses Common,RptTable;
{$R *.dfm}
procedure TFrm_XLDZ.AddListBox(ListBox:TListBox;FileName:string);
var
s:string;
begin
//
ListBox.Clear;
Self.ADOQuery.First;
while not ADOQuery.Eof do
begin
s:=ADOQuery.FieldByName(FileName).AsString;
ListBox.Items.Add(S);
ADOQuery.Next;
end;
end;
procedure TFrm_XLDZ.FormCreate(Sender: TObject);
begin
Self.ADOQuery.Connection:=Frm_Com.ADOConnection;
Self.ADOQuery.SQL.Text:='select * from ZFX order by 总分线编号';
Self.ADOQuery.Open;
Frm_Com.AddCoBoItem(CB_XLFZ,'总分线名称',Self.ADOQuery);//添加变电所
Self.ADOQuery.Close;
CB_XLFZChange(Sender);
end;
procedure TFrm_XLDZ.CB_XLFZChange(Sender: TObject);
begin
ListBox2.Clear;
ListBox3.Clear;
case CB_XLFZ.ItemIndex of
0..2: //排线
begin
Label3.Caption:='区域选择:';
Label4.Caption:='排线名称:';
Label5.Caption:='';
ADOQuery.SQL.Text:='Select * from QY';
ADOquery.Open;
AddListBox(ListBox1,'区域名称');
ADOQuery.Close;
end ;
3://变电所出线
begin
Label3.Caption:='变电所名称:';
Label4.Caption:='开关名称:';
Label5.Caption:='开关编号:';
ADOQuery.SQL.Text:='select * from BDS';
ADOquery.Open;
AddListBox(ListBox1,'变电所名称');
ADOQuery.Close;
end ;
4://变电所母线
begin
Label3.Caption:='变电所名称:';
Label4.Caption:='母线选择:';
Label5.Caption:='';
ADOQuery.SQL.Text:='select * from BDS';
ADOquery.Open;
AddListBox(ListBox1,'变电所名称');
ADOQuery.Close;
end;
5://分支线路
begin
Label3.Caption:='线路名称:';
Label4.Caption:='';
Label5.Caption:='';
ADOQuery.SQL.Text:='select * from FZXL';
ADOquery.Open;
AddListBox(ListBox1,'分线名称');
ADOQuery.Close;
end;
end;
end;
procedure TFrm_XLDZ.ListBox1Click(Sender: TObject);
var
BDS_Num,QNUM,FXNUM:String;//变电所编号,区域编号,分线编号
begin
ListBox3.Clear;
ED_Name.Text:='';
case CB_XLFZ.ItemIndex of
0..2:
begin
FXNUM:='0'+inttostr(CB_XLFZ.ItemIndex+1);
ADOQuery.SQL.Text:='select * from QY where 区域名称='''+ListBox1.Items[ListBox1.ItemIndex]+'''';
AdoQuery.Open;
QNUM:=ADOQuery.FieldByName('区域编号').AsString;
ADOQuery.SQL.Text:='Select * from PXL where 区域编号='''+QNUM+''' and 分线编号='''+FXNUM+'''';
ADOQuery.Open;
AddListBox(ListBox2,'排线名称');
ADOQuery.Close;
end;
3://变电所出线
begin
ADOQuery.SQL.Text:='select * from BDS where 变电所名称='''+ListBox1.Items[ListBox1.ItemIndex]+'''';
ADOQuery.Open;
BDS_NUM:=ADOQuery.FieldByName('变电所编号').AsString;
ADOQuery.SQL.Text:='select 开关名称,开关编号 from KG where 变电所编号='''+BDS_Num+'''';
ADOQuery.Open;
AddListBox(ListBox2,'开关名称');
AddListBox(ListBox3,'开关编号');
ADOQuery.Close;
end;
4://变电所母线
begin
ADOQuery.SQL.Text:='select * from MXFD';
ADOQuery.Open;
AddListBox(ListBox2,'分段名称');
ADOQuery.Close;
end;
5:// 分支线路
begin
ED_Name.Text:=ListBox1.Items[ListBox1.ItemIndex];
end;
end;
end;
procedure TFrm_XLDZ.ListBox2Click(Sender: TObject);
begin
case CB_XLFZ.ItemIndex of
0..2://排线
begin
ED_Name.Text:=ListBox2.Items[ListBox2.ItemIndex];
end;
3://变电所出线
begin
if ListBox3.Items.Count>ListBox2.ItemIndex then
begin
ListBox3.ItemIndex:=ListBox2.ItemIndex;
ED_Name.Text:=ListBox1.Items[ListBox1.ItemIndex]+ListBox2.Items[ListBox2.ItemIndex]+ListBox3.Items[ListBox3.ItemIndex];
end;
end;
4://变电所母线
begin
ED_Name.Text:=ListBox1.Items[ListBox1.ItemIndex]+ListBox2.Items[ListBox2.ItemIndex]+'母线';
end;
end;
end;
procedure TFrm_XLDZ.ListBox3Click(Sender: TObject);
begin
if CB_XLFZ.ItemIndex=3 then//变电所出线
begin
if ListBox2.Items.Count>ListBox3.ItemIndex then
begin
ListBox2.ItemIndex:=ListBox3.ItemIndex;
ED_Name.Text:=ListBox1.Items[ListBox1.ItemIndex]+ListBox2.Items[ListBox2.ItemIndex]+ListBox3.Items[ListBox3.ItemIndex];
end;
end;
end;
procedure TFrm_XLDZ.BT_SureClick(Sender: TObject);
begin
if RG_CZ.ItemIndex<0 then
begin
showmessage('请选择操作!');
exit;
end
else
begin
content.Title:=ED_Name.Text+RG_CZ.Items[RG_CZ.ItemIndex];
Content.B_Type:='XLDZ.ini';
content.Body:=TStringList.Create;
Frm_Com.WriteData(content);
end;
if Frm_Com.WriteINI(content.B_Type)=false then
begin
showmessage('写入配置信息时发生错误!配置文件可能丢失或损坏!');
exit;
end;
//-->创建报表
if trim(ED_Name.Text)='' then
begin
Showmessage('请选择线路称称!');
end
else
begin
//
Frm_Com.WriteData(content);
Application.CreateForm(TFrm_Table,Frm_Table);
Self.Close;
Frm_Table.Show;
end;
end;
procedure TFrm_XLDZ.BT_CancelClick(Sender: TObject);
begin
Close;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -