04-07-2023
This commit is contained in:
61
EnvelopeGenerator.Form/frmMain.vb
Normal file
61
EnvelopeGenerator.Form/frmMain.vb
Normal file
@@ -0,0 +1,61 @@
|
||||
Imports System.Diagnostics.Eventing.Reader
|
||||
Imports DigitalData.Modules.Config
|
||||
Imports DigitalData.Modules.Database
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports DigitalData.Modules.Base
|
||||
|
||||
Public Class frmMain
|
||||
Private LogConfig As LogConfig
|
||||
Private Logger As Logger
|
||||
Private Database As MSSQLServer
|
||||
Private ConfigManager As ConfigManager(Of Config)
|
||||
Private DbConfig As DbConfig
|
||||
|
||||
Private UserId As Integer = 0
|
||||
|
||||
Private Sub frmMain_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
||||
Dim oLogPath = IO.Path.Combine(Application.LocalUserAppDataPath, "Log")
|
||||
LogConfig = New LogConfig(LogConfig.PathType.CustomPath, oLogPath, CompanyName:="Digital Data", ProductName:="Envelope Generator")
|
||||
Logger = LogConfig.GetLogger()
|
||||
|
||||
Try
|
||||
ConfigManager = New ConfigManager(Of Config)(LogConfig, Application.UserAppDataPath)
|
||||
Dim oConnectionString = MSSQLServer.DecryptConnectionString(ConfigManager.Config.ConnectionString)
|
||||
Database = New MSSQLServer(LogConfig, oConnectionString)
|
||||
|
||||
If Database.DBInitialized = True Then
|
||||
DbConfig = GetDatabaseConfig()
|
||||
|
||||
Dim oUserId = Database.GetScalarValue($"SELECT GUID FROM TBDD_USER WHERE USERNAME = '{Environment.UserName}'")
|
||||
UserId = CInt(oUserId)
|
||||
End If
|
||||
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
End Try
|
||||
|
||||
End Sub
|
||||
|
||||
Private Function GetDatabaseConfig() As DbConfig
|
||||
Dim oSql As String = "SELECT TOP 1 * FROM TBSIG_CONFIG"
|
||||
Dim oTable As DataTable = Database.GetDatatable(oSql)
|
||||
Dim oRow = oTable.Rows.Item(0)
|
||||
|
||||
Return New DbConfig() With {
|
||||
.DocumentPath = oRow.ItemEx("DOCUMENT_PATH", "")
|
||||
}
|
||||
End Function
|
||||
|
||||
Private Sub BarButtonItem1_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem1.ItemClick
|
||||
Dim oForm As New frmEditor() With {
|
||||
.State = New State With {
|
||||
.UserId = UserId,
|
||||
.Config = ConfigManager.Config,
|
||||
.DbConfig = DbConfig,
|
||||
.LogConfig = LogConfig,
|
||||
.Database = Database
|
||||
}
|
||||
}
|
||||
oForm.ShowDialog()
|
||||
End Sub
|
||||
End Class
|
||||
Reference in New Issue
Block a user