Flash info

"Those who forget to script are doomed to repeat their work."

Jeffery Hicks (PowerShell MVP)

 
Accueil arrow Forum

Bienvenue sur le forum PowerShell-Scripting.com

 
krouk
Utilisateur

PowerShelleur Débutant
Messages: 4
graphgraph
Karma: 0  
script consommation - 27/01/20 10:01 Bonjour,
Voila j'ai un problème. Je dois faire un script de conso pour le boulot avec un pave numérique dans le script.
Mon problème est que ce pave numérique doit pouvoir écrire dans la texte box sélectionne.
J'ai beau essayer plusieurs solutions je n'y arrive pas.
Si quelqu'un pouvais m'aider ou me mettre sur la voie.

$date = Get-Date -Format "dd_MM_yyyy_hh_mm"
$fichier1 = Get-Item -Path ".PRD_travail.txt"
$fichier2 = Get-Item -Path ".PRD_vierge.txt"

#Chargement des Windows Form
#region
[void][System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
[void][System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")
[Threading.Thread]::CurrentThread.CurrentCulture = 'fr-FR'
#endregion


#################################################
# CONFIGURATION DE LA WINDOWS FORM
#################################################


# Ajout des composants a la Form
$form = New-Object Windows.Forms.Form
$textbox_1 = New-Object System.Windows.Forms.TextBox
$textbox_2 = New-Object System.Windows.Forms.TextBox
$textbox_3 = New-Object System.Windows.Forms.TextBox
$textbox_4 = New-Object System.Windows.Forms.TextBox
$textbox_5 = New-Object System.Windows.Forms.TextBox
$textbox_6 = New-Object System.Windows.Forms.TextBox
$button_quit = New-Object System.Windows.Forms.Button
$button_douchette = New-Object System.Windows.Forms.Button
$label_un = New-Object System.Windows.Forms.Label
$label_deux = New-Object System.Windows.Forms.Label
$label_trois = New-Object System.Windows.Forms.Label
$label_quatre = New-Object System.Windows.Forms.Label
$label_cinq = New-Object System.Windows.Forms.Label
$label_six = New-Object System.Windows.Forms.Label
$button10 = New-Object System.Windows.Forms.Button
$button9 = New-Object System.Windows.Forms.Button
$button8 = New-Object System.Windows.Forms.Button
$button7 = New-Object System.Windows.Forms.Button
$button6 = New-Object System.Windows.Forms.Button
$button5 = New-Object System.Windows.Forms.Button
$button4 = New-Object System.Windows.Forms.Button
$button3 = New-Object System.Windows.Forms.Button
$button2 = New-Object System.Windows.Forms.Button
$button1 = New-Object System.Windows.Forms.Button
$textBoxP = New-Object System.Windows.Forms.TextBox

$InitialFormWindowState = New-Object System.Windows.Forms.FormWindowState


# Gestion event quand on clique sur le bouton Fermer
$button_quit.Add_Click(
{
Move-Item -Path .PRD_travail.txt -Destination M:IMPORTS_EXPORTS_INFORMATIQUEpuitsPRD_ps1_$date.txt
Copy-Item -Path .PRD_vierge.txt .PRD_travail.txt
$textbox_2.Clear()
$textbox_3.Clear()
$textbox_4.Clear()
$textbox_5.Clear()
$textbox_6.Clear()
})

# Gestion event quand on clique sur le bouton OK

$button_douchette.Add_Click(
{
if ( $textbox_1.Text -eq "")
{ Write-Host " Erreur de saisie"}
elseif ( $textbox_2.Text -eq $false)
{ Write-Host " Erreur de saisie"}
elseif ( $textbox_3.Text -eq $false)
{ Write-Host " Erreur de saisie"}
elseif ( $textbox_1.Text -eq $false)
{ Write-Host " Erreur de saisie"}
elseif ( $textbox_3.Text -eq $false)
{ Write-Host " Erreur de saisie"}
elseif ( $textbox_3.Text -eq $false)
{ Write-Host " Erreur de saisie"}
else
{
$ope = $textbox_1.Text
$of = $textbox_2.Text
$art1 = $textbox_3.Text
$art2 = $textbox_4.Text
$br = $textbox_5.Text
$qut = $textbox_6.Text

if ($art1 -eq $art2)
{
Add-Content -Path ".PRD_travail.txt" -Value $ope';'$of';'$art1';'$br';'$qut';'
$textbox_3.Clear()
$textbox_4.Clear()
$textbox_5.Clear()
$textbox_6.Clear()
}
else
{
Write-Host "Erreur les codes articles ne sont pas identiques"
$textbox_3.Clear()
$textbox_4.Clear()
$textbox_5.Clear()
$textbox_6.Clear()
}
}

})


$form.Text = "Douchette"
$form.Size = New-Object System.Drawing.Size(450,350)
$form.ShowIcon = $True
$form.ShowInTaskbar = $True

$form.WindowState = 2
$form.add_Load($handler_form_Load)

# Bouton Quitter
$button_quit.Font = New-Object System.Drawing.Font("Microsoft Sans Serif",24,0,3,0)
$button_quit.Text = "Vider la pointeuse"
$button_quit.Size = New-Object System.Drawing.Size(200,100)
$button_quit.Location = New-Object System.Drawing.Size(1000,400)
$button_quit.BackColor = [System.Drawing.Color]::FromArgb(255,255,0,0)
$button_quit.TabIndex = 8
$form.Controls.Add($button_quit)

#Bouton douchette
$button_douchette.Font = New-Object System.Drawing.Font("Microsoft Sans Serif",24,0,3,0)
$button_douchette.Text = "Enregistrer la conso"
$button_douchette.Size = New-Object System.Drawing.Size(200,100)
$button_douchette.Location = New-Object System.Drawing.Size(1000,100)
$button_douchette.TabIndex = 7
$form.Controls.Add($button_douchette)

# Label 1
$label_un.AutoSize = $true
$label_un.Font = New-Object System.Drawing.Font("Microsoft Sans Serif",26.25,0,3,0)
$label_un.Location = New-Object System.Drawing.Point(10,50)
$label_un.Name = 'label_ref'
$label_un.Size = New-Object System.Drawing.Size(100,20)
$label_un.Text = "Entrez le numéro d'opérateur"
$form.Controls.Add($label_un)

# TextBox_1
$textbox_1.AcceptsReturn = $true
$textbox_1.AutoSize = $true
$textBox_1.Font = New-Object System.Drawing.Font("Microsoft Sans Serif",20.25,0,3,0)
$textbox_1.Location = New-Object System.Drawing.Point(10,100)
$textbox_1.Name = 'textbox_ref'
$textbox_1.Size = New-Object System.Drawing.Size(320,20)
$textbox_1.Text = ""
$textbox_1.TabIndex = 1
$form.Controls.Add($textbox_1)

# Label 2
$label_deux.AutoSize = $true
$label_deux.Font = New-Object System.Drawing.Font("Microsoft Sans Serif",26.25,0,3,0)
$label_deux.Location = New-Object System.Drawing.Point(10,140)
$label_deux.Name = 'label_OF'
$label_deux.Size = New-Object System.Drawing.Size(200,40)
$label_deux.Text = "Entrez le numéro d'OF"
$form.Controls.Add($label_deux)

# TextBox_2
$textbox_2.AcceptsReturn = $true
$textbox_2.AutoSize = $true
$textBox_2.Font = New-Object System.Drawing.Font("Microsoft Sans Serif",20.25,0,3,0)
$textbox_2.Location = New-Object System.Drawing.Point(10,190)
$textbox_2.Name = 'textbox_OF'
$textbox_2.Size = New-Object System.Drawing.Size(320,20)
$textbox_2.Text = ""
$textbox_2.TabIndex = 2
$form.Controls.Add($textbox_2)

# Label 3
$label_trois.AutoSize = $true
$label_trois.Font = New-Object System.Drawing.Font("Microsoft Sans Serif",26.25,0,3,0)
$label_trois.Location = New-Object System.Drawing.Point(10,230)
$label_trois.Name = 'label_OF'
$label_trois.Size = New-Object System.Drawing.Size(320,40)
$label_trois.Text = "Entrez le numéro d'article de l'OF"
$form.Controls.Add($label_trois)

# TextBox_3
$textbox_3.AutoSize = $true
$textbox_3.AcceptsReturn = $true
$textBox_3.Font = New-Object System.Drawing.Font("Microsoft Sans Serif",20.25,0,3,0)
$textbox_3.Location = New-Object System.Drawing.Point(10,280)
$textbox_3.Name = 'textbox_OF'
$textbox_3.Size = New-Object System.Drawing.Size(320,40)
$textbox_3.Text = ""
$textbox_3.TabIndex = 3
$form.Controls.Add($textbox_3)

# Label 4
$label_quatre.AutoSize = $true
$label_quatre.Font = New-Object System.Drawing.Font("Microsoft Sans Serif",26.25,0,3,0)
$label_quatre.Location = New-Object System.Drawing.Point(10,320)
$label_quatre.Name = 'label_OF'
$label_quatre.Size = New-Object System.Drawing.Size(200,40)
$label_quatre.Text = "Entrez le numéro d'article de la caisse"
$form.Controls.Add($label_quatre)

# TextBox_4
$textbox_4.AutoSize = $true
$textbox_4.AcceptsReturn = $true
$textBox_4.Font = New-Object System.Drawing.Font("Microsoft Sans Serif",20.25,0,3,0)
$textbox_4.Location = New-Object System.Drawing.Point(10,370)
$textbox_4.Name = 'textbox_OF'
$textbox_4.Size = New-Object System.Drawing.Size(320,40)
$textbox_4.Text = ""
$textbox_4.TabIndex = 4
$form.Controls.Add($textbox_4)

# Label 5
$label_cinq.AutoSize = $true
$label_cinq.Font = New-Object System.Drawing.Font("Microsoft Sans Serif",26.25,0,3,0)
$label_cinq.Location = New-Object System.Drawing.Point(10,410)
$label_cinq.Name = 'label_OF'
$label_cinq.Size = New-Object System.Drawing.Size(200,40)
$label_cinq.Text = "Entrez le numéro de Lot"
$form.Controls.Add($label_cinq)

# TextBox_5
$textbox_5.AcceptsReturn = $true
$textbox_5.AutoSize = $true
$textBox_5.Font = New-Object System.Drawing.Font("Microsoft Sans Serif",20.25,0,3,0)
$textbox_5.Location = New-Object System.Drawing.Point(10,460)
$textbox_5.Name = 'textbox_OF'
$textbox_5.Size = New-Object System.Drawing.Size(320,40)
$textbox_5.Text = ""
$textbox_5.TabIndex = 5
$form.Controls.Add($textbox_5)

# Label 6
$label_six.AutoSize = $true
$label_six.Font = New-Object System.Drawing.Font("Microsoft Sans Serif",20.25,0,3,0)
$label_six.Location = New-Object System.Drawing.Point(10,520)
$label_six.Name = 'label_OF'
$label_six.Size = New-Object System.Drawing.Size(200,40)
$label_six.Text = "Entrez la quantité"
$form.Controls.Add($label_six)

# TextBox_6
$textbox_6.AutoSize = $true
$textBox_6.Font = New-Object System.Drawing.Font("Microsoft Sans Serif",20.25,0,3,0)
$textbox_6.Location = New-Object System.Drawing.Point(10,560)
$textbox_6.Name = 'textbox_OF'
$textbox_6.Size = New-Object System.Drawing.Size(320,40)
$textbox_6.Text = ""
$textbox_6.TabIndex = 6
$form.Controls.Add($textbox_6)

$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 650
$System_Drawing_Point.Y = 263
$button10.Location = $System_Drawing_Point
$button10.Name = "button10"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 55
$System_Drawing_Size.Width = 250
$button10.Size = $System_Drawing_Size
$button10.Text = "0"
$button10.UseVisualStyleBackColor = $True
$button10.add_click({$textbox_1 += "0"})
$form.Controls.Add($button10)

$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 820
$System_Drawing_Point.Y = 183
$button9.Location = $System_Drawing_Point
$button9.Name = "button9"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 67
$System_Drawing_Size.Width = 80
$button9.Size = $System_Drawing_Size
$button9.Text = "9"
$button9.UseVisualStyleBackColor = $True
$button9.add_click({$textBoxP.Text += "9"})
$form.Controls.Add($button9)

$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 735
$System_Drawing_Point.Y = 183
$button8.Location = $System_Drawing_Point
$button8.Name = "button8"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 67
$System_Drawing_Size.Width = 80
$button8.Size = $System_Drawing_Size
$button8.Text = "8"
$button8.UseVisualStyleBackColor = $True
$button8.add_click({$textbox += "8"})
$form.Controls.Add($button8)

$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 650
$System_Drawing_Point.Y = 183
$button7.Location = $System_Drawing_Point
$button7.Name = "button7"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 67
$System_Drawing_Size.Width = 80
$button7.Size = $System_Drawing_Size
$button7.TabIndex = 6
$button7.Text = "7"
$button7.UseVisualStyleBackColor = $True
$button7.add_click({$textBoxP.Text += "7"})
$form.Controls.Add($button7)

$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 820
$System_Drawing_Point.Y = 109
$button6.Location = $System_Drawing_Point
$button6.Name = "button6"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 67
$System_Drawing_Size.Width = 80
$button6.Size = $System_Drawing_Size
$button6.TabIndex = 5
$button6.Text = "6"
$button6.UseVisualStyleBackColor = $True
$button6.add_click({$textBoxP.Text += "6"})
$form.Controls.Add($button6)

$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 735
$System_Drawing_Point.Y = 109
$button5.Location = $System_Drawing_Point
$button5.Name = "button5"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 67
$System_Drawing_Size.Width = 80
$button5.Size = $System_Drawing_Size
$button5.TabIndex = 4
$button5.Text = "5"
$button5.UseVisualStyleBackColor = $True
$button5.add_click({$textBoxP.Text += "5"})
$form.Controls.Add($button5)

$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 650
$System_Drawing_Point.Y = 109
$button4.Location = $System_Drawing_Point
$button4.Name = "button4"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 67
$System_Drawing_Size.Width = 80
$button4.Size = $System_Drawing_Size
$button4.TabIndex = 3
$button4.Text = "4"
$button4.UseVisualStyleBackColor = $True
$button4.add_click({$textBoxP.Text += "4"})
$form.Controls.Add($button4)

$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 820
$System_Drawing_Point.Y = 35
$button3.Location = $System_Drawing_Point
$button3.Name = "button3"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 67
$System_Drawing_Size.Width = 80
$button3.Size = $System_Drawing_Size
$button3.TabIndex = 2
$button3.Text = "3"
$button3.UseVisualStyleBackColor = $True
$button3.add_click({$textBoxP.Text += "3"})
$form.Controls.Add($button3)

$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 735
$System_Drawing_Point.Y = 36
$button2.Location = $System_Drawing_Point
$button2.Name = "button2"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 67
$System_Drawing_Size.Width = 80
$button2.Size = $System_Drawing_Size
$button2.TabIndex = 1
$button2.Text = "2"
$button2.UseVisualStyleBackColor = $True
$button2.add_click({$textBoxP.Text += "2"})
$form.Controls.Add($button2)

$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 650
$System_Drawing_Point.Y = 35
$button1.Location = $System_Drawing_Point
$button1.Name = "button1"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 67
$System_Drawing_Size.Width = 80
$button1.Size = $System_Drawing_Size
$button1.TabIndex = 0
$button1.Text = "1"
$button1.UseVisualStyleBackColor = $True
$button1.add_click({$textBoxP.Text +="1"})
$form.Controls.Add($button1)

$InitialFormWindowState = $form.WindowState
$form.add_Load($OnLoadForm_StateCorrection)
$form.ShowDialog()| Out-Null
  | | L'administrateur a désactivé l'accés public en écriture.
© 2020 PowerShell-Scripting.com