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

📄 output.pas

📁 Monitor.dfm Meter.dpr pasMain.pas
💻 PAS
字号:
unit OUTPUT;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, ExtCtrls, ComCtrls, Db, DBTables;

type
  Tfrmoutput = class(TForm)
    BTNOUTPUT: TButton;
    BTNQUIT: TButton;
    Savedialog: TSaveDialog;
    ListView1: TListView;
    dataRadio: TRadioGroup;
    functionRadio: TRadioGroup;
    Button1: TButton;
    Query1: TQuery;
    Table1: TTable;
    BatchMove1: TBatchMove;
    Label1: TLabel;
    rdt_com: TComboBox;
    procedure BTNQUITClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure BTNOUTPUTClick(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure ListView1Click(Sender: TObject);
  private
    { Private declarations }
  public
   // table1:ttable;
    { Public declarations }
  end;

var
  frmoutput: Tfrmoutput;

implementation

uses DM, Promot,global;

{$R *.DFM}

procedure Tfrmoutput.BTNQUITClick(Sender: TObject);
begin
        close;
end;

procedure Tfrmoutput.FormCreate(Sender: TObject);
var
    ListItem: TListItem;
    NewColumn: TListColumn;
    i:integer;
    const
    Names: array[0..1, 0..2] of string = (
    ('台区编号', '80', '0'),
    ('台区名称', '80', '0'));

begin
        table1.DatabaseName:=dbname;
        query1.DatabaseName:=dbname;
        with frmoutput.ListView1 do
        begin
        Items.BeginUpdate;
        Items.Clear;
        Columns.Clear;
        //Add new column
        for I := Low(Names) to High(Names) do
        begin
            NewColumn := Columns.Add;
            NewColumn.Width := StrToInt(Names[I][1]);
            NewColumn.Caption := Names[I][0];

            case StrToInt(Names[I][2]) of
            0: NewColumn.Alignment := (taLeftJustify);
            1: NewColumn.Alignment := (taCenter);
            2: NewColumn.Alignment := (taRightJustify);
            end;

        end;
    end;
    DM1.DSTdb.First;
    // listview1.Items.BeginUpdate;
    while not DM1.DSTdb.Eof do
        begin
        with ListView1 do
                begin
                ListItem := Items.add;
                ListItem.Caption := DM1.DSTdb.FieldByname('dno').AsString;
                ListItem.SubItems.add(DM1.DSTdb.FieldByname('name').AsString);
                DM1.DSTdb.Next;
                end;
        end;
        ListItem := listview1.Items.add;
        ListItem.Caption := '所有台区';
        frmoutput.ListView1.Items.EndUpdate;
end;

procedure Tfrmoutput.BTNOUTPUTClick(Sender: TObject);
begin
                with BatchMove1 do
                begin
                Source := Query1;
                Destination := Table1;
                Mode := batCopy;
                Execute;
                ShowMessage(IntToStr(MovedCount) + ' records copied');
                end;
end;
procedure Tfrmoutput.Button1Click(Sender: TObject);
begin
        If functionradio.ItemIndex = 0 Then
            savedialog.Filter:='Text files (*.txt)|*.TXT';
        If functionradio.ItemIndex = 1 Then
            savedialog.Filter:='dbf files (*.dbf)|*.dbf';
        IF listview1.SelCount =0 then
            begin
                frmPromot.Hide;
                frmPromot.Promot.Caption := '请选择导出台区?';
                if frmPromot.ShowModal <> mrOK then exit;
                exit;
            end;
        IF listview1.Items.Count  =0 then
            begin
                frmPromot.Hide;
                frmPromot.Promot.Caption := '无导出台区,请编辑?';
                if frmPromot.ShowModal <> mrOK then exit;
                exit;
            end;
        If dataradio.ItemIndex = 0 Then
            begin
            with query1 do
               begin
                        //active:=true;
                        close;
                        with sql do
                        begin
                        clear;
                        if ListView1.Selected.index=listview1.Items.Count -1 then
                           add('select * from dst ')
                        else
                            begin
                            add('select * from dst  where dno=:paramsdno');
                            parambyname('paramsdno').asstring:=ListView1.Items[ListView1.Selected.index].Caption;
                            end;
                        end;
                        open;
                end;
            end;
        If dataradio.ItemIndex = 1 Then
            begin
            with query1 do
               begin
                        //active:=true;
                        close;
                        with sql do
                        begin
                        clear;
                        if ListView1.Selected.index=listview1.Items.Count -1 then
                        add('select * from mtr ')
                        else
                                begin
                                add('select * from mtr where dno=:paramsdno');
                                parambyname('paramsdno').asstring:=ListView1.Items[ListView1.Selected.index].Caption;
                                end;
                        end;
                        open;
                end;
            end;
        If dataradio.ItemIndex = 2 Then
            begin
            with query1 do
               begin
                        //active:=true;
                        close;
                        with sql do
                        begin
                        clear;
                        if ListView1.Selected.index=listview1.Items.Count -1 then
                                add('select *  from mtr  order by mtr.dno,mtr.uno')
                        else
                                begin
                                add('select * from rmt  ');
                                add('where  rmt.dno=:paramsdno  and rmt.rdt=:paramsrdt');
                                parambyname('paramsdno').asstring:=ListView1.Items[ListView1.Selected.index].Caption;
                                parambyname('paramsrdt').asstring:=rdt_com.text;
                                end;
                        end;
                        open;
                end;
               end;

        if savedialog.Execute then
            //create dst table
            table1.Active := False;
            TAble1.databasename:=extractfilepath(savedialog.filename);

            if  functionradio.ItemIndex = 1 Then
                        table1.tabletype:=TTFOXPRO
            else
                        table1.tabletype:=ttascii;


            table1.tablename:=extractfilename(savedialog.filename);
        end;
procedure Tfrmoutput.ListView1Click(Sender: TObject);
begin
    RDT_com.Items.Clear;
    DM1.TimeDB.Filter := 'DNO = ' + '''' + ListView1.Items[ListView1.Selected.index].Caption + '''';

    if not DM1.timedb.Eof then
    begin
        DM1.TimeDB.Last ;
        RDT_com.Text := DM1.timedb.FieldByname('rdt').AsString;
    end;
    DM1.TimeDB.First;

    while not DM1.TimeDB.Eof do
    begin
        RDT_com.items.Add(DM1.TimeDB.FieldByname('RDT').AsString);
        DM1.TimeDB.Next;
    end;
end;

end.







⌨️ 快捷键说明

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