Files
Nuvolar/Nuvolar.WIN.Debranet.GL/WinApplication.vb
T

117 lines
6.6 KiB
VB.net

Imports Microsoft.VisualBasic
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports DevExpress.ExpressApp.Win
Imports Nuvolar.Module.Win
Imports DevExpress.ExpressApp
Imports DevExpress.Xpo
Imports DevExpress.Data.Filtering
Imports DevExpress.XtraBars.Alerter
Imports DevExpress.ExpressApp.Utils
Imports DevExpress.ExpressApp.Xpo
Imports Nuvolar.Module.GeneralFunction
Imports System.Data.SqlClient
Partial Public Class NuvolarWindowsFormsDebranetGL
Inherits WinApplication
Public Sub New()
InitializeComponent()
InitializeDefaults()
End Sub
Private Sub InitializeDefaults()
LinkNewObjectToParentImmediately = True
UseLightStyle = True
ExecuteStartupLogicBeforeClosingLogonWindow = True
End Sub
Private Sub NuvolarWindowsFormsApplication_DatabaseVersionMismatch(ByVal sender As Object, ByVal e As DevExpress.ExpressApp.DatabaseVersionMismatchEventArgs) Handles MyBase.DatabaseVersionMismatch
e.Updater.Update()
e.Handled = True
End Sub
Protected Overrides Function GetTraceLogDirectory() As String
Return MyBase.GetTraceLogDirectory()
End Function
Protected Overrides Function CreateLogonWindowControllers() As System.Collections.Generic.List(Of DevExpress.ExpressApp.Controller)
Dim _result As System.Collections.Generic.List(Of DevExpress.ExpressApp.Controller)
Dim _CreateLogonWindowsControllerVC As New CreateLogonWindowsControllerVC
_result = MyBase.CreateLogonWindowControllers()
_result.Add(_CreateLogonWindowsControllerVC)
Return _result
End Function
Protected Overrides Sub CreateDefaultObjectSpaceProvider(args As CreateCustomObjectSpaceProviderEventArgs)
args.ObjectSpaceProvider = New XPObjectSpaceProvider(args.ConnectionString, args.Connection, True)
End Sub
Protected Overrides Sub OnLoggedOn(args As DevExpress.ExpressApp.LogonEventArgs)
MyBase.OnLoggedOn(args)
Dim _onew As Xpo.XPObjectSpace = Me.ObjectSpaceProvider.CreateObjectSpace()
Dim _uow As New UnitOfWork(_onew.Session.DataLayer)
Dim _User As DevExpress.Persistent.BaseImpl.User = _onew.FindObject(Of DevExpress.Persistent.BaseImpl.User)(CriteriaOperator.Parse("Oid=?", SecuritySystem.CurrentUserId))
Nuvolar.Module.LockingModule.ReleaseAllLocking(_uow, _User)
Dim cnn As New Object
Dim sql As String = ""
Select Case GLOBAL_SQLType
Case [Module].eSQLType.MSSQL
sql = "BEGIN TRANSACTION ROUNDQTT" + vbNewLine
sql += "UPDATE StorageComputed SET QTTFree=ROUND(QTTFree,4) WHERE QTTFree<>ROUND(QTTFree,4)" + vbNewLine
sql += "UPDATE StorageInRows SET QTT=ROUND(QTT,4) WHERE QTT<>ROUND(QTT,4)" + vbNewLine
sql += "UPDATE StorageInRows SET QTT_Out=ROUND(QTT_Out,4) WHERE QTT_Out<>ROUND(QTT_Out,4)" + vbNewLine
sql += "UPDATE StorageOutRows SET QTT=ROUND(QTT,4) WHERE QTT<>ROUND(QTT,4)" + vbNewLine
sql += "UPDATE StorageOutRows SET QTT_To_DeliveryOut=ROUND(QTT_To_DeliveryOut,4) WHERE QTT_To_DeliveryOut<>ROUND(QTT_To_DeliveryOut,4)" + vbNewLine
sql += "UPDATE DeliveryNoteInRows SET QTT=ROUND(QTT,4) WHERE QTT<>ROUND(QTT,4)" + vbNewLine
sql += "UPDATE DeliveryNoteOutRows SET QTT=ROUND(QTT,4) WHERE QTT<>ROUND(QTT,4)" + vbNewLine
sql += "UPDATE DeliveryNoteOutRows SET QTT_Invoiced=ROUND(QTT_Invoiced,4) WHERE QTT_Invoiced<>ROUND(QTT_Invoiced,4)" + vbNewLine
sql += "COMMIT TRANSACTION ROUNDQTT;"
Case [Module].eSQLType.MySQL
sql = "START TRANSACTION;" + vbNewLine
sql += "UPDATE StorageComputed SET QTTFree=ROUND(QTTFree,4) WHERE QTTFree<>ROUND(QTTFree,4);" + vbNewLine
sql += "UPDATE StorageInRows SET QTT=ROUND(QTT,4) WHERE QTT<>ROUND(QTT,4);" + vbNewLine
sql += "UPDATE StorageInRows SET QTT_Out=ROUND(QTT_Out,4) WHERE QTT_Out<>ROUND(QTT_Out,4);" + vbNewLine
sql += "UPDATE StorageOutRows SET QTT=ROUND(QTT,4) WHERE QTT<>ROUND(QTT,4);" + vbNewLine
sql += "UPDATE StorageOutRows SET QTT_To_DeliveryOut=ROUND(QTT_To_DeliveryOut,4) WHERE QTT_To_DeliveryOut<>ROUND(QTT_To_DeliveryOut,4);" + vbNewLine
sql += "UPDATE DeliveryNoteInRows SET QTT=ROUND(QTT,4) WHERE QTT<>ROUND(QTT,4);" + vbNewLine
sql += "UPDATE DeliveryNoteOutRows SET QTT=ROUND(QTT,4) WHERE QTT<>ROUND(QTT,4);" + vbNewLine
sql += "UPDATE DeliveryNoteOutRows SET QTT_Invoiced=ROUND(QTT_Invoiced,4) WHERE QTT_Invoiced<>ROUND(QTT_Invoiced,4);" + vbNewLine
sql += "COMMIT;"
Case [Module].eSQLType.PostgreSQL
sql = "BEGIN;" + vbNewLine
sql += "UPDATE ""StorageComputed"" SET ""QTTFree""=ROUND(""QTTFree"",4)"" WHERE ""QTTFree""<>ROUND(""QTTFree"",4);" + vbNewLine
sql += "UPDATE ""StorageInRows"" SET ""QTT""=ROUND(""QTT"",4)"" WHERE ""QTT""<>ROUND(""QTT"",4);" + vbNewLine
sql += "UPDATE ""StorageInRows"" SET ""QTT_Out""=ROUND(""QTT_Out"",4)"" WHERE ""QTT_Out""<>ROUND(""QTT_Out"",4);" + vbNewLine
sql += "UPDATE ""StorageOutRows"" SET ""QTT""=ROUND(""QTT"",4)"" WHERE ""QTT""<>ROUND(""QTT"",4);" + vbNewLine
sql += "UPDATE ""StorageOutRows"" SET ""QTT_To_DeliveryOut""=ROUND(""QTT_To_DeliveryOut"",4)"" WHERE ""QTT_To_DeliveryOut""<>ROUND(""QTT_To_DeliveryOut"",4);" + vbNewLine
sql += "UPDATE ""DeliveryNoteInRows"" SET ""QTT""=ROUND(""QTT"",4)"" WHERE ""QTT""<>ROUND(""QTT"",4);" + vbNewLine
sql += "UPDATE ""DeliveryNoteOutRows"" SET ""QTT""=ROUND(""QTT"",4)"" WHERE ""QTT""<>ROUND(""QTT"",4);" + vbNewLine
sql += "UPDATE ""DeliveryNoteOutRows"" SET ""QTT_Invoiced""=ROUND(""QTT_Invoiced"",4)"" WHERE ""QTT_Invoiced""<>ROUND(""QTT_Invoiced"",4);" + vbNewLine
sql += "COMMIT;"
End Select
Try
Dim _row As Integer = _onew.Session.ExecuteNonQuery(sql)
Catch ex As Exception
End Try
End Sub
Protected Overrides Sub OnLoggingOff(args As DevExpress.ExpressApp.LoggingOffEventArgs)
MyBase.OnLoggingOff(args)
Dim _onew As Xpo.XPObjectSpace = Me.ObjectSpaceProvider.CreateObjectSpace()
Dim _uow As New UnitOfWork(_onew.Session.DataLayer)
Dim _User As DevExpress.Persistent.BaseImpl.User = _onew.FindObject(Of DevExpress.Persistent.BaseImpl.User)(CriteriaOperator.Parse("Oid=?", SecuritySystem.CurrentUserId))
Nuvolar.Module.LockingModule.ReleaseAllLocking(_uow, _User)
End Sub
End Class