?? personselect.~pas
字號:
unit personselect;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Buttons, StdCtrls, ComCtrls,GlobalUnit,adodb;
type
TFrmPersonSel = class(TForm)
ListView1: TListView;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
ListView2: TListView;
Label1: TLabel;
Label2: TLabel;
procedure BitBtn2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure ListView1CustomDrawItem(Sender: TCustomListView;
Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);
private
{ Private declarations }
public
{ Public declarations }
end;
var
FrmPersonSel: TFrmPersonSel;
implementation
{$R *.dfm}
procedure TFrmPersonSel.BitBtn2Click(Sender: TObject);
begin
close;
end;
procedure TFrmPersonSel.Button1Click(Sender: TObject);
var
Item: TListItem;
Item2: TListItem;
begin
Item:= ListView1.Selected;
if (Item<>nil) then
begin
Item2:=ListView2.Items.Add;
Item2.Caption:=Item.Caption;
Item2.SubItems.Add(Item.SubItems[0]);
Item.Delete;
end;
end;
procedure TFrmPersonSel.Button2Click(Sender: TObject);
var
Item: TListItem;
Item2: TListItem;
begin
Item2:= ListView2.Selected;
if (Item2<>nil) then
begin
Item:=ListView1.Items.Add;
Item.Caption:=Item2.Caption;
Item.SubItems.Add(Item2.SubItems[0]);
Item2.Delete;
end;
end;
procedure TFrmPersonSel.Button3Click(Sender: TObject);
var
Item: TListItem;
Item2: TListItem;
begin
Item := ListView1.Selected;
while Item <> nil do
begin
Item2:=ListView2.Items.Add;
Item2.Caption:=Item.Caption;
Item2.SubItems.Add(Item.SubItems[0]);
Item := ListView1.GetNextItem(Item, sdAll, [isSelected]);
end;
while ListView1.Selected<>nil do
ListView1.Selected.Delete;
end;
procedure TFrmPersonSel.Button4Click(Sender: TObject);
var
Item: TListItem;
Item2: TListItem;
begin
Item := ListView2.Selected;
while Item <> nil do
begin
Item2:=ListView1.Items.Add;
Item2.Caption:=Item.Caption;
Item2.SubItems.Add(Item.SubItems[0]);
Item := ListView2.GetNextItem(Item, sdAll, [isSelected]);
end;
while ListView2.Selected<>nil do
ListView2.Selected.Delete;
end;
procedure TFrmPersonSel.BitBtn1Click(Sender: TObject);
var
qrTemp:TAdoQuery;
ListItem: TListItem;
i:integer;
userid:string;
username:string;
strSQL:string;
begin
strSQL:='delete from ent_operater where iindex='+inttostr(iindex)+' and step='+inttostr(OpenFlag)+' and status=0';
qrTemp:=TAdoQuery.Create(nil);
qrTemp.Connection :=G_ADOConnection;
qrTemp.SQL.Clear;
qrTemp.SQL.Text:=strSQL;
try
qrTemp.ExecSQL;
except
ShowMessage('刪除不成功!');
end;
for i:=0 to ListView2.Items.Count-1 do
begin
userid:=ListView2.Items[i].Caption;
username:=ListView2.Items[i].SubItems[0];
strSQL:='insert into ent_operater(unit_id,iindex,user_id,step,status) values('+inttostr(g_unit_id)+','+inttostr(iindex)+','''+userid+''','+inttostr(OpenFlag)+',0)';
qrTemp.SQL.Clear;
qrTemp.SQL.Text:=strSQL;
try
qrTemp.ExecSQL;
except
ShowMessage('用戶操作不成功!');
close;
end;
end;
close;
end;
procedure TFrmPersonSel.FormShow(Sender: TObject);
var
qrTemp:TAdoQuery;
ListItem: TListItem;
i:integer;
begin
ListView2.Items.Clear;
ListView1.Items.Clear;
//////////////////////////////////////////////// 填listview1
qrTemp:=TAdoQuery.Create(nil);
qrTemp.Connection :=G_ADOConnection;
qrTemp.SQL.Text:='select * from ent_person where user_id not in(select user_id from ent_operater where iindex='+inttostr(iindex)+' and step='+inttostr(OpenFlag)+')';
qrTemp.Open;
if qrTemp.RecordCount>0 then
begin
qrTemp.First;
for i:=0 to qrTemp.RecordCount-1 do
begin
ListItem:=ListView1.Items.Add;
try
ListItem.Caption:=qrTemp.fieldbyname('user_id').AsString;
ListItem.SubItems.Add(qrTemp.fieldbyname('name').AsString);
qrTemp.Next;
except
qrTemp.Close;//
exit;
end;
end;
end;
//////////////////////////////////////// 填listview2
qrTemp.Close;
qrTemp.SQL.Clear;
qrTemp.SQL.Text:='select a.user_id,b.name from ent_operater a,ent_person b where a.iindex='+inttostr(iindex)+' and a.step='+inttostr(OpenFlag)+' and a.user_id=b.user_id and a.status=0';
// ShowMessage(qrTemp.SQL.Text);
qrTemp.Open;
if qrTemp.RecordCount>0 then
begin
qrTemp.First;
for i:=0 to qrTemp.RecordCount-1 do
begin
ListItem:=ListView2.Items.Add;
try
ListItem.Caption:=qrTemp.fieldbyname('user_id').AsString;
ListItem.SubItems.Add(qrTemp.fieldbyname('name').AsString);
qrTemp.Next;
except
qrTemp.Close;//
exit;
end;
end;
end;
//////////////////////////////////
end;
procedure TFrmPersonSel.ListView1CustomDrawItem(Sender: TCustomListView;
Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);
begin
//if Item.Selected then
//Sender.Canvas.Brush.Color := clRed;
end;
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -