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.

2474 lines
80 KiB

  1. VERSION 5.00
  2. Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.3#0"; "comctl32.ocx"
  3. Begin VB.Form frmMain
  4. BorderStyle = 1 'Fixed Single
  5. ClientHeight = 5550
  6. ClientLeft = 165
  7. ClientTop = 2715
  8. ClientWidth = 8250
  9. Icon = "main.frx":0000
  10. LinkTopic = "Form1"
  11. LockControls = -1 'True
  12. MaxButton = 0 'False
  13. PaletteMode = 1 'UseZOrder
  14. ScaleHeight = 370
  15. ScaleMode = 3 'Pixel
  16. ScaleWidth = 550
  17. WhatsThisHelp = -1 'True
  18. Begin VB.CommandButton cmdDelete
  19. Caption = "del"
  20. Height = 345
  21. Left = 6930
  22. TabIndex = 9
  23. Top = 1635
  24. WhatsThisHelpID = 20080
  25. Width = 1260
  26. End
  27. Begin VB.Frame Frame2
  28. Height = 75
  29. Left = -30
  30. TabIndex = 13
  31. Top = -30
  32. Width = 8355
  33. End
  34. Begin VB.CommandButton cmbEdit
  35. Caption = "edit"
  36. Height = 345
  37. Left = 5520
  38. TabIndex = 8
  39. Top = 1635
  40. WhatsThisHelpID = 20070
  41. Width = 1260
  42. End
  43. Begin VB.CommandButton cmbadd
  44. Caption = "add"
  45. Height = 345
  46. Left = 4080
  47. TabIndex = 7
  48. Top = 1635
  49. WhatsThisHelpID = 20060
  50. Width = 1275
  51. End
  52. Begin VB.Frame FilterFrame
  53. Caption = "filter"
  54. Height = 1290
  55. Left = 2925
  56. TabIndex = 11
  57. Top = 210
  58. Width = 5250
  59. Begin VB.TextBox txtsearch
  60. Height = 285
  61. Left = 1650
  62. MaxLength = 20
  63. TabIndex = 5
  64. Top = 780
  65. WhatsThisHelpID = 20040
  66. Width = 2175
  67. End
  68. Begin VB.CommandButton cmbsearch
  69. Caption = "apply"
  70. Height = 345
  71. Left = 3960
  72. TabIndex = 6
  73. Top = 720
  74. WhatsThisHelpID = 20050
  75. Width = 1185
  76. End
  77. Begin VB.ComboBox combosearch
  78. Height = 315
  79. ItemData = "main.frx":0ABA
  80. Left = 1650
  81. List = "main.frx":0ABC
  82. Style = 2 'Dropdown List
  83. TabIndex = 3
  84. Top = 330
  85. WhatsThisHelpID = 20030
  86. Width = 2175
  87. End
  88. Begin VB.Label FilterLabel
  89. Alignment = 1 'Right Justify
  90. BackStyle = 0 'Transparent
  91. Caption = "by"
  92. Height = 255
  93. Left = 120
  94. TabIndex = 2
  95. Top = 375
  96. WhatsThisHelpID = 20030
  97. Width = 1470
  98. End
  99. Begin VB.Label SearchLabel
  100. Alignment = 1 'Right Justify
  101. BackStyle = 0 'Transparent
  102. Caption = "contain"
  103. Height = 255
  104. Left = 120
  105. TabIndex = 4
  106. Top = 795
  107. WhatsThisHelpID = 20040
  108. Width = 1500
  109. End
  110. End
  111. Begin ComctlLib.TreeView PBTree
  112. Height = 1185
  113. Left = 120
  114. TabIndex = 1
  115. Top = 315
  116. WhatsThisHelpID = 20000
  117. Width = 2580
  118. _ExtentX = 4551
  119. _ExtentY = 2090
  120. _Version = 327682
  121. Indentation = 529
  122. LabelEdit = 1
  123. Sorted = -1 'True
  124. Style = 7
  125. ImageList = "ImageList1"
  126. Appearance = 1
  127. BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
  128. Name = "MS Sans Serif"
  129. Size = 8.25
  130. Charset = 0
  131. Weight = 400
  132. Underline = 0 'False
  133. Italic = 0 'False
  134. Strikethrough = 0 'False
  135. EndProperty
  136. End
  137. Begin ComctlLib.ListView PopList
  138. Height = 3330
  139. Left = 0
  140. TabIndex = 12
  141. Top = 2160
  142. WhatsThisHelpID = 20020
  143. Width = 8205
  144. _ExtentX = 14473
  145. _ExtentY = 5874
  146. View = 3
  147. LabelEdit = 1
  148. LabelWrap = -1 'True
  149. HideSelection = 0 'False
  150. _Version = 327682
  151. ForeColor = -2147483640
  152. BackColor = -2147483643
  153. Appearance = 1
  154. BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
  155. Name = "MS Sans Serif"
  156. Size = 8.25
  157. Charset = 0
  158. Weight = 400
  159. Underline = 0 'False
  160. Italic = 0 'False
  161. Strikethrough = 0 'False
  162. EndProperty
  163. NumItems = 6
  164. BeginProperty ColumnHeader(1) {0713E8C7-850A-101B-AFC0-4210102A8DA7}
  165. Key = ""
  166. Object.Tag = ""
  167. Text = "pop"
  168. Object.Width = 2646
  169. EndProperty
  170. BeginProperty ColumnHeader(2) {0713E8C7-850A-101B-AFC0-4210102A8DA7}
  171. Alignment = 1
  172. Key = ""
  173. Object.Tag = ""
  174. Text = "ac"
  175. Object.Width = 1323
  176. EndProperty
  177. BeginProperty ColumnHeader(3) {0713E8C7-850A-101B-AFC0-4210102A8DA7}
  178. Alignment = 1
  179. Key = ""
  180. Object.Tag = ""
  181. Text = "num"
  182. Object.Width = 1720
  183. EndProperty
  184. BeginProperty ColumnHeader(4) {0713E8C7-850A-101B-AFC0-4210102A8DA7}
  185. Alignment = 2
  186. Key = ""
  187. Object.Tag = ""
  188. Text = "cntry"
  189. Object.Width = 1984
  190. EndProperty
  191. BeginProperty ColumnHeader(5) {0713E8C7-850A-101B-AFC0-4210102A8DA7}
  192. Alignment = 2
  193. Key = ""
  194. Object.Tag = ""
  195. Text = "reg"
  196. Object.Width = 1984
  197. EndProperty
  198. BeginProperty ColumnHeader(6) {0713E8C7-850A-101B-AFC0-4210102A8DA7}
  199. Alignment = 2
  200. Key = ""
  201. Object.Tag = ""
  202. Text = "stat"
  203. Object.Width = 1058
  204. EndProperty
  205. End
  206. Begin VB.Label PBListLabel
  207. BackStyle = 0 'Transparent
  208. Caption = "pb"
  209. Height = 225
  210. Left = 90
  211. TabIndex = 0
  212. Top = 90
  213. WhatsThisHelpID = 20000
  214. Width = 1695
  215. End
  216. Begin ComctlLib.ImageList ImageList1
  217. Left = 2760
  218. Top = 675
  219. _ExtentX = 1005
  220. _ExtentY = 1005
  221. BackColor = -2147483643
  222. ImageWidth = 16
  223. ImageHeight = 16
  224. MaskColor = 12632256
  225. _Version = 327682
  226. BeginProperty Images {0713E8C2-850A-101B-AFC0-4210102A8DA7}
  227. NumListImages = 3
  228. BeginProperty ListImage1 {0713E8C3-850A-101B-AFC0-4210102A8DA7}
  229. Picture = "main.frx":0ABE
  230. Key = ""
  231. EndProperty
  232. BeginProperty ListImage2 {0713E8C3-850A-101B-AFC0-4210102A8DA7}
  233. Picture = "main.frx":0DD8
  234. Key = ""
  235. EndProperty
  236. BeginProperty ListImage3 {0713E8C3-850A-101B-AFC0-4210102A8DA7}
  237. Picture = "main.frx":10F2
  238. Key = ""
  239. EndProperty
  240. EndProperty
  241. End
  242. Begin VB.Label PBLabel
  243. BackStyle = 0 'Transparent
  244. BorderStyle = 1 'Fixed Single
  245. Caption = " "
  246. Height = 315
  247. Left = 75
  248. TabIndex = 10
  249. Top = 1665
  250. WhatsThisHelpID = 20010
  251. Width = 3720
  252. End
  253. Begin VB.Menu file
  254. Caption = "&File--"
  255. Begin VB.Menu m_addpb
  256. Caption = "&New Phone Book...--"
  257. End
  258. Begin VB.Menu m_copypb
  259. Caption = "&Copy Phone Book...--"
  260. End
  261. Begin VB.Menu m_removepb
  262. Caption = "&Delete Phone Book--"
  263. End
  264. Begin VB.Menu div5
  265. Caption = "-"
  266. End
  267. Begin VB.Menu m_printpops
  268. Caption = "&Print POP List--"
  269. End
  270. Begin VB.Menu m_viewlog
  271. Caption = "&View Log---"
  272. End
  273. Begin VB.Menu m_div
  274. Caption = "-"
  275. End
  276. Begin VB.Menu m_exit
  277. Caption = "E&xit--"
  278. End
  279. End
  280. Begin VB.Menu m_edit
  281. Caption = "&Edit--"
  282. Begin VB.Menu m_addpop
  283. Caption = "&Add POP...--"
  284. End
  285. Begin VB.Menu m_editpop
  286. Caption = "&Edit POP...--"
  287. End
  288. Begin VB.Menu m_delpop
  289. Caption = "&Delete POP--"
  290. End
  291. End
  292. Begin VB.Menu m_tools
  293. Caption = "&Tools--"
  294. Begin VB.Menu m_buildPhone
  295. Caption = "&Build Phone Book...--"
  296. End
  297. Begin VB.Menu viewChange
  298. Caption = "View &Phone Book Files...--"
  299. End
  300. Begin VB.Menu m_div1
  301. Caption = "-"
  302. End
  303. Begin VB.Menu m_editflag
  304. Caption = "Edit &Flags...--"
  305. Visible = 0 'False
  306. End
  307. Begin VB.Menu m_editRegion
  308. Caption = "&Regions Editor...--"
  309. End
  310. Begin VB.Menu m_div2
  311. Caption = "-"
  312. End
  313. Begin VB.Menu m_options
  314. Caption = "&Options...--"
  315. End
  316. End
  317. Begin VB.Menu help
  318. Caption = "&Help--"
  319. Begin VB.Menu contents
  320. Caption = "&Help Topics... -- "
  321. End
  322. Begin VB.Menu m_whatsthis
  323. Caption = "What's This? ---"
  324. End
  325. Begin VB.Menu m_div3
  326. Caption = "-"
  327. End
  328. Begin VB.Menu about
  329. Caption = "&About Phone Book Administration--"
  330. End
  331. End
  332. End
  333. Attribute VB_Name = "frmMain"
  334. Attribute VB_GlobalNameSpace = False
  335. Attribute VB_Creatable = False
  336. Attribute VB_PredeclaredId = True
  337. Attribute VB_Exposed = False
  338. Option Explicit
  339. Dim selection As Long
  340. Dim clickSelect As Integer
  341. Function cmdImportPBK(ByVal PBKFile As String, ByRef dbPB As Database) As Integer
  342. ' handles importing phone book file, in PBD format, meaning
  343. ' that adds, edits, deletes are allowed. based on POP ID.
  344. '
  345. ' Add: <new ID>, new data
  346. ' Edit: <POP ID>, new data
  347. ' Delete: <POP ID>, all zeros
  348. Dim intPBKFile As Integer
  349. Dim intX As Long
  350. Dim DelReturn As Integer, SaveRet As Integer
  351. Dim strSQL, strLine As String
  352. Dim varLine As Variant
  353. Dim CountryRS As Recordset
  354. Dim i As Integer
  355. Dim iLineCount As Integer
  356. 'ReDim varRecord(1)
  357. On Error GoTo ImportErr
  358. iLineCount = 0
  359. If CheckPath(PBKFile) <> 0 Then
  360. cmdLogError 6076
  361. cmdImportPBK = 0
  362. Exit Function
  363. End If
  364. intPBKFile = FreeFile
  365. Open PBKFile For Input Access Read As #intPBKFile
  366. Do While Not EOF(intPBKFile)
  367. Line Input #intPBKFile, strLine
  368. If LOF(intPBKFile) = Len(strLine) Then ' check to see if there are any carriage return (Chr(13)) in the file
  369. cmdLogError 6100
  370. cmdImportPBK = 0
  371. Exit Function
  372. End If
  373. iLineCount = iLineCount + 1
  374. If strLine <> "" Then
  375. varLine = SplitLine(strLine, ",") 'SplitLine should return 11 fields (0-10).
  376. 'DeletePOP and SavePOP expect the
  377. 'full 14. The extras are empty here.
  378. If Not IsNumeric(varLine(0)) Then
  379. cmdLogError 6086, " - " & LoadResString(6061) & "; " & LoadResString(6094) & " = " & iLineCount
  380. cmdImportPBK = 0
  381. Exit Function
  382. Else
  383. If varLine(1) = "0" Then
  384. intX = varLine(0)
  385. DelReturn = DeletePOP(intX, dbPB)
  386. If DelReturn <> 0 Then
  387. cmdLogError 6078, " - " & LoadResString(6061) & " = " & CStr(DelReturn)
  388. End If
  389. Else
  390. intX = varLine(0)
  391. If UBound(varLine) <> 10 Then
  392. cmdLogError 6077, " - " & LoadResString(6084) & "; " & LoadResString(6061) & " = " & CStr(intX)
  393. cmdImportPBK = 0 'wrong # of fields
  394. Exit Function
  395. End If
  396. For i = 1 To 10
  397. Select Case i
  398. Case 1
  399. If Not IsNumeric(varLine(i)) Then
  400. cmdLogError 6086, " - " & gsCurrentPB & "; " & LoadResString(6061) & " = " & CStr(intX) & "; " & LoadResString(6062) & " = " & CStr(varLine(i))
  401. cmdImportPBK = 0
  402. Exit Function
  403. End If
  404. strSQL = "SELECT * from Country where CountryNumber = " & CStr(varLine(1))
  405. Set CountryRS = dbPB.OpenRecordset(strSQL)
  406. If CountryRS.BOF And CountryRS.EOF Then
  407. cmdLogError 6090, " - " & gsCurrentPB & "; " & LoadResString(6061) & " = " & CStr(intX) & "; " & LoadResString(6062) & " = " & CStr(varLine(i))
  408. cmdImportPBK = 0
  409. Exit Function
  410. End If
  411. Case 2
  412. If varLine(i) = "" Then
  413. varLine(i) = 0
  414. End If
  415. If Not IsNumeric(varLine(i)) Then
  416. cmdLogError 6086, " - " & gsCurrentPB & "; " & LoadResString(6061) & " = " & CStr(intX) & "; " & LoadResString(6063) & " = " & CStr(varLine(i))
  417. cmdImportPBK = 0
  418. Exit Function
  419. End If
  420. strSQL = "SELECT * from region where RegionID = " & CStr(varLine(2))
  421. Set GsysRgn = dbPB.OpenRecordset(strSQL)
  422. If GsysRgn.BOF And GsysRgn.EOF And CInt(varLine(i)) > 0 Then
  423. cmdLogError 6089, " - " & gsCurrentPB & "; " & LoadResString(6061) & " = " & CStr(intX)
  424. cmdImportPBK = 0
  425. Exit Function
  426. End If
  427. Case 3
  428. If Len(varLine(i)) > 30 Then
  429. cmdLogError 6085, " - " & gsCurrentPB & "; " & LoadResString(6061) & " = " & CStr(intX) & "; " & LoadResString(6064) & " = " & CStr(varLine(i))
  430. cmdImportPBK = 0
  431. Exit Function
  432. End If
  433. If varLine(i) = "" Then
  434. varLine(i) = " "
  435. End If
  436. Case 4
  437. If Len(varLine(i)) > 10 Then
  438. cmdLogError 6085, " - " & gsCurrentPB & "; " & LoadResString(6061) & " = " & CStr(intX) & "; " & LoadResString(6065) & " = " & CStr(varLine(i))
  439. cmdImportPBK = 0
  440. Exit Function
  441. End If
  442. If varLine(i) = "" Then
  443. varLine(i) = " "
  444. End If
  445. Case 5
  446. If Len(varLine(i)) > 40 Then
  447. cmdLogError 6085, " - " & gsCurrentPB & "; " & LoadResString(6061) & " = " & CStr(intX) & "; " & LoadResString(6066) & " = " & CStr(varLine(i))
  448. cmdImportPBK = 0
  449. Exit Function
  450. End If
  451. If varLine(i) = "" Then
  452. varLine(i) = " "
  453. End If
  454. Case 6
  455. If Not IsNumeric(varLine(i)) And varLine(i) <> "" Then
  456. cmdLogError 6086, " - " & gsCurrentPB & "; " & LoadResString(6061) & " = " & CStr(intX) & "; " & LoadResString(6067) & " = " & CStr(varLine(i))
  457. cmdImportPBK = 0
  458. Exit Function
  459. End If
  460. If varLine(i) = "" Then
  461. varLine(i) = 0
  462. End If
  463. Case 7
  464. If Not IsNumeric(varLine(i)) And varLine(i) <> "" Then
  465. cmdLogError 6086, " - " & gsCurrentPB & "; " & LoadResString(6061) & " = " & CStr(intX) & "; " & LoadResString(6068) & " = " & CStr(varLine(i))
  466. cmdImportPBK = 0
  467. Exit Function
  468. End If
  469. If varLine(i) = "" Then
  470. varLine(i) = 0
  471. End If
  472. Case 8
  473. If Not IsNumeric(varLine(i)) And varLine(i) <> "" Then
  474. cmdLogError 6086, " - " & gsCurrentPB & "; " & LoadResString(6061) & " = " & CStr(intX) & "; " & LoadResString(6069) & " = " & CStr(varLine(i))
  475. cmdImportPBK = 0
  476. Exit Function
  477. End If
  478. If varLine(i) = "" Then
  479. varLine(i) = 0
  480. End If
  481. Case 9
  482. If Not IsNumeric(varLine(i)) And varLine(i) <> "" Then
  483. cmdLogError 6086, " - " & gsCurrentPB & "; " & LoadResString(6061) & " = " & CStr(intX) & "; " & LoadResString(6070) & " = " & CStr(varLine(i))
  484. cmdImportPBK = 0
  485. Exit Function
  486. End If
  487. If varLine(i) = "" Then
  488. varLine(i) = 0
  489. End If
  490. End Select
  491. Next i
  492. If Len(varLine(4)) + Len(varLine(5)) > 35 Then
  493. cmdLogError 6091, " - " & gsCurrentPB & "; " & LoadResString(6061) & " = " & CStr(varLine(0))
  494. cmdImportPBK = 0
  495. Exit Function
  496. End If
  497. SaveRet = SavePOP(varLine, dbPB)
  498. If SaveRet <> 0 Then
  499. cmdLogError 6079, " - " & gsCurrentPB & "; " & LoadResString(6061) & " = " & CStr(SaveRet)
  500. cmdImportPBK = 0
  501. Exit Function
  502. End If
  503. End If
  504. End If
  505. End If
  506. Loop
  507. Close #intPBKFile
  508. cmdLogSuccess 6096
  509. On Error GoTo 0
  510. Exit Function
  511. ImportErr:
  512. cmdImportPBK = 1
  513. Exit Function
  514. End Function
  515. Function cmdImportRegions(ByVal RegionFile As String, ByRef dbPB As Database) As Integer
  516. ' this function imports a region file, format:
  517. ' <region ID>, <region name>
  518. '
  519. ' Add: <new region ID>, <new region name>
  520. ' Edit: <region ID>, <new region name>
  521. ' Delete: <region ID>, <empty string>
  522. Dim intRegionFile As Integer
  523. 'Dim rsRegions As Recordset
  524. Dim strSQL, strLine As String
  525. Dim strRegionID, strRegionDesc As String
  526. Dim varLine As Variant
  527. Dim RS As Recordset
  528. Dim NewRgn As Recordset
  529. Dim PerformedDelete As Boolean
  530. Dim rsTempPop As Recordset, rsTempDelta As Recordset
  531. Dim i As Integer, deltnum As Integer
  532. Dim deltasql As String, popsql As String
  533. On Error GoTo RegionImport
  534. PerformedDelete = False
  535. If CheckPath(RegionFile) <> 0 Then
  536. cmdLogError 6076
  537. cmdImportRegions = 0
  538. Exit Function
  539. End If
  540. intRegionFile = FreeFile
  541. Open RegionFile For Input Access Read As #intRegionFile
  542. Do While Not EOF(intRegionFile)
  543. Line Input #intRegionFile, strLine
  544. If LOF(intRegionFile) = Len(strLine) Then ' check to see if there are any carriage return (Chr(13)) in the file
  545. cmdLogError 6100
  546. cmdImportRegions = 0
  547. Exit Function
  548. End If
  549. varLine = SplitLine(strLine, ",")
  550. strRegionID = varLine(0)
  551. strRegionDesc = varLine(1)
  552. If Trim(Str(Val(strRegionID))) = strRegionID Then ' check for integer ID value
  553. If strRegionDesc = "" Then
  554. Set GsysRgn = dbPB.OpenRecordset("SELECT * from region where RegionID = " & strRegionID, dbOpenSnapshot)
  555. strSQL = "DELETE FROM region WHERE RegionID = " & strRegionID
  556. dbPB.Execute strSQL
  557. popsql = "Select * from DialUpPort Where RegionID = " & strRegionID
  558. Set rsTempPop = dbPB.OpenRecordset(popsql, dbOpenDynaset)
  559. If Not (rsTempPop.BOF And rsTempPop.EOF) Then
  560. rsTempPop.MoveFirst
  561. Do Until rsTempPop.EOF
  562. rsTempPop.Edit
  563. rsTempPop!RegionID = 0
  564. rsTempPop.Update
  565. If rsTempPop!status = 1 Then
  566. Set rsTempDelta = dbPB.OpenRecordset("Select * from Delta order by DeltaNum", dbOpenDynaset)
  567. If rsTempDelta.RecordCount = 0 Then
  568. deltnum = 1
  569. Else
  570. rsTempDelta.MoveLast
  571. deltnum = rsTempDelta!deltanum
  572. If deltnum > 6 Then
  573. deltnum = deltnum - 1
  574. End If
  575. End If
  576. For i = 1 To deltnum
  577. deltasql = "Select * from delta where DeltaNum = " & i & _
  578. " AND AccessNumberId = '" & rsTempPop!AccessNumberId & "' " & _
  579. " order by DeltaNum"
  580. Set rsTempDelta = dbPB.OpenRecordset(deltasql, dbOpenDynaset)
  581. If Not (rsTempDelta.BOF And rsTempDelta.EOF) Then
  582. rsTempDelta.Edit
  583. Else
  584. rsTempDelta.AddNew
  585. rsTempDelta!deltanum = i
  586. rsTempDelta!AccessNumberId = rsTempPop!AccessNumberId
  587. End If
  588. If rsTempPop!status = 1 Then
  589. rsTempDelta!CountryNumber = rsTempPop!CountryNumber
  590. rsTempDelta!AreaCode = rsTempPop!AreaCode
  591. rsTempDelta!AccessNumber = rsTempPop!AccessNumber
  592. rsTempDelta!MinimumSpeed = rsTempPop!MinimumSpeed
  593. rsTempDelta!MaximumSpeed = rsTempPop!MaximumSpeed
  594. rsTempDelta!RegionID = rsTempPop!RegionID
  595. rsTempDelta!CityName = rsTempPop!CityName
  596. rsTempDelta!ScriptID = rsTempPop!ScriptID
  597. rsTempDelta!Flags = rsTempPop!Flags
  598. rsTempDelta.Update
  599. End If
  600. Next i
  601. End If
  602. rsTempPop.MoveNext
  603. Loop
  604. End If
  605. PerformedDelete = True
  606. LogRegionDelete GsysRgn!RegionDesc, CStr(GsysRgn!RegionDesc) & ";" & CStr(GsysRgn!RegionID)
  607. Else
  608. Set GsysRgn = dbPB.OpenRecordset("SELECT * from region where RegionID = " & strRegionID, dbOpenSnapshot)
  609. If GsysRgn.EOF And GsysRgn.BOF Then
  610. strSQL = "Select * From region where RegionDesc="" " & strRegionDesc & " "" "
  611. Set RS = dbPB.OpenRecordset(strSQL, dbOpenSnapshot)
  612. If RS.EOF And RS.BOF Then
  613. strSQL = "INSERT INTO Region (RegionID, RegionDesc) VALUES (" & _
  614. strRegionID & ", "" " & strRegionDesc & " "")"
  615. dbPB.Execute strSQL
  616. Set GsysRgn = dbPB.OpenRecordset("SELECT * from region where RegionID = " & strRegionID, dbOpenSnapshot)
  617. LogRegionAdd strRegionDesc, strRegionDesc & ";" & strRegionID
  618. Else
  619. cmdLogError 6088, " - " & gsCurrentPB & "; " & strRegionDesc
  620. cmdImportRegions = 0
  621. Exit Function
  622. End If
  623. Else
  624. strSQL = "Select * From region where RegionDesc="" " & strRegionDesc & " "" "
  625. Set RS = dbPB.OpenRecordset(strSQL, dbOpenSnapshot)
  626. If (RS.EOF And RS.BOF) Then
  627. strSQL = "UPDATE region SET RegionDesc="" " & strRegionDesc & " "" " & _
  628. " WHERE RegionID=" & strRegionID
  629. dbPB.Execute strSQL
  630. strSQL = "INSERT INTO Region (RegionID, RegionDesc) VALUES (" & _
  631. strRegionID & ", "" " & strRegionDesc & " "")"
  632. dbPB.Execute strSQL
  633. Set NewRgn = dbPB.OpenRecordset("SELECT * from region where RegionID = " & strRegionID, dbOpenSnapshot)
  634. LogRegionEdit GsysRgn!RegionDesc, strRegionDesc & ";" & strRegionID
  635. Else
  636. If RS!RegionID = CInt(strRegionID) Then
  637. strSQL = "UPDATE region SET RegionDesc="" " & strRegionDesc & " "" " & _
  638. " WHERE RegionID=" & strRegionID
  639. dbPB.Execute strSQL
  640. strSQL = "INSERT INTO Region (RegionID, RegionDesc) VALUES (" & _
  641. strRegionID & ", "" " & strRegionDesc & " "")"
  642. dbPB.Execute strSQL
  643. Set NewRgn = dbPB.OpenRecordset("SELECT * from region where RegionID = " & strRegionID, dbOpenSnapshot)
  644. LogRegionEdit GsysRgn!RegionDesc, strRegionDesc & ";" & strRegionID
  645. Else
  646. cmdLogError 6088, " - " & gsCurrentPB & "; " & strRegionDesc
  647. cmdImportRegions = 0
  648. Exit Function
  649. End If
  650. End If
  651. End If
  652. End If
  653. End If
  654. Loop
  655. If PerformedDelete Then
  656. If Not ReIndexRegions(dbPB) Then GoTo RegionImport
  657. End If
  658. Close #intRegionFile
  659. cmdLogSuccess 6097
  660. cmdImportRegions = 0
  661. On Error GoTo 0
  662. Exit Function
  663. RegionImport:
  664. cmdLogError 6080, " - " & gsCurrentPB & "; " & LoadResString(6063) & " = " & strRegionID
  665. cmdImportRegions = 0
  666. Exit Function
  667. End Function
  668. Function cmdLogSuccess(ErrorNum As Integer, Optional ErrorMsg As String)
  669. Dim intFile As Integer
  670. Dim strFile As String
  671. On Error GoTo LogErr
  672. gCLError = True
  673. intFile = FreeFile
  674. strFile = locPath & "import.log"
  675. Open strFile For Append As #intFile
  676. On Error GoTo 0
  677. Print #intFile, Now & ", " & gsCurrentPB & ", " & LoadResString(ErrorNum) & ErrorMsg
  678. Close #intFile
  679. Exit Function
  680. LogErr:
  681. Exit Function
  682. End Function
  683. Function cmdPublish(ByVal PhoneBook As String, ByRef dbPB As Database) As Integer
  684. Dim rsConfig As Recordset
  685. Dim Pbversion As Integer
  686. Dim config As Recordset
  687. Dim deltnum, vercheck As Integer
  688. Dim sql1, sql2 As String
  689. Dim vernumsql, mastersql, deltasql As String
  690. Dim deltanum As Integer, vernum As Integer, previousver As Integer
  691. Dim filesaveas As String, i As Integer, verfile As String
  692. Dim fullddffile As String, dtaddffile As String
  693. Dim sShort, sLong As String
  694. Dim strTemp As String
  695. Dim strRelPath As String
  696. Dim strSPCfile As String
  697. Dim strPVKfile As String
  698. Dim filelen As Long
  699. Dim bNewVersion As Boolean
  700. Dim result As Integer
  701. Dim strucFname As OFSTRUCT
  702. Dim strSearchFile As String
  703. Dim strRelativePath As String
  704. Dim configure As Recordset
  705. Dim intX As Integer, previous As Integer
  706. Dim vertualpath As String
  707. Dim strSource As String, strDestination As String
  708. Dim webpostdir As String
  709. Dim webpostdir1 As String
  710. Dim strBaseFile As String
  711. Dim strPBVirPath As String
  712. Dim strPBName As String
  713. Dim postpath As Variant
  714. Dim myValue As Long
  715. Dim intAuthCount As Integer
  716. Dim bErr As Boolean
  717. Dim bTriedRepair As Boolean
  718. Dim intVersion As Integer
  719. Dim intRC As Integer
  720. Dim URL
  721. Set GsysVer = dbPB.OpenRecordset("Select * from PhoneBookVersions order by version", dbOpenDynaset)
  722. Set GsysDelta = dbPB.OpenRecordset("Select * from Delta order by DeltaNum", dbOpenDynaset)
  723. Set rsConfig = dbPB.OpenRecordset("select * from Configuration where Index = 1", dbOpenSnapshot)
  724. Set gsyspb = dbPB
  725. gsCurrentPB = PhoneBook
  726. If GsysVer.RecordCount = 0 Then
  727. Pbversion = 1
  728. Else
  729. GsysVer.MoveLast
  730. Pbversion = GsysVer!version + 1
  731. End If
  732. gBuildDir = rsConfig!PBbuildDir
  733. If IsEmpty(gBuildDir) Or gBuildDir = "" Or IsNull(gBuildDir) Then
  734. gBuildDir = locPath & gsCurrentPB
  735. End If
  736. URL = rsConfig!URL
  737. If CheckPath(gBuildDir) <> 0 Then
  738. cmdLogError 6087
  739. Exit Function
  740. End If
  741. If IsNull(URL) Then
  742. cmdLogError 6087
  743. Exit Function
  744. End If
  745. rsConfig.Close
  746. On Error GoTo ErrTrapFile
  747. gBuildDir = Trim(gBuildDir)
  748. If Right(gBuildDir, 1) = "\" Then
  749. gBuildDir = Left(gBuildDir, Len(gBuildDir) - 1)
  750. End If
  751. strRelPath = gBuildDir & "\"
  752. Set config = dbPB.OpenRecordset("select * from Configuration where Index = 1", dbOpenDynaset)
  753. config.MoveLast
  754. If GsysDelta.RecordCount = 0 Then
  755. deltnum = 1
  756. Else
  757. GsysDelta.MoveLast
  758. deltnum = GsysDelta!deltanum
  759. vercheck = GsysDelta!NewVersion
  760. bNewVersion = False
  761. If Not IsNull(config!NewVersion) Then
  762. If config!NewVersion = 1 Then
  763. bNewVersion = True
  764. End If
  765. End If
  766. If vercheck = 1 And Not bNewVersion Then
  767. cmdLogError (6038)
  768. Exit Function
  769. End If
  770. End If
  771. vernum = Pbversion
  772. mastersql = "SELECT * from DialUpPort where Status = '1' order by AccessNumberId"
  773. Set GsysNDial = dbPB.OpenRecordset(mastersql, dbOpenSnapshot)
  774. If GsysNDial.RecordCount = 0 Then 'master phone file
  775. Set GsysNDial = Nothing
  776. cmdLogError (6039)
  777. Exit Function
  778. Else
  779. sLong = strRelPath
  780. filesaveas = sLong & vernum & "Full.pbk"
  781. verfile = sLong & vernum & ".VER"
  782. Load frmNewVersion
  783. masterOutfile filesaveas, GsysNDial
  784. FileCopy filesaveas, sLong & gsCurrentPB & ".pbk"
  785. frmNewVersion.VersionOutFile verfile, vernum
  786. frmNewVersion.outfullddf sLong, vernum & "Full.pbk", Str(vernum)
  787. frmNewVersion.WriteRegionFile sLong & gsCurrentPB & ".pbr"
  788. If Left(Trim(locPath), 2) <> "\\" Then
  789. ChDrive locPath
  790. End If
  791. ChDir locPath
  792. WaitForApp "full.bat" & " " & _
  793. gQuote & sLong & vernum & "Full.cab" & gQuote & " " & _
  794. gQuote & sLong & vernum & "Full.ddf" & gQuote
  795. End If
  796. 'Check for existence of full.cab
  797. strSearchFile = sLong & vernum & "Full.cab"
  798. result = OpenFile(strSearchFile, strucFname, OF_EXIST)
  799. If result = -1 Then
  800. cmdLogError (6075)
  801. Exit Function
  802. End If
  803. If vernum > 1 Then
  804. deltasql = "Select * from delta order by DeltaNum"
  805. Set GsysNDelta = dbPB.OpenRecordset(deltasql, dbOpenSnapshot)
  806. If GsysNDelta.RecordCount <> 0 Then
  807. GsysNDelta.MoveLast
  808. deltanum = GsysNDelta!deltanum
  809. End If
  810. previousver = vernum - deltanum + 1
  811. For i = 2 To deltanum
  812. deltasql = "Select * from delta where NewVersion <> 1 and DeltaNum = " & i & " order by AccessNumberId"
  813. Set GsysNDelta = dbPB.OpenRecordset(deltasql, dbOpenSnapshot)
  814. filesaveas = sLong & vernum & "DTA" & previousver & ".pbk"
  815. dtaddffile = vernum & "DELTA" & previousver & ".ddf"
  816. deltaoutfile filesaveas, GsysNDelta
  817. frmNewVersion.outdtaddf sLong, dtaddffile, filesaveas, Str(vernum)
  818. WaitForApp "dta.bat" & " " & _
  819. gQuote & sLong & vernum & "DELTA" & previousver & ".cab" & gQuote & " " & _
  820. gQuote & sLong & vernum & "DELTA" & previousver & ".ddf" & gQuote
  821. previousver = previousver + 1
  822. Next i%
  823. End If
  824. Set GsysNDial = Nothing
  825. Set GsysNDelta = Nothing
  826. On Error GoTo ErrTrapPost
  827. bTriedRepair = False
  828. intVersion = Val(Pbversion)
  829. deltanum = GetDeltaCount(intVersion)
  830. postpath = locPath + "pbserver.mdb"
  831. strPBName = gsCurrentPB
  832. strPBVirPath = ReplaceChars(strPBName, " ", "_")
  833. Set configure = dbPB.OpenRecordset("select * from Configuration where Index = 1", dbOpenDynaset)
  834. intRC = frmNewVersion.UpdateHkeeper(postpath, gsCurrentPB, intVersion, strPBVirPath)
  835. ' here's the webpost stuff
  836. webpostdir = gBuildDir & "\" & intVersion & "post"
  837. If CheckPath(webpostdir) = 0 Then
  838. ' dir name in use - rename old
  839. myValue = Hour(Now) * 10000 + Minute(Now) * 100 + Second(Now)
  840. Name webpostdir As webpostdir & "_old_" & myValue
  841. End If
  842. MkDir webpostdir
  843. FileCopy locPath & "pbserver.mdb", webpostdir & "\pbserver.mdb"
  844. ' copy the CABs
  845. FileCopy gBuildDir & "\" & intVersion & "full.cab", webpostdir & "\" & intVersion & "full.cab"
  846. previous = intVersion - deltanum
  847. For intX = 1 To deltanum
  848. strSource = gBuildDir & "\" & intVersion & "delta" & previous & ".cab"
  849. strDestination = webpostdir & "\" & intVersion & "delta" & previous & ".cab"
  850. FileCopy strSource, strDestination
  851. previous = previous + 1
  852. Next intX
  853. intRC = PostFiles(configure!URL, configure!ServerUID, configure!ServerPWD, intVersion, webpostdir, strPBVirPath)
  854. If intRC = 1 Then bErr = True Else bErr = False
  855. If Not bErr Then
  856. GsysVer.AddNew
  857. GsysVer!version = intVersion
  858. GsysVer!CreationDate = Date
  859. GsysVer.Update
  860. Set GsysDelta = dbPB.OpenRecordset("SELECT * FROM delta ORDER BY DeltaNum", dbOpenDynaset)
  861. GsysDelta.MoveLast
  862. deltanum = GsysDelta!deltanum
  863. If deltanum < 6 Then
  864. GsysDelta.AddNew
  865. GsysDelta!deltanum = deltanum + 1
  866. GsysDelta!NewVersion = 1
  867. GsysDelta.Update
  868. Else
  869. sql1 = "DELETE FROM delta WHERE DeltaNum = 1"
  870. dbPB.Execute sql1, dbFailOnError
  871. sql2 = "UPDATE delta SET DeltaNum = DeltaNum - 1"
  872. dbPB.Execute sql2, dbFailOnError
  873. Set GsysDelta = dbPB.OpenRecordset("Select * from Delta order by DeltaNum", dbOpenDynaset)
  874. GsysDelta.AddNew
  875. GsysDelta!deltanum = 6
  876. GsysDelta!NewVersion = 1
  877. GsysDelta.Update
  878. End If
  879. Set GsysDelta = Nothing
  880. End If
  881. If Not bErr Then
  882. cmdLogSuccess 6098
  883. configure.Edit
  884. configure!NewVersion = 0
  885. configure.Update
  886. LogPublish intVersion
  887. End If
  888. configure.Close
  889. Unload frmNewVersion
  890. Exit Function
  891. ErrTrapFile:
  892. Set GsysNDial = Nothing
  893. Set GsysNDelta = Nothing
  894. Select Case Err.Number
  895. Case 3022
  896. cmdLogError (6040)
  897. Case 75
  898. cmdLogError (6041)
  899. Case Else
  900. cmdLogError (6041)
  901. End Select
  902. Exit Function
  903. ErrTrapPost:
  904. Set GsysDelta = Nothing
  905. cmdLogError (6043)
  906. Exit Function
  907. End Function
  908. Public Function PostFiles(ByVal Host As String, ByVal UID As String, ByVal PWD As String, ByVal version As Integer, ByVal PostDir As String, ByVal VirPath As String) As Integer
  909. ' =================================================================================
  910. ' this function handles the
  911. ' POST to the PB Server
  912. '
  913. ' Arguments: host, uid, pwd, version, postdir, virpath
  914. ' Returns: 0 = success
  915. ' 1 = fail
  916. '
  917. ' history: Created April '97 Paul Kreemer
  918. '
  919. ' =================================================================================
  920. Const VROOT As String = "PBSDATA"
  921. Const DIR_DB As String = "DATABASE"
  922. Const LOCALFILE As String = "pbserver.mdb"
  923. Const REMOTEFILE As String = "newpb.mdb"
  924. Dim intAuthCount As Byte
  925. Dim intX As Integer
  926. Dim strBaseFile As String
  927. ' setup the OCX and check for connection
  928. With frmNewVersion.inetOCX
  929. .URL = "ftp://" & Host
  930. .UserName = UID
  931. .Password = PWD
  932. .Protocol = icFTP
  933. .AccessType = icUseDefault
  934. .RequestTimeout = 60
  935. End With
  936. On Error GoTo DirError
  937. frmNewVersion.inetOCX.Execute , "CD /" & VROOT & "/" & VirPath
  938. frmNewVersion.PostWait
  939. ' If the directory doesn't exist then create it
  940. If frmNewVersion.inetOCX.ResponseCode = 12003 Then
  941. frmNewVersion.inetOCX.Execute , "CD /" & VROOT
  942. frmNewVersion.PostWait
  943. If frmNewVersion.inetOCX.ResponseCode = 12003 Then
  944. cmdLogError 6060, " " & Host & " " & frmNewVersion.inetOCX.ResponseInfo
  945. PostFiles = 1
  946. Exit Function
  947. End If
  948. frmNewVersion.inetOCX.Execute , "MKDIR " & VirPath
  949. frmNewVersion.PostWait
  950. If frmNewVersion.inetOCX.ResponseCode = 12003 Then
  951. cmdLogError 6060, " " & Host & " " & frmNewVersion.inetOCX.ResponseInfo
  952. PostFiles = 1
  953. Exit Function
  954. End If
  955. frmNewVersion.inetOCX.Execute , "CD /" & VROOT & "/" & VirPath
  956. frmNewVersion.PostWait
  957. If frmNewVersion.inetOCX.ResponseCode = 12003 Then
  958. cmdLogError 6060, " " & Host & " " & frmNewVersion.inetOCX.ResponseInfo
  959. PostFiles = 1
  960. Exit Function
  961. End If
  962. End If
  963. ' full CAB
  964. frmNewVersion.inetOCX.Execute , "PUT " & gQuote & PostDir & "\" & version & "full.cab" & gQuote & " " & _
  965. version & "full.cab"
  966. frmNewVersion.PostWait
  967. If frmNewVersion.inetOCX.ResponseCode = 12003 Then
  968. cmdLogError 6060, " " & Host & " " & frmNewVersion.inetOCX.ResponseInfo
  969. PostFiles = 1
  970. Exit Function
  971. End If
  972. ' Delta CABs
  973. strBaseFile = version & "delta"
  974. For intX = version - GetDeltaCount(version) To version - 1
  975. frmNewVersion.inetOCX.Execute , "PUT " & gQuote & PostDir & "\" & strBaseFile & intX & ".cab" & gQuote & " " & _
  976. strBaseFile & intX & ".cab"
  977. frmNewVersion.PostWait
  978. Next
  979. If frmNewVersion.inetOCX.ResponseCode = 12003 Then
  980. cmdLogError 6060, " " & Host & " " & frmNewVersion.inetOCX.ResponseInfo
  981. PostFiles = 1
  982. Exit Function
  983. End If
  984. ' go to db dir
  985. frmNewVersion.inetOCX.Execute , "CD /" & VROOT & "/" & DIR_DB
  986. frmNewVersion.PostWait
  987. If frmNewVersion.inetOCX.ResponseCode = 12003 Then
  988. cmdLogError 6060, " " & Host & " " & frmNewVersion.inetOCX.ResponseInfo
  989. PostFiles = 1
  990. Exit Function
  991. End If
  992. 'PBSERVER.mdb (NewPB.mdb)
  993. frmNewVersion.inetOCX.Execute , "PUT " & gQuote & PostDir & "\" & LOCALFILE & gQuote & " " & REMOTEFILE
  994. frmNewVersion.PostWait
  995. If frmNewVersion.inetOCX.ResponseCode = 12003 Then
  996. cmdLogError 6060, " " & Host & " " & frmNewVersion.inetOCX.ResponseInfo
  997. PostFiles = 1
  998. Exit Function
  999. End If
  1000. ' NewPB.txt
  1001. frmNewVersion.inetOCX.Execute , "PUT " & gQuote & gBuildDir & "\" & version & ".ver" & gQuote & " newpb.txt"
  1002. frmNewVersion.PostWait
  1003. If frmNewVersion.inetOCX.ResponseCode = 12003 Then
  1004. cmdLogError 6060, " " & Host & " " & frmNewVersion.inetOCX.ResponseInfo
  1005. PostFiles = 1
  1006. Exit Function
  1007. End If
  1008. frmNewVersion.inetOCX.Execute , "QUIT"
  1009. PostFiles = 0
  1010. Exit Function
  1011. DirError:
  1012. Select Case Err.Number
  1013. Case 35750 To 35755, 35761 'Unable to contact
  1014. cmdLogError 6042
  1015. PostFiles = 1
  1016. Case 35756 To 35760 'Connection Timed Out
  1017. cmdLogError 6043
  1018. PostFiles = 1
  1019. Case Else
  1020. cmdLogError 6043
  1021. PostFiles = 1
  1022. End Select
  1023. End Function
  1024. Function EndApp()
  1025. On Error Resume Next
  1026. OSWinHelp Me.hWnd, App.HelpFile, HelpConstants.cdlHelpQuit, 0
  1027. 'DBEngine.Idle 'dbFreeLocks
  1028. GsysRgn.Close
  1029. Set GsysRgn = Nothing
  1030. GsysCty.Close
  1031. Set GsysCty = Nothing
  1032. GsysDial.Close
  1033. Set GsysDial = Nothing
  1034. GsysVer.Close
  1035. Set GsysVer = Nothing
  1036. GsysDelta.Close
  1037. Set GsysDelta = Nothing
  1038. GsysNRgn.Close
  1039. Set GsysNRgn = Nothing
  1040. GsysNCty.Close
  1041. Set GsysNCty = Nothing
  1042. GsysNDial.Close
  1043. Set GsysNDial = Nothing
  1044. GsysNVer.Close
  1045. Set GsysNVer = Nothing
  1046. GsysNDelta.Close
  1047. Set GsysNDelta = Nothing
  1048. temp.Close
  1049. Set temp = Nothing
  1050. gsyspb.Close
  1051. Set gsyspb = Nothing
  1052. Gsyspbpost.Close
  1053. Set Gsyspbpost = Nothing
  1054. MyWorkspace.Close
  1055. Set MyWorkspace = Nothing
  1056. End
  1057. End Function
  1058. Function FillPBTree() As Integer
  1059. Dim itmX As Node
  1060. Dim varRegKeys As Variant
  1061. Dim intX As Integer
  1062. Dim strPB As String
  1063. Dim strPath As String
  1064. On Error GoTo FillpbTreeErr
  1065. PBTree.Nodes.Clear
  1066. DoEvents
  1067. ' get pb list from registry
  1068. varRegKeys = GetINISetting("Phonebooks", "") 'all settings
  1069. If TypeName(varRegKeys) = Empty Then
  1070. FillPBTree = 1
  1071. Exit Function
  1072. End If
  1073. intX = 0
  1074. Do While varRegKeys(intX, 0) <> Empty
  1075. strPB = Trim(varRegKeys(intX, 1))
  1076. If strPB <> "" And Not IsNull(strPB) Then
  1077. strPath = locPath & strPB
  1078. If CheckPath(strPath) = 0 Then 'verify files
  1079. Set itmX = PBTree.Nodes.Add()
  1080. With itmX
  1081. .Image = 2
  1082. .Text = varRegKeys(intX, 0)
  1083. .Key = varRegKeys(intX, 0)
  1084. End With
  1085. End If
  1086. End If
  1087. intX = intX + 1
  1088. Loop
  1089. PBTree.Sorted = True
  1090. HighlightPB gsCurrentPB
  1091. Exit Function
  1092. FillpbTreeErr:
  1093. FillPBTree = 1
  1094. Exit Function
  1095. 'Set itmX = PBTree.Nodes.Add()
  1096. 'With itmX
  1097. ' .Image = 1
  1098. ' .Text = "Big New Phone Book"
  1099. ' .key = itmX.Text
  1100. 'End With
  1101. 'Set child = PBTree.Nodes.Add(itmX.Index, tvwChild, , "Current Release", 3)
  1102. 'Set child = PBTree.Nodes.Add(itmX.Index, tvwChild, , "Previous Releases", 3)
  1103. 'Set subChild = PBTree.Nodes.Add(child, tvwChild, , "2", 3)
  1104. 'Set subChild = PBTree.Nodes.Add(child, tvwChild, , "1", 3)
  1105. End Function
  1106. Function FillPOPList() As Integer
  1107. Dim sqlstm, strTemp As String
  1108. Dim intRow, intX As Integer
  1109. Dim itmX As ListItem
  1110. On Error GoTo ErrTrap
  1111. If gsCurrentPB = "" Then
  1112. PopList.ListItems.Clear
  1113. Exit Function
  1114. End If
  1115. Me.Enabled = False
  1116. Screen.MousePointer = 11
  1117. sqlstm = "SELECT DISTINCTROW DialUpPort.CityName, Country.CountryName, Region.RegionDesc, DialUpPort.RegionID, DialUpPort.AreaCode, DialUpPort.AccessNumber, DialUpPort.Status, DialUpPort.AccessNumberId " & _
  1118. "FROM (Country INNER JOIN DialUpPort ON Country.CountryNumber = DialUpPort.CountryNumber) LEFT JOIN Region ON DialUpPort.RegionId = Region.RegionId "
  1119. Select Case combosearch.ItemData(combosearch.ListIndex)
  1120. Case 0, -1 '"all pops"
  1121. ' nothing
  1122. Case 1 '"access number"
  1123. sqlstm = sqlstm & " WHERE AccessNumber like '*" & txtsearch.Text & "*" & "'"
  1124. Case 2 '"area code"
  1125. sqlstm = sqlstm & " WHERE AreaCode like '*" & txtsearch.Text & "*" & "'"
  1126. Case 3 '"country"
  1127. sqlstm = sqlstm & " WHERE CountryName like '*" & txtsearch.Text & "*" & "'"
  1128. Case 4 '"pop name"
  1129. sqlstm = sqlstm & " WHERE CityName like '*" & txtsearch.Text & "*" & "'"
  1130. Case 5 '"region"
  1131. sqlstm = sqlstm & " WHERE RegionDesc like '*" & txtsearch.Text & "*" & "'"
  1132. Case 6 '"status"
  1133. strTemp = ""
  1134. For intX = 0 To 1
  1135. If InStr(LCase(gStatusText(intX)), Trim(LCase(txtsearch.Text))) <> 0 Then
  1136. If strTemp = "" Then
  1137. strTemp = Trim(Str(intX))
  1138. Else
  1139. strTemp = "*"
  1140. End If
  1141. End If
  1142. Next
  1143. If strTemp = "" Then
  1144. PopList.ListItems.Clear
  1145. Me.Enabled = True
  1146. Screen.MousePointer = 0
  1147. Exit Function
  1148. End If
  1149. sqlstm = sqlstm & " WHERE Status like '" & strTemp & "'"
  1150. End Select
  1151. sqlstm = sqlstm & ";"
  1152. Set GsysNDial = gsyspb.OpenRecordset(sqlstm, dbOpenSnapshot)
  1153. If GsysNDial.BOF = False Then
  1154. GsysNDial.MoveLast
  1155. If GsysNDial.RecordCount > 50 Then RefreshPBLabel "loading"
  1156. PopList.ListItems.Clear
  1157. PopList.Sorted = False
  1158. GsysNDial.MoveFirst
  1159. Do While Not GsysNDial.EOF
  1160. Set itmX = PopList.ListItems.Add()
  1161. With itmX
  1162. .Text = GsysNDial!CityName
  1163. .SubItems(1) = GsysNDial!AreaCode
  1164. .SubItems(2) = GsysNDial!AccessNumber
  1165. .SubItems(3) = GsysNDial!countryname
  1166. intX = GsysNDial!RegionID
  1167. Select Case intX
  1168. Case 0, -1
  1169. .SubItems(4) = gRegionText(intX)
  1170. Case Else
  1171. .SubItems(4) = GsysNDial!RegionDesc
  1172. End Select
  1173. .SubItems(5) = gStatusText(GsysNDial!status)
  1174. strTemp = "Key:" & GsysNDial!AccessNumberId
  1175. .Key = strTemp
  1176. End With
  1177. If GsysNDial.AbsolutePosition Mod 300 = 0 Then DoEvents
  1178. GsysNDial.MoveNext
  1179. Loop
  1180. Else
  1181. PopList.ListItems.Clear
  1182. End If
  1183. PopList.Sorted = True
  1184. Me.Enabled = True
  1185. Screen.MousePointer = 0
  1186. Exit Function
  1187. ErrTrap:
  1188. Me.Enabled = True
  1189. FillPOPList = 1
  1190. Screen.MousePointer = 0
  1191. Exit Function
  1192. End Function
  1193. Function HighlightPB(strPBName As String) As Integer
  1194. ' highlight pb in tree view control
  1195. ' and clear the other nodes image setting.
  1196. Dim intX As Integer
  1197. For intX = 1 To PBTree.Nodes.Count
  1198. PBTree.Nodes(intX).Image = 2
  1199. If PBTree.Nodes(intX).Key = strPBName Then
  1200. PBTree.Nodes(intX).Image = 1
  1201. PBTree.Nodes(intX).Selected = True
  1202. PBTree.Nodes(intX).EnsureVisible
  1203. End If
  1204. Next
  1205. RefreshPBLabel ""
  1206. End Function
  1207. Function LoadMainRes() As Integer
  1208. Dim cRef As Integer
  1209. Dim intX As Integer
  1210. On Error GoTo ResErr
  1211. cRef = 3010
  1212. 'global status text array
  1213. gStatusText(0) = LoadResString(4061)
  1214. gStatusText(1) = LoadResString(4060)
  1215. 'gRegionText(-1) = LoadResString(4063)
  1216. gRegionText(0) = LoadResString(4063)
  1217. PBListLabel.Caption = LoadResString(cRef + 0)
  1218. FilterFrame.Caption = LoadResString(cRef + 1)
  1219. FilterLabel.Caption = LoadResString(cRef + 2)
  1220. SearchLabel.Caption = LoadResString(cRef + 3)
  1221. cmbsearch.Caption = LoadResString(cRef + 4)
  1222. cmbadd.Caption = LoadResString(cRef + 5)
  1223. cmbEdit.Caption = LoadResString(cRef + 6)
  1224. cmdDelete.Caption = LoadResString(cRef + 7)
  1225. 'column headers
  1226. For intX = 1 To 6
  1227. PopList.ColumnHeaders(intX).Text = LoadResString(cRef + 7 + intX)
  1228. Next
  1229. ' pop search list
  1230. For intX = 0 To 6
  1231. combosearch.AddItem LoadResString(cRef + 15 + intX)
  1232. combosearch.ItemData(combosearch.NewIndex) = intX
  1233. Next
  1234. combosearch.Text = LoadResString(cRef + 15)
  1235. 'menus
  1236. file.Caption = LoadResString(cRef + 22)
  1237. m_edit.Caption = LoadResString(cRef + 23)
  1238. m_tools.Caption = LoadResString(cRef + 24)
  1239. help.Caption = LoadResString(cRef + 25)
  1240. m_addpb.Caption = LoadResString(cRef + 26)
  1241. m_copypb.Caption = LoadResString(cRef + 27)
  1242. m_removepb.Caption = LoadResString(cRef + 28)
  1243. m_exit.Caption = LoadResString(cRef + 29)
  1244. m_addpop.Caption = LoadResString(cRef + 30)
  1245. m_editpop.Caption = LoadResString(cRef + 31)
  1246. m_delpop.Caption = LoadResString(cRef + 32)
  1247. m_buildPhone.Caption = LoadResString(cRef + 33)
  1248. viewChange.Caption = LoadResString(cRef + 34)
  1249. m_editRegion.Caption = LoadResString(cRef + 36)
  1250. m_options.Caption = LoadResString(cRef + 37)
  1251. contents.Caption = LoadResString(cRef + 38)
  1252. about.Caption = LoadResString(cRef + 39)
  1253. m_printpops.Caption = LoadResString(cRef + 40)
  1254. m_viewlog.Caption = LoadResString(cRef + 41)
  1255. m_whatsthis.Caption = LoadResString(cRef + 42)
  1256. ' set fonts
  1257. SetFonts Me
  1258. PopList.Font.Charset = gfnt.Charset
  1259. PopList.Font.Name = gfnt.Name
  1260. PopList.Font.Size = gfnt.Size
  1261. LoadMainRes = 0
  1262. On Error GoTo 0
  1263. Exit Function
  1264. ResErr:
  1265. LoadMainRes = 1
  1266. Exit Function
  1267. End Function
  1268. Function RefreshPBLabel(ByVal Action As String) As Integer
  1269. On Error GoTo LabelErr
  1270. If gsCurrentPB <> "" Then
  1271. Select Case Action
  1272. Case "loading"
  1273. PBLabel.Caption = " " & LoadResString(3061) & " " & gsCurrentPB
  1274. Case Else
  1275. PBLabel.Caption = " " & gsCurrentPB & " - [" & combosearch.Text & "]"
  1276. End Select
  1277. Else
  1278. PBLabel.Caption = " " & LoadResString(3060) & " "
  1279. End If
  1280. DoEvents
  1281. On Error GoTo 0
  1282. Exit Function
  1283. LabelErr:
  1284. Exit Function
  1285. End Function
  1286. Function RemovePB() As Integer
  1287. ' get the open phonebook and ask if it should
  1288. ' be removed. clean out pbserver.mdb
  1289. Dim varRegKeys As Variant
  1290. Dim intRC As Integer
  1291. On Error GoTo delErr
  1292. If gsCurrentPB = "" Then Exit Function
  1293. intRC = MsgBox(LoadResString(4066) & Chr(13) & Chr(13) & gsCurrentPB & Chr(13) & Chr(13) & LoadResString(4088), vbQuestion + 4 + 256)
  1294. If intRC = 6 Then
  1295. DBEngine.Idle
  1296. gsyspb.Close
  1297. Set gsyspb = Nothing
  1298. Kill gsCurrentPBPath
  1299. ' delete entry and flush out INI edits
  1300. OSWritePrivateProfileString "Phonebooks", gsCurrentPB, vbNullString, locPath & gsRegAppTitle & ".ini"
  1301. OSWritePrivateProfileString vbNullString, vbNullString, vbNullString, locPath & gsRegAppTitle & ".ini"
  1302. ' clear hkeeper
  1303. Set Gsyspbpost = DBEngine.Workspaces(0).OpenDatabase(locPath + "pbserver.mdb")
  1304. DBEngine.Idle
  1305. Gsyspbpost.Execute "DELETE from Phonebooks WHERE ISPid = (select ISPid from ISPs where Description ='" & gsCurrentPB & "')", dbFailOnError
  1306. Gsyspbpost.Execute "DELETE from ISPs WHERE Description = '" & gsCurrentPB & "'", dbFailOnError
  1307. Gsyspbpost.Close
  1308. Set Gsyspbpost = Nothing
  1309. If SetCurrentPB("") = 0 Then
  1310. PopList.ListItems.Clear
  1311. FillPBTree
  1312. RefreshButtons
  1313. End If
  1314. End If
  1315. Exit Function
  1316. delErr:
  1317. Exit Function
  1318. End Function
  1319. Function RunCommandLine() As Integer
  1320. ' this function manages the no-GUI, command-line
  1321. ' execution of PBAdmin.exe
  1322. Dim ArgArray As Variant
  1323. Dim strArg As String
  1324. Dim bImport, bImportPBK, bImportRegions, bPublish, bNewDB As Boolean
  1325. Dim bHelp As Boolean
  1326. Dim bSetOptions As Boolean
  1327. Dim strPhoneBook, strPBPath As String
  1328. Dim strPBKFile, strRegionFile As String
  1329. Dim strNewDB As String
  1330. Dim strURL As String
  1331. Dim strUser As String
  1332. Dim strPassword As String
  1333. Dim intX, intRC As Integer
  1334. Dim dbPB As Database
  1335. Dim RetVal As Integer
  1336. On Error GoTo RunErr
  1337. ArgArray = GetCommandLine
  1338. If UBound(ArgArray) = 0 Then
  1339. RunCommandLine = 0
  1340. Exit Function
  1341. End If
  1342. 'MsgBox str(Asc(ArgArray(0)))
  1343. 'If ArgArray(0) = "" Then
  1344. ' RunCommandLine = 0
  1345. ' Exit Function
  1346. 'End If
  1347. strPhoneBook = ""
  1348. intX = 1
  1349. Do While intX <= UBound(ArgArray)
  1350. Select Case ArgArray(intX)
  1351. Case "/?"
  1352. ' list switches
  1353. bHelp = True
  1354. Case "/I"
  1355. intX = intX + 1
  1356. strPhoneBook = ArgArray(intX)
  1357. bImport = True
  1358. Case "/P"
  1359. intX = intX + 1
  1360. strPBKFile = ArgArray(intX)
  1361. bImportPBK = True
  1362. Case "/R"
  1363. intX = intX + 1
  1364. strRegionFile = ArgArray(intX)
  1365. bImportRegions = True
  1366. Case "/B"
  1367. intX = intX + 1
  1368. strPhoneBook = ArgArray(intX)
  1369. bPublish = True
  1370. Case "/N"
  1371. intX = intX + 1
  1372. strNewDB = ArgArray(intX)
  1373. bNewDB = True
  1374. Case "/O"
  1375. intX = intX + 1
  1376. strPhoneBook = ArgArray(intX)
  1377. intX = intX + 1
  1378. strURL = ArgArray(intX)
  1379. intX = intX + 1
  1380. strUser = ArgArray(intX)
  1381. intX = intX + 1
  1382. strPassword = ArgArray(intX)
  1383. bSetOptions = True
  1384. Case Else
  1385. bHelp = True
  1386. End Select
  1387. intX = intX + 1
  1388. Loop
  1389. If bHelp Then
  1390. MsgBox LoadResString(6057), vbInformation
  1391. End
  1392. End If
  1393. If strPhoneBook <> "" Then ' open database
  1394. If Right(strPhoneBook, 4) = ".mdb" Then
  1395. strPhoneBook = Left(strPhoneBook, Len(strPhoneBook) - 4)
  1396. End If
  1397. strPBPath = GetLocalPath & strPhoneBook
  1398. If CheckPath(strPBPath) <> 0 Then
  1399. cmdLogError 6082, " - " & strPhoneBook
  1400. End
  1401. End If
  1402. gsCurrentPB = strPhoneBook
  1403. On Error Resume Next
  1404. ConvertDatabaseIfNeeded DBEngine.Workspaces(0), strPBPath & ".mdb", dbDriverNoPrompt, False
  1405. Set dbPB = DBEngine.Workspaces(0).OpenDatabase(strPBPath & ".mdb", dbDriverNoPrompt, False, DBPassword)
  1406. ' Cannot open same object twice & close it twice. Otherwise you
  1407. ' will get a runtime error. v-vijayb 6/11/99
  1408. Set gsyspb = dbPB
  1409. 'Set gsyspb = DBEngine.Workspaces(0).OpenDatabase(strPBPath & ".mdb")
  1410. If Err.Number <> 0 Then
  1411. Select Case Err.Number
  1412. Case 3051
  1413. cmdLogError 6027, " - " & gsCurrentPB
  1414. End
  1415. Case 3343
  1416. cmdLogError 6028, " - " & gsCurrentPB
  1417. End
  1418. Case 3045
  1419. cmdLogError 6029, " - " & gsCurrentPB
  1420. End
  1421. Case Else
  1422. cmdLogError 6030, " - " & gsCurrentPB
  1423. End
  1424. End Select
  1425. End If
  1426. On Error GoTo RunErr
  1427. 'import regions
  1428. If bImportRegions Then
  1429. If cmdImportRegions(strRegionFile, dbPB) <> 0 Then
  1430. dbPB.Close
  1431. cmdLogError 6080
  1432. End
  1433. End If
  1434. End If
  1435. 'import pbk/pbd
  1436. If bImportPBK Then
  1437. If cmdImportPBK(strPBKFile, dbPB) <> 0 Then
  1438. 'error
  1439. dbPB.Close
  1440. cmdLogError 6080
  1441. End
  1442. End If
  1443. End If
  1444. 'publish: UpdateHkeeper
  1445. If bPublish Then
  1446. If cmdPublish(strPhoneBook, dbPB) <> 0 Then
  1447. dbPB.Close
  1448. cmdLogError 6081
  1449. End 'error
  1450. End If
  1451. End If
  1452. If bSetOptions Then
  1453. SetOptions strURL, strUser, strPassword
  1454. End If
  1455. dbPB.Close
  1456. 'gsyspb.Close
  1457. Else
  1458. ' Create a new PB
  1459. If bNewDB Then
  1460. CreatePB (strNewDB)
  1461. Else
  1462. If bImportPBK Or bImportRegions Then
  1463. cmdLogError 6092
  1464. Else
  1465. cmdLogError 6093
  1466. End If
  1467. End If
  1468. End If
  1469. End
  1470. Exit Function
  1471. RunErr:
  1472. cmdLogError 6081
  1473. End
  1474. End Function
  1475. Function SetCurrentPB(ByVal strPBName As String) As Integer
  1476. ' all phonebooks are in app directory, for now.
  1477. ' the registry layout does allow storing them anywhere, with
  1478. ' any name, excepting pbserver.mdb and hkeeper.mdb.
  1479. Dim strPBFile, strPath As String
  1480. Dim rsTest As Recordset
  1481. On Error GoTo SetCurrentPBErr
  1482. If strPBName = gsCurrentPB Then
  1483. Exit Function
  1484. ElseIf strPBName = "" Then
  1485. strPBFile = ""
  1486. Else
  1487. strPBFile = GetINISetting("Phonebooks", strPBName)
  1488. If CheckPath(locPath & strPBFile) <> 0 Then
  1489. strPBFile = ""
  1490. End If
  1491. End If
  1492. 'close old Phone Book
  1493. gsCurrentPBPath = ""
  1494. gsCurrentPB = ""
  1495. FillPOPList
  1496. DBEngine.Idle
  1497. Set MyWorkspace = Nothing
  1498. If strPBFile = "" And strPBName <> "" Then ' bad pb, delete entry
  1499. On Error GoTo DelSettingErr
  1500. OSWritePrivateProfileString "Phonebooks", strPBName, vbNullString, locPath & gsRegAppTitle & ".ini"
  1501. OSWritePrivateProfileString vbNullString, vbNullString, vbNullString, locPath & gsRegAppTitle & ".ini"
  1502. strPBName = ""
  1503. strPath = ""
  1504. MsgBox LoadResString(6026), vbExclamation
  1505. FillPBTree
  1506. Else ' looking good
  1507. Set MyWorkspace = Workspaces(0)
  1508. strPath = locPath & strPBFile
  1509. On Error GoTo BadFileErr
  1510. ConvertDatabaseIfNeeded MyWorkspace, strPath, dbDriverNoPrompt, False
  1511. Set gsyspb = MyWorkspace.OpenDatabase(strPath, dbDriverNoPrompt, False, DBPassword) 'exclusive
  1512. Set rsTest = gsyspb.OpenRecordset("select * from Configuration", dbOpenSnapshot)
  1513. rsTest.Close
  1514. Set rsTest = Nothing
  1515. DBEngine.Idle 'dbFreeLocks
  1516. 'UpgradePB
  1517. End If
  1518. On Error GoTo SetCurrentPBErr
  1519. gsCurrentPBPath = strPath
  1520. gsCurrentPB = strPBName
  1521. If FillPOPList <> 0 Then
  1522. MsgBox LoadResString(6030), vbExclamation
  1523. gsCurrentPB = ""
  1524. SetCurrentPB = 1
  1525. End If
  1526. OSWritePrivateProfileString "General", "LastPhonebookUsed", gsCurrentPB, locPath & gsRegAppTitle & ".ini"
  1527. OSWritePrivateProfileString vbNullString, vbNullString, vbNullString, locPath & gsRegAppTitle & ".ini"
  1528. HighlightPB strPBName
  1529. RefreshButtons
  1530. selection = 0
  1531. updateFound = 0
  1532. On Error GoTo 0
  1533. Exit Function
  1534. SetCurrentPBErr:
  1535. SetCurrentPB = 1
  1536. Exit Function
  1537. BadFileErr:
  1538. If strPBName <> "" Then
  1539. Select Case Err.Number
  1540. Case 3051
  1541. MsgBox LoadResString(6027) & _
  1542. Chr(13) & Chr(13) & strPath, vbInformation
  1543. Case 3343
  1544. MsgBox LoadResString(6028) & _
  1545. Chr(13) & Chr(13) & strPath, vbExclamation
  1546. Case 3045
  1547. MsgBox LoadResString(6029) & Chr(13) & Chr(13) & Err.Description, vbInformation
  1548. Case Else
  1549. MsgBox LoadResString(6030) & Chr(13) & Chr(13) & Err.Description, vbExclamation
  1550. End Select
  1551. End If
  1552. strPBName = ""
  1553. strPath = ""
  1554. Resume Next
  1555. DelSettingErr:
  1556. Resume Next
  1557. End Function
  1558. Function Startup() As Integer
  1559. ' handle all app init here
  1560. Dim intRC As Integer
  1561. Dim varPhonebooks, varLastPB As Variant
  1562. Dim bTriedReg As Boolean
  1563. On Error GoTo StartupErr
  1564. ' set global values
  1565. gsRegAppTitle = "PBAdmin"
  1566. gsCurrentPB = "-"
  1567. gQuote = Chr(34)
  1568. gCLError = False
  1569. GetFont gfnt
  1570. LoadMainRes 'load labels
  1571. DoEvents
  1572. ' Check for required files
  1573. GetLocalPath
  1574. On Error GoTo HelpFileErr
  1575. App.HelpFile = locPath & gsRegAppTitle & ".hlp"
  1576. HTMLHelpFile = GetWinDir & "\help\cps_ops.chm"
  1577. On Error GoTo HkeeperErr
  1578. Set Gsyspbpost = DBEngine.Workspaces(0).OpenDatabase(locPath & "pbserver.mdb")
  1579. Gsyspbpost.Close
  1580. 'DBEngine.Idle
  1581. On Error GoTo Empty_PBErr
  1582. Set Gsyspbpost = DBEngine.Workspaces(0).OpenDatabase(locPath & "Empty_PB.mdb")
  1583. Gsyspbpost.Close
  1584. App.title = LoadResString(1001)
  1585. 'cmd line processing
  1586. On Error GoTo CmdErr
  1587. RunCommandLine
  1588. On Error GoTo StartupErr
  1589. frmMain.Show
  1590. 'kludge to set the font property of these two controls
  1591. PBTree.Font.Charset = gfnt.Charset
  1592. PBTree.Font.Name = gfnt.Name
  1593. PBTree.Font.Size = gfnt.Size
  1594. PBLabel.Font.Charset = gfnt.Charset
  1595. PBLabel.Font.Name = gfnt.Name
  1596. PBLabel.Font.Size = gfnt.Size
  1597. intRC = FillPBTree
  1598. 'get last used phone book and make it current
  1599. varLastPB = GetINISetting("General", "LastPhonebookUsed")
  1600. If IsNull(varLastPB) Then
  1601. ' fallback to first pb in list
  1602. varPhonebooks = GetINISetting("Phonebooks", "")
  1603. If TypeName(varPhonebooks) <> Empty And Not IsNull(varPhonebooks) Then
  1604. varLastPB = varPhonebooks(0, 0)
  1605. Else
  1606. varLastPB = ""
  1607. End If
  1608. End If
  1609. PBLabel.Visible = True
  1610. ' set misc
  1611. Me.Caption = App.title
  1612. SetCurrentPB varLastPB
  1613. RefreshButtons
  1614. On Error GoTo 0
  1615. Exit Function
  1616. StartupErr:
  1617. Startup = 1
  1618. Exit Function
  1619. HelpFileErr:
  1620. MsgBox LoadResString(6031), vbExclamation
  1621. App.HelpFile = ""
  1622. Resume Next
  1623. HkeeperErr:
  1624. ' problem w/ hkeeper.mdb. this is the first DAO test so first try to
  1625. ' reregister the dao dll. if that fails then display message and end.
  1626. If CheckPath(locPath & "pbserver.mdb") <> 0 Or bTriedReg Then
  1627. MsgBox LoadResString(6032) & Chr(13) & locPath & "pbserver.mdb", vbCritical
  1628. End
  1629. Else
  1630. Dim strDAOPath As String
  1631. Dim lngValue As Long
  1632. 'strDAOPath = RegGetValue("Software\Microsoft\Shared Tools\DAO", "Path")
  1633. 'strDAOPath = GetMyShortPath(strDAOPath)
  1634. bTriedReg = True
  1635. If Not (IsNull(strDAOPath) Or strDAOPath = "") Then
  1636. WaitForApp "regsvr32 /s " & strDAOPath
  1637. Set Gsyspbpost = DBEngine.Workspaces(0).OpenDatabase(locPath & "pbserver.mdb")
  1638. Resume Next
  1639. Else
  1640. GoTo HkeeperErr
  1641. End If
  1642. End If
  1643. Empty_PBErr:
  1644. MsgBox LoadResString(6032) & Chr(13) & locPath & "Empty_PB.mdb", vbCritical
  1645. End
  1646. CmdErr:
  1647. ' error processing commandline
  1648. End
  1649. End Function
  1650. Function GetCommandLine(Optional MaxArgs)
  1651. 'Declare variables.
  1652. Dim C, CmdLine, CmdLnLen, InArg, i, NumArgs
  1653. 'See if MaxArgs was provided.
  1654. If IsMissing(MaxArgs) Then MaxArgs = 10
  1655. 'Make array of the correct size.
  1656. ReDim ArgArray(MaxArgs)
  1657. NumArgs = 0: InArg = False
  1658. 'Get command line arguments.
  1659. CmdLine = Command()
  1660. CmdLnLen = Len(CmdLine)
  1661. 'Go thru command line one character
  1662. 'at a time.
  1663. For i = 1 To CmdLnLen
  1664. C = Mid(CmdLine, i, 1)
  1665. 'Test for space or tab.
  1666. If (C <> " " And C <> vbTab) Then
  1667. 'Neither space nor tab.
  1668. 'Test if already in argument.
  1669. If Not InArg Then
  1670. 'New argument begins.
  1671. 'Test for too many arguments.
  1672. If NumArgs = MaxArgs Then Exit For
  1673. NumArgs = NumArgs + 1
  1674. InArg = True
  1675. End If
  1676. 'Concatenate character to current argument.
  1677. ArgArray(NumArgs) = ArgArray(NumArgs) & C
  1678. Else
  1679. 'Found a space or tab.
  1680. 'Set InArg flag to False.
  1681. InArg = False
  1682. End If
  1683. Next i
  1684. 'Resize array just enough to hold arguments.
  1685. ReDim Preserve ArgArray(NumArgs)
  1686. 'Return Array in Function name.
  1687. GetCommandLine = ArgArray()
  1688. End Function
  1689. Private Sub about_Click()
  1690. frmabout.Show vbModal
  1691. End Sub
  1692. Private Sub cmbsearch_GotFocus()
  1693. cmbEdit.Enabled = False
  1694. cmdDelete.Enabled = False
  1695. m_editpop.Enabled = False
  1696. m_delpop.Enabled = False
  1697. End Sub
  1698. Private Sub combosearch_GotFocus()
  1699. cmbEdit.Enabled = False
  1700. cmdDelete.Enabled = False
  1701. m_editpop.Enabled = False
  1702. m_delpop.Enabled = False
  1703. End Sub
  1704. Private Sub Form_KeyPress(KeyAscii As Integer)
  1705. CheckChar KeyAscii
  1706. End Sub
  1707. Private Sub Form_Unload(Cancel As Integer)
  1708. EndApp
  1709. End Sub
  1710. Private Sub m_addpop_Click()
  1711. cmbadd_Click
  1712. End Sub
  1713. Private Sub m_buildPhone_Click()
  1714. Screen.MousePointer = 11
  1715. frmNewVersion.Show vbModal
  1716. RefreshButtons
  1717. End Sub
  1718. Private Sub cmbadd_Click()
  1719. 'Dim strReturn As String
  1720. 'Dim lngBuffer As Long
  1721. 'Dim lngRC As Long
  1722. 'strReturn = Space(50)
  1723. 'lngBuffer = Len(strReturn)
  1724. 'lngRC = WNetGetConnection(txtsearch.Text, strReturn, lngBuffer)
  1725. 'MsgBox strReturn & " id:" & lngRC, , "wnetgetconnection"
  1726. 'Exit sub
  1727. frmPopInsert.Show vbModal
  1728. RefreshButtons
  1729. End Sub
  1730. Private Sub cmbEdit_Click()
  1731. If updateFound = 0 Then Exit Sub
  1732. frmupdate.Show vbModal
  1733. End Sub
  1734. Private Sub cmbsearch_Click()
  1735. Screen.MousePointer = 11
  1736. cmbsearch.Enabled = False
  1737. updateFound = 0 ' clear the pop-selected variables
  1738. selection = 0
  1739. If FillPOPList = 0 Then
  1740. RefreshPBLabel ""
  1741. RefreshButtons
  1742. End If
  1743. cmbsearch.Enabled = True
  1744. Screen.MousePointer = 0
  1745. End Sub
  1746. Private Sub cmdDelete_Click()
  1747. Dim response As Integer, deltnum As Integer
  1748. Dim Message As String, title As String, dialogtype As Long
  1749. Dim i As Integer, deltasql As String, deltafind As Integer
  1750. Dim deletecheck As Recordset
  1751. Dim statuscheck As Integer
  1752. On Error GoTo ErrTrap
  1753. Set GsysDial = gsyspb.OpenRecordset("select * from Dialupport where accessnumberId = " & selection, dbOpenSnapshot)
  1754. If GsysDial.EOF And GsysDial.BOF Then Exit Sub
  1755. If updateFound = GsysDial!AccessNumberId Then
  1756. Message = LoadResString(6033)
  1757. dialogtype = vbYesNo + vbQuestion + vbDefaultButton2
  1758. response = MsgBox(Message, dialogtype)
  1759. If response = 6 Then
  1760. Screen.MousePointer = 11
  1761. statuscheck = 0
  1762. If GsysDial!status = "1" Then
  1763. statuscheck = 1
  1764. End If
  1765. gsyspb.Execute "DELETE from DialUpPort where AccessNumberId = " & updateFound
  1766. If statuscheck = 1 Then
  1767. 'insert the delta table
  1768. Set GsysDelta = gsyspb.OpenRecordset("Select * from Delta order by DeltaNum", dbOpenDynaset)
  1769. If GsysDelta.RecordCount = 0 Then
  1770. deltnum = 1
  1771. Else
  1772. GsysDelta.MoveLast
  1773. deltnum = GsysDelta!deltanum
  1774. If deltnum > 6 Then
  1775. deltnum = deltnum - 1
  1776. End If
  1777. End If
  1778. For i = 1 To deltnum
  1779. deltasql = "Select * from delta where DeltaNum = " & i% & _
  1780. " AND AccessNumberId = '" & updateFound & "' " & _
  1781. " order by DeltaNum"
  1782. Set GsysDelta = gsyspb.OpenRecordset(deltasql, dbOpenDynaset)
  1783. If Not (GsysDelta.BOF And GsysDelta.EOF) Then
  1784. GsysDelta.Edit
  1785. Else
  1786. GsysDelta.AddNew
  1787. GsysDelta!deltanum = i%
  1788. GsysDelta!AccessNumberId = updateFound
  1789. End If
  1790. GsysDelta!CountryNumber = 0
  1791. GsysDelta!AreaCode = 0
  1792. GsysDelta!AccessNumber = 0
  1793. GsysDelta!MinimumSpeed = 0
  1794. GsysDelta!MaximumSpeed = 0
  1795. GsysDelta!RegionID = 0
  1796. GsysDelta!CityName = "0"
  1797. GsysDelta!ScriptID = "0"
  1798. GsysDelta!Flags = 0
  1799. GsysDelta.Update
  1800. Next i%
  1801. End If
  1802. Set deletecheck = gsyspb.OpenRecordset("DialUpPort", dbOpenSnapshot)
  1803. If deletecheck.RecordCount = 0 Then
  1804. gsyspb.Execute "DELETE from PhoneBookVersions"
  1805. gsyspb.Execute "DELETE from delta"
  1806. End If
  1807. Else
  1808. Exit Sub
  1809. End If
  1810. LogPOPDelete GsysDial
  1811. GsysDial.Close
  1812. Set GsysDial = Nothing
  1813. PopList.ListItems.Remove "Key:" & updateFound
  1814. selection = 0
  1815. updateFound = 0
  1816. RefreshButtons
  1817. frmMain.PopList.SetFocus
  1818. Screen.MousePointer = 0
  1819. End If
  1820. On Error GoTo 0
  1821. Exit Sub
  1822. ErrTrap:
  1823. Screen.MousePointer = 0
  1824. MsgBox LoadResString(6056) & Chr(13) & Chr(13) & Err.Description, vbExclamation
  1825. Exit Sub
  1826. End Sub
  1827. Private Sub combosearch_Click()
  1828. If combosearch.Text = LoadResString(3025) Then
  1829. txtsearch.Enabled = False
  1830. SearchLabel.Enabled = False
  1831. Else
  1832. txtsearch.Enabled = True
  1833. SearchLabel.Enabled = True
  1834. End If
  1835. RefreshButtons
  1836. End Sub
  1837. Private Sub contents_Click()
  1838. 'OSWinHelp Me.hWnd, App.HelpFile, HelpConstants.cdlHelpContents, 0
  1839. HtmlHelp Me.hWnd, HTMLHelpFile & ">proc4", HH_DISPLAY_TOPIC, CStr("cps_topnode.htm")
  1840. End Sub
  1841. Private Sub Form_Load()
  1842. Dim cRef As Integer
  1843. On Error GoTo LoadErr
  1844. 'If App.PrevInstance Then
  1845. ' MsgBox LoadResString(6035), vbExclamation
  1846. ' End
  1847. 'End If
  1848. Screen.MousePointer = 11
  1849. CenterForm Me, Screen
  1850. If Startup <> 0 Then
  1851. 'If 0 = 1 Then
  1852. Screen.MousePointer = 0
  1853. MsgBox LoadResString(6036), vbCritical
  1854. End
  1855. End If
  1856. Screen.MousePointer = 0
  1857. On Error GoTo 0
  1858. Exit Sub
  1859. LoadErr:
  1860. Screen.MousePointer = 0
  1861. Exit Sub
  1862. End Sub
  1863. Private Sub m_addpb_Click()
  1864. Dim strNewPB As String
  1865. Dim itmX As Node
  1866. On Error GoTo AddPBErr
  1867. frmNewPB.Show vbModal
  1868. strNewPB = frmNewPB.strPB
  1869. Unload frmNewPB
  1870. If strNewPB <> "" Then
  1871. SetCurrentPB strNewPB
  1872. FillPBTree
  1873. 'frmcab.Show vbModal ' show options page
  1874. End If
  1875. Exit Sub
  1876. AddPBErr:
  1877. Exit Sub
  1878. End Sub
  1879. Private Sub m_copypb_Click()
  1880. Dim intRC As Integer
  1881. Dim strNewPB As String
  1882. Dim itmX As Node
  1883. On Error GoTo CopyPBErr
  1884. frmCopyPB.Show vbModal
  1885. strNewPB = frmCopyPB.strPB
  1886. Unload frmCopyPB
  1887. If strNewPB <> "" Then
  1888. SetCurrentPB strNewPB
  1889. FillPBTree
  1890. 'frmcab.Show vbModal
  1891. End If
  1892. Exit Sub
  1893. CopyPBErr:
  1894. Exit Sub
  1895. End Sub
  1896. Private Sub m_delpop_Click()
  1897. cmdDelete_Click
  1898. End Sub
  1899. Private Sub m_editpop_Click()
  1900. cmbEdit_Click
  1901. End Sub
  1902. Private Sub m_editRegion_Click()
  1903. Screen.MousePointer = 11
  1904. frmLoadRegion.Show vbModal
  1905. End Sub
  1906. Private Sub m_exit_Click()
  1907. EndApp
  1908. End Sub
  1909. Private Sub m_printpops_Click()
  1910. On Error GoTo ErrTrap
  1911. Screen.MousePointer = 13
  1912. m_printpops.Enabled = False
  1913. ' popup print screen and let it print
  1914. Load frmPrinting
  1915. frmPrinting.JobType = 2
  1916. frmPrinting.Show vbModal
  1917. m_printpops.Enabled = True
  1918. Screen.MousePointer = 0
  1919. Exit Sub
  1920. ErrTrap:
  1921. m_printpops.Enabled = True
  1922. Screen.MousePointer = 0
  1923. Exit Sub
  1924. End Sub
  1925. Private Sub m_removepb_Click()
  1926. RemovePB
  1927. End Sub
  1928. Private Sub m_options_Click()
  1929. Screen.MousePointer = 11
  1930. frmcab.Show vbModal
  1931. End Sub
  1932. Private Sub m_viewlog_Click()
  1933. Dim strFile As String
  1934. Dim intFile As Integer
  1935. On Error GoTo LogErr
  1936. strFile = locPath & gsCurrentPB & "\" & gsCurrentPB & ".log"
  1937. If CheckPath(strFile) <> 0 Then
  1938. MakeLogFile gsCurrentPB
  1939. End If
  1940. Shell "notepad " & strFile, vbNormalFocus
  1941. On Error GoTo 0
  1942. Exit Sub
  1943. LogErr:
  1944. MsgBox LoadResString(6053), vbExclamation
  1945. Exit Sub
  1946. End Sub
  1947. Private Sub m_whatsthis_Click()
  1948. frmMain.WhatsThisMode
  1949. End Sub
  1950. Private Sub PBTree_DblClick()
  1951. If gsCurrentPB <> "" Then
  1952. frmcab.Show vbModal
  1953. End If
  1954. End Sub
  1955. Private Sub PBTree_GotFocus()
  1956. cmbEdit.Enabled = False
  1957. cmdDelete.Enabled = False
  1958. m_editpop.Enabled = False
  1959. m_delpop.Enabled = False
  1960. End Sub
  1961. Private Sub PBTree_NodeClick(ByVal ClickedNode As Node)
  1962. ' this routine just sets the current pb based
  1963. ' on the clicked node.
  1964. ' we're currently only displaying pb nodes so
  1965. ' it can be very simple.
  1966. Dim strNewPB As String
  1967. Dim intRC As Integer
  1968. On Error Resume Next
  1969. Screen.MousePointer = 11
  1970. ' change current phonebook
  1971. strNewPB = ClickedNode.Key
  1972. If strNewPB = "" Then
  1973. Screen.MousePointer = 0
  1974. Exit Sub
  1975. End If
  1976. If SetCurrentPB(strNewPB) <> 0 Then
  1977. Screen.MousePointer = 0
  1978. Exit Sub
  1979. End If
  1980. selection = 0
  1981. updateFound = 0
  1982. RefreshButtons
  1983. Screen.MousePointer = 0
  1984. On Error GoTo 0
  1985. End Sub
  1986. Private Sub PopList_ColumnClick(ByVal ColumnHeader As ColumnHeader)
  1987. On Error Resume Next
  1988. Screen.MousePointer = 11
  1989. DoEvents
  1990. PopList.SortKey = ColumnHeader.index - 1
  1991. PopList.Sorted = True
  1992. Screen.MousePointer = 0
  1993. On Error GoTo 0
  1994. End Sub
  1995. Private Sub PopList_DblClick()
  1996. 'selection = Val(Right$(PopList.SelectedItem.Key, Len(PopList.SelectedItem.Key) - 4))
  1997. 'updateFound = selection
  1998. If selection <> 0 And Not IsNull(selection) Then
  1999. cmbEdit_Click
  2000. End If
  2001. End Sub
  2002. Private Sub PopList_GotFocus()
  2003. If gsCurrentPB <> "" Then
  2004. cmbEdit.Enabled = True
  2005. cmdDelete.Enabled = True
  2006. m_editpop.Enabled = True
  2007. m_delpop.Enabled = True
  2008. End If
  2009. End Sub
  2010. Private Sub PopList_ItemClick(ByVal Item As ListItem)
  2011. On Error GoTo ItemErr
  2012. ' here's our baby
  2013. selection = Val(Right$(Item.Key, Len(Item.Key) - 4))
  2014. updateFound = selection
  2015. RefreshButtons
  2016. On Error GoTo 0
  2017. Exit Sub
  2018. ItemErr:
  2019. Exit Sub
  2020. End Sub
  2021. Private Sub txtsearch_Change()
  2022. cmbsearch.Default = True
  2023. RefreshButtons
  2024. End Sub
  2025. Private Sub txtsearch_GotFocus()
  2026. SelectText txtsearch
  2027. cmbEdit.Enabled = False
  2028. cmdDelete.Enabled = False
  2029. m_editpop.Enabled = False
  2030. m_delpop.Enabled = False
  2031. End Sub
  2032. Function RefreshButtons() As Integer
  2033. ' this routine attempts to handle all of the main
  2034. ' screen ui - buttons and menus.
  2035. Dim bSetting As Boolean
  2036. Dim rsTemp As Recordset
  2037. cmbsearch.Enabled = Not txtsearch = "" Or combosearch.Text = LoadResString(3025)
  2038. If Not cmbsearch.Enabled Then
  2039. cmbsearch.Default = False
  2040. End If
  2041. 'based on PB selected
  2042. If gsCurrentPB <> "" Then
  2043. bSetting = True
  2044. cmbadd.Enabled = bSetting
  2045. m_addpop.Enabled = bSetting
  2046. m_copypb.Enabled = bSetting
  2047. m_removepb.Enabled = bSetting
  2048. m_viewlog.Enabled = bSetting
  2049. m_buildPhone.Enabled = bSetting
  2050. viewChange.Enabled = bSetting
  2051. m_editRegion.Enabled = bSetting
  2052. m_options.Enabled = bSetting
  2053. FilterFrame.Enabled = bSetting
  2054. 'pop list print
  2055. If PopList.ListItems.Count = 0 Then
  2056. m_printpops.Enabled = False
  2057. Else
  2058. m_printpops.Enabled = True
  2059. End If
  2060. ' handle regions editing
  2061. 'If gsCurrentPBPath <> "" Then
  2062. ' Set rsTemp = GsysPb.OpenRecordset("PhonebookVersions", dbOpenSnapshot)
  2063. ' If rsTemp.BOF And rsTemp.EOF Then
  2064. 'enable
  2065. ' m_editRegion.Enabled = True
  2066. ' Else
  2067. 'disable region edits
  2068. ' m_editRegion.Enabled = False
  2069. ' End If
  2070. ' rsTemp.Close
  2071. 'End If
  2072. ' based on pop selected
  2073. If selection > 0 Then
  2074. bSetting = True
  2075. Else
  2076. bSetting = False
  2077. End If
  2078. cmbEdit.Enabled = bSetting
  2079. cmdDelete.Enabled = bSetting
  2080. m_editpop.Enabled = bSetting
  2081. m_delpop.Enabled = bSetting
  2082. Else
  2083. bSetting = False
  2084. cmbadd.Enabled = bSetting
  2085. cmbEdit.Enabled = bSetting
  2086. cmdDelete.Enabled = bSetting
  2087. m_viewlog.Enabled = bSetting
  2088. m_addpop.Enabled = bSetting
  2089. m_editpop.Enabled = bSetting
  2090. m_delpop.Enabled = bSetting
  2091. m_copypb.Enabled = bSetting
  2092. m_removepb.Enabled = bSetting
  2093. m_printpops.Enabled = bSetting
  2094. m_buildPhone.Enabled = bSetting
  2095. viewChange.Enabled = bSetting
  2096. m_editflag.Enabled = bSetting
  2097. m_editRegion.Enabled = bSetting
  2098. m_options.Enabled = bSetting
  2099. FilterFrame.Enabled = bSetting
  2100. End If
  2101. End Function
  2102. Private Sub viewChange_Click()
  2103. Dim masterSet As Recordset
  2104. Dim sql As String
  2105. On Error GoTo ErrTrap
  2106. Screen.MousePointer = 11
  2107. sql = "Select AccessNumberId as [Access ID], AreaCode as [Area Code], AccessNumber as [Access number], Status, MinimumSpeed as [Min speed], Maximumspeed as [Max speed], CityName as [POP name], CountryNumber as [Country Number], ServiceType as [Service type], RegionId as [Region ID], ScriptID as [Dial-up connection], SupportNumber as [Flags for input], flipFactor as [Flip factor], Flags , Comments from DialUpPort order by AccessNumberId"
  2108. Set masterSet = gsyspb.OpenRecordset(sql, dbOpenSnapshot)
  2109. If masterSet.EOF And masterSet.BOF Then
  2110. masterSet.Close
  2111. Screen.MousePointer = 0
  2112. MsgBox LoadResString(6034), vbExclamation
  2113. Exit Sub
  2114. End If
  2115. masterSet.Close
  2116. frmdelta.Show vbModal
  2117. Exit Sub
  2118. ErrTrap:
  2119. Screen.MousePointer = 0
  2120. MsgBox LoadResString(6056) & Chr(13) & Chr(13) & Err.Description, vbExclamation
  2121. Exit Sub
  2122. End Sub
  2123. ' This function returns the path to the Windows directory as a
  2124. ' string.
  2125. Function GetWinDir() As String
  2126. Dim lpbuffer As String * 255
  2127. Dim Length As Long
  2128. Length = apiGetWindowsDirectory(lpbuffer, Len(lpbuffer))
  2129. GetWinDir = Left(lpbuffer, Length)
  2130. End Function