u_add_custom.~pas

来自「以多个信息系统为例」· ~PAS 代码 · 共 82 行

~PAS
82
字号
unit u_add_custom;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, ExtCtrls, ExtDlgs;

type
  TF_add_custom = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    i_id_type: TListBox;
    Label3: TLabel;
    i_sex: TRadioGroup;
    i_name: TEdit;
    i_id_copy: TImage;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    i_from: TEdit;
    i_id: TEdit;
    i_addr: TMemo;
    i_remark: TMemo;
    B_add: TButton;
    OpenPictureDialog1: TOpenPictureDialog;
    procedure i_idChange(Sender: TObject);
    procedure i_id_copyDblClick(Sender: TObject);
    procedure B_addClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
  private
    { Private declarations }
  public
    procedure SetID(ID:String);
  end;

var
  F_add_custom: TF_add_custom;

implementation

uses u_data;
{$R *.DFM}

procedure TF_add_custom.SetID(ID:String);
begin
  i_id.Text:=ID;
end;

procedure TF_add_custom.i_idChange(Sender: TObject);
begin
  if not B_add.Enabled then B_add.Enabled:=True;
end;

procedure TF_add_custom.i_id_copyDblClick(Sender: TObject);
begin
  if OpenPictureDialog1.Execute then
    i_id_copy.Picture.LoadFromFile(OpenPictureDialog1.FileName);
end;

procedure TF_add_custom.B_addClick(Sender: TObject);
var
  IDType,Sex:String;
begin
  IDType:=IntToStr(i_id_type.ItemIndex);
  if i_sex.ItemIndex=0 then
    Sex:='M'
  else
    Sex:='F';
  DM_main.AddCustom(i_id.Text, IDType, i_name.Text, Sex,
    i_from.Text, i_addr.Text, i_remark.Text, OpenPictureDialog1.FileName);
end;

procedure TF_add_custom.FormShow(Sender: TObject);
begin
  DM_main.GetIDType(i_id_type.Items);
  i_id_type.ItemIndex:=0;
end;

end.

⌨️ 快捷键说明

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