Skip to content

Commit

Permalink
- in gotobom and gotomaterial using sender.datacontext instead of erp…
Browse files Browse the repository at this point in the history
…Material as erpmaterial is out of scope
  • Loading branch information
ThomasRossmeisl committed Nov 30, 2022
1 parent a6246f3 commit 836d8a9
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 33 deletions.
10 changes: 5 additions & 5 deletions Files/powerEvents/Events/TransferERPBomViaFileTab.ps1
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#region Debugging
if((Get-Process -Id $PID).ProcessName -in @('powershell','powershell_ise') -and $host.Name.StartsWith('powerEvents') -eq $false){
Import-Module powerEvents

Open-VaultConnection -Server $env:Computername -Vault Vault -User Administrator -Password ""
$selectedFile = Get-VaultFile -File '$/Designs/FlcRootItem.iam'
$selectedFile = Get-VaultFile -Properties @{ Name = 'FlcRootItem.iam' }

function Add-VaultTab($name, $EntityType, $Action){
Add-Type -AssemblyName PresentationFramework

Expand Down Expand Up @@ -75,8 +75,8 @@ Add-VaultTab -Name 'ERP BOM' -EntityType 'File' -Action {
else {
$erpItemTab_GoToBOMButton.Add_Click({
param($Sender)
Start-Process -FilePath $erpBomHeader.Link

Start-Process -FilePath $Sender.DataContext.Link
})
}
$erpBomTab_control.DataContext = $erpBomHeader
Expand Down
10 changes: 5 additions & 5 deletions Files/powerEvents/Events/TransferERPBomViaItemTab.ps1
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#region Debugging
if((Get-Process -Id $PID).ProcessName -in @('powershell','powershell_ise') -and $host.Name.StartsWith('powerEvents') -eq $false){
Import-Module powerEvents

Open-VaultConnection -Server $env:Computername -Vault Vault -User Administrator -Password ""
$selectedItem = Get-VaultItem -Number 'co-00000'
$selectedItem = Get-VaultItem -Number 'FlcRootItem'

function Add-VaultTab($name, $EntityType, $Action){
Add-Type -AssemblyName PresentationFramework

Expand Down Expand Up @@ -75,8 +75,8 @@ Add-VaultTab -Name 'ERP BOM' -EntityType 'Item' -Action {
else {
$erpItemTab_GoToBOMButton.Add_Click({
param($Sender)
Start-Process -FilePath $erpBomHeader.Link

Start-Process -FilePath $Sender.DataContext.Link
})
}
$erpBomTab_control.DataContext = $erpBomHeader
Expand Down
22 changes: 11 additions & 11 deletions Files/powerEvents/Events/TransferERPItemViaFileTab.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ if((Get-Process -Id $PID).ProcessName -in @('powershell','powershell_ise') -and

Open-VaultConnection -Server $env:Computername -Vault Vault -User Administrator -Password ""
$selectedFile = Get-VaultFile -File '$/Designs/MultipageInv.idw'

function Add-VaultTab($name, $EntityType, $Action){
Add-Type -AssemblyName PresentationFramework

Expand Down Expand Up @@ -58,7 +58,7 @@ Add-VaultTab -Name 'ERP Item' -EntityType 'File' -Action {
param($selectedFile)

$erpItemTab_control = [Windows.Markup.XamlReader]::Load([System.Xml.XmlNodeReader]::new([xml](Get-Content "$PSScriptRoot\TransferERPItemTab.xaml")))

$statusMessage_label = $erpItemTab_control.FindName('lblStatusMessage')
$erpServices = Get-ERPServices -Available
if (-not $erpServices) {
Expand Down Expand Up @@ -87,7 +87,7 @@ Add-VaultTab -Name 'ERP Item' -EntityType 'File' -Action {
$erpItemTab_control.IsEnabled = $false
return $erpItemTab_control
}

if (-not $erpMaterial) {
$statusMessage_label.Content = 'ERP: Create Material'

Expand All @@ -97,15 +97,15 @@ Add-VaultTab -Name 'ERP Item' -EntityType 'File' -Action {
$erpItemTab_CreateOrUpdateMaterialButton.Content = 'Create ERP Item'
$erpItemTab_CreateOrUpdateMaterialButton.Add_Click({
param($Sender)

$createdErpMaterial = Add-ErpObject -EntitySet "Materials" -Properties $erpMaterial
if ($? -eq $false) {
return
}

$null = ShowMessageBox -Message "$($createdErpMaterial.Number) successfully created" -Title "powerGate ERP - Create Material" -Icon "Information"
SetEntityProperties -erpMaterial $createdErpMaterial -vaultEntity $selectedFile

[System.Windows.Forms.SendKeys]::SendWait("{F5}")
})

Expand All @@ -117,7 +117,7 @@ Add-VaultTab -Name 'ERP Item' -EntityType 'File' -Action {
$erpItemTab_CreateOrUpdateMaterialButton.Content = 'Update ERP Item'
$erpItemTab_CreateOrUpdateMaterialButton.Add_Click({
param($Sender)

$updatedErpMaterial = Update-ERPObject -EntitySet "Materials" -Key $erpMaterial._Keys -Properties $erpMaterial._Properties
if ($? -eq $false) {
return
Expand All @@ -130,9 +130,9 @@ Add-VaultTab -Name 'ERP Item' -EntityType 'File' -Action {

$erpItemTab_GoToMaterialButton.Add_Click({
param($Sender)
if ($erpMaterial.Link) {
Start-Process -FilePath $erpMaterial.Link

if ($Sender.DataContext.Link) {
Start-Process -FilePath $Sender.DataContext.Link
}
})

Expand Down Expand Up @@ -161,7 +161,7 @@ Add-VaultTab -Name 'ERP Item' -EntityType 'File' -Action {
$message = "The ERP item $($foundErpMaterial.Number) is already assigned to `n$($fileNames).`n"
}
}

$answer = ShowMessageBox -Message ($message + "Do you really want to link the item '$($foundErpMaterial.Number)'?") -Title "powerGate ERP - Link Item" -Button "YesNo" -Icon "Question"
if ($answer -eq [System.Windows.Forms.DialogResult]::Yes) {
SetEntityProperties -erpMaterial $foundErpMaterial -vaultEntity $selectedFile
Expand Down
24 changes: 12 additions & 12 deletions Files/powerEvents/Events/TransferERPItemViaItemTab.ps1
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#region Debugging
if((Get-Process -Id $PID).ProcessName -in @('powershell','powershell_ise') -and $host.Name.StartsWith('powerEvents') -eq $false){
Import-Module powerEvents

Open-VaultConnection -Server $env:Computername -Vault Vault -User Administrator -Password ""
$selectedItem = Get-VaultItem -Number 'co-00000'

function Add-VaultTab($name, $EntityType, $Action){
Add-Type -AssemblyName PresentationFramework

Expand Down Expand Up @@ -56,7 +56,7 @@ function CanCreateOrUpdateErpMaterial {
Add-VaultTab -Name 'ERP Item' -EntityType 'Item' -Action {
param($selectedItem)
$erpItemTab_control = [Windows.Markup.XamlReader]::Load([System.Xml.XmlNodeReader]::new([xml](Get-Content "$PSScriptRoot\TransferERPItemTab.xaml")))

$statusMessage_label = $erpItemTab_control.FindName("lblStatusMessage")
$erpServices = Get-ERPServices -Available
if (-not $erpServices) {
Expand Down Expand Up @@ -85,7 +85,7 @@ Add-VaultTab -Name 'ERP Item' -EntityType 'Item' -Action {
$erpItemTab_control.IsEnabled = $false
return $erpItemTab_control
}

if (-not $erpMaterial) {
$statusMessage_label.Content = 'ERP: Create Material'

Expand All @@ -95,15 +95,15 @@ Add-VaultTab -Name 'ERP Item' -EntityType 'Item' -Action {
$erpItemTab_CreateOrUpdateMaterialButton.Content = 'Create ERP Item'
$erpItemTab_CreateOrUpdateMaterialButton.Add_Click({
param($Sender)

$createdErpMaterial = Add-ErpObject -EntitySet "Materials" -Properties $erpMaterial
if ($? -eq $false) {
return
}

$null = ShowMessageBox -Message "$($createdErpMaterial.Number) successfully created" -Title "powerGate ERP - Create Material" -Icon "Information"
SetEntityProperties -erpMaterial $createdErpMaterial -vaultEntity $selectedItem

[System.Windows.Forms.SendKeys]::SendWait("{F5}")
})

Expand All @@ -115,7 +115,7 @@ Add-VaultTab -Name 'ERP Item' -EntityType 'Item' -Action {
$erpItemTab_CreateOrUpdateMaterialButton.Content = 'Update ERP Item'
$erpItemTab_CreateOrUpdateMaterialButton.Add_Click({
param($Sender)

$updatedErpMaterial = Update-ERPObject -EntitySet "Materials" -Key $erpMaterial._Keys -Properties $erpMaterial._Properties
if ($? -eq $false) {
return
Expand All @@ -128,9 +128,9 @@ Add-VaultTab -Name 'ERP Item' -EntityType 'Item' -Action {

$erpItemTab_GoToMaterialButton.Add_Click({
param($Sender)
if ($erpMaterial.Link) {
Start-Process -FilePath $erpMaterial.Link

if ($Sender.DataContext.Link) {
Start-Process -FilePath $Sender.DataContext.Link
}
})

Expand Down Expand Up @@ -158,7 +158,7 @@ Add-VaultTab -Name 'ERP Item' -EntityType 'Item' -Action {
return
}
}

$answer = ShowMessageBox -Message ($message + "Do you really want to link the item '$($foundErpMaterial.Number)'?") -Title "powerGate ERP - Link Item" -Button "YesNo" -Icon "Question"
if ($answer -eq [System.Windows.Forms.DialogResult]::Yes) {
SetEntityProperties -erpMaterial $foundErpMaterial -vaultEntity $selectedItem
Expand Down

0 comments on commit 836d8a9

Please sign in to comment.