SHARE
TWEET

Untitled

Ortund Oct 26th, 2011 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Private Sub AddUpdateOrg(ByVal OrganizationName As String, ByVal Action As String, Optional ByVal Target As Integer = Nothing)
  2.     ' ###############################################################
  3.     ' #                ADD OR UPDATE AN ORGANIZATION                #
  4.     ' # ============================================================#
  5.     ' # PARAMETERS                                                  #
  6.     ' # ----------                                                  #
  7.     ' # OrganizationName As String                                  #
  8.     ' # The organization name that is to be stored in the database. #
  9.     ' #                                                             #
  10.     ' # Action As String                                            #
  11.     ' # What action will be taken by this procedure, add or update. #
  12.     ' #                                                             #
  13.     ' # Optional Target As Integer (Default: Nothing)               #
  14.     ' # If updating an existing record, specify the OrganizationID  #
  15.     ' # of the target organization.                                 #
  16.     ' ###############################################################
  17.  
  18.     ' Get the list of Modules selected for this organization
  19.     Dim ModuleList As New List(Of Integer)
  20.     For i As Integer = 0 To chkModules.Items.Count - 1
  21.         If chkModules.Items(i).Selected Then
  22.             ModuleList.Add(chkModules.Items(i).Value)
  23.         End If
  24.     Next
  25.  
  26.     Dim sql As String = Nothing
  27.  
  28.     Select Case Action
  29.         Case "Add"
  30.             sql = "insert into Organizations(OrganizationName) values ('" & OrganizationName & "')"
  31.  
  32.         Case "Update"
  33.             sql = "update Organizations set OrganizationName = '" & OrganizationName & "' " & _
  34.                 "where OrganizationID = " & Target
  35.     End Select
  36.  
  37.     Dim dr As SqlDataReader = d.GetReader("select * from OrgModules where OrgID = " & Target)
  38.     If dr.HasRows Then
  39.         dr.Close()
  40.         UpdateModules(Target, ModuleList, "update")
  41.     Else
  42.         dr.Close()
  43.         UpdateModules(Target, ModuleList, "insert")
  44.     End If
  45.     d.DoCommand(sql)
  46. End Sub
  47.  
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top