FileFlow/Global_Indexer/frmLicense.vb

94 lines
3.9 KiB
VB.net

Imports System.Resources
Public Class frmLicense
Private LocRM As ResourceManager
Private Sub btnPW_check_Click(sender As System.Object, e As System.EventArgs) Handles btnPW_check.Click
If Me.txtPW.Text <> "" Then
If Me.txtPW.Text = "35452dd!" Then
Me.grbBoxlicense.Visible = True
Refresh_Licence(False)
Me.lblPW.Visible = False
Me.txtPW.Visible = False
Me.btnPW_check.Visible = False
Else
Me.grbBoxlicense.Visible = False
'MsgBox("Das eingegebene Passwort stimmt nicht überein!", MsgBoxStyle.Critical, "Falsche Eingabe:")
MsgBox(LocRM.GetString("PasswortStimmtNicht"), MsgBoxStyle.Critical, LocRM.GetString("FalseEingabe"))
Me.txtPW.Text = ""
Me.txtPW.Focus()
End If
End If
End Sub
Private Sub btnnewLicenses_Click(sender As System.Object, e As System.EventArgs) Handles btnnewLicenses.Click
Try
If Me.txtNewlicences.Text <> "" And txtProfile.Text <> "" Then
'Encode the license
Dim result As String = ClassLicence.LicenseManager.EncodeLicenseKey(txtNewlicences.Text & "#" & dtpGueltig_GI.Text & "#" & txtProfile.Text & "#" & txtHotKey.Text, "#DigitalData35452!#")
txtlicensekey.Text = result
Dim sql As String = "UPDATE TBGI_CONFIGURATION SET LICENSEKEY = '" & result & "' where guid = 1"
If DATABASE_ECM.ExecuteNonQuery(sql) = True Then
Refresh_Licence(True)
End If
'MsgBox("Die Lizenzen wurden erfolgreich aktualisiert!", MsgBoxStyle.Exclamation, "Erfolgsmeldung:")
End If
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical, "Unexpected error in New Licenses:")
End Try
End Sub
Sub Refresh_Licence(Neu As Boolean)
Dim lizenzzahl As Integer
Try
Dim sql As String = "SELECT LICENSEKEY FROM TBGI_CONFIGURATION WHERE GUID = 1"
Dim lic As String = DATABASE_ECM.GetScalarValue(sql)
Dim licString = ClassLicence.LicenseManager.DecodeLicenseKey(lic)
Dim split() = licString.ToString.Split("#")
If lic <> "" Then
lizenzzahl = split(0)
LICENSE_COUNT = lizenzzahl
Else
lizenzzahl = "0"
End If
txtNewlicences.Text = lizenzzahl
dtpGueltig_GI.Value = split(1)
If CDate(split(1)) < CDate(Now.ToShortDateString) Then
LICENSE_EXPIRED = True
Else
LICENSE_EXPIRED = False
End If
txtProfile.Text = split(2)
LICENSE_DOCTYPE_COUNT = CInt(txtProfile.Text)
Try
txtHotKey.Text = split(3)
Catch ex As Exception
txtHotKey.Text = 0
End Try
Me.lblAktuelleLizenzen.Text = LocRM.GetString("AnzahlLizenzen") & lizenzzahl
If Neu = True Then
If CInt(lizenzzahl) > 0 Then
MsgBox(LocRM.GetString("LizenzAktualisiert"), MsgBoxStyle.Information, LocRM.GetString("Erfolgsmeldung"))
End If
End If
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Unexpected error in Licensemanager:")
End Try
End Sub
Private Sub frmLicense_Load(sender As Object, e As System.EventArgs) Handles Me.Load
Try
LocRM = New ResourceManager("Global_Indexer._frmLicense", GetType(frmLicense).Assembly)
grbBoxlicense.Visible = False
Me.lblPW.Visible = True
Me.txtPW.Visible = True
Me.btnPW_check.Visible = True
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Unexpected error in Formular Load:")
End Try
End Sub
End Class