1、我要判定密码输入三次错误,系统自动退出;
我实现密码判定的代码为:
if user='admin' and pass='sys' then
//主窗体打开
else
messagebox('密码错误,请重新输入')
要怎么才能判定三次错误退出系统登录呢?
2、我用combobox显示商品名称,我单击combobox中的商品名称就将该商品名称的相关的信息添加到memo中,将现在的商品的价格加到一起赋给edit。
我现在已经在combobox的change事件中写了如下的代码判定
if pos(combobox1.text+';' , memo1.text)=0 then
memo1.text := memo1.text + combobox1.Text + ';'
else
Application.MessageBox('数据已经存在!','信息提示!',MB_Iconinformation);
所加数据是否重复,combobox中的值是从属性里面直接加如的,也到是能够实现但是,我要用下面的代码:
var
s:String;
I:Integer;
begin
with Table1 do
for I:=0 to RecordCount-1 do
begin
s:=Table1['Name'];
ComboBox1.Items.Add(s);
Table1.Next;
end;
end;
将combobox的值从表当中追加进去,所要的功能就不能实现了(不能判定是否已经添加过),现在麻烦你帮我看看我应该怎么做呢?将table中的name(商品名称添加到combobox),单击combobox中的值就将该名称对应的信息显示在memo中,将选中的商品名称的价格累加赋给edit?
3、我想在关闭窗体之前判定append或者是EDIT、INSERT状态的数据是否已经保存,如果保存过就关闭,没有出现提示信息。请问我应该怎么做呢?4、我添加了一条记录进行保存,我在保存的时候判定数据是否已经存在,请问我应该怎么做呢?
我实现密码判定的代码为:
if user='admin' and pass='sys' then
//主窗体打开
else
messagebox('密码错误,请重新输入')
要怎么才能判定三次错误退出系统登录呢?
2、我用combobox显示商品名称,我单击combobox中的商品名称就将该商品名称的相关的信息添加到memo中,将现在的商品的价格加到一起赋给edit。
我现在已经在combobox的change事件中写了如下的代码判定
if pos(combobox1.text+';' , memo1.text)=0 then
memo1.text := memo1.text + combobox1.Text + ';'
else
Application.MessageBox('数据已经存在!','信息提示!',MB_Iconinformation);
所加数据是否重复,combobox中的值是从属性里面直接加如的,也到是能够实现但是,我要用下面的代码:
var
s:String;
I:Integer;
begin
with Table1 do
for I:=0 to RecordCount-1 do
begin
s:=Table1['Name'];
ComboBox1.Items.Add(s);
Table1.Next;
end;
end;
将combobox的值从表当中追加进去,所要的功能就不能实现了(不能判定是否已经添加过),现在麻烦你帮我看看我应该怎么做呢?将table中的name(商品名称添加到combobox),单击combobox中的值就将该名称对应的信息显示在memo中,将选中的商品名称的价格累加赋给edit?
3、我想在关闭窗体之前判定append或者是EDIT、INSERT状态的数据是否已经保存,如果保存过就关闭,没有出现提示信息。请问我应该怎么做呢?4、我添加了一条记录进行保存,我在保存的时候判定数据是否已经存在,请问我应该怎么做呢?
解决方案 »
- dbf 表导入/导出 Excel
- 菜鸟问题:delphi 启用word 为何启用不了?急!
- 如何根据数据库动态创建tabsheet
- delphi数据库实时更新的问题
- 不同表查询结果综合
- 动态生成了五个button,怎么知道那一个被单击了? 它们分别执行不同的代码!!
- 求助:关于stringgrid的问题
- 需要大家解决的TDBgrid问题
- help!为什么在access表中的一个小数位大于4位的数据用ado连接后在dbgrid、dbedit上只能显示四位,该如何决解?
- 在delphi中如何更改数据库字段的定义?
- 用过AVPhone的请进
- 如何把一个listview的subtiems的值符值给另一个listview的subtiems,谢谢
if user='admin' and pass='sys' then
//主窗体打开
else
begin
inc(i);
if i<3 then
messagebox('密码错误,请重新输入')
else
Application.Terminate;
2、写个循环,for i:=0 to combobmex1.items.count-1 取每一项的值,判断是否添加过。
3、if ds.state in [dsEdit, dsInsert] then
begin
showmessage('数据还没有保存,请保存后退出');
exit;
end;
4、按照主键,取以前的数据判断是否已经存在。
var i:integer=0;
if user='admin' and pass='sys' then
//主窗体打开
else
begin
inc(i);
if i<3 then
messagebox('密码错误,请重新输入')
else
Application.Terminate;
end;
cs:integer;
.
.if user='admin' and pass='sys' then
//主窗体打开
else
begin
cs:=cs+1;
if cs>=3 then
begin
showmessage("已经输入3次,系统退出!");
application.terminate;
end;
messagebox('密码错误,请重新输入')
end;
showmessage("该记录已经存在");
用一个变量比如i:integer;
只要输入错误就增加1 i:=0;
while i<=3 do
begin
if user='admin' and pass='sys' then
//主窗体打开
else
begin
messagebox('密码错误,请重新输入')
i:=i+1;
end;
end;
if i=4 then
beginend;第二个问题:
没有仔细看,不过建议你不要用ComboBox.Text;
用ComboBox.Items[i]
2
SQL语句:
Select Distinct [Name] From mytable
3if (Query1.State<>dsInsert) and (Query1.State<>dsEdit) and (Query1.State<>dsAppend) then
Application.Terminate;
4用SQL
select * From mytable where field1=:a and field2=:b and ...
parambyname('a').asstring:=a;
...
Active:=True;
if Query1.RecordCount=0 then
Query1.AppendRecord([a,b,...]);
不过这些问题有这么关键吗?能影响到你日后的路怎么走的问题good luck
procedure Tfrmlogin.Button1Click(Sender: TObject);
begin
with table1 do
begin setkey;
fieldbyname('name').asstring:=edit1.text;
if gotokey then
if edit2.text=fieldbyname('pass').asstring then
begin
frmlogin.close; if fieldbyname('a1').asstring='是' then
frmmain.N11.visible:=true
else
frmmain.N11.visible:=false;
if fieldbyname('b1').asstring='是' then
frmmain.N111.visible:=true
else
frmmain.N111.visible:=false;
if fieldbyname('c1').asstring='是' then
frmmain.N21.visible:=true
else
frmmain.N21.visible:=false;
if fieldbyname('c11').asstring='是' then
frmmain.N31.visible:=true
else
frmmain.N31.visible:=false;
end
else
begin
showmessage('密码错误,请重新输入!');
edit2.text:='';
edit2.SetFocus();
end
else
begin
showmessage('该用户不存在,请确认!');
edit1.text:='';
edit2.text:='';
edit1.SetFocus();
end
endend;