Merge branch 'master' into print-function

This commit is contained in:
JackCarterSmith 2017-10-15 12:34:42 +02:00 committed by GitHub
commit 03d9b0e58f
11 changed files with 180 additions and 41 deletions

View File

@ -0,0 +1,30 @@
1463671755
7020175153
5404717746
3296685637
0736311783
9076156940
5837970452
4352106486
9547078358
1798072890
1389587524
3541155156
8190600237
2774273532
4811090670
1317029903
6191218542
6626901383
0898950400
2743029532
9237839921
4168614523
9812526007
2588574302
1200837449
8481657818
4044723385
8222876041
0008935301
0061659415

View File

@ -13,7 +13,7 @@
' TODO: personnalisez les informations d'assembly de l'application dans le volet "Application" de la ' TODO: personnalisez les informations d'assembly de l'application dans le volet "Application" de la
' boîte de dialogue Propriétés du projet (sous le menu "Projet"). ' boîte de dialogue Propriétés du projet (sous le menu "Projet").
Me.LabelProductName.Text = My.Application.Info.ProductName Me.LabelProductName.Text = My.Application.Info.ProductName
Me.LabelVersion.Text = String.Format("Version {0}.{1}", My.Application.Info.Version.Major, My.Application.Info.Version.Minor) Me.LabelVersion.Text = String.Format("Version {0}", My.Application.Info.Version)
Me.LabelCopyright.Text = My.Application.Info.Copyright Me.LabelCopyright.Text = My.Application.Info.Copyright
Me.LabelCompanyName.Text = My.Application.Info.CompanyName Me.LabelCompanyName.Text = My.Application.Info.CompanyName
Me.TextBoxDescription.Text = My.Application.Info.Description Me.TextBoxDescription.Text = My.Application.Info.Description

View File

@ -30,7 +30,7 @@ Public Class AddMachine
Try Try
Main.StatusLabel.Text = "Tentative d'ajout de l'ordinateur à la base de données..." Main.StatusLabel.Text = "Tentative d'ajout de l'ordinateur à la base de données..."
Using con As New SQLiteConnection("URI=file:db.sqlite") Using con As New SQLiteConnection("URI=file:" & Main.dbLocFile)
con.Open() con.Open()
Dim cmd As New SQLiteCommand(con) Dim cmd As New SQLiteCommand(con)
cmd.CommandText = "INSERT INTO computers_desc VALUES ('" & NewIDBox.Text & "','" & NewNameBox.Text & "'," & NewEtatBox.SelectedIndex & "," & CheckToNumeric(NewSerieCheckBox) & ",'" & Replace(NewDetailsBox.Text, "'", "_*_") & "',0,'N/A','" & NewGivenByBox.Text & "');" cmd.CommandText = "INSERT INTO computers_desc VALUES ('" & NewIDBox.Text & "','" & NewNameBox.Text & "'," & NewEtatBox.SelectedIndex & "," & CheckToNumeric(NewSerieCheckBox) & ",'" & Replace(NewDetailsBox.Text, "'", "_*_") & "',0,'N/A','" & NewGivenByBox.Text & "');"
@ -42,9 +42,12 @@ Public Class AddMachine
Main.log.Info("Computer " & NewIDBox.Text & " added") Main.log.Info("Computer " & NewIDBox.Text & " added")
Main.StatusLabel.Text = "Ordinateur ajouté avec succés dans la base de données." Main.StatusLabel.Text = "Ordinateur ajouté avec succés dans la base de données."
Main.ListAllInv() Main.ListAllInv()
Main.log.Info("Added computer " & NewIDBox.Text & " with success !")
Me.Close() Me.Close()
Catch ex As Exception Catch ex As Exception
Main.StatusLabel.Text = "Une erreur avec la base SQLite s'est produite !" Main.StatusLabel.Text = "Une erreur avec la base SQLite s'est produite !"
Main.log.Critical("Error has been occur when saving data to DB !")
Main.log.Critical(ex.Message)
MsgBox(ex.Message) MsgBox(ex.Message)
End Try End Try
End Sub End Sub

View File

@ -35,8 +35,8 @@
<CreateWebPageOnPublish>true</CreateWebPageOnPublish> <CreateWebPageOnPublish>true</CreateWebPageOnPublish>
<WebPage>index.htm</WebPage> <WebPage>index.htm</WebPage>
<OpenBrowserOnPublish>false</OpenBrowserOnPublish> <OpenBrowserOnPublish>false</OpenBrowserOnPublish>
<ApplicationRevision>6</ApplicationRevision> <ApplicationRevision>3</ApplicationRevision>
<ApplicationVersion>0.9.5.%2a</ApplicationVersion> <ApplicationVersion>0.10.1.3</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust> <UseApplicationTrust>false</UseApplicationTrust>
<CreateDesktopShortcut>true</CreateDesktopShortcut> <CreateDesktopShortcut>true</CreateDesktopShortcut>
<PublishWizardCompleted>true</PublishWizardCompleted> <PublishWizardCompleted>true</PublishWizardCompleted>
@ -91,7 +91,7 @@
<SignManifests>true</SignManifests> <SignManifests>true</SignManifests>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<ManifestCertificateThumbprint>D00CE50649372742555DAC702A1327003B99D37C</ManifestCertificateThumbprint> <ManifestCertificateThumbprint>620A13A82ECD693F86DBAEDE2FA8737A6A18D351</ManifestCertificateThumbprint>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<ManifestKeyFile>ISEN-Repair Inventory Manager_TemporaryKey.pfx</ManifestKeyFile> <ManifestKeyFile>ISEN-Repair Inventory Manager_TemporaryKey.pfx</ManifestKeyFile>

View File

@ -3,11 +3,11 @@
Public Class Logger Public Class Logger
'DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") 'DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")
Dim logFileName As String = "logs\" & DateTime.Now.ToString("yyyy-MM-dd") & ".txt" Dim logFileName As String = Main.localAppData & "logs\" & DateTime.Now.ToString("yyyy-MM-dd") & ".txt"
Public Sub Load() Public Sub Load()
If Not My.Computer.FileSystem.DirectoryExists("logs") Then My.Computer.FileSystem.CreateDirectory("logs") If Not My.Computer.FileSystem.DirectoryExists(Main.localAppData & "logs") Then My.Computer.FileSystem.CreateDirectory(Main.localAppData & "logs")
If Not My.Computer.FileSystem.FileExists(logFileName) Then File.WriteAllLines(logFileName, {"LOG FILE - " & DateTime.Now.ToString("dd/MM/yyyy"), "--------------------", "[" & DateTime.Now.ToString("HH:mm:ss") & "][INFO] Loading software"}) If Not My.Computer.FileSystem.FileExists(logFileName) Then File.WriteAllLines(logFileName, {"--------------------------------------------------------------", "------------------- LOG FILE - " & DateTime.Now.ToString("dd/MM/yyyy") & " -------------------", "--------------------------------------------------------------", "[" & DateTime.Now.ToString("HH:mm:ss") & "][INFO] Init software"})
End Sub End Sub
Public Sub Info(str As String) Public Sub Info(str As String)

View File

@ -24,8 +24,13 @@ Partial Class Main
Private Sub InitializeComponent() Private Sub InitializeComponent()
Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(Main)) Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(Main))
Me.MenuStrip1 = New System.Windows.Forms.MenuStrip() Me.MenuStrip1 = New System.Windows.Forms.MenuStrip()
Me.QuitterToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
Me.AddComputerToolMenuItem = New System.Windows.Forms.ToolStripMenuItem() Me.AddComputerToolMenuItem = New System.Windows.Forms.ToolStripMenuItem()
Me.EnleverPCsToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
Me.GénérerDesIDsToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() Me.GénérerDesIDsToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
Me.DBToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
Me.ImporterToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
Me.ExporterToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
Me.AboutToolMenuItem = New System.Windows.Forms.ToolStripMenuItem() Me.AboutToolMenuItem = New System.Windows.Forms.ToolStripMenuItem()
Me.StatusStrip1 = New System.Windows.Forms.StatusStrip() Me.StatusStrip1 = New System.Windows.Forms.StatusStrip()
Me.StatusLabel = New System.Windows.Forms.ToolStripStatusLabel() Me.StatusLabel = New System.Windows.Forms.ToolStripStatusLabel()
@ -60,7 +65,8 @@ Partial Class Main
Me.OSBox = New System.Windows.Forms.TextBox() Me.OSBox = New System.Windows.Forms.TextBox()
Me.ArchBox = New System.Windows.Forms.TextBox() Me.ArchBox = New System.Windows.Forms.TextBox()
Me.EditButton = New System.Windows.Forms.Button() Me.EditButton = New System.Windows.Forms.Button()
Me.DBAccessToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() Me.OpenBackupFile = New System.Windows.Forms.OpenFileDialog()
Me.SaveBackupFile = New System.Windows.Forms.SaveFileDialog()
Me.MenuStrip1.SuspendLayout() Me.MenuStrip1.SuspendLayout()
Me.StatusStrip1.SuspendLayout() Me.StatusStrip1.SuspendLayout()
Me.GroupBox1.SuspendLayout() Me.GroupBox1.SuspendLayout()
@ -70,18 +76,30 @@ Partial Class Main
' '
'MenuStrip1 'MenuStrip1
' '
Me.MenuStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.AddComputerToolMenuItem, Me.GénérerDesIDsToolStripMenuItem, Me.DBAccessToolStripMenuItem, Me.AboutToolMenuItem}) Me.MenuStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.QuitterToolStripMenuItem, Me.AddComputerToolMenuItem, Me.EnleverPCsToolStripMenuItem, Me.GénérerDesIDsToolStripMenuItem, Me.DBToolStripMenuItem, Me.AboutToolMenuItem})
Me.MenuStrip1.Location = New System.Drawing.Point(0, 0) Me.MenuStrip1.Location = New System.Drawing.Point(0, 0)
Me.MenuStrip1.Name = "MenuStrip1" Me.MenuStrip1.Name = "MenuStrip1"
Me.MenuStrip1.Size = New System.Drawing.Size(874, 24) Me.MenuStrip1.Size = New System.Drawing.Size(874, 24)
Me.MenuStrip1.TabIndex = 0 Me.MenuStrip1.TabIndex = 0
Me.MenuStrip1.Text = "MenuStrip1" Me.MenuStrip1.Text = "MenuStrip1"
' '
'QuitterToolStripMenuItem
'
Me.QuitterToolStripMenuItem.Name = "QuitterToolStripMenuItem"
Me.QuitterToolStripMenuItem.Size = New System.Drawing.Size(56, 20)
Me.QuitterToolStripMenuItem.Text = "Quitter"
'
'AddComputerToolMenuItem 'AddComputerToolMenuItem
' '
Me.AddComputerToolMenuItem.Name = "AddComputerToolMenuItem" Me.AddComputerToolMenuItem.Name = "AddComputerToolMenuItem"
Me.AddComputerToolMenuItem.Size = New System.Drawing.Size(93, 20) Me.AddComputerToolMenuItem.Size = New System.Drawing.Size(81, 20)
Me.AddComputerToolMenuItem.Text = "Ajouter un PC" Me.AddComputerToolMenuItem.Text = "Ajouter PCs"
'
'EnleverPCsToolStripMenuItem
'
Me.EnleverPCsToolStripMenuItem.Name = "EnleverPCsToolStripMenuItem"
Me.EnleverPCsToolStripMenuItem.Size = New System.Drawing.Size(80, 20)
Me.EnleverPCsToolStripMenuItem.Text = "Enlever PCs"
' '
'GénérerDesIDsToolStripMenuItem 'GénérerDesIDsToolStripMenuItem
' '
@ -89,6 +107,26 @@ Partial Class Main
Me.GénérerDesIDsToolStripMenuItem.Size = New System.Drawing.Size(100, 20) Me.GénérerDesIDsToolStripMenuItem.Size = New System.Drawing.Size(100, 20)
Me.GénérerDesIDsToolStripMenuItem.Text = "Générer des IDs" Me.GénérerDesIDsToolStripMenuItem.Text = "Générer des IDs"
' '
'DBToolStripMenuItem
'
Me.DBToolStripMenuItem.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.ImporterToolStripMenuItem, Me.ExporterToolStripMenuItem})
Me.DBToolStripMenuItem.Name = "DBToolStripMenuItem"
Me.DBToolStripMenuItem.Size = New System.Drawing.Size(34, 20)
Me.DBToolStripMenuItem.Text = "DB"
Me.DBToolStripMenuItem.TextAlign = System.Drawing.ContentAlignment.BottomCenter
'
'ImporterToolStripMenuItem
'
Me.ImporterToolStripMenuItem.Name = "ImporterToolStripMenuItem"
Me.ImporterToolStripMenuItem.Size = New System.Drawing.Size(120, 22)
Me.ImporterToolStripMenuItem.Text = "Importer"
'
'ExporterToolStripMenuItem
'
Me.ExporterToolStripMenuItem.Name = "ExporterToolStripMenuItem"
Me.ExporterToolStripMenuItem.Size = New System.Drawing.Size(120, 22)
Me.ExporterToolStripMenuItem.Text = "Exporter"
'
'AboutToolMenuItem 'AboutToolMenuItem
' '
Me.AboutToolMenuItem.Name = "AboutToolMenuItem" Me.AboutToolMenuItem.Name = "AboutToolMenuItem"
@ -447,11 +485,17 @@ Partial Class Main
Me.EditButton.Text = "Editer le suivi" Me.EditButton.Text = "Editer le suivi"
Me.EditButton.UseVisualStyleBackColor = False Me.EditButton.UseVisualStyleBackColor = False
' '
'DBAccessToolStripMenuItem 'OpenBackupFile
' '
Me.DBAccessToolStripMenuItem.Name = "DBAccessToolStripMenuItem" Me.OpenBackupFile.DefaultExt = "sqlite"
Me.DBAccessToolStripMenuItem.Size = New System.Drawing.Size(73, 20) Me.OpenBackupFile.Filter = "Fichier SQLite|*.sqlite"
Me.DBAccessToolStripMenuItem.Text = "DB Access" Me.OpenBackupFile.Title = "Importer la DB"
'
'SaveBackupFile
'
Me.SaveBackupFile.DefaultExt = "sqlite"
Me.SaveBackupFile.Filter = "Fichier SQLite|*.sqlite"
Me.SaveBackupFile.Title = "Exporter la DB"
' '
'Main 'Main
' '
@ -525,5 +569,11 @@ Partial Class Main
Friend WithEvents IDBox As MaskedTextBox Friend WithEvents IDBox As MaskedTextBox
Private WithEvents AddComputerToolMenuItem As ToolStripMenuItem Private WithEvents AddComputerToolMenuItem As ToolStripMenuItem
Friend WithEvents GénérerDesIDsToolStripMenuItem As ToolStripMenuItem Friend WithEvents GénérerDesIDsToolStripMenuItem As ToolStripMenuItem
Friend WithEvents DBAccessToolStripMenuItem As ToolStripMenuItem Friend WithEvents DBToolStripMenuItem As ToolStripMenuItem
Friend WithEvents OpenBackupFile As OpenFileDialog
Friend WithEvents SaveBackupFile As SaveFileDialog
Friend WithEvents ImporterToolStripMenuItem As ToolStripMenuItem
Friend WithEvents ExporterToolStripMenuItem As ToolStripMenuItem
Friend WithEvents QuitterToolStripMenuItem As ToolStripMenuItem
Friend WithEvents EnleverPCsToolStripMenuItem As ToolStripMenuItem
End Class End Class

View File

@ -123,6 +123,12 @@
<metadata name="StatusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <metadata name="StatusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>132, 17</value> <value>132, 17</value>
</metadata> </metadata>
<metadata name="OpenBackupFile.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>249, 17</value>
</metadata>
<metadata name="SaveBackupFile.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>389, 17</value>
</metadata>
<metadata name="$this.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="$this.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value> <value>True</value>
</metadata> </metadata>

View File

@ -1,16 +1,21 @@
Imports System.Data.SQLite Imports System.Data.SQLite
Imports System.Text Imports System.Text
Imports System.IO Imports System.IO
Imports System.Environment
Imports System.ComponentModel
Public Class Main Public Class Main
Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) 'Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Dim manualID_selected As Boolean = False Dim manualID_selected As Boolean = False
Dim idList As New ArrayList Dim idList As New ArrayList
Public log As New Logger Public log As New Logger
Public Shared localAppData As String = GetFolderPath(SpecialFolder.LocalApplicationData) & "\InvManager\"
Public Shared dbLocFile As String = localAppData & "db.sqlite"
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
log.Load() log.Load()
log.Info("Check and load of database")
CheckIfFirstRun() CheckIfFirstRun()
ListAllInv() ListAllInv()
End Sub End Sub
@ -19,8 +24,8 @@ Public Class Main
''' Function to check if app is running for the first time ''' Function to check if app is running for the first time
''' </summary> ''' </summary>
Private Sub CheckIfFirstRun() Private Sub CheckIfFirstRun()
log.Info("Check and load of database") If Not My.Computer.FileSystem.DirectoryExists(localAppData) Then My.Computer.FileSystem.CreateDirectory(localAppData)
If Not My.Computer.FileSystem.FileExists("db.sqlite") Then If Not My.Computer.FileSystem.FileExists(dbLocFile) Then
If MsgBox("La base de données SQLite est introuvable ou inaccessible, souhaitez-vous la régénérer ?", 4161, "Base SQLite absente ou inaccessible") = 1 Then If MsgBox("La base de données SQLite est introuvable ou inaccessible, souhaitez-vous la régénérer ?", 4161, "Base SQLite absente ou inaccessible") = 1 Then
RegenerateDB() RegenerateDB()
Else Else
@ -38,7 +43,7 @@ Public Class Main
Dim dtr As SQLiteDataReader Dim dtr As SQLiteDataReader
Try Try
Using con As New SQLiteConnection("URI=file:db.sqlite") Using con As New SQLiteConnection("URI=file:" & dbLocFile)
con.Open() con.Open()
Using cmd As New SQLiteCommand(con) Using cmd As New SQLiteCommand(con)
cmd.CommandText = "SELECT * FROM computers_desc WHERE id=" & idToCheck & ";" cmd.CommandText = "SELECT * FROM computers_desc WHERE id=" & idToCheck & ";"
@ -53,7 +58,9 @@ Public Class Main
Catch ex As Exception Catch ex As Exception
StatusLabel.Text = "Une erreur avec la base SQLite s'est produite !" StatusLabel.Text = "Une erreur avec la base SQLite s'est produite !"
MsgBox(ex.Message) log.Critical("Error has been occur when connect to DB !")
log.Critical(ex.Message)
MsgBox("Error ! Check log file for details.")
End Try End Try
Return True Return True
@ -143,16 +150,19 @@ Public Class Main
Try Try
StatusLabel.Text = "Reconstructions de la base SQLite..." StatusLabel.Text = "Reconstructions de la base SQLite..."
Using con As New SQLiteConnection("URI=file:db.sqlite") Using con As New SQLiteConnection("URI=file:" & dbLocFile)
con.Open() con.Open()
Dim cmd As New SQLiteCommand(genesis_seq, con) Dim cmd As New SQLiteCommand(genesis_seq, con)
cmd.ExecuteNonQuery() cmd.ExecuteNonQuery()
con.Close() con.Close()
End Using End Using
StatusLabel.Text = "La base SQLite a été reconstruite avec succès !" StatusLabel.Text = "La base SQLite a été reconstruite avec succès !"
log.Info("Base SQLite reconstructed.")
Catch ex As Exception Catch ex As Exception
StatusLabel.Text = "Une erreur avec la base SQLite s'est produite !" StatusLabel.Text = "Une erreur avec la base SQLite s'est produite !"
MsgBox(ex.Message) log.Critical("Error has been occur when reconstrut DB !")
log.Critical(ex.Message)
MsgBox("Error ! Check log file for details.")
End Try End Try
End Sub End Sub
@ -168,7 +178,7 @@ Public Class Main
InvList.DisplayMember = "Nom" InvList.DisplayMember = "Nom"
Try Try
StatusLabel.Text = "Récupération des données depuis la base SQLite..." StatusLabel.Text = "Récupération des données depuis la base SQLite..."
Using con As New SQLiteConnection("URI=file:db.sqlite") Using con As New SQLiteConnection("URI=file:" & dbLocFile)
con.Open() con.Open()
Using cmd As New SQLiteCommand(con) Using cmd As New SQLiteCommand(con)
cmd.CommandText = "SELECT id,name FROM computers_desc;" cmd.CommandText = "SELECT id,name FROM computers_desc;"
@ -184,7 +194,9 @@ Public Class Main
StatusLabel.Text = "Récupération avec succés de la base SQLite." StatusLabel.Text = "Récupération avec succés de la base SQLite."
Catch ex As Exception Catch ex As Exception
StatusLabel.Text = "Une erreur avec la base SQLite s'est produite !" StatusLabel.Text = "Une erreur avec la base SQLite s'est produite !"
MsgBox(ex.Message) log.Critical("Error has been occur when retrieve data from DB !")
log.Critical(ex.Message)
MsgBox("Error ! Check log file for details.")
End Try End Try
End Sub End Sub
@ -222,7 +234,7 @@ Public Class Main
Dim dtr As SQLiteDataReader Dim dtr As SQLiteDataReader
Try Try
Using con As New SQLiteConnection("URI=file:db.sqlite") Using con As New SQLiteConnection("URI=file:" & dbLocFile)
con.Open() con.Open()
Using cmd As New SQLiteCommand(con) Using cmd As New SQLiteCommand(con)
cmd.CommandText = "SELECT * FROM computers_desc WHERE id='" & IDBox.Text & "';" cmd.CommandText = "SELECT * FROM computers_desc WHERE id='" & IDBox.Text & "';"
@ -257,7 +269,9 @@ Public Class Main
End Using End Using
Catch ex As Exception Catch ex As Exception
StatusLabel.Text = "Une erreur avec la base SQLite s'est produite !" StatusLabel.Text = "Une erreur avec la base SQLite s'est produite !"
MsgBox(ex.Message) log.Critical("Error has been occur when retrieve data from DB !")
log.Critical(ex.Message)
MsgBox("Error ! Check log file for details.")
End Try End Try
End If End If
End Sub End Sub
@ -270,7 +284,7 @@ Public Class Main
Dim dtr As SQLiteDataReader Dim dtr As SQLiteDataReader
Try Try
Using con As New SQLiteConnection("URI=file:db.sqlite") Using con As New SQLiteConnection("URI=file:" & dbLocFile)
con.Open() con.Open()
Using cmd As New SQLiteCommand(con) Using cmd As New SQLiteCommand(con)
cmd.CommandText = "SELECT * FROM computers_progress WHERE id='" & machineID & "';" cmd.CommandText = "SELECT * FROM computers_progress WHERE id='" & machineID & "';"
@ -326,7 +340,9 @@ Public Class Main
If HWCheck.Checked And OSCheck.Checked And DrvCheck.Checked And SoftCheck.Checked And ActivateCheck.Checked Then SendOutButton.Enabled = True Else SendOutButton.Enabled = False 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 Catch ex As Exception
StatusLabel.Text = "Une erreur avec la base SQLite s'est produite !" StatusLabel.Text = "Une erreur avec la base SQLite s'est produite !"
MsgBox(ex.Message) log.Critical("Error has been occur when retrieve data from DB !")
log.Critical(ex.Message)
MsgBox("Error ! Check log file for details.")
End Try End Try
End Sub End Sub
@ -335,7 +351,7 @@ Public Class Main
Try Try
StatusLabel.Text = "Supression d'un ordinateur de la base de données..." StatusLabel.Text = "Supression d'un ordinateur de la base de données..."
Using con As New SQLiteConnection("URI=file:db.sqlite") Using con As New SQLiteConnection("URI=file:" & dbLocFile)
con.Open() con.Open()
Dim cmd As New SQLiteCommand(con) Dim cmd As New SQLiteCommand(con)
cmd.CommandText = "DELETE FROM computers_desc WHERE id='" & IDBox.Text & "';" cmd.CommandText = "DELETE FROM computers_desc WHERE id='" & IDBox.Text & "';"
@ -345,10 +361,13 @@ Public Class Main
con.Close() con.Close()
End Using End Using
StatusLabel.Text = "Ordinateur supprimé avec succès !" StatusLabel.Text = "Ordinateur supprimé avec succès !"
log.Info("Delete computer " & IDBox.Text & " with success !")
ListAllInv() ListAllInv()
Catch ex As Exception Catch ex As Exception
StatusLabel.Text = "Une erreur avec la base SQLite s'est produite !" StatusLabel.Text = "Une erreur avec la base SQLite s'est produite !"
MsgBox(ex.Message) log.Critical("Error has been occur when saving data to DB !")
log.Critical(ex.Message)
MsgBox("Error ! Check log file for details.")
End Try End Try
End Sub End Sub
@ -374,11 +393,42 @@ Public Class Main
IDBox.Text = tempStor IDBox.Text = tempStor
End Sub End Sub
Private Sub DBAccessToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles DBAccessToolStripMenuItem.Click Private Sub ExporterToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ExporterToolStripMenuItem.Click
Dim p As New ProcessStartInfo SaveBackupFile.InitialDirectory() = GetFolderPath(SpecialFolder.Desktop)
p.FileName = "explorer.exe" SaveBackupFile.FileName() = "invMan_" & DateTime.Now.ToString("yyyy-MM-dd_HH.mm") & ".sqlite"
p.Arguments = Directory.GetCurrentDirectory SaveBackupFile.ShowDialog()
p.UseShellExecute = False End Sub
Process.Start(p)
Private Sub SaveBackupFile_FileOk(sender As Object, e As CancelEventArgs) Handles SaveBackupFile.FileOk
Using src As FileStream = File.Open(dbLocFile, FileMode.Open)
src.CopyTo(SaveBackupFile.OpenFile)
End Using
log.Info("DB exporté avec succès")
End Sub
Private Sub ImporterToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ImporterToolStripMenuItem.Click
OpenBackupFile.InitialDirectory() = GetFolderPath(SpecialFolder.Desktop)
OpenBackupFile.ShowDialog()
End Sub
Private Sub OpenBackupFile_FileOk(sender As Object, e As CancelEventArgs) Handles OpenBackupFile.FileOk
If My.Computer.FileSystem.FileExists(dbLocFile) Then
If MsgBox("ATTENTION ! Ceci va écraser la base de donnée existante souhaitez-vous continuer ?", 292, "Overwrite") = 7 Then Exit Sub
End If
Using dest As FileStream = File.Open(dbLocFile, FileMode.Create)
OpenBackupFile.OpenFile.CopyTo(dest)
End Using
ListAllInv()
log.Info("DB importé avec succès")
End Sub
Private Sub QuitterToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles QuitterToolStripMenuItem.Click
If MsgBox("Souhaitez-vous faire une backup de la DB ?", 292, "Backup") = 7 Then End
If Not My.Computer.FileSystem.DirectoryExists(localAppData & "backups") Then My.Computer.FileSystem.CreateDirectory(localAppData & "backups")
File.Copy(dbLocFile, localAppData & "backups\db_" & DateTime.Now.ToString("yyyy-MM-dd_HH.mm") & ".bck")
log.Info("Backup de la DB")
End
End Sub End Sub
End Class End Class

View File

@ -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("0.9.5.3")> <Assembly: AssemblyVersion("0.11.2.2")>
<Assembly: AssemblyFileVersion("0.9.5.3")> <Assembly: AssemblyFileVersion("0.11.2.2")>

View File

@ -20,7 +20,7 @@
' Version.Text = System.String.Format(Version.Text, My.Application.Info.Version.Major, My.Application.Info.Version.Minor) ' Version.Text = System.String.Format(Version.Text, My.Application.Info.Version.Major, My.Application.Info.Version.Minor)
Version.Text = String.Format("Version {0}.{1}.{2}", My.Application.Info.Version.Major, My.Application.Info.Version.Minor, My.Application.Info.Version.MajorRevision) Version.Text = String.Format("Version {0}.{1}", My.Application.Info.Version.Major, My.Application.Info.Version.Minor)
'Informations de copyright 'Informations de copyright
Copyright.Text = My.Application.Info.Copyright Copyright.Text = My.Application.Info.Copyright