Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")
- [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
- $objForm = New-Object System.Windows.Forms.Form
- $objForm.Text = "Inventory Search Tool"
- $objForm.Size = New-Object System.Drawing.Size(300,200)
- $objForm.StartPosition = "CenterScreen"
- $objForm.KeyPreview = $True
- $objForm.Add_KeyDown({if ($_.KeyCode -eq "Enter")
- {$pn=$objTextBox.Text;$objForm.Close()}})
- $objForm.Add_KeyDown({if ($_.KeyCode -eq "Escape")
- {$objForm.Close()}})
- $SearchButton = New-Object System.Windows.Forms.Button
- $SearchButton.Location = New-Object System.Drawing.Size(75,120)
- $SearchButton.Size = New-Object System.Drawing.Size(75,23)
- $SearchButton.Text = "Search"
- $SearchButton.Add_Click({$pn=$objTextBox.Text;$objForm.Close()})
- $objForm.Controls.Add($SearchButton)
- $CancelButton = New-Object System.Windows.Forms.Button
- $CancelButton.Location = New-Object System.Drawing.Size(150,120)
- $CancelButton.Size = New-Object System.Drawing.Size(75,23)
- $CancelButton.Text = "Cancel"
- $CancelButton.Add_Click({$objForm.Close()})
- $objForm.Controls.Add($CancelButton)
- $objLabel = New-Object System.Windows.Forms.Label
- $objLabel.Location = New-Object System.Drawing.Size(10,20)
- $objLabel.Size = New-Object System.Drawing.Size(280,20)
- $objLabel.Text = "Please enter the Product Number in the space below:"
- $objForm.Controls.Add($objLabel)
- $objTextBox = New-Object System.Windows.Forms.TextBox
- $objTextBox.Location = New-Object System.Drawing.Size(10,40)
- $objTextBox.Size = New-Object System.Drawing.Size(260,20)
- $objForm.Controls.Add($objTextBox)
- $objForm.Topmost = $True
- $objForm.Add_Shown({$objForm.Activate()})
- [void] $objForm.ShowDialog()
- $strQuery = "SELECT [Inventory].[VendorPartID],[Inventory].[Description],[Inventory].[OnHand]
- FROM [Inventory]
- WHERE [Inventory].[VendorPartID] LIKE '$pn%' ;"
- $strConn = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=\\25.139.75.171\SharedDocs\InvenTrakk\inventrakk.mwf"
- $oConn = New-Object System.Data.OleDb.OleDbConnection $strConn
- $oCmd = New-Object System.Data.OleDb.OleDbCommand($strQuery, $oConn)
- $oConn.Open()
- $oReader = $oCmd.ExecuteReader()
- [void]$oReader.Read()
- $oJumper = New-Object PSObject
- $oJumper | Add-Member NoteProperty VendorPartID $oReader[0]
- $oJumper | Add-Member NoteProperty Description $oReader[1]
- $oJumper | Add-Member NoteProperty OnHand $oReader[2]
- $oJumper
- $oReader.Close()
- $oConn.Close()
- $pn
- $strQuery
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement