hfqx.pas

来自「学生管理系统小鸟做了」· PAS 代码 · 共 72 行

PAS
72
字号
unit hfqx;

interface

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

type
  Tfmhfqx = class(TForm)
    DBGrid1: TDBGrid;
    Label1: TLabel;
    Edit1: TEdit;
    Button1: TButton;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  fmhfqx: Tfmhfqx;

implementation

uses dm;

{$R *.dfm}

procedure Tfmhfqx.Button1Click(Sender: TObject);
begin
fmdm.qryhfqx.Close;
fmdm.qryhfqx.SQL.Clear;
fmdm.qryhfqx.SQL.Add('update tab_stu set stu_usertype=:A where stu_id=:S');
fmdm.qryhfqx.Parameters.ParamByName('A').Value:=strtoint('1');
fmdm.qryhfqx.Parameters.ParamByName('S').Value:=edit1.Text;
    try
      fmdm.qryhfqx.ExecSQL;
      MessageDlg('操作成功!', mtInformation, [mbYes],0);
    except
      MessageDlg('操作失败!', mtInformation, [mbYes],0);
    end;
fmdm.qryhfqx.Close;
fmdm.qryhfqx.SQL.Clear;
fmdm.qryhfqx.SQL.Add('select * from tab_stu');
fmdm.qryhfqx.Open;
end;

procedure Tfmhfqx.Button2Click(Sender: TObject);
begin
fmdm.qryhfqx.Close;
fmdm.qryhfqx.SQL.Clear;
fmdm.qryhfqx.SQL.Add('update tab_stu set stu_usertype=:A where stu_id=:S');
fmdm.qryhfqx.Parameters.ParamByName('A').Value:=strtoint('0');
fmdm.qryhfqx.Parameters.ParamByName('S').Value:=edit1.Text;
    try
      fmdm.qryhfqx.ExecSQL;
      MessageDlg('操作成功!', mtInformation, [mbYes],0);
    except
      MessageDlg('操作失败!', mtInformation, [mbYes],0);
    end;
fmdm.qryhfqx.Close;
fmdm.qryhfqx.SQL.Clear;
fmdm.qryhfqx.SQL.Add('select * from tab_stu');
fmdm.qryhfqx.Open;
end;

end.

⌨️ 快捷键说明

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