Finish coding addComputer form

This commit is contained in:
JackCarterSmith 2017-05-31 09:37:41 +02:00
parent fb69c0cc77
commit 33425bd427
5 changed files with 56 additions and 17 deletions

View File

@ -27,7 +27,6 @@ Partial Class AddMachine
Me.NewIDBox = New System.Windows.Forms.TextBox() Me.NewIDBox = New System.Windows.Forms.TextBox()
Me.NewGivenByBox = New System.Windows.Forms.TextBox() Me.NewGivenByBox = New System.Windows.Forms.TextBox()
Me.Label8 = New System.Windows.Forms.Label() Me.Label8 = New System.Windows.Forms.Label()
Me.NewEtatBox = New System.Windows.Forms.TextBox()
Me.NewSerieCheckBox = New System.Windows.Forms.CheckBox() Me.NewSerieCheckBox = New System.Windows.Forms.CheckBox()
Me.NewDetailsBox = New System.Windows.Forms.TextBox() Me.NewDetailsBox = New System.Windows.Forms.TextBox()
Me.Label5 = New System.Windows.Forms.Label() Me.Label5 = New System.Windows.Forms.Label()
@ -38,16 +37,17 @@ Partial Class AddMachine
Me.PictureBox1 = New System.Windows.Forms.PictureBox() Me.PictureBox1 = New System.Windows.Forms.PictureBox()
Me.AddCompCancelButton = New System.Windows.Forms.Button() Me.AddCompCancelButton = New System.Windows.Forms.Button()
Me.AddComputerButton = New System.Windows.Forms.Button() Me.AddComputerButton = New System.Windows.Forms.Button()
Me.NewEtatBox = New System.Windows.Forms.ComboBox()
Me.GroupBox2.SuspendLayout() Me.GroupBox2.SuspendLayout()
CType(Me.PictureBox1, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.PictureBox1, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout() Me.SuspendLayout()
' '
'GroupBox2 'GroupBox2
' '
Me.GroupBox2.Controls.Add(Me.NewEtatBox)
Me.GroupBox2.Controls.Add(Me.NewIDBox) Me.GroupBox2.Controls.Add(Me.NewIDBox)
Me.GroupBox2.Controls.Add(Me.NewGivenByBox) Me.GroupBox2.Controls.Add(Me.NewGivenByBox)
Me.GroupBox2.Controls.Add(Me.Label8) Me.GroupBox2.Controls.Add(Me.Label8)
Me.GroupBox2.Controls.Add(Me.NewEtatBox)
Me.GroupBox2.Controls.Add(Me.NewSerieCheckBox) Me.GroupBox2.Controls.Add(Me.NewSerieCheckBox)
Me.GroupBox2.Controls.Add(Me.NewDetailsBox) Me.GroupBox2.Controls.Add(Me.NewDetailsBox)
Me.GroupBox2.Controls.Add(Me.Label5) Me.GroupBox2.Controls.Add(Me.Label5)
@ -87,13 +87,6 @@ Partial Class AddMachine
Me.Label8.TabIndex = 15 Me.Label8.TabIndex = 15
Me.Label8.Text = "Provenance :" Me.Label8.Text = "Provenance :"
' '
'NewEtatBox
'
Me.NewEtatBox.Location = New System.Drawing.Point(37, 47)
Me.NewEtatBox.Name = "NewEtatBox"
Me.NewEtatBox.Size = New System.Drawing.Size(131, 20)
Me.NewEtatBox.TabIndex = 1
'
'NewSerieCheckBox 'NewSerieCheckBox
' '
Me.NewSerieCheckBox.AutoSize = True Me.NewSerieCheckBox.AutoSize = True
@ -185,6 +178,15 @@ Partial Class AddMachine
Me.AddComputerButton.Text = "Ajouter" Me.AddComputerButton.Text = "Ajouter"
Me.AddComputerButton.UseVisualStyleBackColor = True Me.AddComputerButton.UseVisualStyleBackColor = True
' '
'NewEtatBox
'
Me.NewEtatBox.FormattingEnabled = True
Me.NewEtatBox.Items.AddRange(New Object() {"R.I.P", "Peut faire l'affaire", "En état", "Neuf"})
Me.NewEtatBox.Location = New System.Drawing.Point(45, 47)
Me.NewEtatBox.Name = "NewEtatBox"
Me.NewEtatBox.Size = New System.Drawing.Size(121, 21)
Me.NewEtatBox.TabIndex = 1
'
'AddMachine 'AddMachine
' '
Me.AcceptButton = Me.AddComputerButton Me.AcceptButton = Me.AddComputerButton
@ -211,7 +213,6 @@ Partial Class AddMachine
Friend WithEvents GroupBox2 As GroupBox Friend WithEvents GroupBox2 As GroupBox
Friend WithEvents NewGivenByBox As TextBox Friend WithEvents NewGivenByBox As TextBox
Friend WithEvents Label8 As Label Friend WithEvents Label8 As Label
Friend WithEvents NewEtatBox As TextBox
Friend WithEvents NewSerieCheckBox As CheckBox Friend WithEvents NewSerieCheckBox As CheckBox
Friend WithEvents NewDetailsBox As TextBox Friend WithEvents NewDetailsBox As TextBox
Friend WithEvents Label5 As Label Friend WithEvents Label5 As Label
@ -223,4 +224,5 @@ Partial Class AddMachine
Friend WithEvents NewIDBox As TextBox Friend WithEvents NewIDBox As TextBox
Friend WithEvents AddCompCancelButton As Button Friend WithEvents AddCompCancelButton As Button
Friend WithEvents AddComputerButton As Button Friend WithEvents AddComputerButton As Button
Friend WithEvents NewEtatBox As ComboBox
End Class End Class

View File

@ -1,4 +1,6 @@
Public Class AddMachine Imports System.Data.SQLite
Public Class AddMachine
Public Shared newID As String Public Shared newID As String
Private Sub AddMachine_Load(sender As Object, e As EventArgs) Handles MyBase.Load Private Sub AddMachine_Load(sender As Object, e As EventArgs) Handles MyBase.Load
@ -9,9 +11,40 @@
NewIDBox.Text = newID NewIDBox.Text = newID
NewNameBox.Focus() NewNameBox.Focus()
NewEtatBox.SelectedIndex = 0
End Sub End Sub
Private Function CheckToNumeric(control As CheckBox) As String
If control.Checked Then Return "1"
Return "0"
End Function
Private Sub AddCompCancelButton_Click(sender As Object, e As EventArgs) Handles AddCompCancelButton.Click Private Sub AddCompCancelButton_Click(sender As Object, e As EventArgs) Handles AddCompCancelButton.Click
Me.Close() Me.Close()
End Sub End Sub
Private Sub AddComputerButton_Click(sender As Object, e As EventArgs) Handles AddComputerButton.Click
Dim addComputer_seq As String = "
INSERT INTO computers_desc VALUES ('" & NewIDBox.Text & "','" & NewNameBox.Text & "'," & NewEtatBox.SelectedIndex + 1 & "," & CheckToNumeric(NewSerieCheckBox) & ",'" & NewDetailsBox.Text & "',0,'N/A','" & NewGivenByBox.Text & "');
INSERT INTO computers_progress VALUES ('" & NewIDBox.Text & "',0,0,0,0,0,1,1,1);
"
If NewNameBox.Text = "" Then MsgBox("Vous ne pouvez pas laisser un nom vide !", 48, "Erreur de saisie") : Exit Sub
If NewDetailsBox.Text = "" Then NewDetailsBox.Text = "N/A"
If NewGivenByBox.Text = "" Then NewGivenByBox.Text = "N/A"
Try
Main.StatusLabel.Text = "Tentative d'ajout de l'ordinateur à la base de données..."
Using con As New SQLiteConnection("URI=file:db.sqlite")
con.Open()
Dim cmd As New SQLiteCommand(addComputer_seq, con)
If cmd.ExecuteNonQuery() <> 2 Then MsgBox("Erreur inconnue au niveau de la base de données !", 16, "Defaillance générale !") : End
con.Close()
End Using
Main.StatusLabel.Text = "Ordinateur ajouté avec succés dans la base de données."
Main.ListAllInv()
Me.Close()
Catch ex As Exception
Main.StatusLabel.Text = "Une erreur avec la base SQLite s'est produite !"
MsgBox(ex.Message)
End Try
End Sub
End Class End Class

View File

@ -57,6 +57,9 @@
<PropertyGroup> <PropertyGroup>
<AssemblyOriginatorKeyFile>JCS.pfx</AssemblyOriginatorKeyFile> <AssemblyOriginatorKeyFile>JCS.pfx</AssemblyOriginatorKeyFile>
</PropertyGroup> </PropertyGroup>
<PropertyGroup>
<SignManifests>false</SignManifests>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />

View File

@ -28,7 +28,7 @@ Public Class Main
`comms` TEXT NOT NULL DEFAULT 'N/A', `comms` TEXT NOT NULL DEFAULT 'N/A',
`gived` INTEGER NOT NULL DEFAULT 0, `gived` INTEGER NOT NULL DEFAULT 0,
`giveTo` TEXT NOT NULL DEFAULT 'N/A', `giveTo` TEXT NOT NULL DEFAULT 'N/A',
`getBy` NUMERIC NOT NULL DEFAULT 'ISEN' `getBy` TEXT NOT NULL DEFAULT 'ISEN'
); );
CREATE TABLE `computers_progress` ( CREATE TABLE `computers_progress` (
`id` TEXT NOT NULL DEFAULT 0000000000 UNIQUE, `id` TEXT NOT NULL DEFAULT 0000000000 UNIQUE,
@ -62,9 +62,10 @@ Public Class Main
End Try End Try
End Sub End Sub
Private Sub ListAllInv() Public Sub ListAllInv()
Dim dtr As SQLiteDataReader Dim dtr As SQLiteDataReader
InvList.Items.Clear()
InvList.ValueMember = "Equippements" InvList.ValueMember = "Equippements"
InvList.DisplayMember = "Nom" InvList.DisplayMember = "Nom"
Try Try

View File

@ -9,8 +9,8 @@ Imports System.Runtime.InteropServices
' Vérifiez les valeurs des attributs de l'assembly ' Vérifiez les valeurs des attributs de l'assembly
<Assembly: AssemblyTitle("ISEN-Repair Inventory Manager")> <Assembly: AssemblyTitle("ISEN-Repair Inventory Manager")>
<Assembly: AssemblyDescription("Soft de gestion et du suivi des PCs de la Repair, les entrées et les sorties ainsi que les empruns.")> <Assembly: AssemblyDescription("Soft de gestion et du suivi des ordinateurs de la Repair, les entrées et les sorties ainsi que les empruns.")>
<Assembly: AssemblyCompany("JCS's Production")> <Assembly: AssemblyCompany("by JackCarterSmith")>
<Assembly: AssemblyProduct("ISEN-Repair Inventory Manager")> <Assembly: AssemblyProduct("ISEN-Repair Inventory Manager")>
<Assembly: AssemblyCopyright("Copyright © 2017")> <Assembly: AssemblyCopyright("Copyright © 2017")>
<Assembly: AssemblyTrademark("")> <Assembly: AssemblyTrademark("")>
@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
' en utilisant '*', comme indiqué ci-dessous : ' en utilisant '*', comme indiqué ci-dessous :
' <Assembly: AssemblyVersion("1.0.*")> ' <Assembly: AssemblyVersion("1.0.*")>
<Assembly: AssemblyVersion("1.0.0.0")> <Assembly: AssemblyVersion("1.1.52.0")>
<Assembly: AssemblyFileVersion("1.0.0.0")> <Assembly: AssemblyFileVersion("1.1.52.0")>