?? mxcz.pas
字號:
unit MXCZ;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls,Common, DB, ADODB;
type
TFrm_MXCZ = class(TForm)
CB_BDS: TComboBox;
CB_MXNAME: TComboBox;
Label1: TLabel;
Label2: TLabel;
BT_Sure: TButton;
BT_Cancel: TButton;
RG_ZH: TRadioGroup;
RG_AC: TRadioGroup;
ADOQuery: TADOQuery;
procedure RG_ZHClick(Sender: TObject);
procedure RG_ACClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure BT_SureClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure BT_CancelClick(Sender: TObject);
private
{ Private declarations }
function GetData(BDS_Name,MX_Name,CZ_Type:string):TKContent;
public
{ Public declarations }
end;
var
Frm_MXCZ: TFrm_MXCZ;
content:TKContent;
implementation
uses RptTable;
{$R *.dfm}
function TFrm_MXCZ.GetData(BDS_Name,MX_Name,CZ_Type:string):TKContent;
var
content:TKContent;
s,BDS_Num,MX_NUM:string;
begin
//獲變電所編號
ADOQuery.Close;
ADOQuery.SQL.Text:='select * from BDS where 變電所名稱='''+BDS_Name+'''';
ADOQuery.Open;
BDS_Num:=ADOQuery.FieldByName('變電所編號').AsString;
//獲母線編號
ADOQuery.Close;
ADOQuery.SQL.Text:='select * from MXFD where 分段名稱='''+MX_Name+'''';
ADOQuery.Open;
MX_NUM:=ADOQuery.FieldByName('分段編號').AsString;
//獲取操作內(nèi)容
ADOQuery.Close;
ADOQuery.SQL.Text:='select * from MXCZ where 變電所編號='''+BDS_Num+''' and 母線編號='''+MX_NUM+''' and 操作類型='''+CZ_Type+''' order by 序號';
ADOQuery.Open;
content.Body:=TStringList.Create;
ADOQuery.First;
while not ADOQuery.Eof do
begin
s:=trim(ADOQuery.FieldByName('操作內(nèi)容').AsString);
content.Body.Add(s);
ADOQuery.Next;
end;
ADOQuery.Close;
Result:=content;
end;
procedure TFrm_MXCZ.RG_ZHClick(Sender: TObject);
begin
RG_AC.ItemIndex:=-1;
end;
procedure TFrm_MXCZ.RG_ACClick(Sender: TObject);
begin
RG_ZH.ItemIndex:=-1;
end;
procedure TFrm_MXCZ.FormCreate(Sender: TObject);
begin
Self.ADOQuery.Connection:=Frm_Com.ADOConnection;
Self.ADOQuery.SQL.Text:='select * from BDS';
Self.ADOQuery.Open;
Frm_Com.AddCoBoItem(CB_BDS,'變電所名稱',Self.ADOQuery);//添加變電所
Self.ADOQuery.SQL.Text:='select * from MXFD';
Self.ADOQuery.Open;
Frm_Com.AddCoBoItem(CB_MXNAME,'分段名稱',Self.ADOQuery);//添加開關(guān)名
Self.ADOQuery.Close;
end;
procedure TFrm_MXCZ.BT_SureClick(Sender: TObject);
begin
//
content.Body:=TStringList.Create;
case RG_ZH.ItemIndex of
0:
begin
content.Title:=CB_BDS.Text+CB_MXNAME.Text+'母線停電';
content.Body.Add(CB_MXNAME.Text+'母線由運行轉(zhuǎn)熱備用');
content.Body.Add(CB_MXNAME.Text+'母線由熱備用轉(zhuǎn)冷備用');
content.B_Type:='ZH.ini';
end;
1:
begin
content.Title:=CB_BDS.Text+CB_MXNAME.Text+'母線送電';
content.Body.Add(CB_MXNAME.Text+'母線由冷備用轉(zhuǎn)熱備用');
content.Body.Add(CB_MXNAME.Text+'母線由熱備用轉(zhuǎn)運行');
content.B_Type:='ZH.ini';
end;
end;
case RG_AC.ItemIndex of
0:
begin
content:=GetData(CB_BDS.Text,CB_MXName.Text,'停電檢修');
content.Title:=CB_BDS.Text+CB_MXName.Text+'母線停電檢修';
content.B_Type:='AC2.ini';
end;
1:
begin
content:=GetData(CB_BDS.Text,CB_MXName.Text,'拆除安措');
content.Title:=CB_BDS.Text+CB_MXName.Text+'母線拆除安措';
content.B_Type:='AC2.ini';
end;
end;
if (RG_ZH.ItemIndex=-1) and (RG_AC.ItemIndex=-1) then//if Trim(content.B_Type)='' then
begin
showmessage('請選擇票令類型!');
exit;
end;
content.Body.Add(CB_BDS.Text);//發(fā)令單位
//-->寫入配置信息
if Frm_Com.WriteINI(content.B_Type)=false then
begin
showmessage('寫入配置信息時發(fā)生錯誤!配置文件可能丟失或損壞!');
exit;
end;
//-->創(chuàng)建報表
Self.Hide;
Frm_Com.WriteData(content);
Application.CreateForm(TFrm_Table,Frm_Table);
Frm_Table.Show;
Self.Close;
end;
procedure TFrm_MXCZ.FormShow(Sender: TObject);
begin
//初始化
Content.Title:='';
end;
procedure TFrm_MXCZ.BT_CancelClick(Sender: TObject);
begin
Close;
end;
end.
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -