Coding trash button... but it cause bugs with list refresh

This commit is contained in:
JackCarterSmith 2017-05-31 10:29:23 +02:00
parent 6b4f2e8db4
commit e8a7dec124
2 changed files with 38 additions and 22 deletions

View File

@ -29,7 +29,6 @@ Partial Class Main
Me.StatusStrip1 = New System.Windows.Forms.StatusStrip()
Me.StatusLabel = New System.Windows.Forms.ToolStripStatusLabel()
Me.GroupBox1 = New System.Windows.Forms.GroupBox()
Me.InvSearchBar = New System.Windows.Forms.TextBox()
Me.InvList = New System.Windows.Forms.ListBox()
Me.SendOutButton = New System.Windows.Forms.Button()
Me.TrashButton = New System.Windows.Forms.Button()
@ -105,7 +104,6 @@ Partial Class Main
'
'GroupBox1
'
Me.GroupBox1.Controls.Add(Me.InvSearchBar)
Me.GroupBox1.Controls.Add(Me.InvList)
Me.GroupBox1.Location = New System.Drawing.Point(12, 27)
Me.GroupBox1.Name = "GroupBox1"
@ -114,42 +112,38 @@ Partial Class Main
Me.GroupBox1.TabStop = False
Me.GroupBox1.Text = "Inventaire"
'
'InvSearchBar
'
Me.InvSearchBar.Location = New System.Drawing.Point(7, 20)
Me.InvSearchBar.Name = "InvSearchBar"
Me.InvSearchBar.Size = New System.Drawing.Size(323, 20)
Me.InvSearchBar.TabIndex = 1
'
'InvList
'
Me.InvList.FormattingEnabled = True
Me.InvList.Location = New System.Drawing.Point(6, 48)
Me.InvList.Location = New System.Drawing.Point(6, 17)
Me.InvList.Name = "InvList"
Me.InvList.ScrollAlwaysVisible = True
Me.InvList.Size = New System.Drawing.Size(324, 277)
Me.InvList.Size = New System.Drawing.Size(324, 316)
Me.InvList.Sorted = True
Me.InvList.TabIndex = 2
'
'SendOutButton
'
Me.SendOutButton.BackColor = System.Drawing.Color.Green
Me.SendOutButton.Location = New System.Drawing.Point(701, 343)
Me.SendOutButton.Name = "SendOutButton"
Me.SendOutButton.Size = New System.Drawing.Size(156, 23)
Me.SendOutButton.TabIndex = 6
Me.SendOutButton.TabStop = False
Me.SendOutButton.Text = "Livré"
Me.SendOutButton.UseVisualStyleBackColor = True
Me.SendOutButton.Text = "A été livré"
Me.SendOutButton.UseVisualStyleBackColor = False
'
'TrashButton
'
Me.TrashButton.BackColor = System.Drawing.Color.Firebrick
Me.TrashButton.ForeColor = System.Drawing.Color.White
Me.TrashButton.Location = New System.Drawing.Point(361, 343)
Me.TrashButton.Name = "TrashButton"
Me.TrashButton.Size = New System.Drawing.Size(156, 23)
Me.TrashButton.TabIndex = 7
Me.TrashButton.TabStop = False
Me.TrashButton.Text = "Jeté"
Me.TrashButton.UseVisualStyleBackColor = True
Me.TrashButton.Text = "A été jeté"
Me.TrashButton.UseVisualStyleBackColor = False
'
'Label1
'
@ -361,7 +355,7 @@ Partial Class Main
'
'ComputerRepairGlobalProgress
'
Me.ComputerRepairGlobalProgress.ForeColor = System.Drawing.Color.Crimson
Me.ComputerRepairGlobalProgress.ForeColor = System.Drawing.Color.SteelBlue
Me.ComputerRepairGlobalProgress.Location = New System.Drawing.Point(6, 90)
Me.ComputerRepairGlobalProgress.Name = "ComputerRepairGlobalProgress"
Me.ComputerRepairGlobalProgress.Size = New System.Drawing.Size(496, 23)
@ -432,13 +426,14 @@ Partial Class Main
'
'EditButton
'
Me.EditButton.BackColor = System.Drawing.Color.Gold
Me.EditButton.Location = New System.Drawing.Point(523, 343)
Me.EditButton.Name = "EditButton"
Me.EditButton.Size = New System.Drawing.Size(172, 23)
Me.EditButton.TabIndex = 8
Me.EditButton.TabStop = False
Me.EditButton.Text = "Modifier"
Me.EditButton.UseVisualStyleBackColor = True
Me.EditButton.Text = "Editer le suivi"
Me.EditButton.UseVisualStyleBackColor = False
'
'Main
'
@ -465,7 +460,6 @@ Partial Class Main
Me.StatusStrip1.ResumeLayout(False)
Me.StatusStrip1.PerformLayout()
Me.GroupBox1.ResumeLayout(False)
Me.GroupBox1.PerformLayout()
Me.GroupBox2.ResumeLayout(False)
Me.GroupBox2.PerformLayout()
Me.GroupBox3.ResumeLayout(False)
@ -479,7 +473,6 @@ Partial Class Main
Friend WithEvents StatusStrip1 As StatusStrip
Friend WithEvents StatusLabel As ToolStripStatusLabel
Friend WithEvents GroupBox1 As GroupBox
Friend WithEvents InvSearchBar As TextBox
Friend WithEvents InvList As ListBox
Friend WithEvents SendOutButton As Button
Friend WithEvents TrashButton As Button

View File

@ -104,7 +104,6 @@ Public Class Main
IDBox.Text = dtr.GetString(0)
manualID_selected = True
NameBox.Text = dtr.GetString(1)
InvSearchBar.Text = dtr.GetString(1)
If dtr.GetInt32(2) = 0 Then
EtatBox.Text = "R.I.P"
ElseIf dtr.GetInt32(2) = 1 Then
@ -162,7 +161,6 @@ Public Class Main
manualID_selected = True
StatusLabel.Text = "ID trouvé !"
NameBox.Text = dtr.GetString(1)
InvSearchBar.Text = dtr.GetString(1)
If dtr.GetInt32(2) = 0 Then
EtatBox.Text = "R.I.P"
ElseIf dtr.GetInt32(2) = 1 Then
@ -250,6 +248,31 @@ Public Class Main
End Using
con.Close()
End Using
If HWCheck.Checked And OSCheck.Checked And DrvCheck.Checked And SoftCheck.Checked And ActivateCheck.Checked Then SendOutButton.Enabled = True Else SendOutButton.Enabled = False
Catch ex As Exception
StatusLabel.Text = "Une erreur avec la base SQLite s'est produite !"
MsgBox(ex.Message)
End Try
End Sub
Private Sub TrashButton_Click(sender As Object, e As EventArgs) Handles TrashButton.Click
If MsgBox("ATTENTION ! Voulez vous vraiment supprimer cette ordinateur de la base de données ?", 292, "Trash") = 7 Then Exit Sub
Dim trash_seq As String = "
DELETE FROM computers_desc WHERE id='" & IDBox.Text & "';
DELETE FROM computers_progress WHERE id='" & IDBox.Text & "';
"
Try
StatusLabel.Text = "Supression d'un ordinateur de la base de données..."
Using con As New SQLiteConnection("URI=file:db.sqlite")
con.Open()
Dim cmd As New SQLiteCommand(trash_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
StatusLabel.Text = "Ordinateur supprimé avec succès !"
ListAllInv()
Catch ex As Exception
StatusLabel.Text = "Une erreur avec la base SQLite s'est produite !"
MsgBox(ex.Message)