Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Private Sub AddUpdateOrg(ByVal OrganizationName As String, ByVal Action As String, Optional ByVal Target As Integer = Nothing)
- ' ###############################################################
- ' # ADD OR UPDATE AN ORGANIZATION #
- ' # ============================================================#
- ' # PARAMETERS #
- ' # ---------- #
- ' # OrganizationName As String #
- ' # The organization name that is to be stored in the database. #
- ' # #
- ' # Action As String #
- ' # What action will be taken by this procedure, add or update. #
- ' # #
- ' # Optional Target As Integer (Default: Nothing) #
- ' # If updating an existing record, specify the OrganizationID #
- ' # of the target organization. #
- ' ###############################################################
- ' Get the list of Modules selected for this organization
- Dim ModuleList As New List(Of Integer)
- For i As Integer = 0 To chkModules.Items.Count - 1
- If chkModules.Items(i).Selected Then
- ModuleList.Add(chkModules.Items(i).Value)
- End If
- Next
- Dim sql As String = Nothing
- Select Case Action
- Case "Add"
- sql = "insert into Organizations(OrganizationName) values ('" & OrganizationName & "')"
- Case "Update"
- sql = "update Organizations set OrganizationName = '" & OrganizationName & "' " & _
- "where OrganizationID = " & Target
- End Select
- Dim dr As SqlDataReader = d.GetReader("select * from OrgModules where OrgID = " & Target)
- If dr.HasRows Then
- dr.Close()
- UpdateModules(Target, ModuleList, "update")
- Else
- dr.Close()
- UpdateModules(Target, ModuleList, "insert")
- End If
- d.DoCommand(sql)
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement