Delphi中如何实现ComboBox中出现的记录是不重复的
我先做了一个信息录入的界面,在其中有查询录入信息的功能,就是有一个RadioButton选择按什么条件查询,一个ComboBox在已经录入的信息中选择查询条件,但是这个C...
我先做了一个信息录入的界面,在其中有查询录入信息的功能,就是有一个RadioButton选择按什么条件查询,一个ComboBox在已经录入的信息中选择查询条件,但是这个ComboBox出现的记录总是重复,不知道怎么改?
把代码贴上来
procedure Tchaxun_dcxx.FormShow(Sender: TObject);
begin
ComboBox1.Clear;
ComboBox2.Clear;
ComboBox3.Clear;
ComboBox4.Clear;
ComboBox5.Clear;
ComboBox6.Clear;
ComboBox7.Clear;
with DataModule3.ADO_dcxx do
begin
close;
sql.Clear;
sql.Add('select * from 调查信息表');
open;
end;
if DataModule3.ADO_dcxx.RecordCount>0 then
begin
while not DataModule3.ADO_dcxx.Eof do
begin
ComboBox1.Items.Add(Trim(DataModule3.ADO_dcxx.fieldbyname('调查信息编号').AsString));
ComboBox2.Items.Add(Trim(DataModule3.ADO_dcxx.fieldbyname('被调查对象').AsString));
ComboBox3.Items.Add(Trim(DataModule3.ADO_dcxx.fieldbyname('客户编号').AsString));
ComboBox4.Items.Add(Trim(DataModule3.ADO_dcxx.fieldbyname('联系人编号').AsString));
ComboBox5.Items.Add(Trim(DataModule3.ADO_dcxx.fieldbyname('客户满意度').AsString));
ComboBox6.Items.Add(Trim(DataModule3.ADO_dcxx.fieldbyname('业务员').AsString));
ComboBox7.Items.Add(Trim(DataModule3.ADO_dcxx.fieldbyname('调查信息名称').AsString));
DataModule3.ADO_dcxx.Next;
end;
DataModule3.ADO_dcxx.First;
end;
end;
procedure Tchaxun_dcxx.Button1Click(Sender: TObject);
begin
if(not RadioButton1.Checked) and (not RadioButton2.Checked)
and(not RadioButton3.Checked) and (not RadioButton4.Checked)
and (not RadioButton5.Checked)
and(not RadioButton6.Checked) and (not RadioButton7.Checked)
then messagedlg('您还没有选择查询方式',mtwarning,[mbOk],0);
begin
with DataModule3.ADO_dcxx do
begin
close;
with sql do
begin
sql.Clear;
sql.Add('select * from 调查信息表 where');
if RadioButton1.Checked then
ADD('调查信息编号='+quotedstr(ComboBox1.Text));
if RadioButton2.Checked then
ADD('被调查对象='+quotedstr(ComboBox2.Text));
if RadioButton3.Checked then
ADD('客户编号='+quotedstr(ComboBox3.Text));
if RadioButton4.Checked then
ADD('联系人编号='+quotedstr(ComboBox4.Text));
if RadioButton5.Checked then
ADD('客户满意度='+quotedstr(ComboBox5.Text));
if RadioButton6.Checked then
ADD('业务员='+quotedstr(ComboBox6.Text));
if RadioButton7.Checked then
ADD('调查信息名称='+quotedstr(ComboBox7.Text));
end;
open;
DataModule3.ADO_dcxx.Active:=true;
end;
if DataModule3.ADO_dcxx.Eof then showmessage('对不起,未找到您所需的记录');
end;
end;
procedure Tchaxun_dcxx.Button2Click(Sender: TObject);
begin
chaxun_dcxx.Close;
end; 展开
把代码贴上来
procedure Tchaxun_dcxx.FormShow(Sender: TObject);
begin
ComboBox1.Clear;
ComboBox2.Clear;
ComboBox3.Clear;
ComboBox4.Clear;
ComboBox5.Clear;
ComboBox6.Clear;
ComboBox7.Clear;
with DataModule3.ADO_dcxx do
begin
close;
sql.Clear;
sql.Add('select * from 调查信息表');
open;
end;
if DataModule3.ADO_dcxx.RecordCount>0 then
begin
while not DataModule3.ADO_dcxx.Eof do
begin
ComboBox1.Items.Add(Trim(DataModule3.ADO_dcxx.fieldbyname('调查信息编号').AsString));
ComboBox2.Items.Add(Trim(DataModule3.ADO_dcxx.fieldbyname('被调查对象').AsString));
ComboBox3.Items.Add(Trim(DataModule3.ADO_dcxx.fieldbyname('客户编号').AsString));
ComboBox4.Items.Add(Trim(DataModule3.ADO_dcxx.fieldbyname('联系人编号').AsString));
ComboBox5.Items.Add(Trim(DataModule3.ADO_dcxx.fieldbyname('客户满意度').AsString));
ComboBox6.Items.Add(Trim(DataModule3.ADO_dcxx.fieldbyname('业务员').AsString));
ComboBox7.Items.Add(Trim(DataModule3.ADO_dcxx.fieldbyname('调查信息名称').AsString));
DataModule3.ADO_dcxx.Next;
end;
DataModule3.ADO_dcxx.First;
end;
end;
procedure Tchaxun_dcxx.Button1Click(Sender: TObject);
begin
if(not RadioButton1.Checked) and (not RadioButton2.Checked)
and(not RadioButton3.Checked) and (not RadioButton4.Checked)
and (not RadioButton5.Checked)
and(not RadioButton6.Checked) and (not RadioButton7.Checked)
then messagedlg('您还没有选择查询方式',mtwarning,[mbOk],0);
begin
with DataModule3.ADO_dcxx do
begin
close;
with sql do
begin
sql.Clear;
sql.Add('select * from 调查信息表 where');
if RadioButton1.Checked then
ADD('调查信息编号='+quotedstr(ComboBox1.Text));
if RadioButton2.Checked then
ADD('被调查对象='+quotedstr(ComboBox2.Text));
if RadioButton3.Checked then
ADD('客户编号='+quotedstr(ComboBox3.Text));
if RadioButton4.Checked then
ADD('联系人编号='+quotedstr(ComboBox4.Text));
if RadioButton5.Checked then
ADD('客户满意度='+quotedstr(ComboBox5.Text));
if RadioButton6.Checked then
ADD('业务员='+quotedstr(ComboBox6.Text));
if RadioButton7.Checked then
ADD('调查信息名称='+quotedstr(ComboBox7.Text));
end;
open;
DataModule3.ADO_dcxx.Active:=true;
end;
if DataModule3.ADO_dcxx.Eof then showmessage('对不起,未找到您所需的记录');
end;
end;
procedure Tchaxun_dcxx.Button2Click(Sender: TObject);
begin
chaxun_dcxx.Close;
end; 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询