Depart_RoleFrm_Button5_Click
'===============================取得机构ID===========================
Dim DID As Integer '机构ID
Dim cmd As new sqlcommand
Dim dt As DataTable
Dim txt As winform.textbox=e.Form.controls("textbox1")
cmd.c
cmd.commandtext="select * from {TDepart}"
dt=cmd.executereader()
Dim dr As DataRow=dt.find("[FullName]="& txt.value &"")
DID=dr("ID")
'=============================添加机构角色=================================
Dim RID As Integer '角色ID
Dim STR As String '机构角色
Dim cmd1 As new sqlcommand '连接角色表
Dim cmd2 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="inser into {TDepart_Roles} ([DepartID],[RoleID],[Remark],[CreaterID],[CreateTime]) Values('"& DID &"','"& Rid &"','"& STR &"','"& CurrentUserID &"','"& date.today() &"')"
dt1=cmd1.executereader()
For i As Integer =0 To lstR.items.count-1
Dim dr1 As DataRow=dt1.find("[name]="& lstR.items(i) &"")
RID=dr1("ID")
STR=TXT.value & "\" & lstR.items(i)
lstDR.items.add(STR)
Next
[此贴子已经被作者于2011-5-10 21:11:55编辑过]