-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClose-Delivery.ps1
More file actions
61 lines (55 loc) · 1.88 KB
/
Copy pathClose-Delivery.ps1
File metadata and controls
61 lines (55 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
function Close-Delivery {
[CmdletBinding()]
param (
[parameter(Mandatory = $false)]
[ValidateScript({ Test-ValidateId -id $_ })]
[int]$deliveryId
,
[parameter(Mandatory = $false)]
[ValidateScript({ Test-ValidateNo -no $_ })]
[int]$deliveryNo
,
[Parameter(Mandatory = $false)]
[ValidateScript({ Test-ValidateConn -conn $_ })]
$conn
,
[Parameter(Mandatory = $false)]
[ValidateScript({ Test-ValidatePathUDL -path $_ })]
[string]$udl
,
[Parameter(Mandatory = $false)]
[ValidateScript({ Test-ValidateConnStr -connStr $_ })]
[string]$connStr
)
begin {
Write-Verbose -Message ((Get-ResStr 'STARTING_FUNCTION') -f $myInvocation.Mycommand)
Test-ValidateSingle -validParams (Get-SingleDeliveryKeys) @PSBoundParameters
Test-ValidateSingle -validParams (Get-SingleConnection) @PSBoundParameters
New-Variable -Name "sql" -Scope "Private" -Value ""
New-Variable -Name "myConn" -Scope "Private" -Value $null
$initialVariables = Get-CurrentVariables -Debug:$DebugPreference
}
process {
$myConn = Get-Conn -conn $conn -udl $udl -connStr $connStr
if ($deliveryId) {
$sql = @"
SET NOCOUNT ON;
DECLARE @DeliveryId int
SET @DeliveryId = $deliveryId
EXEC dbo.cn_lfBuchen @lf_id=@DeliveryId
"@
} else {
$sql = @"
SET NOCOUNT ON;
DECLARE @DeliveryNo int
SET @DeliveryNo = $deliveryNo
EXEC dbo.cn_lfBuchen @lf_Nummer=@DeliveryNo
"@
}
$myConn.Execute($sql) | out-null
}
end {
Get-CurrentVariables -InitialVariables $initialVariables -Debug:$DebugPreference
}
# Test: Close-Delivery -deliveryNo 68 -udl 'C:\temp\EULANDA_1 Truccamo.udl'
}