📄 uform_use_select.~pas
字号:
unit Uform_use_select;
//显示用户列表以供选择
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, ComCtrls, ExtCtrls, ImgList, DB, ADODB;
type
Tform_use_select = class(TForm)
Panel1: TPanel;
Image1: TImage;
Label2: TLabel;
Label4: TLabel;
Label3: TLabel;
Label1: TLabel;
Bevel1: TBevel;
Image2: TImage;
Panel2: TPanel;
Apart_list: TListView;
Panel3: TPanel;
Panel4: TPanel;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
recordset_temp: TADOQuery;
ImageList1: TImageList;
procedure FormShow(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
intCount:integer;
yesno:bool;
userid:integer;
usercode:string;
end;
var
form_use_select: Tform_use_select;
implementation
{$R *.dfm}
procedure Tform_use_select.FormShow(Sender: TObject);
//初始化窗口
var
i:integer;
ListItem: TListItem;
p:^integer;
begin
//从数据库中查询所有客户的数据
apart_list.Items.Clear ;
recordset_temp.SQL.Clear ;
recordset_temp.SQL.Add (
'select [CUSTOM_ID],[CUSTOM_CODE],[CUSTOM_MNAME],[CUSTOM_FNAME],[CUSTOM_TEL],[AREA_NAME],[CUSTOM_ADD],[FROM_NAME],[CUSTOM_POST],[CUSTOM_DATE] ' +
'from [CUSTOM],[AREA],[FROM] '+
'where [CUSTOM_AREA]=[AREA_ID] and [CUSTOM_FROM]=[FROM_ID]');
recordset_temp.Open ;
intCount:=recordset_temp.RecordCount ;
Label4.Caption :=inttostr(intCount) + '名';
//将客户数据逐个添加进客户列表
for i:=1 to recordset_temp.RecordCount do
begin
listitem:=apart_LIST.Items.Add ;
listitem.Caption :=recordset_temp.Fields[1].AsString ;
listitem.ImageIndex :=0;
listitem.SubItems.Add(recordset_temp.Fields[2].asstring);
listitem.SubItems.Add(recordset_temp.Fields[3].asstring);
listitem.SubItems.Add(recordset_temp.Fields[4].asstring);
listitem.SubItems.Add(recordset_temp.Fields[5].asstring);
listitem.SubItems.Add(recordset_temp.Fields[6].asstring);
listitem.SubItems.Add(recordset_temp.Fields[7].asstring);
listitem.SubItems.Add(recordset_temp.Fields[8].asstring);
listitem.SubItems.Add(DateTimeToStr(recordset_temp.Fields[9].AsDateTime));
new(p);
p^ := recordset_temp.Fields[0].AsInteger ;
listitem.Data :=p;
recordset_temp.Next;
end;
//设置标志变量
yesno:=false;
end;
procedure Tform_use_select.BitBtn2Click(Sender: TObject);
//关闭窗口
begin
close;
end;
procedure Tform_use_select.BitBtn1Click(Sender: TObject);
//选定客户
var
p:^integer;
begin
//是否选中了某客户
if apart_list.Selected =nil then exit;
//在数据库中查找该用户
p:=Apart_list.Selected.Data;
userid:=p^;
recordset_temp.SQL.Clear ;
recordset_temp.SQL.Add ('select * from [CUSTOM] where [CUSTOM_ID]=' + inttostr(p^));
recordset_temp.Open ;
//确认用户存在
if recordset_temp.RecordCount <>0 then
begin
usercode:=recordset_temp.Fields[1].AsString ;
recordset_temp.Close;
yesno:=true;
close;
end;
recordset_temp.close ;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -