procedure TLoginForm.BitBtn1Click(Sender: TObject);
var
password,username:string;
begin
username:=combobox1.Text; // 用户名
password:=edit1.Text; //密码
inc(itimes);
if combobox1.Items.Count>0 then
begin
combobox1.ItemIndex:=0;
with datamd.ADOManage do
begin
// 当用户名与密码正确并且输入次数少于三次时就登录成功
if locate('用户名',username,[lopartialkey]) and locate('密码',password,[lopartialkey]) and (itimes<4) then
begin
close;
sql.Clear;
sql.Add('select * from manage where 用户名='''+username+''''+' and 密码='''+password+'''');
open;
application.CreateForm(TmainForm,mainform);
mainform.StatusBar1.Panels.Items[1].Text:=username;
mainform.StatusBar1.Panels.Items[3].Text:=fieldbyname('权限').AsString;
if fieldbyname('权限').AsString='操作员' then
begin
with mainform do
begin
roomsetitem.Enabled:=false;
roommanageitem.Enabled:=false;
edwitem.Enabled:=false;
Mdfyitem.Enabled:=false;
adduitem.Enabled:=false;
epitem.Enabled:=false;
end
end;
loginform.Hide;
loginform.Free;
mainform.ShowModal;
mainform.Free;
end
else
begin
if MessageDlg('密码密码,请重新输入',mtConfirmation, [mbYes, mbNo],0)=mrYes then
begin
edit1.Clear;
edit1.SetFocus;
end
else
close;
end;
if itimes>3 then
begin
showmessage('很抱歉。你没有权力使用本系统');
application.Terminate;
end;
end;
end
else
showmessage('数据库没有用户名');
end;谁能帮我解释上面的句子呢?
特别是 with.......do ..那句
还有application.CreateForm(TmainForm,mainform);
locate 这两句,上面那句为什么要建立呢?不要行吗?最好能介解释清楚点OK
var
password,username:string;
begin
username:=combobox1.Text; // 用户名
password:=edit1.Text; //密码
inc(itimes);
if combobox1.Items.Count>0 then
begin
combobox1.ItemIndex:=0;
with datamd.ADOManage do
begin
// 当用户名与密码正确并且输入次数少于三次时就登录成功
if locate('用户名',username,[lopartialkey]) and locate('密码',password,[lopartialkey]) and (itimes<4) then
begin
close;
sql.Clear;
sql.Add('select * from manage where 用户名='''+username+''''+' and 密码='''+password+'''');
open;
application.CreateForm(TmainForm,mainform);
mainform.StatusBar1.Panels.Items[1].Text:=username;
mainform.StatusBar1.Panels.Items[3].Text:=fieldbyname('权限').AsString;
if fieldbyname('权限').AsString='操作员' then
begin
with mainform do
begin
roomsetitem.Enabled:=false;
roommanageitem.Enabled:=false;
edwitem.Enabled:=false;
Mdfyitem.Enabled:=false;
adduitem.Enabled:=false;
epitem.Enabled:=false;
end
end;
loginform.Hide;
loginform.Free;
mainform.ShowModal;
mainform.Free;
end
else
begin
if MessageDlg('密码密码,请重新输入',mtConfirmation, [mbYes, mbNo],0)=mrYes then
begin
edit1.Clear;
edit1.SetFocus;
end
else
close;
end;
if itimes>3 then
begin
showmessage('很抱歉。你没有权力使用本系统');
application.Terminate;
end;
end;
end
else
showmessage('数据库没有用户名');
end;谁能帮我解释上面的句子呢?
特别是 with.......do ..那句
还有application.CreateForm(TmainForm,mainform);
locate 这两句,上面那句为什么要建立呢?不要行吗?最好能介解释清楚点OK
解决方案 »
- 急急急,能人帮满
- DELPHI写的软件到时间自动运行问题
- 关于dbgrid显示数据问题请教
- 我用DLL创建的MDICHILD,如何在该MDICHILD关闭的时候释放掉DLL呢 ?
- 关于ClientDataSet数据集过滤问题,大家请进?
- 数据查找问题。
- 向高手请教DELPHI中中文件绑定
- 请教:资料输入窗口,控件应该以一种什么样的方式同数据库对应表相关联?
- 给大家介绍一个下载delphi源代码和图书的地方
- 能否用程序来实现对数码相机的控制,如果可以该怎样做?
- 多層系統中數據更新沖tu(有人修改過正在保存的記錄),,怎 樣處理clientdataset reconcileError事件﹐怎樣根據Errorcode翻譯Error Massag
- 进行了安全设置的access数据库文件.mdb(创建了*.mdw),如何用ado控件连接?
begin
end;
这个里边包含的所有东西也就是with do 中间所写的对象名的方法或属性
例如
with edit1 do
begin
text:='aaa';
enable:=false;application.CreateForm(TmainForm,mainform); 这个问题很好解释
其实就是和创建一个MainForm的对象是一样的
application.createform(Tmainform,mainform) 和这种写法类似
mainform:=Tmainform.create(application);
至于详细的说明 找本基础的书里都有
end;
和这个相等
edit1.text:='aaa';
edit1.enable:=false;
上面的写法是为了看起来更方便 节约代码.
begin
end;
这个里边包含的所有东西也就是with do 中间所写的对象名的方法或属性
例如
with edit1 do
begin
text:='aaa';
enable:=false;
end;
和这个相等
edit1.text:='aaa';
edit1.enable:=false;
上面的写法是为了看起来更方便 节约代码.
application.CreateForm(TmainForm,mainform); 这个问题很好解释
其实就是和创建一个MainForm的对象是一样的
application.createform(Tmainform,mainform) 和这种写法类似
mainform:=Tmainform.create(application);
至于详细的说明 找本基础的书里都有
你们只的基础的书是那些呢?因为我找了一些都没有解决那些是怎么样用的,能介绍几本吗?
我是一个刚刚接触delphid什么都不懂
obj.data1 := 1;
obj.dataw :=2;即可改为with obj do begin
data1 := 1;
data2 := 2;
end
2.application.CreateForm(TmainForm,mainform);作用:应用程序自己建立窗口,可以不用,在用的时候自己建立就可以了。
Var
mainForm: TmainForm;
begin
mainForm := TmainForm.Create(nil);
end;
3.locate是用来将cursor定位到数据集中的符合条件的记录,三个参数'用户名',username,[lopartialkey]的意思分别是,字段名, 字段值,一个查询约束(针对字符串类型的字段)帮助上有,多看帮助!