
-
1 point Member
-
macmaster9600
- Member since 09-14-2008, 1:07 AM
- Posts 6
|
Private Sub CAPTToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CAPTToolStripMenuItem.Click On Error GoTo err_handler
Dim FName As String = ""
Dim LName As String = ""
Dim SASN, City2, LV1A, LV1B, LV1C, strLECCompany, strPon As String
'sets string so ticket form will auto grab from capt as well
strgrab = "CAPT"Call CheckIE("http://capt.corp.coperate.com/Default.aspx", "CAPT") strHTMLCaptTable = ParseBy3variable(strHTMLSource, "this.src='Images/
strgrab = "CAPT"Call CheckIE("http://capt.corp.coperate.com/Default.aspx", "CAPT")<>, "<TABLE class=OrderTable", "</TABLE>") ' Get Text Between the Table to find Due Date
parseCTLnumber(objiedoc)
ParseName(ParseBy2variable(strHTMLSource, "_lblEUName>", "</SPAN>"), FName, LName) ' Split up Name
'FirstName.Text = StrConv(strFirstName, VbStrConv.ProperCase) ' First Name
'LastName.Text = StrConv(strLastName, VbStrConv.ProperCase) ' Last Name
txtHSN.Text = ParseBy3variable(strHTMLSource, "_txtSANO", "value=", " name=") ' Street Number
'txtDir.Text = ParseBy3variable(strHTMLSource, "_txtSASD", "value=", " name=") ' Street Direction
SASN = ParseBy3variable(strHTMLSource, "_txtSASN", "value=", " name=") ' Street Name
txtSNM.Text = StrConv(Replace(SASN, Chr(34), ""), VbStrConv.ProperCase) ' Take "" out of Street name if space
'txtType.Text = StrConv(ParseBy3variable(strHTMLSource, "_txtSATH", "value=", " name="), VbStrConv.ProperCase) ' Street Type
City2 = ParseBy3variable(strHTMLSource, "_txtCITY2", "value=", " name=") ' City
cmbCity.Text = StrConv(Replace(City2, Chr(34), ""), VbStrConv.ProperCase) 'Take "" out of City name if space
txtStateSearch.Text = ParseBy3variable(strHTMLSource, "_txtSTATE2", "value=", " name=") ' State
txtZIP.Text = ParseBy3variable(strHTMLSource, "_txtZipCode2", "value=", " name=") ' Zip
LV1A = ParseBy3variable(strHTMLSource, "_txtLV1A", "value=", " name=") ' get all levels
LV1B = ParseBy3variable(strHTMLSource, "_txtLV2A", "value=", " name=") ' get all levels
LV1C = ParseBy3variable(strHTMLSource, "_txtLV3A", "value=", " name=") ' get all levels
'Level.Text = LV1A + LV1B + LV1C ' Put all Levels Together
'LRN.Text = ParseBy3variable(strHTMLSource, "_txtLRN", "value=", " name=")strLECCompany = ParseBy3variable(strHTMLSource, "_txtCarrier", "value=", " name=")
'LECCompany.Text = Replace(strLECCompany, Chr(34), "")
'If Level.Text = "0" Then ' Make sure level dont = 0 if so removes 0
' Level.Text = ""
'End If
strPon = ParseBy3variable(strHTMLCaptTable, "ponver", ",", "</A>") ' Grab Pon
strPon = Split(strPon, "-")(0) ' split up pon and ver
'txtODRPon.Text = strPon
txtTN.Text = ParseBy2variable(strHTMLCaptTable, "_lblatn>", "</SPAN>") ' Grab TN from table
If txtTN.Text = "" Then ' if pon comes back empty no order open in captMsgBox("You do not have an order open.", MsgBoxStyle.SystemModal)
Exit Sub
End IfIf btnSearch.Enabled = True Then btnSearch_Click(sender, e)
Exit Sub
err_handler:
If Err.Number = 91 ThenMsgBox("You do not have an order open. Please open an order and try again.", MsgBoxStyle.Critical, "No order open")
Else
MsgBox(Err.Number & Err.Description & Err.Erl)
End If
End SubPublic Sub ParseName(ByVal strFullName As String, ByVal FName As String, ByVal LName As String)
Dim P As Integer
Dim strCutName As String
Dim strReminderOfName As String
strFirstName = ""
strLastName = ""P = InStr(strFullName, ",")
If P > 0 Then
Dim I As Integer
strFullName = Trim$(strFullName)
P = 1 For I = Len(strFullName) To 1 Step -1
If Mid$(strFullName, I, 1) = "," Then
P = I + 1
Exit For
End IfNext I
If P = 1 Then
strCutName = strFullName
strReminderOfName = ""
Else
strCutName = Mid$(strFullName, P)
strReminderOfName = Trim$(Left$(strFullName, P - 1)) End If
strFirstName = strCutName '(First Name)
strLastName = strReminderOfName '(Last Name)
strLastName = StrConv(Replace(strLastName, ",", ""), VbStrConv.ProperCase) ' (Take out ,)
strFirstName = Trim(strFirstName) '(Remove Spaces)
strLastName = Trim(strLastName) ' (Remove Spaces)
Else
Dim I As Integer
strFullName = Trim$(strFullName)
P = 1 For I = Len(strFullName) To 1 Step -1
If Mid$(strFullName, I, 1) = " " Then
P = I + 1
Exit For
End IfNext I
If P = 1 Then
strCutName = strFullName
strReminderOfName = ""
Else
strCutName = Mid$(strFullName, P)
strReminderOfName = Trim$(Left$(strFullName, P - 1))
End If
strLastName = strCutName 'Last Name)
strFirstName = strReminderOfName 'First Name
End If
End SubFunction ParseBy3variable(ByVal strHTML As String, ByVal DelimiterA As String, ByVal DelimiterB As String, ByVal DelimiterC As String)
ParseBy3variable = ""
Dim A, B, D As Integer
Dim C As String
A = 1 While InStr(A, strHTML, DelimiterA) > 0
A = InStr(A, strHTML, DelimiterA) + Len(DelimiterA)
B = InStr(A, strHTML, DelimiterC)
C = Microsoft.VisualBasic.Mid(strHTML, A, B - A)
D = InStr(1, C, DelimiterB)
If D = 0 Then
Exit Function
End If
ParseBy3variable = Microsoft.VisualBasic.Mid(C, D + 6)
End While
End FunctionFunction ParseBy2variable(ByVal strHTML As String, ByVal DelimiterA1 As String, ByVal DelimiterB1 As String)
ParseBy2variable = ""
Dim A As Integer, B As Integer
A = 1 While InStr(A, strHTML, DelimiterA1) > 0
A = InStr(A, strHTML, DelimiterA1) + Len(DelimiterA1)
B = InStr(A, strHTML, DelimiterB1)
ParseBy2variable = Microsoft.VisualBasic.Mid(strHTML, A, B - A)
End While
End FunctionPublic Sub CheckIE(ByVal URLa, ByVal URLname)
Dim objSW As SHDocVw.ShellWindowsDim objIE As SHDocVw.InternetExplorer
Dim objDoc As Object
Dim bAppRunning As BooleanobjSW = New SHDocVw.ShellWindows
If objSW.Count Then ' newFor Each objDoc In objSW
If InStr(1, objDoc.LocationName, URLname) Then
bAppRunning = True
objDoc.Visible = True
objDoc.StatusBar = 1
Dim i As Integer
i = 1
While objDoc.Busy : End While : While objDoc.ReadyState <> 4 : End WhilestrHTMLSource = objDoc.Document.getElementsByTagName("html")(0).outerHTMLGetDLtable(objDoc.Document, "LTY*")
objiedoc = objDoc
Exit For
End IfNext objDoc
End If
If bAppRunning = False Then
objIE = CreateObject( "InternetExplorer.Application") ' new
objIE.Visible = True
objIE.Navigate(URLa)
objIE.StatusBar = 1 Dim i As Int16 = 1
While objIE.Busy : End While : While objIE.ReadyState <> 4 : End WhilestrHTMLSource = objIE.Document.getElementsByTagName("html")(0).outerHTMLEnd If
objIE = Nothing
objSW = Nothing
objDoc = Nothing
End SubPublic Sub GetDLtable(ByVal IE As Object, ByVal TableSearch As String)
Dim varTables As Object
Dim varRows As Object
Dim lngRow As Object
Dim varCells As Object
Dim lngColumn As LongvarTables = IE.All.tags("TABLE") For Each varTable In varTables
'Use the innerText to see if this is the table we want.
If varTable.innerText Like TableSearch Then
varRows = varTable.Rows
lngRow = 2 'This will be the first output rowFor Each varRow In varRows
varCells = varRow.Cells
lngColumn = 1 'This will be the output columnFor Each varCell In varCells
strTableText(lngColumn - 1) = varCell.innerText
lngColumn = lngColumn + 1 Next varCell
lngRow = lngRow + 1 Next varRow
End IfNext varTable
End SubFunction parsebycombobox(ByVal ie As Object, ByVal controlname As String)
parsebycombobox = ""
Dim strby2 As String = ""Dim theElementCollection = ie.Document.GetElementsByTagName("SELECT") For Each curElement In theElementCollection
If Microsoft.VisualBasic.Right(curElement.GetAttribute("Name"), controlname.Length) = controlname ThenDim strby3 As String = ie.Document.getElementByid(curElement.name).value()
'MsgBox(ParseBy2variable(curElement.name, "gridOrder:_", ":"))strby2 = ParseBy2variable(strHTMLSource, strby3 & " selected>", "</OPTION>")
End If
Next
parsebycombobox = strby2
End FunctionPublic Sub parseCTLnumber(ByVal ie As Object)
strCTLnumber = ""Dim theElementCollection = ie.Document.GetElementsByTagName("SELECT") For Each curElement In theElementCollection
'we look for the ddlcounty only because that is one control that is only visible when an order is open.
'any other control that is visible only when a control is open will work as well.
'the "9" value is the length of the ddlcounty string
If Microsoft.VisualBasic.Right(curElement.GetAttribute("Name"), 9) = "ddlCounty" ThenstrCTLnumber = ParseBy2variable(curElement.name, "gridOrder:_", ":")
'MsgBox(strCTLnumber)
End If
Next
End SubPublic Function FindWindowByLocationURL(ByVal LocationURL As String) As SHDocVw.InternetExplorer
FindWindowByLocationURL = New SHDocVw.InternetExplorerDim objSW As New SHDocVw.ShellWindows
Dim timer As Date
blnwindowfound = False
If objSW.Count ThenFor Each objIE In objSW
If InStr(1, objIE.LocationURL, LocationURL) Then
blnwindowfound = True
objIE.StatusBar = 1
objIE.Visible = True
WaitAgain:
timer = Now While objIE.Busy
If DateDiff(DateInterval.Second, Now, timer, FirstDayOfWeek.Monday, FirstWeekOfYear.Jan1) > 10 Then
objIE.Refresh() GoTo WaitAgain
End If
Application.DoEvents()
End While
timer = Now While objIE.ReadyState <> 4
If DateDiff(DateInterval.Second, Now, timer, FirstDayOfWeek.Monday, FirstWeekOfYear.Jan1) > 10 Then
objIE.Refresh() GoTo WaitAgain
End If
Application.DoEvents()
End While
FindWindowByLocationURL = objIE
Exit For
End IfIf objIE.LocationURL = "" Then objIE.Quit() Next objIE
End If
If blnwindowfound = False ThenFindWindowByLocationURL = CreateObject("InternetExplorer.Application")
FindWindowByLocationURL.StatusBar = 1
FindWindowByLocationURL.Visible = True
End If
SetForegroundWindow(FindWindowByLocationURL.HWND)
End Function
|
|