dkgl.pas

来自「企业安防管理系统」· PAS 代码 · 共 72 行

PAS
72
字号
unit dkgl;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons, ExtCtrls, jpeg;

type
  TForm22 = class(TForm)
    Panel1: TPanel;
    Label1: TLabel;
    ComboBox1: TComboBox;
    BitBtn1: TBitBtn;
    Image1: TImage;
    procedure BitBtn1Click(Sender: TObject);
   private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form22: TForm22;
implementation
  uses DataModal,Main;
{$R *.dfm}

procedure TForm22.BitBtn1Click(Sender: TObject);
begin
  if Trim(ComboBox1.Text)<>'' then
  begin
    with Data.ADOQuery1 do
    begin
      Close;
      SQL.Clear;
      SQL.Add('select * from 端口表');
      Open;
    end;
    Try
      Form1.MSComm1.PortOpen := False;
      Form1.MSComm1.CommPort := ComboBox1.ItemIndex+1;
      Form1.MSComm1.PortOpen:= True;
      if Data.ADOQuery1.RecordCount>0 then
      begin
        Data.ADOQuery1.Edit;
        Data.ADOQuery1.Fields[0].Value := IntToStr(ComboBox1.ItemIndex+1);
        Data.ADOQuery1.Post;
      end
      else
      begin
        with Data.ADOQuery1 do
        begin
          Close;
          SQL.Clear;
          SQL.Add('insert 端口表 values(:a)');
          Parameters.ParamByName('a').Value := IntToStr(ComboBox1.ItemIndex+1);
          ExecSQL;
        end;
      end;
      Application.MessageBox('设置成功.','提示',64);
    Except
      Form1.MSComm1.CommPort := 1;
      Form1.MSComm1.PortOpen:= True;
      Application.MessageBox('系统出错.','提示',64);
    end;
  end;
end;

end.

⌨️ 快捷键说明

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