Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2014
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.50 KB | None | 0 0
  1. [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")
  2. [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
  3.  
  4. $objForm = New-Object System.Windows.Forms.Form
  5. $objForm.Text = "Inventory Search Tool"
  6. $objForm.Size = New-Object System.Drawing.Size(300,200)
  7. $objForm.StartPosition = "CenterScreen"
  8.  
  9. $objForm.KeyPreview = $True
  10. $objForm.Add_KeyDown({if ($_.KeyCode -eq "Enter")
  11. {$pn=$objTextBox.Text;$objForm.Close()}})
  12. $objForm.Add_KeyDown({if ($_.KeyCode -eq "Escape")
  13. {$objForm.Close()}})
  14.  
  15. $SearchButton = New-Object System.Windows.Forms.Button
  16. $SearchButton.Location = New-Object System.Drawing.Size(75,120)
  17. $SearchButton.Size = New-Object System.Drawing.Size(75,23)
  18. $SearchButton.Text = "Search"
  19. $SearchButton.Add_Click({$pn=$objTextBox.Text;$objForm.Close()})
  20. $objForm.Controls.Add($SearchButton)
  21.  
  22. $CancelButton = New-Object System.Windows.Forms.Button
  23. $CancelButton.Location = New-Object System.Drawing.Size(150,120)
  24. $CancelButton.Size = New-Object System.Drawing.Size(75,23)
  25. $CancelButton.Text = "Cancel"
  26. $CancelButton.Add_Click({$objForm.Close()})
  27. $objForm.Controls.Add($CancelButton)
  28.  
  29. $objLabel = New-Object System.Windows.Forms.Label
  30. $objLabel.Location = New-Object System.Drawing.Size(10,20)
  31. $objLabel.Size = New-Object System.Drawing.Size(280,20)
  32. $objLabel.Text = "Please enter the Product Number in the space below:"
  33. $objForm.Controls.Add($objLabel)
  34.  
  35. $objTextBox = New-Object System.Windows.Forms.TextBox
  36. $objTextBox.Location = New-Object System.Drawing.Size(10,40)
  37. $objTextBox.Size = New-Object System.Drawing.Size(260,20)
  38. $objForm.Controls.Add($objTextBox)
  39.  
  40. $objForm.Topmost = $True
  41.  
  42. $objForm.Add_Shown({$objForm.Activate()})
  43. [void] $objForm.ShowDialog()
  44.  
  45.  
  46. $strQuery = "SELECT [Inventory].[VendorPartID],[Inventory].[Description],[Inventory].[OnHand]
  47. FROM [Inventory]
  48. WHERE [Inventory].[VendorPartID] LIKE '$pn%' ;"
  49.  
  50. $strConn = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=\\25.139.75.171\SharedDocs\InvenTrakk\inventrakk.mwf"
  51. $oConn = New-Object System.Data.OleDb.OleDbConnection $strConn
  52. $oCmd = New-Object System.Data.OleDb.OleDbCommand($strQuery, $oConn)
  53. $oConn.Open()
  54. $oReader = $oCmd.ExecuteReader()
  55. [void]$oReader.Read()
  56. $oJumper = New-Object PSObject
  57. $oJumper | Add-Member NoteProperty VendorPartID $oReader[0]
  58. $oJumper | Add-Member NoteProperty Description $oReader[1]
  59. $oJumper | Add-Member NoteProperty OnHand $oReader[2]
  60. $oJumper
  61. $oReader.Close()
  62. $oConn.Close()
  63.  
  64.  
  65. $pn
  66. $strQuery
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement