-- 作者:huntkey
-- 发布时间:2011/5/13 21:31:00
--
\'=============================添加机构角色=================================
Dim RID As Integer \'角色ID
Dim STR As String \'机构角色
Dim cmd1 As new sqlcommand \'连接角色表
Dim cmd2 As new sqlcommand \'连接机构_角色表
Dim cmd3 As new sqlcommand \'连接机构_角色表
Dim dt1 As DataTable
Dim lstR As winform.Listbox=e.Form.controls("listbox1") \'已选角色列表
Dim lstDR As winform.Listbox=e.Form.controls("listbox2") \'预览
cmd1.c
cmd2.c
cmd1.commandtext="select * from {TRole}"
cmd2.commandtext="insert {TDepart_Roles} ([DepartID],[RoleID],[Remark],[CreaterID],[CreateTime]) Values(\'"& DID &"\',\'"& RID &"\',\'"& STR &"\',\'"& CurrentUserID &"\',\'"& date.today() &"\')"
dt1=cmd1.executereader()
cmd3.c
cmd3.commandtext="select * from {TDepart_Roles} where [Remark]=\'"& STR &"\'"
For i As Integer =0 To lstR.items.count-1
Dim dr1 As DataRow=dt1.find("[name]=\'"& lstR.items(i).trim() &"\'")
RID=dr1("ID")
STR=TXT.value.trim() & "\\" & lstR.items(i)
lstDR.items.add(STR)
If cmd3.executenonquery()=1 Then
Messagebox.show(""& STR &"已存在!","提示")
Exit For
ElseIf cmd2.executenonquery()=0 Then
messagebox.show("添加失败!","提示")
goto h
End If
Next
If messagebox.show("添加成功!","提示") Then
txt.value=""
lstR.items.clear
End If
h:
[此贴子已经被作者于2011-5-13 21:31:52编辑过]
|