unit Unit8;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DB, ADODB;
type
TForm8 = class(TForm)
Label1: TLabel;
CheckBox1: TCheckBox;
Label2: TLabel;
CheckBox2: TCheckBox;
Label3: TLabel;
CheckBox3: TCheckBox;
CheckBox4: TCheckBox;
Label4: TLabel;
Label5: TLabel;
CheckBox5: TCheckBox;
Label6: TLabel;
CheckBox6: TCheckBox;
Label7: TLabel;
CheckBox7: TCheckBox;
Label8: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Edit4: TEdit;
Edit5: TEdit;
Edit6: TEdit;
Edit7: TEdit;
Label9: TLabel;
Label10: TLabel;
Edit8: TEdit;
Label11: TLabel;
Edit9: TEdit;
Label12: TLabel;
Edit10: TEdit;
Label13: TLabel;
Label14: TLabel;
Label15: TLabel;
Label16: TLabel;
Label17: TLabel;
Edit11: TEdit;
Edit12: TEdit;
Edit13: TEdit;
Edit14: TEdit;
Edit15: TEdit;
Button1: TButton;
Button2: TButton;
Edit3: TEdit;
procedure Formactivate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form8: TForm8;
implementation
uses Unit1
{$R *.dfm}
procedure TForm8.Formactivate(Sender: TObject);
begin
form1.adoquery1.Close;
form1.adoquery1.SQL.Clear;
form1.adoquery1.SQL.Add('select * from 学生表 where 学号=:sno');
form1.ADOQUERY1.Parameters.ParamValues['sno']:=form1.edit1.text;
form1.adoquery1.Open;
EDIT9.TEXT:=form1.ADOQuery1.FieldValues['姓名'];
EDIT8.TEXT:=form1.ADOQuery1.FieldValues['学号'];
EDIT11.TEXT:=form1.ADOQuery1.FieldValues['性别'];
EDIT12.TEXT:=form1.ADOQuery1.FieldValues['学院'];
EDIT13.TEXT:=form1.ADOQuery1.FieldValues['专业'];
EDIT14.TEXT:=form1.ADOQuery1.FieldValues['年级'];
EDIT15.TEXT:=form1.ADOQuery1.FieldValues['班级'];
end;
procedure TForm8.Button1Click(Sender: TObject);
var s_name,s_sex,s_age,s_add,s_xueyuan,s_zhuanye,s_nianji,s_banji,sql,sno:string;
begin
s_name:=EDIT9.TEXT;
s_sex:=EDIT11.TEXT;
s_age:=EDIT10.TEXT;
s_xueyuan:=EDIT12.TEXT;
s_zhuanye:=EDIT13.TEXT;
s_nianji:=EDIT14.TEXT;
s_banji:=EDIT15.TEXT;
s_add:=EDIT11.TEXT;
sno:=form1.edit2.text;
if checkbox1.checked then //判断所选中的项目,并更改其值;
s_name:= trim(EDIT1.TEXT) ;
if checkbox3.checked then
s_sex:= EDIT3.TEXT ;
if checkbox2.checked then
s_age:= EDIT2.TEXT ;
if checkbox4.checked then
s_xueyuan:= EDIT4.TEXT ;
if checkbox5.checked then
s_zhuanye:= EDIT5.TEXT ;
if checkbox6.checked then
s_nianji:= EDIT6.TEXT ;
if checkbox7.checked then
s_banji:= EDIT7.TEXT ;
if MessageDlg('你确定要修改此项吗?',mtConfirmation,[mbYes, mbNo], 0)=mrYes then
begin
sql := 'update 学生表 set 姓名='''+s_name+''',性别='''+s_sex+''',年龄='''+s_age+''',学院='''+s_xueyuan+''',专业='''+s_zhuanye+''',年级='''+s_nianji+''',班级='''+s_banji+''' where 学号='''+sno+'''';
form1.adoQuery1.Close;
form1.adoQuery1.SQL.Clear;
form1.adoQuery1.SQL.Add(sql);
form1.adoQuery1.ExecSQL;
showmessage('恭喜你! 指定项目信息已经更改~') ;
end
else showmessage('你选择不修改此项!请继续其他操作');
end; //if 语句
procedure TForm8.Button2Click(Sender: TObject);
begin
form8.Close;
end;
end.
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DB, ADODB;
type
TForm8 = class(TForm)
Label1: TLabel;
CheckBox1: TCheckBox;
Label2: TLabel;
CheckBox2: TCheckBox;
Label3: TLabel;
CheckBox3: TCheckBox;
CheckBox4: TCheckBox;
Label4: TLabel;
Label5: TLabel;
CheckBox5: TCheckBox;
Label6: TLabel;
CheckBox6: TCheckBox;
Label7: TLabel;
CheckBox7: TCheckBox;
Label8: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Edit4: TEdit;
Edit5: TEdit;
Edit6: TEdit;
Edit7: TEdit;
Label9: TLabel;
Label10: TLabel;
Edit8: TEdit;
Label11: TLabel;
Edit9: TEdit;
Label12: TLabel;
Edit10: TEdit;
Label13: TLabel;
Label14: TLabel;
Label15: TLabel;
Label16: TLabel;
Label17: TLabel;
Edit11: TEdit;
Edit12: TEdit;
Edit13: TEdit;
Edit14: TEdit;
Edit15: TEdit;
Button1: TButton;
Button2: TButton;
Edit3: TEdit;
procedure Formactivate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form8: TForm8;
implementation
uses Unit1
{$R *.dfm}
procedure TForm8.Formactivate(Sender: TObject);
begin
form1.adoquery1.Close;
form1.adoquery1.SQL.Clear;
form1.adoquery1.SQL.Add('select * from 学生表 where 学号=:sno');
form1.ADOQUERY1.Parameters.ParamValues['sno']:=form1.edit1.text;
form1.adoquery1.Open;
EDIT9.TEXT:=form1.ADOQuery1.FieldValues['姓名'];
EDIT8.TEXT:=form1.ADOQuery1.FieldValues['学号'];
EDIT11.TEXT:=form1.ADOQuery1.FieldValues['性别'];
EDIT12.TEXT:=form1.ADOQuery1.FieldValues['学院'];
EDIT13.TEXT:=form1.ADOQuery1.FieldValues['专业'];
EDIT14.TEXT:=form1.ADOQuery1.FieldValues['年级'];
EDIT15.TEXT:=form1.ADOQuery1.FieldValues['班级'];
end;
procedure TForm8.Button1Click(Sender: TObject);
var s_name,s_sex,s_age,s_add,s_xueyuan,s_zhuanye,s_nianji,s_banji,sql,sno:string;
begin
s_name:=EDIT9.TEXT;
s_sex:=EDIT11.TEXT;
s_age:=EDIT10.TEXT;
s_xueyuan:=EDIT12.TEXT;
s_zhuanye:=EDIT13.TEXT;
s_nianji:=EDIT14.TEXT;
s_banji:=EDIT15.TEXT;
s_add:=EDIT11.TEXT;
sno:=form1.edit2.text;
if checkbox1.checked then //判断所选中的项目,并更改其值;
s_name:= trim(EDIT1.TEXT) ;
if checkbox3.checked then
s_sex:= EDIT3.TEXT ;
if checkbox2.checked then
s_age:= EDIT2.TEXT ;
if checkbox4.checked then
s_xueyuan:= EDIT4.TEXT ;
if checkbox5.checked then
s_zhuanye:= EDIT5.TEXT ;
if checkbox6.checked then
s_nianji:= EDIT6.TEXT ;
if checkbox7.checked then
s_banji:= EDIT7.TEXT ;
if MessageDlg('你确定要修改此项吗?',mtConfirmation,[mbYes, mbNo], 0)=mrYes then
begin
sql := 'update 学生表 set 姓名='''+s_name+''',性别='''+s_sex+''',年龄='''+s_age+''',学院='''+s_xueyuan+''',专业='''+s_zhuanye+''',年级='''+s_nianji+''',班级='''+s_banji+''' where 学号='''+sno+'''';
form1.adoQuery1.Close;
form1.adoQuery1.SQL.Clear;
form1.adoQuery1.SQL.Add(sql);
form1.adoQuery1.ExecSQL;
showmessage('恭喜你! 指定项目信息已经更改~') ;
end
else showmessage('你选择不修改此项!请继续其他操作');
end; //if 语句
procedure TForm8.Button2Click(Sender: TObject);
begin
form8.Close;
end;
end.