procedure TForm12.Button6Click(Sender: TObject); var tempquery:Tadoquery; begin if trim(Edit6.Text)='' then begin Windows.Beep(700,200);Edit6.SetFocus;Exit;end; if Trim(Edit5.Text)<>Trim(Edit4.Text) then begin Application.MessageBox('不好意思,出错啦! 相关内容如下:'+#13+#13+'[主要信息:] 不能添加用户!'+#13+'[原因:] 用户信息不完整,新密码与新密码确认不一致!'+#13+'[解决方法:] 请重新输入新密码以及新密码确认,然后再试...','Information',MB_OK+MB_ICONINFORMATION);edit4.SetFocus;Exit;end; try with tempquery do begin tempquery:=TADOQuery.Create(nil); Connection:=dm.ADOConnection1; Close; SQL.Clear; sql.Add('insert into yhtb (yhm,yhmm,yhlx) values(:temp1,:temp2,:temp3)'); Parameters.ParamByName('temp1').Value:=Trim(Edit6.Text); if RadioButton3.Checked then Parameters.ParamByName('temp3').Value:='系统管理员'; if RadioButton4.Checked then Parameters.ParamByName('temp3').Value:='普通用户'; Parameters.ParamByName('temp2').Value:=Trim(edit4.Text); ExecSQL; Close; FreeAndNil(tempquery); Windows.Beep(900,100); DBGrid1.DataSource.DataSet.Close; DBGrid1.DataSource.DataSet.Open; end;//end with Edit6.SetFocus; Edit6.Text:=''; Edit4.Text:=''; Edit5.Text:=''; except on E: Exception do if Pos('重复键',e.Message)>0 then begin Application.MessageBox('不好意思,出错啦! 相关内容如下:'+#13+#13+'[主要信息:] 主键冲突,新建用户帐户失败!'+#13+'[原因:] 用户帐户名可能已经存在!'+#13+'[解决方法:] 请更改另一用户名,然后再试...','Information',MB_OK+MB_ICONINFORMATION); Windows.Beep(700,200); end; end;//end tryend; //////////////我以前的
var
tempquery:Tadoquery;
begin
if trim(Edit6.Text)='' then begin Windows.Beep(700,200);Edit6.SetFocus;Exit;end;
if Trim(Edit5.Text)<>Trim(Edit4.Text) then begin Application.MessageBox('不好意思,出错啦! 相关内容如下:'+#13+#13+'[主要信息:] 不能添加用户!'+#13+'[原因:] 用户信息不完整,新密码与新密码确认不一致!'+#13+'[解决方法:] 请重新输入新密码以及新密码确认,然后再试...','Information',MB_OK+MB_ICONINFORMATION);edit4.SetFocus;Exit;end;
try
with tempquery do begin
tempquery:=TADOQuery.Create(nil);
Connection:=dm.ADOConnection1;
Close;
SQL.Clear;
sql.Add('insert into yhtb (yhm,yhmm,yhlx) values(:temp1,:temp2,:temp3)');
Parameters.ParamByName('temp1').Value:=Trim(Edit6.Text);
if RadioButton3.Checked then Parameters.ParamByName('temp3').Value:='系统管理员';
if RadioButton4.Checked then Parameters.ParamByName('temp3').Value:='普通用户';
Parameters.ParamByName('temp2').Value:=Trim(edit4.Text);
ExecSQL;
Close;
FreeAndNil(tempquery);
Windows.Beep(900,100);
DBGrid1.DataSource.DataSet.Close;
DBGrid1.DataSource.DataSet.Open;
end;//end with
Edit6.SetFocus;
Edit6.Text:='';
Edit4.Text:='';
Edit5.Text:='';
except
on E: Exception do if Pos('重复键',e.Message)>0 then begin
Application.MessageBox('不好意思,出错啦! 相关内容如下:'+#13+#13+'[主要信息:] 主键冲突,新建用户帐户失败!'+#13+'[原因:] 用户帐户名可能已经存在!'+#13+'[解决方法:] 请更改另一用户名,然后再试...','Information',MB_OK+MB_ICONINFORMATION);
Windows.Beep(700,200);
end;
end;//end tryend;
//////////////我以前的