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

📄 unit_unit.pas

📁 本系统是一套专门为美容行业设计开发的智能经营管理软件
💻 PAS
字号:
unit unit_unit;

interface

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

type
  Tfrm_unit = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    edt_UnitName: TEdit;
    edt_address: TEdit;
    edt_telephone: TEdit;
    edt_fax: TEdit;
    sbtn_sure: TSpeedButton;
    SpeedButton3: TSpeedButton;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure sbtn_closeClick(Sender: TObject);
    procedure sbtn_sureClick(Sender: TObject);
    procedure FormKeyPress(Sender: TObject; var Key: Char);
  private
    { Private declarations }
  public
    procedure ref;
    { Public declarations }
  end;

var
  frm_unit: Tfrm_unit;

implementation
  uses unit_TotalPublic, Unit_DataModule;
{$R *.dfm}

procedure Tfrm_unit.ref();
begin
  with dmod.qrydata do
  begin
    Close;
    SQL.Text := 'select * from unit';
    Open;

    edt_UnitName.Text := FieldByName('UnitName').asstring;
    edt_address.Text := FieldByName('address').asstring;
    edt_telephone.Text := FieldByName('telephone').AsString;
    edt_fax.Text := FieldByName('fax').asstring;
  end;
  sbtn_sure.Enabled := GetPower(SysUserId,'单位信息','修改权'); 
end;

procedure Tfrm_unit.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  Action:=cafree;
  frm_unit:=nil;
end;

procedure Tfrm_unit.sbtn_closeClick(Sender: TObject);
begin
  close;
end;

procedure Tfrm_unit.sbtn_sureClick(Sender: TObject);
begin
  if trim(edt_UnitName.Text)='' then
  begin
    MessageBox(handle,'请输入单位名称!','提示',mb_ok+mb_iconinformation);
    edt_UnitName.SetFocus;
    exit;
  end;
  try
    dmod.Database.StartTransaction;
    with dmod.qrydata do
    begin
      Close;
      SQL.Text := 'delete from unit';
      ExecSQL;

      Close;
      SQL.Text := 'insert into unit (UnitName,address,telephone,fax)'+
                  ' values '+
                  '(:UnitName,:address,:telephone,:fax)';
      ParamByName('UnitName').asstring:=trim(edt_UnitName.text);
      ParamByName('address').asstring:=trim(edt_address.text);
      ParamByName('telephone').asstring:=trim(edt_telephone.text);
      ParamByName('fax').asstring:=trim(edt_fax.text);
      ExecSQL;
    end;
  finally
    try
      dmod.Database.Commit;
      Close;
    except
      dmod.Database.Rollback;
      MessageBox(handle,'操作失败,请重试!','提示',mb_ok+mb_iconinformation);
      edt_UnitName.SetFocus;
    end;
  end;
end;

procedure Tfrm_unit.FormKeyPress(Sender: TObject; var Key: Char);
var
  temp,temp1:boolean;
begin
  temp:=false;
  temp1:=true;
  if key=#13 then
  begin
    temp:=true;
    if (ActiveControl is TEdit) then
    if TEdit(ActiveControl).name ='edt_fax' then temp1:=false;
  end;
  if temp then
  begin
    if temp1 then
    begin
      key:=#0;
      perform(WM_NEXTDLGCTL,0,0);
    end else sbtn_sureclick(nil);
  end;
end;

end.

⌨️ 快捷键说明

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