unit7.pas

来自「这是一个关于delphi数据库方面的源程序」· PAS 代码 · 共 65 行

PAS
65
字号
unit Unit7;



interface



uses

  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

  Dialogs, StdCtrls, DBCtrls, DBTables, DB;



type

  TFormFChPwd = class(TForm)

    Table1: TTable;

    DataSource1: TDataSource;

    Query1: TQuery;

    DBLookupComboBox1: TDBLookupComboBox;

    Label1: TLabel;

    Label2: TLabel;

    Label3: TLabel;

    Edit2: TEdit;

    Edit1: TEdit;

    Button1: TButton;

    procedure Button1Click(Sender: TObject);

  private

    { Private declarations }

  public

    { Public declarations }

  end;



var

  FormFChPwd: TFormFChPwd;



implementation



{$R *.dfm}



procedure TFormFChPwd.Button1Click(Sender: TObject);

var

  id:string;

begin

  if DBLookupComboBox1.Text='' then

  begin

    ShowMessage('请选择学生');

    Exit;

  end;

  id := Table1.Lookup('姓名',DBLookupComboBox1.Text,'学号');

  if Edit1.Text <> Edit2.Text then

  begin

    ShowMessage('两个密码不相同');

    Exit;

  end

  else

  begin

    Query1.SQL.Text := 'Update 密码.db set 密码="' + Edit1.Text

                        + '" where 学号="'+ id +'"';

    Query1.ExecSQL;

    Query1.Close;

    ShowMessage('修改成功!');

    Edit1.Text :='';

    Edit2.Text :='';

    FormFChPwd.Close;

  end;



end;



end.

⌨️ 快捷键说明

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