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

📄 frmycconfig.pas

📁 delphi语言开发的矢量图形处理对象
💻 PAS
字号:
unit frmYcConfig;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ComCtrls, dbisamtb, DB, ExtCtrls,DrwBaseType;

type
  TfrmYc_Config = class(TForm)
    GroupBox1: TGroupBox;
    Edit1: TEdit;
    UpDown1: TUpDown;
    CheckBox1: TCheckBox;
    GroupBox2: TGroupBox;
    edtNum: TEdit;
    Label1: TLabel;
    cboYc: TComboBox;
    Label2: TLabel;
    Button1: TButton;
    Button2: TButton;
    DBISAMQuery1: TDBISAMQuery;
    DBISAMDatabase1: TDBISAMDatabase;
    RadioGroup1: TRadioGroup;
    GroupBox3: TGroupBox;
    cboDataType: TComboBox;
    Label3: TLabel;
    Label4: TLabel;
    cboTime: TComboBox;
    Label5: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    procedure edtNumChange(Sender: TObject);
    procedure edtNumKeyPress(Sender: TObject; var Key: Char);
    procedure FormCreate(Sender: TObject);
    procedure cboYcClick(Sender: TObject);
    procedure cboDataTypeClick(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
    procedure initYcData;
  public
    { Public declarations }
    cur_Param:TYcData;
    procedure initParam(curParam:TYcData);
  end;

var
  frmYc_Config: TfrmYc_Config;

implementation
uses
  StrUtils;
{$R *.dfm}

procedure TfrmYc_Config.edtNumChange(Sender: TObject);
var
  yc_code,iPos:integer;
begin
  if trim(edtNum.Text)='' then exit;
  yc_Code:=strToint(edtNum.Text);
  iPos:=cboYc.Items.IndexOfObject(Pointer(yc_code));
  if iPos>=0 then
  begin
    cboYc.ItemIndex :=iPos;
  end;
end;

procedure TfrmYc_Config.edtNumKeyPress(Sender: TObject; var Key: Char);
begin
  if not (key in ['0'..'9',#8]) then
  key:=#0;
end;

procedure TfrmYc_Config.initYcData;
var
  dataBasePath:string;
begin
  dataBasePath:=ExtractFilePath(Application.ExeName)+'data';
  DBISAMDatabase1.Directory :=dataBasePath;
  cboYc.Clear;
  try
    DbisamDatabase1.Open;
    with DbisamQuery1 do
    begin
      SQL.Clear;
      SQL.Add('Select * from Yc_Define Order By Gather_Code');
      Open;
      while not Eof do
      begin
        cboYc.Items.AddObject(FieldByName('Name').AsString,
        pointer(FieldByName('Gather_Code').AsInteger));
        Next;
      end;
      Close;
    end;
  finally
    DbisamDatabase1.Close;
  end;
end;

procedure TfrmYc_Config.FormCreate(Sender: TObject);
begin
  initYcData;
end;

procedure TfrmYc_Config.cboYcClick(Sender: TObject);
var
  ycNum:integer;
begin
  if cboYc.ItemIndex <0 then
  exit;
  ycNum:=longint(cboYc.Items.Objects[cboYc.ItemIndex]);
  edtNum.Text :=intTostr(ycNum);
end;

procedure TfrmYc_Config.cboDataTypeClick(Sender: TObject);
var
  i:integer;
begin
  if cboDataType.ItemIndex <0 then exit;
  case cboDataType.ItemIndex of
    0:cboTime.Enabled :=false;
    1:begin
        cboTime.Enabled :=true;
        cboTime.Clear;
        for i:=1 to 24 do
        cboTime.Items.Add(intTostr(i));
        cboTime.ItemIndex :=0;
        label6.Caption :='小时';
      end;
    2:begin
        cboTime.Enabled :=true;
        cboTime.Clear;
        for i:=1 to 31 do
        cboTime.Items.Add(intTostr(i));
        cboTime.ItemIndex :=0;
        label6.Caption :='天';
      end;
    3:begin
        cboTime.Enabled :=true;
        cboTime.Clear;
        for i:=1 to 12 do
        cboTime.Items.Add(intTostr(i));
        cboTime.ItemIndex :=0;
        label6.Caption :='月';
      end;
  end;
end;

procedure TfrmYc_Config.initParam(curParam: TYcData);
begin
  cur_Param:=curParam;
  UpDown1.Position :=curParam.DataNum;
  edtNum.Text :=intTostr(curParam.gatherCode);
  CheckBox1.Checked :=curParam.isAbs;
  RadioGroup1.ItemIndex :=curParam.dataFormat -1;
  //数据类型信息设置
  cboDataType.ItemIndex :=curParam.dataType -1;
  cboDataType.OnClick(nil);
  if curParam.dataType >1 then
  cboTime.ItemIndex :=curParam.dataTime -1;
end;

procedure TfrmYc_Config.Button1Click(Sender: TObject);
begin
  cur_Param.DataNum :=UpDown1.Position;
  if edtNum.Text <>'' then
    cur_Param.gatherCode :=strToint(frmYc_Config.edtNum.Text)
  else
    cur_Param.gatherCode :=0;
  cur_Param.Name :=cboYc.Text;
  cur_Param.isAbs :=CheckBox1.Checked;
  cur_Param.dataFormat :=RadioGroup1.ItemIndex +1;
  case radioGroup1.ItemIndex of
    0:cur_Param.Value :=strTofloat(dupestring('9',cur_Param.DataNum)+'.99');
    1:cur_Param.Value :=strTofloat(dupestring('9',cur_Param.DataNum));
    2:cur_Param.Value :=1.0;
  end;
  cur_Param.dataType :=cboDataType.ItemIndex +1;
  if cboDataType.ItemIndex<=0 then
     cur_Param.dataTime :=0
  else
     cur_Param.dataTime :=strToint(cboTime.Items.Strings[cboTime.itemIndex]);
end;

end.

⌨️ 快捷键说明

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