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

📄 input.pas

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

interface

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

type
  Tfrminput = class(TForm)
    functionradio: TRadioGroup;
    dataradio: TRadioGroup;
    ListView1: TListView;
    Button1: TButton;
    Button3: TButton;
    Table1: TTable;
    BatchMove1: TBatchMove;
    OpenDialog: TOpenDialog;
    Button2: TButton;
    Table2: TTable;
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);


  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frminput: Tfrminput;

implementation

uses DM,global, Info;

{$R *.DFM}

procedure Tfrminput.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;
        table2.DatabaseName:=dbname;
        with frminput.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 := '所有台区';
        frminput.ListView1.Items.EndUpdate;
end;


procedure Tfrminput.Button1Click(Sender: TObject);

begin
        If functionradio.ItemIndex = 0 Then
            opendialog.Filter:='Text files (*.txt)|*.TXT';

        If functionradio.ItemIndex = 1 Then
            opendialog.Filter:='Text files (*.dbf)|*.dbf';


        if opendialog.Execute then
            begin
          //create dst table
            if  (dataradio.ItemIndex = 0) and (functionradio.ItemIndex = 1) Then
            begin
            if not Table1.Exists then begin
            table1.Active := False;
            table1.databasename:=extractfilepath(opendialog.filename);
            //table1.tabletype:=TTDBASE;
            table1.tabletype:=TTFOXPRO;
            table1.tablename:=extractfilename(opendialog.filename);
            //table1.CreateTable ;
            end;
            if not Table2.Exists then begin
            table2.Active := False;
            table2.databasename:=dbname;
            table2.tabletype:=TTparadox;
            table2.tablename:='dst';
            end;
            END;
            //create mtr table
            if  (dataradio.ItemIndex = 1) and (functionradio.ItemIndex = 1) Then
            begin
            if not Table1.Exists then begin
            table1.Active := False;
            table1.databasename:=extractfilepath(opendialog.filename);
            //table1.tabletype:=TTdbase;
            table1.tabletype:=TTFOXPRO;
            table1.tablename:=extractfilename(opendialog.filename);
            end;
            if not Table2.Exists then begin
            table2.Active := False;
            table2.databasename:=dbname;
            table2.tabletype:=TTparadox;
            table2.tablename:='mtr';
            end;
            END;
     //create rmt table
            if  (dataradio.ItemIndex = 2) and (functionradio.ItemIndex = 1) Then
            begin
            if not Table1.Exists then begin
       //     table1:=ttable.create(self);
            table1.Active := False;
            table1.databasename:=extractfilepath(opendialog.filename);
            //table1.tabletype:=TTDBASE;
            table1.tabletype:=TTFOXPRO;
            table1.tablename:=extractfilename(opendialog.filename);
            end;
            if not Table2.Exists then begin
       //     table1:=ttable.create(self);
            table2.Active := False;
            table2.databasename:=dbname;
            table2.tabletype:=TTparadox;
            table2.tablename:='rmt';
            end;
            END;
             if  (dataradio.ItemIndex = 0) and (functionradio.ItemIndex = 0) Then
            begin
            if not Table1.Exists then begin
     //       table1:=ttable.create(self);
            table1.Active := False;
            table1.databasename:=extractfilepath(opendialog.filename);
            table1.tabletype:=ttascii;
            table1.tablename:=extractfilename(opendialog.filename);
            end;
            if not Table2.Exists then begin
       //     table1:=ttable.create(self);
            table2.Active := False;
            table2.databasename:=dbname;
            table2.tabletype:=TTparadox;
            table2.tablename:='dst';
            end;
            END;
            //create mtr table
            if  (dataradio.ItemIndex = 1) and (functionradio.ItemIndex = 0) Then
            begin
            if not Table1.Exists then begin
     //       table1:=ttable.create(self);
            table1.Active := False;
            table1.databasename:=extractfilepath(opendialog.filename);
            table1.tabletype:=ttascii;
            table1.tablename:=extractfilename(opendialog.filename);
            end;
            if not Table2.Exists then begin
       //     table1:=ttable.create(self);
            table2.Active := False;
            table2.databasename:=dbname;
            table2.tabletype:=TTparadox;
            table2.tablename:='mtr';
            end;
            END;
     //create rmt table
            if  (dataradio.ItemIndex = 2) and (functionradio.ItemIndex = 0) Then
            begin
            if not Table1.Exists then begin
       //     table1:=ttable.create(self);
            table1.Active := False;
            table1.databasename:=extractfilepath(opendialog.filename);
            table1.tabletype:=ttascii;
            table1.tablename:=extractfilename(opendialog.filename);
            end;
            if not Table2.Exists then begin
       //     table1:=ttable.create(self);
            table2.Active := False;
            table2.databasename:=dbname;
            table2.tabletype:=TTparadox;
            table2.tablename:='rmt';
            end;
            end;
        end;
END;
procedure Tfrminput.Button2Click(Sender: TObject);
var
        tempstr,tempdno:string;
        i:integer;
        Item: tListItem;
begin
        tempdno:=ListView1.Items[ListView1.Selected.index].Caption;
        table1.Filter:= 'DNO = ' + '''' + tempdno + '''';
        table1.Active:=true;
        tempstr:=table1.fieldbyname('Rdt').asstring;
        with BatchMove1 do
        begin
                Source := table1;
                Destination := table2;
                if (dataradio.ItemIndex = 1) then
                        Mode := batappend
                else
                        mode:=batAppendUpdate;
                Execute;
                ShowMessage(IntToStr(MovedCount) + ' records copied');
        end;
        if  (dataradio.ItemIndex = 2) Then
                begin

                        DM1.TimeDB.Append;
                        DM1.TimeDB.FieldByName('DNO').AsString := tempdno;
                        DM1.TimeDB.FieldByName('RDT').AsString := tempstr;

                        DM1.TimeDB.Post;
                        DM1.TimeDB.FlushBuffers ;
                        DM1.TimeDB.Refresh ;
                end;
           for i := 0 to frmInfo.ListView1.Items.Count - 1 do
                begin
                        If frmInfo.ListView1.Items[i].SubItems.Strings[2] = tempdno then
                        begin
                                frmInfo.ListView1SelectItem(frmInfo, Item, True);
                                break;
                        end;
                end;
       
end;

procedure Tfrminput.Button3Click(Sender: TObject);
begin
    close;
end;

end.

⌨️ 快捷键说明

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