Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

781 lines
20 KiB

  1. VERSION 5.00
  2. Begin VB.Form frmSynonymSets
  3. BorderStyle = 1 'Fixed Single
  4. Caption = "Edit Synonym Sets"
  5. ClientHeight = 9375
  6. ClientLeft = 45
  7. ClientTop = 330
  8. ClientWidth = 9495
  9. LinkTopic = "Form1"
  10. MaxButton = 0 'False
  11. MinButton = 0 'False
  12. ScaleHeight = 9375
  13. ScaleWidth = 9495
  14. Begin VB.CommandButton cmdClose
  15. Caption = "Close"
  16. Height = 375
  17. Left = 8160
  18. TabIndex = 18
  19. Top = 8880
  20. Width = 1215
  21. End
  22. Begin VB.ListBox lstAllSynonymSets
  23. Height = 2985
  24. Left = 120
  25. TabIndex = 1
  26. Tag = "1"
  27. Top = 360
  28. Width = 9255
  29. End
  30. Begin VB.Frame fraSelectedSynonymSet
  31. Caption = "Selected Synonym Set"
  32. Height = 4695
  33. Left = 120
  34. TabIndex = 4
  35. Top = 4080
  36. Width = 9255
  37. Begin VB.TextBox txtName
  38. Height = 285
  39. Left = 1680
  40. TabIndex = 6
  41. Tag = "1"
  42. Top = 360
  43. Width = 7455
  44. End
  45. Begin VB.ListBox lstAllKeywords
  46. Height = 2790
  47. Left = 120
  48. MultiSelect = 2 'Extended
  49. TabIndex = 8
  50. Tag = "1"
  51. Top = 1200
  52. Width = 3735
  53. End
  54. Begin VB.ListBox lstKeywordsInSynonymSet
  55. Height = 2790
  56. Left = 5400
  57. MultiSelect = 2 'Extended
  58. TabIndex = 15
  59. Tag = "1"
  60. Top = 1320
  61. Width = 3735
  62. End
  63. Begin VB.CommandButton cmdCancel
  64. Caption = "Cancel"
  65. Height = 375
  66. Left = 7920
  67. TabIndex = 17
  68. Top = 4200
  69. Width = 1215
  70. End
  71. Begin VB.CommandButton cmdUpdateCreate
  72. Caption = "Update/Create"
  73. Height = 375
  74. Left = 6480
  75. TabIndex = 16
  76. Top = 4200
  77. Width = 1335
  78. End
  79. Begin VB.CommandButton cmdRemoveAll
  80. Caption = "<< Remove All"
  81. Height = 375
  82. Left = 3960
  83. TabIndex = 11
  84. Top = 2880
  85. Width = 1335
  86. End
  87. Begin VB.CommandButton cmdRemove
  88. Caption = "<< Remove"
  89. Height = 375
  90. Left = 3960
  91. TabIndex = 10
  92. Top = 2400
  93. Width = 1335
  94. End
  95. Begin VB.CommandButton cmdAdd
  96. Caption = "Add >>"
  97. Height = 375
  98. Left = 3960
  99. TabIndex = 9
  100. Top = 1920
  101. Width = 1335
  102. End
  103. Begin VB.Label lblAllKeywords
  104. Caption = "All Keywords:"
  105. Height = 255
  106. Left = 120
  107. TabIndex = 7
  108. Top = 960
  109. Width = 3735
  110. End
  111. Begin VB.Label lblName
  112. Caption = "Synonym Set Name:"
  113. Height = 255
  114. Left = 120
  115. TabIndex = 5
  116. Top = 360
  117. Width = 1455
  118. End
  119. Begin VB.Label lblKeywordsInSynonymSet3
  120. Caption = "contains the following Keywords:"
  121. Height = 255
  122. Left = 5400
  123. TabIndex = 14
  124. Top = 1080
  125. Width = 3735
  126. End
  127. Begin VB.Label lblKeywordsInSynonymSet2
  128. Caption = "<Synonym Set>"
  129. BeginProperty Font
  130. Name = "MS Sans Serif"
  131. Size = 8.25
  132. Charset = 0
  133. Weight = 700
  134. Underline = 0 'False
  135. Italic = 0 'False
  136. Strikethrough = 0 'False
  137. EndProperty
  138. Height = 255
  139. Left = 6720
  140. TabIndex = 13
  141. Top = 840
  142. Width = 2295
  143. End
  144. Begin VB.Label lblKeywordsInSynonymSet1
  145. Caption = "The Synonym Set"
  146. Height = 255
  147. Left = 5400
  148. TabIndex = 12
  149. Top = 840
  150. Width = 1335
  151. End
  152. End
  153. Begin VB.CommandButton cmdDelete
  154. Caption = "Delete"
  155. Height = 375
  156. Left = 8160
  157. TabIndex = 3
  158. Top = 3480
  159. Width = 1215
  160. End
  161. Begin VB.CommandButton cmdCreate
  162. Caption = "Create"
  163. Height = 375
  164. Left = 6840
  165. TabIndex = 2
  166. Top = 3480
  167. Width = 1215
  168. End
  169. Begin VB.Label lblAllSynonymSets
  170. Caption = "All Synonym Sets:"
  171. Height = 255
  172. Left = 120
  173. TabIndex = 0
  174. Top = 120
  175. Width = 1695
  176. End
  177. End
  178. Attribute VB_Name = "frmSynonymSets"
  179. Attribute VB_GlobalNameSpace = False
  180. Attribute VB_Creatable = False
  181. Attribute VB_PredeclaredId = True
  182. Attribute VB_Exposed = False
  183. Option Explicit
  184. Private p_clsSynonymSets As AuthDatabase.SynonymSets
  185. Private p_clsKeywords As AuthDatabase.Keywords
  186. Private p_rsAllSynonymSets As ADODB.Recordset
  187. Private p_rsAllKeywords As ADODB.Recordset
  188. Private p_rsKeywordsInSynonymSetCopy As ADODB.Recordset
  189. Private p_blnUpdating As Boolean
  190. Private p_blnCreating As Boolean
  191. Private Const STR_DEFAULT_SYNONYM_SET_NAME_C As String = "<Synonym Set>"
  192. Private Sub Form_Load()
  193. On Error GoTo LErrorHandler
  194. Set p_clsSynonymSets = g_AuthDatabase.SynonymSets
  195. Set p_clsKeywords = g_AuthDatabase.Keywords
  196. Set p_rsAllSynonymSets = New ADODB.Recordset
  197. Set p_rsAllKeywords = New ADODB.Recordset
  198. Set p_rsKeywordsInSynonymSetCopy = New ADODB.Recordset
  199. cmdClose.Cancel = True
  200. p_UpdateAllSynonymSets
  201. p_UpdateAllKeywords
  202. p_DisableDelete
  203. p_DisableSelectedSynonymSet
  204. p_SetModeCreating False
  205. p_SetToolTips
  206. SetFontInternal Me
  207. LEnd:
  208. Exit Sub
  209. LErrorHandler:
  210. p_DisplayErrorMessage "Form_Load"
  211. GoTo LEnd
  212. End Sub
  213. Private Sub Form_Unload(Cancel As Integer)
  214. Set p_clsSynonymSets = Nothing
  215. Set p_clsKeywords = Nothing
  216. Set p_rsAllSynonymSets = Nothing
  217. Set p_rsKeywordsInSynonymSetCopy = Nothing
  218. Set p_rsAllKeywords = Nothing
  219. End Sub
  220. Private Sub lstAllSynonymSets_Click()
  221. On Error GoTo LErrorHandler
  222. If (p_blnCreating Or p_blnUpdating) Then
  223. Exit Sub
  224. End If
  225. If (lstAllSynonymSets.ListIndex <> -1) Then
  226. p_rsAllSynonymSets.Move lstAllSynonymSets.ListIndex, adBookmarkFirst
  227. p_EnableDelete
  228. p_EnableSelectedSynonymSetExceptUpdateCreateCancel
  229. p_GetAndUpdateKeywordsInSynonymSet p_rsAllSynonymSets("EID")
  230. txtName = p_rsAllSynonymSets("Name") & ""
  231. Else
  232. p_DisableSelectedSynonymSet
  233. p_GetAndUpdateKeywordsInSynonymSet INVALID_ID_C
  234. txtName = ""
  235. End If
  236. lblKeywordsInSynonymSet2.Caption = txtName
  237. LEnd:
  238. Exit Sub
  239. LErrorHandler:
  240. p_DisplayErrorMessage "lstAllSynonymSets_Click"
  241. GoTo LEnd
  242. End Sub
  243. Private Sub cmdCreate_Click()
  244. On Error GoTo LErrorHandler
  245. p_SetModeCreating True
  246. LEnd:
  247. Exit Sub
  248. LErrorHandler:
  249. p_DisplayErrorMessage "cmdCreate_Click"
  250. GoTo LEnd
  251. End Sub
  252. Private Sub cmdDelete_Click()
  253. On Error GoTo LErrorHandler
  254. Dim intEID As Long
  255. intEID = p_rsAllSynonymSets("EID")
  256. p_clsSynonymSets.Delete intEID
  257. p_UpdateAllSynonymSets
  258. LEnd:
  259. Exit Sub
  260. LErrorHandler:
  261. p_DisplayErrorMessage "cmdDelete_Click"
  262. GoTo LEnd
  263. End Sub
  264. Private Sub cmdAdd_Click()
  265. On Error GoTo LErrorHandler
  266. Dim intIndex As Long
  267. Dim intKID As Long
  268. If (p_rsAllKeywords.RecordCount > 0) Then
  269. p_rsAllKeywords.MoveFirst
  270. End If
  271. For intIndex = 0 To lstAllKeywords.ListCount - 1
  272. If (lstAllKeywords.Selected(intIndex)) Then
  273. lstAllKeywords.Selected(intIndex) = False
  274. intKID = p_rsAllKeywords("KID")
  275. If (Not p_KIDAlreadyInSynonymSet(intKID)) Then
  276. p_rsKeywordsInSynonymSetCopy.AddNew
  277. p_rsKeywordsInSynonymSetCopy("KID") = intKID
  278. p_rsKeywordsInSynonymSetCopy("Keyword") = p_rsAllKeywords("Keyword")
  279. End If
  280. End If
  281. p_rsAllKeywords.MoveNext
  282. Next
  283. p_UpdateKeywordsInSynonymSet
  284. If (Not p_blnCreating) Then
  285. p_SetModeUpdating True
  286. End If
  287. LEnd:
  288. Exit Sub
  289. LErrorHandler:
  290. p_DisplayErrorMessage "cmdAdd_Click"
  291. GoTo LEnd
  292. End Sub
  293. Private Sub cmdRemove_Click()
  294. On Error GoTo LErrorHandler
  295. Dim intIndex As Long
  296. If (p_rsKeywordsInSynonymSetCopy.RecordCount > 0) Then
  297. p_rsKeywordsInSynonymSetCopy.MoveFirst
  298. End If
  299. For intIndex = 0 To lstKeywordsInSynonymSet.ListCount - 1
  300. If (lstKeywordsInSynonymSet.Selected(intIndex)) Then
  301. p_rsKeywordsInSynonymSetCopy.Delete
  302. End If
  303. p_rsKeywordsInSynonymSetCopy.MoveNext
  304. Next
  305. p_UpdateKeywordsInSynonymSet
  306. If (Not p_blnCreating) Then
  307. p_SetModeUpdating True
  308. End If
  309. LEnd:
  310. Exit Sub
  311. LErrorHandler:
  312. p_DisplayErrorMessage "cmdRemove_Click"
  313. GoTo LEnd
  314. End Sub
  315. Private Sub cmdRemoveAll_Click()
  316. On Error GoTo LErrorHandler
  317. Dim intIndex As Long
  318. For intIndex = 0 To lstKeywordsInSynonymSet.ListCount - 1
  319. lstKeywordsInSynonymSet.Selected(intIndex) = True
  320. Next
  321. cmdRemove_Click
  322. LEnd:
  323. Exit Sub
  324. LErrorHandler:
  325. p_DisplayErrorMessage "cmdRemoveAll_Click"
  326. GoTo LEnd
  327. End Sub
  328. Private Sub cmdUpdateCreate_Click()
  329. On Error GoTo LErrorHandler
  330. Dim strName As String
  331. strName = RemoveExtraSpaces(txtName.Text)
  332. If (strName = "") Then
  333. MsgBox "Synonym Set Name cannot be an empty string", vbExclamation + vbOKOnly
  334. txtName.SetFocus
  335. Exit Sub
  336. End If
  337. If (p_blnCreating) Then
  338. p_CreateSynonymSet strName
  339. Else
  340. p_UpdateSynonymSet p_rsAllSynonymSets("EID"), strName
  341. End If
  342. LEnd:
  343. Exit Sub
  344. LErrorHandler:
  345. p_DisplayErrorMessage "cmdUpdateCreate_Click"
  346. GoTo LEnd
  347. End Sub
  348. Private Sub cmdCancel_Click()
  349. On Error GoTo LErrorHandler
  350. If (p_blnCreating) Then
  351. p_SetModeCreating False
  352. ElseIf (p_blnUpdating) Then
  353. p_SetModeUpdating False
  354. End If
  355. p_DisableUpdateCreateCancel
  356. LEnd:
  357. Exit Sub
  358. LErrorHandler:
  359. p_DisplayErrorMessage "cmdCancel_Click"
  360. GoTo LEnd
  361. End Sub
  362. Private Sub cmdClose_Click()
  363. Unload Me
  364. End Sub
  365. Private Sub txtName_KeyPress(KeyAscii As Integer)
  366. On Error GoTo LErrorHandler
  367. p_EnableUpdateCreateCancel
  368. If (Not p_blnCreating) Then
  369. p_SetModeUpdating True
  370. End If
  371. LEnd:
  372. Exit Sub
  373. LErrorHandler:
  374. p_DisplayErrorMessage "txtName_KeyPress"
  375. GoTo LEnd
  376. End Sub
  377. Private Sub p_UpdateAllSynonymSets()
  378. p_clsSynonymSets.GetAllSynonymSetsRs p_rsAllSynonymSets
  379. lstAllSynonymSets.Clear
  380. Do While (Not p_rsAllSynonymSets.EOF)
  381. lstAllSynonymSets.AddItem p_rsAllSynonymSets("Name") & ""
  382. p_rsAllSynonymSets.MoveNext
  383. Loop
  384. End Sub
  385. Private Sub p_UpdateKeywordsInSynonymSet()
  386. lstKeywordsInSynonymSet.Clear
  387. If (p_rsKeywordsInSynonymSetCopy.RecordCount <> 0) Then
  388. p_rsKeywordsInSynonymSetCopy.MoveFirst
  389. End If
  390. Do While (Not p_rsKeywordsInSynonymSetCopy.EOF)
  391. lstKeywordsInSynonymSet.AddItem p_rsKeywordsInSynonymSetCopy("Keyword") & ""
  392. p_rsKeywordsInSynonymSetCopy.MoveNext
  393. Loop
  394. End Sub
  395. Private Sub p_GetAndUpdateKeywordsInSynonymSet(i_intEID As Long)
  396. Dim rs As ADODB.Recordset
  397. Set rs = New ADODB.Recordset
  398. p_clsKeywords.GetKeywordsInSynonymSet i_intEID, rs
  399. CopyRecordSet rs, p_rsKeywordsInSynonymSetCopy
  400. p_UpdateKeywordsInSynonymSet
  401. End Sub
  402. Private Sub p_UpdateAllKeywords()
  403. p_clsKeywords.GetAllKeywordsRs p_rsAllKeywords
  404. lstAllKeywords.Clear
  405. Do While (Not p_rsAllKeywords.EOF)
  406. lstAllKeywords.AddItem p_rsAllKeywords("Keyword") & ""
  407. p_rsAllKeywords.MoveNext
  408. Loop
  409. End Sub
  410. Private Sub p_EnableCreate()
  411. cmdCreate.Enabled = True
  412. End Sub
  413. Private Sub p_DisableCreate()
  414. cmdCreate.Enabled = False
  415. End Sub
  416. Private Sub p_EnableDelete()
  417. cmdDelete.Enabled = True
  418. End Sub
  419. Private Sub p_DisableDelete()
  420. cmdDelete.Enabled = False
  421. End Sub
  422. Private Sub p_DisableSelectedSynonymSet()
  423. fraSelectedSynonymSet.Enabled = False
  424. lblName.Enabled = False
  425. txtName.Enabled = False
  426. lblAllKeywords.Enabled = False
  427. lstAllKeywords.Enabled = False
  428. cmdAdd.Enabled = False
  429. cmdRemove.Enabled = False
  430. cmdRemoveAll.Enabled = False
  431. lblKeywordsInSynonymSet1.Enabled = False
  432. lblKeywordsInSynonymSet2.Enabled = False
  433. lblKeywordsInSynonymSet3.Enabled = False
  434. lstKeywordsInSynonymSet.Enabled = False
  435. p_DisableUpdateCreateCancel
  436. End Sub
  437. Private Sub p_EnableSelectedSynonymSetExceptUpdateCreateCancel()
  438. fraSelectedSynonymSet.Enabled = True
  439. lblName.Enabled = True
  440. txtName.Enabled = True
  441. lblAllKeywords.Enabled = True
  442. lstAllKeywords.Enabled = True
  443. cmdAdd.Enabled = True
  444. cmdRemove.Enabled = True
  445. cmdRemoveAll.Enabled = True
  446. lblKeywordsInSynonymSet1.Enabled = True
  447. lblKeywordsInSynonymSet2.Enabled = True
  448. lblKeywordsInSynonymSet3.Enabled = True
  449. lstKeywordsInSynonymSet.Enabled = True
  450. End Sub
  451. Private Sub p_EnableUpdateCreateCancel()
  452. cmdUpdateCreate.Enabled = True
  453. cmdCancel.Enabled = True
  454. End Sub
  455. Private Sub p_DisableUpdateCreateCancel()
  456. cmdUpdateCreate.Enabled = False
  457. cmdCancel.Enabled = False
  458. End Sub
  459. Private Sub p_NameUpdate()
  460. cmdUpdateCreate.Caption = "Update"
  461. End Sub
  462. Private Sub p_NameCreate()
  463. cmdUpdateCreate.Caption = "Create"
  464. End Sub
  465. Private Sub p_SetModeCreating(i_bln)
  466. If (i_bln) Then
  467. p_blnCreating = True
  468. p_DisableCreate
  469. p_DisableDelete
  470. fraSelectedSynonymSet.Caption = "Creating new Synonym Set"
  471. lblKeywordsInSynonymSet2.Caption = STR_DEFAULT_SYNONYM_SET_NAME_C
  472. p_EnableSelectedSynonymSetExceptUpdateCreateCancel
  473. txtName = ""
  474. txtName.SetFocus
  475. p_GetAndUpdateKeywordsInSynonymSet INVALID_ID_C
  476. p_EnableUpdateCreateCancel
  477. p_NameCreate
  478. Else
  479. p_blnCreating = False
  480. p_EnableCreate
  481. fraSelectedSynonymSet.Caption = "Selected Synonym Set"
  482. lstAllSynonymSets_Click
  483. p_DisableUpdateCreateCancel
  484. p_NameUpdate
  485. End If
  486. End Sub
  487. Private Sub p_SetModeUpdating(i_bln)
  488. If (i_bln) Then
  489. p_blnUpdating = True
  490. p_DisableCreate
  491. p_DisableDelete
  492. p_EnableUpdateCreateCancel
  493. Else
  494. p_blnUpdating = False
  495. p_EnableCreate
  496. lstAllSynonymSets_Click
  497. p_DisableUpdateCreateCancel
  498. End If
  499. End Sub
  500. ' Output in o_arrKeywords(1..Number of keywords)
  501. Private Sub p_GetKeywordsInSynonymSet(o_arrKeywords() As Long)
  502. Dim intIndex As Long
  503. Dim intCount As Long
  504. intCount = lstKeywordsInSynonymSet.ListCount
  505. If (intCount = 0) Then
  506. ReDim o_arrKeywords(0)
  507. Exit Sub
  508. End If
  509. ReDim o_arrKeywords(intCount)
  510. p_rsKeywordsInSynonymSetCopy.MoveFirst
  511. intIndex = 1
  512. Do While (Not p_rsKeywordsInSynonymSetCopy.EOF)
  513. o_arrKeywords(intIndex) = p_rsKeywordsInSynonymSetCopy("KID")
  514. p_rsKeywordsInSynonymSetCopy.MoveNext
  515. intIndex = intIndex + 1
  516. Loop
  517. End Sub
  518. Private Function p_KIDAlreadyInSynonymSet(i_intKID As Long) As Boolean
  519. p_KIDAlreadyInSynonymSet = False
  520. If (p_rsKeywordsInSynonymSetCopy.RecordCount = 0) Then
  521. Exit Function
  522. End If
  523. p_rsKeywordsInSynonymSetCopy.MoveFirst
  524. p_rsKeywordsInSynonymSetCopy.Find "KID = " & i_intKID, , adSearchForward
  525. If (Not p_rsKeywordsInSynonymSetCopy.EOF) Then
  526. p_KIDAlreadyInSynonymSet = True
  527. End If
  528. End Function
  529. Private Sub p_CreateSynonymSet(i_strName As String)
  530. Dim arrKeywords() As Long
  531. p_GetKeywordsInSynonymSet arrKeywords
  532. p_clsSynonymSets.Create i_strName, arrKeywords
  533. p_UpdateAllSynonymSets
  534. p_SetModeCreating False
  535. End Sub
  536. Private Sub p_UpdateSynonymSet(i_intEID As Long, i_strName As String)
  537. Dim arrKeywords() As Long
  538. p_GetKeywordsInSynonymSet arrKeywords
  539. p_clsSynonymSets.Update i_intEID, i_strName, arrKeywords
  540. p_UpdateAllSynonymSets
  541. p_SetModeUpdating False
  542. End Sub
  543. Private Sub p_DisplayErrorMessage( _
  544. ByVal i_strFunction As String _
  545. )
  546. Select Case Err.Number
  547. Case errContainsGarbageChar
  548. MsgBox "The Name " & txtName & " contains garbage characters", _
  549. vbExclamation + vbOKOnly
  550. Case errAlreadyExists
  551. MsgBox "The Name " & txtName & " already exists", _
  552. vbExclamation + vbOKOnly
  553. Case E_FAIL
  554. DisplayDatabaseLockedError
  555. Case errDatabaseVersionIncompatible
  556. DisplayDatabaseVersionError
  557. Case errNotPermittedForAuthoringGroup, errAuthoringGroupDiffers, _
  558. errAuthoringGroupNotPresent
  559. DisplayAuthoringGroupError
  560. Case Else
  561. g_ErrorInfo.SetInfoAndDump i_strFunction
  562. End Select
  563. End Sub
  564. Private Sub p_SetToolTips()
  565. lblAllSynonymSets.ToolTipText = "This is a list of all Synonym Sets that have " & _
  566. "been created for this database."
  567. lstAllSynonymSets.ToolTipText = lblAllSynonymSets.ToolTipText
  568. lblName.ToolTipText = "If you have selected a Synonym Set, its name will appear here. " & _
  569. "If you are creating a new Synonym Set, type in the new name here."
  570. txtName.ToolTipText = lblName.ToolTipText
  571. lblAllKeywords.ToolTipText = "This is a list of all keywords that have been created " & _
  572. "for this database."
  573. lstAllKeywords.ToolTipText = lblAllKeywords.ToolTipText
  574. lblKeywordsInSynonymSet1.ToolTipText = "This is a list of all the keywords that " & _
  575. "the selected synonym set contains."
  576. lblKeywordsInSynonymSet2.ToolTipText = lblKeywordsInSynonymSet1.ToolTipText
  577. lblKeywordsInSynonymSet3.ToolTipText = lblKeywordsInSynonymSet1.ToolTipText
  578. lstKeywordsInSynonymSet.ToolTipText = lblKeywordsInSynonymSet1.ToolTipText
  579. End Sub