Files
Nuvolar/Nuvolar.Module/BusinessObjects/Business/StorageTransactions/In/StorageTransactionsInVC.vb
T
2017-03-08 11:21:27 +01:00

1180 lines
78 KiB
VB.net

Imports System
Imports System.ComponentModel
Imports System.Collections.Generic
Imports System.Diagnostics
Imports System.Text
Imports DevExpress.ExpressApp
Imports DevExpress.ExpressApp.Actions
Imports DevExpress.Persistent.Base
Imports DevExpress.Xpo.Session
Imports DevExpress.Data.Filtering
Imports DevExpress.Xpo
Imports DevExpress.ExpressApp.Editors
Imports DevExpress.ExpressApp.SystemModule
Imports DevExpress.Persistent.Validation
Imports DevExpress.Persistent.BaseImpl
Imports DevExpress.ExpressApp.Utils
Imports System.Linq
Imports System.Linq.Expressions
Public Class StorageTransactionsInVC
Inherits DevExpress.ExpressApp.ViewController
Public Event InitWork(ByVal _Minimum As Long, ByVal _Step As Long, ByVal _Maximum As Long)
Public Event DoWork()
Public Event FinalWork
Public Sub New()
MyBase.New()
InitializeComponent()
RegisterActions(components)
End Sub
Protected Overrides Sub OnActivated()
MyBase.OnActivated()
Frame.GetController(Of StorageTransactionsInVC)().aToTable_StorageIn.Active.SetItemValue("", False) ' -- Betárolási biz. sor hozzáadása
Frame.GetController(Of StorageTransactionsInVC)().aFinalizeAndNew_StorageIn.Active.SetItemValue("", False) ' -- Betárolási biz. véglegesítése és új nyitása
Frame.GetController(Of StorageTransactionsInVC)().aToTableD_SIH.Active.SetItemValue("", False) ' -- Sor törlése Betárolási biz ról
Frame.GetController(Of StorageTransactionsInVC)().aDown_StorageIn.Active.SetItemValue("", False) ' -- Betárolási sor lejebb
Frame.GetController(Of StorageTransactionsInVC)().aUp_StorageIn.Active.SetItemValue("", False) ' -- Betárolási sor feljebb
Frame.GetController(Of StorageTransactionsInVC)().aBackToEdit_StorageInHeader.Active.SetItemValue("", False)
Frame.GetController(Of StorageTransactionsInVC)().aStorageInStorno.Active.SetItemValue("", False)
Frame.GetController(Of StorageTransactionsInVC)().aStorageInFromPdaCollection.Active.SetItemValue("", False)
'Frame.GetController(Of StorageTransactionsInVC)().aStorageInHeader_InsertInventoryTransfer.Active.SetItemValue("", False)
If View.Id = "StorageOutRows_ListView_Overstored" Then
Frame.GetController(Of NewObjectViewController).Active.SetItemValue("", False)
Frame.GetController(Of CloneObject.CloneObjectViewController).Active.SetItemValue("", False)
End If
If View.Id Like "Storage*Header_*View" Then '--Anyagmozgást ne lehessen törölni---
Frame.GetController(Of DevExpress.ExpressApp.SystemModule.DeleteObjectsViewController)().Active.SetItemValue("", False)
End If
If View.Id Like "Products*" Then
Frame.GetController(Of DevExpress.ExpressApp.SystemModule.DeleteObjectsViewController)().Active.SetItemValue("", False)
End If
'------------------------------------------ LISTVIEWS --------------------------------------------------------------------------------------------------------
If View.Id = "StorageInHeader_ListView" Then
Frame.GetController(Of DevExpress.ExpressApp.SystemModule.NewObjectViewController)().Active.SetItemValue("", False)
Frame.GetController(Of DevExpress.ExpressApp.SystemModule.DeleteObjectsViewController)().Active.SetItemValue("", False)
Frame.GetController(Of DevExpress.ExpressApp.CloneObject.CloneObjectViewController)().Active.SetItemValue("", False)
Frame.GetController(Of StorageTransactionsInVC)().aBackToEdit_StorageInHeader.Active.SetItemValue("", True)
Frame.GetController(Of StorageTransactionsInPrint)().aStorageTransactionsInPrint.Active.SetItemValue("", False)
Frame.GetController(Of StorageTransactionsInVC)().aStorageInStorno.Active.SetItemValue("", True)
AddHandler View.SelectionChanged, AddressOf StorageInHeader_ListView_View_SelectionChanged
End If
If View.Id = "StorageInHeader_ListView_Editable" Then
Frame.GetController(Of StorageTransactionsInPrint)().aStorageTransactionsInPrint.Active.SetItemValue("", False)
Frame.GetController(Of StorageTransactionsInVC)().aStorageInStorno.Active.SetItemValue("", False)
Frame.GetController(Of DeleteObjectsViewController).Active.SetItemValue("", False)
Frame.GetController(Of CloneObject.CloneObjectViewController).Active.SetItemValue("", False)
End If
If View.Id = "StorageInHeader_StorageInRows_ListView" Then
Frame.GetController(Of DevExpress.ExpressApp.SystemModule.LinkUnlinkController)().Active.SetItemValue("", False)
Frame.GetController(Of DevExpress.ExpressApp.SystemModule.NewObjectViewController)().Active.SetItemValue("", False)
Frame.GetController(Of DevExpress.ExpressApp.SystemModule.DeleteObjectsViewController)().Active.SetItemValue("", False)
Frame.GetController(Of DevExpress.ExpressApp.CloneObject.CloneObjectViewController)().Active.SetItemValue("", False)
Frame.GetController(Of DevExpress.ExpressApp.SystemModule.ListViewProcessCurrentObjectController)().Active.SetItemValue("", False)
Frame.GetController(Of StorageTransactionsInVC)().aUp_StorageIn.Active.SetItemValue("", True)
Frame.GetController(Of StorageTransactionsInVC)().aDown_StorageIn.Active.SetItemValue("", True)
End If
If View.Id = "StorageInRows_ListView_Order" Then
Frame.GetController(Of DevExpress.ExpressApp.SystemModule.NewObjectViewController)().Active.SetItemValue("", False)
Frame.GetController(Of DevExpress.ExpressApp.SystemModule.DeleteObjectsViewController)().Active.SetItemValue("", False)
Frame.GetController(Of DevExpress.ExpressApp.SystemModule.ListViewProcessCurrentObjectController)().Active.SetItemValue("", False)
End If
If View.Id = "StorageInRows_ListView" Then
Frame.GetController(Of DevExpress.ExpressApp.SystemModule.NewObjectViewController)().Active.SetItemValue("", False)
Frame.GetController(Of DevExpress.ExpressApp.CloneObject.CloneObjectViewController)().Active.SetItemValue("", False)
End If
If View.Id = "StorageInRowsFromPDACollectionPopup_ListView" Then
Frame.GetController(Of DevExpress.ExpressApp.SystemModule.NewObjectViewController)().Active.SetItemValue("", False)
Frame.GetController(Of DevExpress.ExpressApp.SystemModule.DeleteObjectsViewController)().Active.SetItemValue("", False)
Frame.GetController(Of DevExpress.ExpressApp.CloneObject.CloneObjectViewController)().Active.SetItemValue("", False)
Frame.GetController(Of DevExpress.ExpressApp.SystemModule.ListViewProcessCurrentObjectController)().Active.SetItemValue("", False)
End If
If View.Id = "StorageInRowsFromPDACollectionPopup_StoragePDACollectionRows_ListView" Then
Frame.GetController(Of DevExpress.ExpressApp.SystemModule.NewObjectViewController)().Active.SetItemValue("", False)
Frame.GetController(Of DevExpress.ExpressApp.SystemModule.LinkUnlinkController)().Active.SetItemValue("", False)
Frame.GetController(Of DevExpress.ExpressApp.SystemModule.DeleteObjectsViewController)().Active.SetItemValue("", False)
Frame.GetController(Of DevExpress.ExpressApp.CloneObject.CloneObjectViewController)().Active.SetItemValue("", False)
Frame.GetController(Of DevExpress.ExpressApp.SystemModule.ListViewProcessCurrentObjectController)().Active.SetItemValue("", False)
End If
'------------------------------------------ DETAILVIEWS ------------------------------------------------------------------------------------------------------
'-- Ne lehessen stornózni, ha stornózott ---------
If View.Id = "StorageInHeader_DetailView" Then
Dim _StorageInHeader As StorageInHeader
_StorageInHeader = View.SelectedObjects(0)
If _StorageInHeader Is Nothing Then
Else
If _StorageInHeader.IsStorno = True Or _StorageInHeader.IsEditable = True Then
Frame.GetController(Of StorageTransactionsInVC)().aStorageInStorno.Active.SetItemValue("", False)
End If
If _StorageInHeader.IsStorno = False And _StorageInHeader.IsEditable = False Then
Frame.GetController(Of StorageTransactionsInVC)().aStorageInStorno.Active.SetItemValue("", True)
End If
If _StorageInHeader.IsEditable = False Then
Frame.GetController(Of StorageTransactionsInVC)().aFinalize_StorageIn.Active.SetItemValue("", False)
Frame.GetController(Of StorageTransactionsInVC)().aFinalizeAndNew_StorageIn.Active.SetItemValue("", False)
Frame.GetController(Of DevExpress.ExpressApp.SystemModule.ModificationsController)().Active.SetItemValue("", False)
Frame.GetController(Of StorageTransactionsInVC)().aStorageInStorno.Active.SetItemValue("", False)
Frame.GetController(Of DevExpress.ExpressApp.SystemModule.NewObjectViewController)().Active.SetItemValue("", False)
Frame.GetController(Of DevExpress.ExpressApp.CloneObject.CloneObjectViewController)().Active.SetItemValue("", False)
Frame.GetController(Of StorageTransactionsInPrint)().aStorageTransactionsInPrint.Active.SetItemValue("", False)
Else
Frame.GetController(Of StorageTransactionsInVC)().aFinalizeAndNew_StorageIn.Active.SetItemValue("", True)
Frame.GetController(Of StorageTransactionsInVC)().aFinalize_StorageIn.Active.SetItemValue("", True)
Frame.GetController(Of StorageTransactionsInVC)().aToTable_StorageIn.Active.SetItemValue("", True)
Frame.GetController(Of StorageTransactionsInVC)().aToTableD_SIH.Active.SetItemValue("", True)
Frame.GetController(Of StorageTransactionsInVC)().aStorageInFromPdaCollection.Active.SetItemValue("", True)
Frame.GetController(Of StorageTransactionsInPrint)().aStorageTransactionsInPrint.Active.SetItemValue("", False)
Frame.GetController(Of DevExpress.ExpressApp.SystemModule.NewObjectViewController)().Active.SetItemValue("", False)
Frame.GetController(Of DevExpress.ExpressApp.CloneObject.CloneObjectViewController)().Active.SetItemValue("", False)
End If
End If
End If
If View.Id = "StorageInRows_Split_PopUp_DetailView" Then
AddHandler Frame.GetController(Of DialogController)().AcceptAction.Executing, AddressOf StorageInRows_Split_PopUp_DetailView_AcceptAction_Executing
End If
If View.Id = "StorageOutRowsInRows_ListView_Overstored" Then
AddHandler Frame.GetController(Of DialogController)().AcceptAction.Executing, AddressOf StorageOutRowsInRows_ListView_Overstored_AcceptAction_Executing
End If
End Sub
Protected Overrides Sub OnDeactivated()
MyBase.OnDeactivated()
Frame.GetController(Of DevExpress.ExpressApp.CloneObject.CloneObjectViewController)().Active.SetItemValue("", True)
'------------------------------------------ LISTVIEWS --------------------------------------------------------------------------------------------------------
If View.Id = "StorageInHeader_ListView" Then
Frame.GetController(Of DevExpress.ExpressApp.SystemModule.NewObjectViewController)().Active.SetItemValue("", True)
Frame.GetController(Of DevExpress.ExpressApp.SystemModule.DeleteObjectsViewController)().Active.SetItemValue("", True)
Frame.GetController(Of DevExpress.ExpressApp.CloneObject.CloneObjectViewController)().Active.SetItemValue("", True)
RemoveHandler View.SelectionChanged, AddressOf StorageInHeader_ListView_View_SelectionChanged
End If
If View.Id = "StorageInHeader_StorageInRows_ListView" Then
Frame.GetController(Of DevExpress.ExpressApp.SystemModule.LinkUnlinkController)().Active.SetItemValue("", True)
Frame.GetController(Of DevExpress.ExpressApp.SystemModule.NewObjectViewController)().Active.SetItemValue("", True)
Frame.GetController(Of DevExpress.ExpressApp.SystemModule.DeleteObjectsViewController)().Active.SetItemValue("", True)
Frame.GetController(Of DevExpress.ExpressApp.CloneObject.CloneObjectViewController)().Active.SetItemValue("", True)
Frame.GetController(Of DevExpress.ExpressApp.SystemModule.ListViewProcessCurrentObjectController)().Active.SetItemValue("", True)
End If
If View.Id = "StorageInHeader_ListView_Editable" Then
Frame.GetController(Of DeleteObjectsViewController).Active.SetItemValue("", True)
Frame.GetController(Of CloneObject.CloneObjectViewController).Active.SetItemValue("", True)
End If
If View.Id = "StorageInRows_ListView" Then
Frame.GetController(Of DevExpress.ExpressApp.SystemModule.NewObjectViewController)().Active.SetItemValue("", True)
Frame.GetController(Of DevExpress.ExpressApp.CloneObject.CloneObjectViewController)().Active.SetItemValue("", True)
End If
If View.Id = "StorageInRowsFromPDACollectionPopup_ListView" Then
Frame.GetController(Of DevExpress.ExpressApp.SystemModule.NewObjectViewController)().Active.SetItemValue("", True)
Frame.GetController(Of DevExpress.ExpressApp.SystemModule.DeleteObjectsViewController)().Active.SetItemValue("", True)
Frame.GetController(Of DevExpress.ExpressApp.CloneObject.CloneObjectViewController)().Active.SetItemValue("", True)
Frame.GetController(Of DevExpress.ExpressApp.SystemModule.ListViewProcessCurrentObjectController)().Active.SetItemValue("", True)
End If
If View.Id = "StorageInRowsFromPDACollectionPopup_StoragePDACollectionRows_ListView" Then
Frame.GetController(Of DevExpress.ExpressApp.SystemModule.NewObjectViewController)().Active.SetItemValue("", True)
Frame.GetController(Of DevExpress.ExpressApp.SystemModule.LinkUnlinkController)().Active.SetItemValue("", True)
Frame.GetController(Of DevExpress.ExpressApp.SystemModule.DeleteObjectsViewController)().Active.SetItemValue("", True)
Frame.GetController(Of DevExpress.ExpressApp.CloneObject.CloneObjectViewController)().Active.SetItemValue("", True)
Frame.GetController(Of DevExpress.ExpressApp.SystemModule.ListViewProcessCurrentObjectController)().Active.SetItemValue("", True)
End If
'------------------------------------------ DETAILVIEWS ------------------------------------------------------------------------------------------------------
If View.Id = "StorageInRows_Split_PopUp_DetailView" Then
RemoveHandler Frame.GetController(Of DialogController)().AcceptAction.Executing, AddressOf StorageInRows_Split_PopUp_DetailView_AcceptAction_Executing
End If
End Sub
Private Sub aFinalize_StorageIn_Execute(ByVal sender As System.Object, ByVal e As DevExpress.ExpressApp.Actions.SimpleActionExecuteEventArgs) Handles aFinalize_StorageIn.Execute
'-- Betárolás véglegesítése
Dim _onew As Xpo.XPObjectSpace = Application.CreateObjectSpace
Dim _uow As New UnitOfWork(_onew.Session.DataLayer)
Dim _ocur As Xpo.XPObjectSpace = TryCast(View.ObjectSpace, Xpo.XPObjectSpace)
Dim _uow_lock As New UnitOfWork(_onew.Session.DataLayer)
Dim _User As User = _onew.GetObject(TryCast(SecuritySystem.CurrentUser, User))
Dim _StorageInHeader As StorageInHeader = _onew.GetObjectByKey(Of StorageInHeader)(TryCast(e.SelectedObjects(0), StorageInHeader).Oid)
Try
If _StorageInHeader.Storage IsNot Nothing And _StorageInHeader.StorageInRows.Count = 0 Then _
Throw New Exception("*Nem lehet véglegesíteni a betárolási bizonylatot!" & vbNewLine & vbNewLine & _
"Kérem ellenőrizze, hogy be lett-e állítva raktár, illetve" & vbNewLine & _
"definiált-e betárolási sorokat!")
If Not LockingModule.LockObject(_uow_lock, GetType(StorageComputed), "-", _User) Then
Dim _LockingObject As LockingObject = _onew.FindObject(Of LockingObject)(CriteriaOperator.Parse("TableName=?", GetType(StorageComputed).Name + "-" + "-"))
Dim _Prompt As String = DevExpress.ExpressApp.Utils.CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions\StorageComputed", "CanNotStorageInByLocking")
Dim _Title As String = DevExpress.ExpressApp.Utils.CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions", "MsgBoxError")
MsgBox(String.Format(_Prompt, _LockingObject.User.FullName, _LockingObject.ObjectCreated), MsgBoxStyle.Information + MsgBoxStyle.OkOnly, _Title)
Exit Sub
Else
If _StorageInHeader.IsFinalized Then
For Each _StorageInRows As StorageInRows In _StorageInHeader.StorageInRows
Dim _StorageComputed As StorageComputed = _onew.FindObject(Of StorageComputed)(CriteriaOperator.Parse("Products=? and Storage=?", _
_onew.GetObject(_StorageInRows.Products), _onew.GetObject(_StorageInHeader.Storage)))
Dim _StorageMoveEvents_Collection As New XPCollection(Of StorageMoveEvents)(_onew.Session, CriteriaOperator.Parse("StorageInRows=?", _onew.GetObject(_StorageInRows)))
_StorageMoveEvents_Collection.Sorting.Add(New SortProperty("ObjectCreated", DB.SortingDirection.Descending))
Dim _StorageMoveEvents As New StorageMoveEvents(_onew.Session)
If _StorageInRows.QTT_Will > 0 Then
_StorageInRows.QTT = _StorageInRows.QTT_Will
_StorageComputed.QTTFree += _StorageInRows.QTT_Will
_StorageComputed.QTTReservedIn -= _StorageInRows.QTT_Will
If _StorageMoveEvents_Collection.Count < 0 Then
_StorageMoveEvents.StorageInRows = _onew.GetObject(_StorageMoveEvents_Collection(0).StorageInRows)
_StorageMoveEvents.QTT_Free_Before = _StorageMoveEvents_Collection(0).QTT_Free_After
Else
_StorageMoveEvents.StorageInRows = _onew.GetObject(_StorageInRows)
_StorageMoveEvents.QTT_Free_Before = 0
End If
_StorageMoveEvents.QTT = _StorageInRows.QTT_Will
_StorageMoveEvents.QTT_Free_After = _StorageMoveEvents.QTT_Free_Before + _StorageMoveEvents.QTT
_StorageMoveEvents.MoveEventsType = eMoveEventsType.StorageInFinal
_StorageMoveEvents.ExecutionDate = GetSQLTime(_ocur.Session)
_StorageInRows.QTT_Will = 0
End If
Next
_StorageInHeader.IsEditable = False
_onew.CommitChanges()
Dim _ReportData As ReportData = _onew.FindObject(Of ReportData)(CriteriaOperator.Parse("Oid=?", _StorageInHeader.Storage.ReportIn.Oid), True)
If _ReportData Is Nothing Or _StorageInHeader Is Nothing Then
Else
Frame.GetController(Of Reports.ReportServiceController).ShowPreview(_ReportData, CriteriaOperator.Parse("StorageInHeader.DocumentNumber =?", _StorageInHeader.DocumentNumber), True)
End If
If Frame.GetController(Of RefreshController).RefreshAction.Enabled Then
Frame.GetController(Of RefreshController).RefreshAction.DoExecute()
End If
View.Close()
Else
For Each _StorageInRows As StorageInRows In _StorageInHeader.StorageInRows
Dim _StorageComputed As StorageComputed = _onew.FindObject(Of StorageComputed)(CriteriaOperator.Parse("Products=? and Storage=?", _
_onew.GetObject(_StorageInRows.Products), _onew.GetObject(_StorageInHeader.Storage)))
Dim _StorageMoveEvents As New StorageMoveEvents(_onew.Session)
If _StorageInRows.QTT_Will > 0 Then
_StorageInRows.QTT = _StorageInRows.QTT_Will
_StorageComputed.QTTFree += _StorageInRows.QTT_Will
_StorageComputed.QTTReservedIn -= _StorageInRows.QTT_Will
_StorageMoveEvents.StorageInRows = _onew.GetObject(_StorageInRows)
_StorageMoveEvents.QTT = _StorageInRows.QTT_Will
_StorageMoveEvents.QTT_Free_After = _StorageComputed.QTTFree
_StorageMoveEvents.QTT_Free_Before = _StorageMoveEvents.QTT_Free_After - _StorageMoveEvents.QTT
_StorageMoveEvents.MoveEventsType = eMoveEventsType.StorageInFinal
_StorageMoveEvents.ExecutionDate = _StorageInRows.StorageInHeader.CreateDate
_StorageInRows.QTT_Will = 0
End If
'_StorageInRows.StorageInRowsFrom.QTT_Overstored_Will -= _StorageInRows.QTT
'_StorageInRows.StorageInRowsFrom.QTT_Overstored += _StorageInRows.QTT_Overstored
'_StorageInRows.StorageInRowsFrom.QTT_Overstor_Will = _StorageInRows.QTT
Next
_StorageInHeader.IsEditable = False
_StorageInHeader.IsFinalized = True
_onew.CommitChanges()
If _StorageInHeader.StorageMoveType.MoveType = eMoveType.InventoryTransfer Then
CheckInventoryTransferStorageInRows(_uow, _StorageInHeader.StorageInRows)
End If
Dim _ReportData As ReportData = _onew.FindObject(Of ReportData)(CriteriaOperator.Parse("Oid=?", _StorageInHeader.Storage.ReportIn.Oid), True)
If _ReportData Is Nothing Or _StorageInHeader Is Nothing Then
Else
Frame.GetController(Of Reports.ReportServiceController).ShowPreview(_ReportData, CriteriaOperator.Parse("StorageInHeader.DocumentNumber =?", _StorageInHeader.DocumentNumber), True)
End If
If Frame.GetController(Of RefreshController).RefreshAction.Enabled Then
Frame.GetController(Of RefreshController).RefreshAction.DoExecute()
End If
View.Close()
End If
End If
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.OkOnly + MsgBoxStyle.Critical, "Hiba")
Finally
LockingModule.UnLockObject(_uow_lock, GetType(StorageComputed), "-", _User)
End Try
End Sub
Private Sub aToTable_StorageIn_Execute(ByVal sender As System.Object, ByVal e As DevExpress.ExpressApp.Actions.SimpleActionExecuteEventArgs) Handles aToTable_StorageIn.Execute
Dim _ocur As Xpo.XPObjectSpace = View.ObjectSpace
Dim _onew As Xpo.XPObjectSpace = Application.CreateObjectSpace
Dim _uow As New UnitOfWork(_onew.Session.DataLayer)
Dim _uow_lock As New UnitOfWork(_ocur.Session.DataLayer)
Dim _user_lock As User = _uow_lock.GetObjectByKey(Of User)(SecuritySystem.CurrentUserId)
Dim _StorageInHeader As StorageInHeader = TryCast(e.SelectedObjects(0), StorageInHeader)
Try
'// Objektum zárolása adott oid-re !
If Not LockObject(_uow_lock, GetType(StorageComputed), _StorageInHeader.row_Products.Oid.ToString, _user_lock) Then
Dim _LockingObject As LockingObject = _onew.FindObject(Of LockingObject)(CriteriaOperator.Parse("TableName=?", GetType(StorageComputed).Name + "-" + "-"))
Dim _Prompt As String = DevExpress.ExpressApp.Utils.CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions\StorageComputed", "CanNotStorageInByLocking")
Dim _Title As String = DevExpress.ExpressApp.Utils.CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions", "MsgBoxError")
MsgBox(String.Format(_Prompt, _LockingObject.User.FullName, _LockingObject.ObjectCreated, MsgBoxStyle.Information + MsgBoxStyle.OkOnly, _Title))
Exit Sub
Else
Dim _StorageInRows As StorageInRows = _ocur.CreateObject(Of StorageInRows)()
Dim _StorageComputed As StorageComputed = _ocur.FindObject(Of StorageComputed)(CriteriaOperator.Parse("Products=? and Storage=?", _
_StorageInHeader.row_Products, _StorageInHeader.Storage))
If _StorageComputed Is Nothing Then
_StorageComputed = _ocur.CreateObject(Of StorageComputed)()
_StorageComputed.Storage = _StorageInHeader.Storage
_StorageComputed.Products = _StorageInHeader.row_Products
_StorageComputed.QTTReservedIn = _StorageInHeader.row_QTT_WILL
Else
_StorageComputed.QTTReservedIn += _StorageInHeader.row_QTT_WILL
End If
_StorageInRows.AddRows(_StorageInHeader)
_ocur.CommitChanges()
If _StorageInHeader.StorageMoveType.MoveType = eMoveType.InventoryTransfer Then
CheckInventoryTransferStorageInRows(_uow, _StorageInHeader.StorageInRows)
End If
_StorageInHeader.row_Products = Nothing
_StorageInHeader.row_QTT_WILL = 0
_StorageInHeader.row_Weight = 0
_StorageInHeader.row_PacketNumber = ""
_StorageInHeader.row_SerialNumber = ""
View.Refresh()
End If
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.OkOnly + MsgBoxStyle.Critical, String.Format(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions", "MsgBoxCheckItAgain")))
Finally
If Not ReleaseAllLocking(_uow_lock, _user_lock) Then _
Throw New Exception("*Váratlan hiba történt a(z) " + _StorageInHeader.row_Products.ShortName + " termék zárolását nem lehet feoldani! Kérem, forduljon a rendszergazdához!")
End Try
End Sub
Private Sub aFinalizeAndNew_StorageIn_Execute(ByVal sender As System.Object, ByVal e As DevExpress.ExpressApp.Actions.SimpleActionExecuteEventArgs) Handles aFinalizeAndNew_StorageIn.Execute
Try
Dim _ocur As Xpo.XPObjectSpace = View.ObjectSpace
Dim _StorageInHeader As StorageInHeader = TryCast(e.SelectedObjects(0), StorageInHeader)
If _StorageInHeader.Storage IsNot Nothing And _StorageInHeader.StorageInRows.Count > 0 Then Throw New Exception("*Nem lehet véglegesíteni a betárolási bizonylatot!" & vbNewLine & vbNewLine & _
"Kérem ellenőrizze, hogy be lett-e állítva raktár, illetve" & vbNewLine & _
"definiált-e betárolási sorokat!")
Frame.GetController(Of StorageTransactionsInVC).aFinalize_StorageIn.DoExecute()
Frame.GetController(Of NewObjectViewController)().NewObjectAction.DoExecute(Frame.GetController(Of NewObjectViewController)().NewObjectAction.Items(0))
View.Close(False)
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.OkOnly + MsgBoxStyle.Critical, String.Format(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions", "MsgBoxCheckItAgain")))
End Try
End Sub
Private Sub aStorageInStorno_Execute(ByVal sender As System.Object, ByVal e As DevExpress.ExpressApp.Actions.SimpleActionExecuteEventArgs) Handles aStorageInStorno.Execute
Dim _onew As Xpo.XPObjectSpace = Application.CreateObjectSpace
Dim _uow_lock As New UnitOfWork(_onew.Session.DataLayer)
Dim _User As User = _onew.GetObject(TryCast(SecuritySystem.CurrentUser, User))
Try
' Ellenőrzések
'__________________________________________________________________________
Dim _StorageInHeader As StorageInHeader = _onew.GetObject(TryCast(View.SelectedObjects(0), StorageInHeader))
If _StorageInHeader Is Nothing Then Throw New Exception("*Váratlan hiba történt a folyamat megszakadt!")
If _StorageInHeader.IsEditable = True Or
_StorageInHeader.IsStorno = True Then Throw New Exception(String.Format("A {0} számú betárolási bizonylatot nem lehet stornírozni, mert", _StorageInHeader.DocumentNumber) + _
vbNewLine + "még nem lett véglegesítve, vagy már stornózásra kerűlt!" + vbNewLine + "Kérem, ellenőrizze!")
Dim _StorageInRowsError_Collection As New ArrayList
For Each _StorageInRows As StorageInRows In _StorageInHeader.StorageInRows
If _StorageInRows.QTT_Out > 0 Then _
_StorageInRowsError_Collection.Add(_StorageInRows)
Next
If _StorageInRowsError_Collection.Count > 0 Then
Dim _ErrorMessage As String = "Probléma merült fel a következő betárolási sorokkal:" + vbNewLine
For Each _StorageInRows As StorageInRows In _StorageInRowsError_Collection
_ErrorMessage += _StorageInRows.RowIndex + " " + _StorageInRows.Products.ShortName _
+ " " + _StorageInRows.QTT + vbNewLine
Next
_ErrorMessage += "Valószínűleg történt már kitárolás a betárolási sorról."
_ErrorMessage += "Kérem, ellenőrizze!"
Throw New Exception(_ErrorMessage)
End If
' StorageComputed zárolás
'__________________________________________________________________________
If Not LockingModule.LockObject(_uow_lock, GetType(StorageComputed), "-", _User) Then
Dim _LockingObject As LockingObject = _onew.FindObject(Of LockingObject)(CriteriaOperator.Parse("TableName=?", GetType(StorageComputed).Name + "-" + "-"))
Dim _Prompt As String = DevExpress.ExpressApp.Utils.CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions\StorageComputed", "CanNotStorageInByLocking")
Dim _Title As String = DevExpress.ExpressApp.Utils.CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions", "MsgBoxError")
MsgBox(String.Format(_Prompt, _LockingObject.User.FullName, _LockingObject.ObjectCreated), MsgBoxStyle.Information + MsgBoxStyle.OkOnly, _Title)
Exit Sub
Else
' Betárolás stornózás
'__________________________________________________________________________
Dim _StorageInHeaderNew As New StorageInHeader(_onew.Session)
With _StorageInHeaderNew
.Storage = _StorageInHeader.Storage
.StorageMoveType = _StorageInHeader.StorageMoveType
.Active = False
.IsStorno = True
.IsEditable = False
.IsFinalized = False
.CreateDate = GetSQLTime(_onew.Session)
End With
_StorageInHeader.IsStorno = True
_StorageInHeader.Active = False
_StorageInHeader.IsEditable = False
For Each _StorageInRows As StorageInRows In _StorageInHeader.StorageInRows
Dim _StorageInRowsNew As New StorageInRows(_onew.Session)
With _StorageInRowsNew
.StorageInHeader = _StorageInHeaderNew
.RowIndex = _StorageInHeaderNew.StorageInRows.Count
.Products = _StorageInRows.Products
.QTT = _StorageInRows.QTT * (-1)
.QTT_Will = 0
.QTT_Out = 0
.QTT_Out_Will = 0
.Active = False
.OnStorno = True
.PacketNumber = _StorageInRows.PacketNumber
.SerialNumber = _StorageInRows.SerialNumber
.Storage = _StorageInHeaderNew.Storage
.Weight = _StorageInRows.Weight
If _StorageInRows.DeliveryNoteInRows IsNot Nothing Then
.DeliveryNoteInRows = _StorageInRows.DeliveryNoteInRows
End If
End With
Dim _StorageComputed As StorageComputed = _onew.FindObject(Of StorageComputed)(CriteriaOperator.Parse("Storage=? AND Products=?", _StorageInHeader.Storage, _StorageInRows.Products))
_StorageComputed.QTTFree -= _StorageInRows.QTT
Dim _StorageMoveEvents_Collection As New XPCollection(Of StorageMoveEvents)(_onew.Session, CriteriaOperator.Parse("StorageInRows=?", _StorageInRows), _
New SortProperty("ObjectCreated", DB.SortingDirection.Descending))
Dim _StorageMoveEvents As New StorageMoveEvents(_onew.Session)
With _StorageMoveEvents
.StorageInRows = _StorageInRows
.QTT = (-1) * _StorageInRows.QTT
.QTT_Free_Before = _StorageMoveEvents_Collection(0).QTT_Free_After
.QTT_Free_After = _StorageMoveEvents.QTT_Free_Before + _StorageMoveEvents.QTT
.MoveEventsType = eMoveEventsType.StorageInStorno
.ObjectCreated = GetSQLTime(_onew.Session)
End With
Next
End If
_onew.CommitChanges()
Frame.GetController(Of RefreshController).RefreshAction.DoExecute()
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.OkOnly + MsgBoxStyle.Critical, String.Format(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions", "MsgBoxCheckItAgain")))
Finally
LockingModule.UnLockObject(_uow_lock, GetType(StorageComputed), "-", _User)
End Try
End Sub
Private Sub aToTableD_SIH_Execute(ByVal sender As System.Object, ByVal e As DevExpress.ExpressApp.Actions.SimpleActionExecuteEventArgs) Handles aToTableD_SIH.Execute
Dim _ocur As Xpo.XPObjectSpace = TryCast(View.ObjectSpace, Xpo.XPObjectSpace)
Dim _onew As Xpo.XPObjectSpace = Application.CreateObjectSpace
Dim _uow As New UnitOfWork(_onew.Session.DataLayer)
Dim _StorageInHeader As StorageInHeader = TryCast(View.SelectedObjects(0), StorageInHeader)
Dim _uow_lock As New UnitOfWork(_ocur.Session.DataLayer)
Dim _User As User = _uow_lock.GetObjectByKey(Of User)(SecuritySystem.CurrentUserId)
Dim _StorageInHeader_ListEditor As ListPropertyEditor = TryCast(View, DetailView).FindItem("StorageInRows")
Try
Dim _StorageInRows As StorageInRows
Dim _StorageInRows_Collection As New ArrayList
If Not LockingModule.LockObject(_uow_lock, GetType(StorageComputed), "-", _User) Then
Dim _LockingObject As LockingObject = _onew.FindObject(Of LockingObject)(CriteriaOperator.Parse("TableName=?", GetType(StorageComputed).Name + "-" + "-"))
Dim _Prompt As String = DevExpress.ExpressApp.Utils.CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions\StorageComputed", "CanNotStorageInByLocking")
Dim _Title As String = DevExpress.ExpressApp.Utils.CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions", "MsgBoxError")
MsgBox(String.Format(_Prompt, _LockingObject.User.FullName, _LockingObject.ObjectCreated), MsgBoxStyle.Information + MsgBoxStyle.OkOnly, _Title)
Exit Sub
Else
For Each _StorageInRows In _StorageInHeader_ListEditor.ListView.SelectedObjects
_StorageInRows.RemoveRows()
Dim _StorageComputed As StorageComputed = _ocur.FindObject(Of StorageComputed)(CriteriaOperator.Parse("Storage=? AND Products=?", _
_StorageInHeader.Storage, _StorageInRows.Products))
If _StorageComputed Is Nothing Then Throw New Exception("*Váratlan hiba történt, a folyamat megszakadt!")
_StorageComputed.QTTReservedIn -= _StorageInRows.QTT_Will
'If _StorageComputed.QTTFree = 0 And _
' _StorageComputed.QTTReserved = 0 And _
' _StorageComputed.QTTReservedIn = 0 And _
' _StorageComputed.QTTReservedOut = 0 Then
' _StorageComputed.Delete()
'End If
If _StorageInHeader.StorageMoveType.MoveType = eMoveType.InventoryTransfer Then
_StorageInRows.StorageInRowsFrom.QTT_Overstored -= _StorageInRows.QTT_Will
_StorageInRows.StorageInRowsFrom = Nothing
End If
_StorageInRows_Collection.Add(_StorageInRows)
Next
_ocur.Delete(_StorageInRows_Collection)
_ocur.CommitChanges()
If _StorageInHeader.StorageMoveType.MoveType = eMoveType.InventoryTransfer Then
CheckInventoryTransferStorageInRows(_uow, _StorageInHeader.StorageInRows)
End If
View.Refresh()
End If
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.OkOnly + MsgBoxStyle.Critical, String.Format(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions", "MsgBoxCheckItAgain")))
Finally
LockingModule.UnLockObject(_uow_lock, GetType(StorageComputed), "-", _User)
End Try
End Sub
Private Sub aUp_StorageIn_Execute(ByVal sender As System.Object, ByVal e As DevExpress.ExpressApp.Actions.SimpleActionExecuteEventArgs) Handles aUp_StorageIn.Execute
Try
Dim _ocur As Xpo.XPObjectSpace = TryCast(View.ObjectSpace, Xpo.XPObjectSpace)
Dim _StorageInHeader As StorageInHeader = TryCast(View.SelectedObjects(0), StorageInRows).StorageInHeader
Dim _StorageInRowsMinus As StorageInRows = Nothing
Dim _StorageInRowsSelected As StorageInRows = TryCast(View.SelectedObjects(0), StorageInRows)
If _StorageInRowsSelected Is Nothing Then Throw New Exception("*Nincs sor kiválasztva, vagy nem a sor kijelölése az aktív!")
If _StorageInRowsSelected.RowIndex > 0 Then
For Each _StorageInrows As StorageInRows In _StorageInHeader.StorageInRows
If _StorageInrows.RowIndex = _StorageInRowsSelected.RowIndex - 1 Then
_StorageInRowsMinus = _StorageInrows
Exit For
End If
Next
If _StorageInRowsMinus IsNot Nothing Then
_StorageInRowsSelected.RowIndex -= 1
_StorageInRowsMinus.RowIndex += 1
End If
End If
_ocur.CommitChanges()
View.Refresh()
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.OkOnly + MsgBoxStyle.Critical, String.Format(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions", "MsgBoxCheckItAgain")))
End Try
End Sub
Private Sub aDown_StorageIn_Execute(ByVal sender As System.Object, ByVal e As DevExpress.ExpressApp.Actions.SimpleActionExecuteEventArgs) Handles aDown_StorageIn.Execute
Try
Dim _ocur As Xpo.XPObjectSpace = TryCast(View.ObjectSpace, Xpo.XPObjectSpace)
Dim _StorageInHeader As StorageInHeader = TryCast(View.SelectedObjects(0), StorageInRows).StorageInHeader
Dim _StorageInRowsPlus As StorageInRows = Nothing
Dim _StorageInRowsSelected As StorageInRows = TryCast(View.SelectedObjects(0), StorageInRows) ' Kiveszi a kijelölt sorok közül az elsőt
If _StorageInRowsSelected Is Nothing Then Throw New Exception("*Nincs sor kiválasztva, vagy nem a sor kijelölése az aktív!")
If _StorageInRowsSelected.RowIndex < _StorageInHeader.StorageInRows.Count - 1 Then
For Each _StorageInrows As StorageInRows In _StorageInHeader.StorageInRows
If _StorageInrows.RowIndex = _StorageInRowsSelected.RowIndex + 1 Then
_StorageInRowsPlus = _StorageInrows
Exit For
End If
Next
If _StorageInRowsPlus IsNot Nothing Then
_StorageInRowsSelected.RowIndex += 1
_StorageInRowsPlus.RowIndex -= 1
End If
End If
_ocur.CommitChanges()
View.Refresh()
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.OkOnly + MsgBoxStyle.Critical, String.Format(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions", "MsgBoxCheckItAgain")))
End Try
End Sub
'Private Sub sis_SIFinal(ByVal p_StorageInHeader As StorageInHeader, ByVal _p_ocur As Xpo.XPObjectSpace)
' For Each _StorageInRows As StorageInRows In p_StorageInHeader.StorageInRows
' Dim _StorageComputed As StorageComputed = _p_ocur.FindObject(Of StorageComputed)(CriteriaOperator.Parse("Products=? and Storage=?", _StorageInRows.Products, p_StorageInHeader.Storage))
' Dim _StorageMoveEvents As StorageMoveEvents = _p_ocur.CreateObject(Of StorageMoveEvents)()
' If _StorageInRows.QTT_Will > 0 Then
' _StorageInRows.QTT = _StorageInRows.QTT_Will
' _StorageComputed.QTTFree += _StorageInRows.QTT_Will
' _StorageComputed.QTTReservedIn -= _StorageInRows.QTT_Will
' _StorageMoveEvents.StorageInRows = _StorageInRows
' _StorageMoveEvents.QTT = _StorageInRows.QTT_Will
' _StorageMoveEvents.QTT_Free_After = _StorageComputed.QTTFree
' _StorageMoveEvents.QTT_Free_Before = _StorageMoveEvents.QTT_Free_After - _StorageMoveEvents.QTT
' _StorageMoveEvents.MoveEventsType = eMoveEventsType.StorageInFinal
' _StorageMoveEvents.ExecutionDate = GetSQLTime(_p_ocur.Session)
' _StorageInRows.QTT_Will = 0
' End If
' Next
' p_StorageInHeader.IsEditable = False
' p_StorageInHeader.IsFinalized = True
' _p_ocur.CommitChanges()
'End Sub
Private Sub aBackToEdit_StorageInHeader_Execute(sender As System.Object, e As DevExpress.ExpressApp.Actions.SimpleActionExecuteEventArgs) Handles aBackToEdit_StorageInHeader.Execute
Dim _onew As Xpo.XPObjectSpace = Application.CreateObjectSpace
Dim _ocur As Xpo.XPObjectSpace = TryCast(View.ObjectSpace, Xpo.XPObjectSpace)
Dim _uow_lock As New UnitOfWork(_onew.Session.DataLayer)
Dim _User As User = _onew.GetObject(TryCast(SecuritySystem.CurrentUser, User))
Dim _StorageInHeader As StorageInHeader = _onew.FindObject(Of StorageInHeader)(CriteriaOperator.Parse("Oid=?", TryCast(View.SelectedObjects(0), StorageInHeader).Oid))
Try
If _StorageInHeader.Storage IsNot Nothing And _StorageInHeader.StorageInRows.Count = 0 Then _
Throw New Exception("*Nem lehet véglegesíteni a betárolási bizonylatot!" & vbNewLine & vbNewLine & _
"Kérem ellenőrizze, hogy be lett-e állítva raktár, illetve" & vbNewLine & _
"definiált-e betárolási sorokat!")
If Not LockingModule.LockObject(_uow_lock, GetType(StorageComputed), "-", _User) Then
Dim _LockingObject As LockingObject = _onew.FindObject(Of LockingObject)(CriteriaOperator.Parse("TableName=?", GetType(StorageComputed).Name + "-" + "-"))
Dim _Prompt As String = DevExpress.ExpressApp.Utils.CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions\StorageComputed", "CanNotStorageInByLocking")
Dim _Title As String = DevExpress.ExpressApp.Utils.CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions", "MsgBoxError")
MsgBox(String.Format(_Prompt, _LockingObject.User.FullName, _LockingObject.ObjectCreated), MsgBoxStyle.Information + MsgBoxStyle.OkOnly, _Title)
Exit Sub
Else
If _StorageInHeader.Active = True Then
Dim _AllowBackToEdit As Boolean = False
For Each _StorageInRows As StorageInRows In _StorageInHeader.StorageInRows
If _StorageInRows.QTT_Out = 0 Then
_AllowBackToEdit = True
Exit For
End If
Next
If _AllowBackToEdit = True Then
_StorageInHeader.IsEditable = True
For Each _StorageInRows As StorageInRows In _StorageInHeader.StorageInRows
Dim _StorageComputed As StorageComputed = _onew.FindObject(Of StorageComputed)(CriteriaOperator.Parse("Storage=? AND Products=?", _
_onew.GetObject(_StorageInRows.StorageInHeader.Storage), _onew.GetObject(_StorageInRows.Products)))
_StorageComputed.QTTFree -= _StorageInRows.QTT
_StorageComputed.QTTReservedIn += _StorageInRows.QTT
Dim _StorageMoveEvents_Collection As New XPCollection(Of StorageMoveEvents)(_onew.Session, CriteriaOperator.Parse("StorageInRows=?", _onew.GetObject(_StorageInRows)))
_StorageMoveEvents_Collection.Sorting.Add(New SortProperty("ObjectCreated", DB.SortingDirection.Descending))
_StorageInRows.QTT_Will = _StorageInRows.QTT
_StorageInRows.QTT = 0
Dim _StorageMoveEvents As New StorageMoveEvents(_onew.Session)
_StorageMoveEvents.StorageInRows = _onew.GetObject(_StorageMoveEvents_Collection(0).StorageInRows)
_StorageMoveEvents.StorageOutRows = _onew.GetObject(_StorageMoveEvents_Collection(0).StorageOutRows)
_StorageMoveEvents.QTT_Free_Before = _StorageMoveEvents_Collection(0).QTT_Free_After
_StorageMoveEvents.QTT = (-1) * _StorageInRows.QTT_Will
_StorageMoveEvents.QTT_Free_After = _StorageMoveEvents.QTT_Free_Before + _StorageMoveEvents.QTT
_StorageMoveEvents.MoveEventsType = eMoveEventsType.StorageInBackToEdit
_StorageMoveEvents.ExecutionDate = GetSQLTime(_ocur.Session)
Next
_onew.CommitChanges()
End If
End If
If Frame.GetController(Of RefreshController).RefreshAction.Enabled Then
Frame.GetController(Of RefreshController).RefreshAction.DoExecute()
End If
End If
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.OkOnly + MsgBoxStyle.Critical, "Hiba")
Finally
LockingModule.UnLockObject(_uow_lock, GetType(StorageComputed), "-", _User)
End Try
End Sub
Private Sub StorageInHeader_ListView_View_SelectionChanged(sender As Object, e As EventArgs)
If View.SelectedObjects.Count = 1 Then
Dim _StorageInHeader As StorageInHeader = TryCast(View.SelectedObjects(0), StorageInHeader)
If _StorageInHeader IsNot Nothing Then
If _StorageInHeader.IsStorno = False Then
Frame.GetController(Of StorageTransactionsInVC)().aStorageInStorno.Enabled.SetItemValue("", True)
Frame.GetController(Of StorageTransactionsInVC)().aBackToEdit_StorageInHeader.Enabled.SetItemValue("", True)
Else
Frame.GetController(Of StorageTransactionsInVC)().aStorageInStorno.Enabled.SetItemValue("", False)
Frame.GetController(Of StorageTransactionsInVC)().aBackToEdit_StorageInHeader.Enabled.SetItemValue("", False)
End If
End If
End If
End Sub
Private Sub aStorageInFromPdaCollection_CustomizePopupWindowParams(sender As Object, e As DevExpress.ExpressApp.Actions.CustomizePopupWindowParamsEventArgs) Handles aStorageInFromPdaCollection.CustomizePopupWindowParams
Dim _onew As Xpo.XPObjectSpace = Application.CreateObjectSpace
Dim _StoragePDACollectionHeader_Collection As New XPCollection(Of StoragePDACollectionHeader)(_onew.Session, CriteriaOperator.Parse("StoragePDACollectionHeaderStatus=0 " _
+ "AND StoragePDACollectionRows.Count>0"))
Dim _CS As New CollectionSource(_onew, GetType(StorageInRowsFromPDACollectionPopup))
For Each _StoragePDACollectionHeader As StoragePDACollectionHeader In _StoragePDACollectionHeader_Collection
Dim _StorageInRowsFromPDACollectionPopup As StorageInRowsFromPDACollectionPopup = _onew.CreateObject(Of StorageInRowsFromPDACollectionPopup)()
_StorageInRowsFromPDACollectionPopup.StoragePDACollectionHeader = _StoragePDACollectionHeader
_CS.Add(_StorageInRowsFromPDACollectionPopup)
Next
e.View = Application.CreateListView("StorageInRowsFromPDACollectionPopup_ListView", _CS, False)
End Sub
Private Sub aStorageInFromPdaCollection_Execute(sender As System.Object, e As DevExpress.ExpressApp.Actions.PopupWindowShowActionExecuteEventArgs) Handles aStorageInFromPdaCollection.Execute
Try
If e.PopupWindow.View.SelectedObjects.Count = 0 Then Throw New Exception("*Nincs kiválasztva egyetlen kollekció sem!" + vbNewLine _
+ "A művelet megszakadt.")
Dim _ocur As Xpo.XPObjectSpace = View.ObjectSpace
Dim _StorageInHeader As StorageInHeader = TryCast(View.SelectedObjects(0), StorageInHeader)
For Each _StorageInRowsFromPDACollectionPopup As StorageInRowsFromPDACollectionPopup In e.PopupWindow.View.SelectedObjects
If _StorageInRowsFromPDACollectionPopup.StoragePDACollectionHeader.StoragePDACollectionRows.Count > 0 Then
_StorageInRowsFromPDACollectionPopup.StoragePDACollectionHeader.StoragePDACollectionHeaderStatus = 1
For Each _StoragePDACollectionRows As StoragePDACollectionRows In _StorageInRowsFromPDACollectionPopup.StoragePDACollectionHeader.StoragePDACollectionRows
_StorageInHeader.row_Products = _ocur.GetObjectByKey(Of Products)(_StoragePDACollectionRows.Products.Oid)
_StorageInHeader.row_QTT_WILL = _StoragePDACollectionRows.QTT
Frame.GetController(Of StorageTransactionsInVC).aToTable_StorageIn.DoExecute()
Next
End If
Next
_ocur.CommitChanges()
Catch ext As Exception
MsgBox(ext.Message)
End Try
End Sub
Private Sub aGenerateStorageInPDACollection_CustomizePopupWindowParams(sender As Object, e As DevExpress.ExpressApp.Actions.CustomizePopupWindowParamsEventArgs) Handles aGenerateStorageInPDACollection.CustomizePopupWindowParams
Try
Dim _onew As Xpo.XPObjectSpace = Application.CreateObjectSpace
Dim _GenerateStorageInPDALocationCollection As GenerateStorageInPDALocationCollection = _onew.CreateObject(Of GenerateStorageInPDALocationCollection)()
e.View = Application.CreateDetailView(_onew, "GenerateStorageInPDALocationCollection_DetailView", False, _GenerateStorageInPDALocationCollection)
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.OkOnly)
End Try
End Sub
Private Sub aGenerateStorageInPDACollection_Execute(sender As System.Object, e As DevExpress.ExpressApp.Actions.PopupWindowShowActionExecuteEventArgs) Handles aGenerateStorageInPDACollection.Execute
Try
Dim _ocur As Xpo.XPObjectSpace = View.ObjectSpace
Dim _StorageInHeader As StorageInHeader = TryCast(View.SelectedObjects(0), StorageInHeader)
Dim _GenerateStorageInPDALocationCollection As GenerateStorageInPDALocationCollection = TryCast(e.PopupWindow.View.SelectedObjects(0), GenerateStorageInPDALocationCollection)
If _StorageInHeader Is Nothing Then Throw New Exception("*Nincs kijelölve egyetlen véglegesített betárolás sem!")
Dim _StoragePDACollectionHeader As StoragePDACollectionHeader = _ocur.CreateObject(Of StoragePDACollectionHeader)()
_StoragePDACollectionHeader.StoragePDACollectionHeaderStatus = eStoragePDACollectionHeaderStatus.eOpen
_StoragePDACollectionHeader.StorageCollectionType = eStoragePDACollectionType.eIsLocationIn
_StoragePDACollectionHeader.StoragePDAParameters = _ocur.GetObjectByKey(Of StoragePDAParameters)(_GenerateStorageInPDALocationCollection.StoragePDAParameters.Oid)
_StoragePDACollectionHeader.StorageInHeader = _StorageInHeader
_StoragePDACollectionHeader.CustomersFrom = _ocur.GetObject(_GenerateStorageInPDALocationCollection.StoragePDAParameters.CustomersFrom)
If _StorageInHeader.StorageInRows.Count > 0 Then
For Each _StorageInRows As StorageInRows In _StorageInHeader.StorageInRows
Dim _StoragePDACollectionRows As StoragePDACollectionRows = _ocur.CreateObject(Of StoragePDACollectionRows)()
_StoragePDACollectionRows.StoragePDACollectionHeader = _StoragePDACollectionHeader
_StoragePDACollectionRows.Products = _StorageInRows.Products
_StoragePDACollectionRows.QTT = _StorageInRows.QTT
_StoragePDACollectionRows.DateModified = GetSQLTime(_ocur.Session)
_StoragePDACollectionRows.SerialNumber = _StorageInRows.SerialNumber
_StoragePDACollectionRows.PacketNumber = _StorageInRows.PacketNumber
_StoragePDACollectionRows.ConnectOid = _StorageInRows.Oid 'A kötés miatt kell !!!
If _StorageInRows.Products.ProductsBarcodes.Count > 0 Then
_StoragePDACollectionRows.Barcode = _StorageInRows.Products.ProductsBarcodes(0).Barcode
End If
Next
End If
_ocur.CommitChanges()
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.OkOnly)
End Try
End Sub
Private Sub aStorageInHeader_InsertInventoryTransfer_CustomizePopupWindowParams(sender As Object, e As CustomizePopupWindowParamsEventArgs) Handles aStorageInHeader_InsertInventoryTransfer.CustomizePopupWindowParams
Try
Dim _onew As Xpo.XPObjectSpace = Application.CreateObjectSpace
Dim _StorageInHeader As StorageInHeader = TryCast(View.SelectedObjects(0), StorageInHeader)
Dim _StorageInRows_InTable As StorageInRows
Dim _StorageInRowsFrom_Collection As New XPCollection(Of StorageInRows)(_onew.Session, CriteriaOperator.Parse("1=2"))
Dim _StorageOutHeader_Collection As New XPCollection(Of StorageOutHeader)(_onew.Session, CriteriaOperator.Parse("IsEditable=False AND StorageTo=? AND Storage=?", _
_onew.GetObject(_StorageInHeader.Storage), _onew.GetObject(_StorageInHeader.StorageFrom)))
Dim _StorageOutRows_CollectionSource As New CollectionSource(_onew, GetType(StorageOutRows))
Dim _Filter As String = "Oid in("
Dim _StorageOutRowsInRows As StorageOutRowsInRows
For Each _StorageOutHeader As StorageOutHeader In _StorageOutHeader_Collection
For Each _StorageOutRows As StorageOutRows In _StorageOutHeader.StorageOutRows
Dim _Need As Boolean = True
For Each _StorageOutRowsInRows In _StorageOutRows.StorageOutRowsInRows
If _StorageOutRowsInRows.StorageInRows.QTT_Overstored < _StorageOutRowsInRows.StorageInRows.QTT_Out Then
For Each _StorageInRows_InTable In _StorageInHeader.StorageInRows
If _StorageOutRowsInRows.StorageInRows.Oid = _StorageInRows_InTable.StorageInRowsFrom.Oid Then
_Need = False
Exit For
End If
Next
Else
_Need = False
End If
Next
If _need Then
_Filter += "'" + _StorageOutRows.Oid.ToString + "',"
End If
Next
Next
_Filter = _Filter.Remove(_Filter.Length - 1, 1)
_Filter += ")"
_StorageOutRows_CollectionSource.BeginUpdateCriteria()
_StorageOutRows_CollectionSource.Criteria.Clear()
If _Filter.Length > 8 Then
_StorageOutRows_CollectionSource.Criteria("Filter") = CriteriaOperator.Parse(_Filter)
Else
_StorageOutRows_CollectionSource.Criteria.Add("1", CriteriaOperator.Parse("1=2"))
End If
_StorageOutRows_CollectionSource.EndUpdateCriteria()
e.View = Application.CreateListView("StorageOutRows_ListView_Overstored", _StorageOutRows_CollectionSource, False)
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.OkOnly + MsgBoxStyle.Critical, String.Format(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions", "MsgBoxCheckItAgain")))
End Try
End Sub
Private Sub aStorageInHeader_InsertInventoryTransfer_Execute(sender As Object, e As PopupWindowShowActionExecuteEventArgs) Handles aStorageInHeader_InsertInventoryTransfer.Execute
Dim _onew As Xpo.XPObjectSpace = Application.CreateObjectSpace
Dim _ocur As Xpo.XPObjectSpace = TryCast(View.ObjectSpace, Xpo.XPObjectSpace)
Dim _uow_lock As New UnitOfWork(_onew.Session.DataLayer)
Dim _User As User = _onew.GetObject(TryCast(SecuritySystem.CurrentUser, User))
Try
If Not LockingModule.LockObject(_uow_lock, GetType(StorageComputed), "-", _User) Then
Dim _LockingObject As LockingObject = _onew.FindObject(Of LockingObject)(CriteriaOperator.Parse("TableName=?", GetType(StorageComputed).Name + "-" + "-"))
Dim _Prompt As String = DevExpress.ExpressApp.Utils.CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions\StorageComputed", "CanNotStorageInByLocking")
Dim _Title As String = DevExpress.ExpressApp.Utils.CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions", "MsgBoxError")
MsgBox(String.Format(_Prompt, _LockingObject.User.FullName, _LockingObject.ObjectCreated), MsgBoxStyle.Information + MsgBoxStyle.OkOnly, _Title)
Exit Sub
Else
Dim _StorageInHeader As StorageInHeader = TryCast(View.SelectedObjects(0), StorageInHeader)
For Each _StorageOutRows As StorageOutRows In e.PopupWindow.View.SelectedObjects
For Each _StorageOutRowsInRows As StorageOutRowsInRows In _StorageOutRows.StorageOutRowsInRows
_StorageOutRowsInRows = _ocur.GetObject(_StorageOutRowsInRows)
Dim _StorageComputed As StorageComputed = _ocur.FindObject(Of StorageComputed)(CriteriaOperator.Parse("Products=? and Storage=?", _
_ocur.GetObject(_StorageOutRowsInRows.StorageInRows.Products), _ocur.GetObject(_StorageInHeader.Storage)))
If _StorageComputed Is Nothing Then
_StorageComputed = _ocur.CreateObject(Of StorageComputed)()
_StorageComputed.Storage = _StorageInHeader.Storage
_StorageComputed.Products = _ocur.GetObject(_StorageOutRowsInRows.StorageInRows.Products)
_StorageComputed.QTTReservedIn = _StorageOutRowsInRows.QTT
Else
_StorageComputed.QTTReservedIn += _StorageOutRowsInRows.QTT
End If
Dim _StorageInRows As New StorageInRows(_ocur.Session)
With _StorageInRows
.StorageInHeader = _StorageInHeader
.Products = _ocur.GetObject(_StorageOutRowsInRows.StorageInRows.Products)
.QTT_Will = _StorageOutRowsInRows.QTT
.PacketNumber = _StorageOutRowsInRows.StorageInRows.PacketNumber
.SerialNumber = _StorageOutRowsInRows.StorageInRows.SerialNumber
.WeightMode = _StorageOutRowsInRows.StorageInRows.WeightMode
.Weight = .QTT_Will * (_StorageOutRowsInRows.StorageInRows.Weight / _StorageOutRowsInRows.StorageInRows.QTT)
.RowIndex = _StorageInHeader.StorageInRows.Count
.StorageInRowsFrom = _StorageOutRowsInRows.StorageInRows
.DeliveryNoteInRows = _ocur.GetObject(_StorageOutRowsInRows.StorageInRows.DeliveryNoteInRows)
End With
_StorageOutRowsInRows.StorageInRows.QTT_Overstored += _StorageOutRowsInRows.QTT
Next
Next
_ocur.CommitChanges()
End If
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.OkOnly + MsgBoxStyle.Critical, String.Format(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions", "MsgBoxCheckItAgain")))
Finally
LockingModule.UnLockObject(_uow_lock, GetType(StorageComputed), "-", _User)
End Try
End Sub
Private Sub aStorageInRows_Split_CustomizePopupWindowParams(sender As Object, e As CustomizePopupWindowParamsEventArgs) Handles aStorageInRows_Split.CustomizePopupWindowParams
Dim _onew As Xpo.XPObjectSpace = Application.CreateObjectSpace
Dim _StorageInRows As StorageInRows = TryCast(View.SelectedObjects(0), StorageInRows)
Dim _StorageInRows_Split_PopUp As New StorageInRows_Split_PopUp(_onew.Session)
_StorageInRows_Split_PopUp.QTT_Max = _StorageInRows.QTT - _StorageInRows.QTT_Out
_StorageInRows_Split_PopUp.StorageInRows = _onew.GetObject(_StorageInRows)
e.View = Application.CreateDetailView(_onew, "StorageInRows_Split_PopUp_DetailView", False, _StorageInRows_Split_PopUp)
End Sub
Private Sub aStorageInRows_Split_Execute(sender As Object, e As PopupWindowShowActionExecuteEventArgs) Handles aStorageInRows_Split.Execute
Dim _ocur As Xpo.XPObjectSpace = TryCast(View.ObjectSpace, Xpo.XPObjectSpace)
Dim _StorageInRows As StorageInRows = TryCast(View.SelectedObjects(0), StorageInRows)
Dim _QTT_Max As Double = TryCast(e.PopupWindow.View.SelectedObjects(0), StorageInRows_Split_PopUp).QTT_Max
If _QTT_Max > 0 And _QTT_Max < _StorageInRows.QTT Then
Dim _StorageInRows_New As New StorageInRows(_ocur.Session)
With _StorageInRows_New
.StorageInHeader = _StorageInRows.StorageInHeader
.Products = _StorageInRows.Products
.QTT = _QTT_Max
.QTT_Will = 0
.QTT_Out = 0
.QTT_Out_Will = 0
.QTT_Overstored = 0
.Active = _StorageInRows.Active
.DeliveryNoteInRows = _StorageInRows.DeliveryNoteInRows
.PacketNumber = _StorageInRows.PacketNumber
.SerialNumber = _StorageInRows.SerialNumber
.Weight = _StorageInRows.Weight
.WeightMode = _StorageInRows.WeightMode
.Storage = _StorageInRows.Storage
.StorageInRowsFrom = _StorageInRows.StorageInRowsFrom
.AveragePriceInHUF = _StorageInRows.AveragePriceInHUF
End With
_StorageInRows.QTT -= _QTT_Max
Dim _StorageMoveEvents As StorageMoveEvents = _ocur.FindObject(Of StorageMoveEvents)(CriteriaOperator.Parse("StorageInRows=? AND MoveEventsType=0", _StorageInRows))
With _StorageMoveEvents
.QTT -= _QTT_Max
.QTT_Free_After -= _QTT_Max
End With
Dim _StorageMoveEvents_New As New StorageMoveEvents(_ocur.Session)
With _StorageMoveEvents_New
.StorageInRows = _StorageInRows_New
.QTT = _StorageInRows_New.QTT
.QTT_Free_Before = _StorageMoveEvents.QTT_Free_After
.QTT_Free_After = .QTT_Free_Before + .QTT
.ExecutionDate = _StorageMoveEvents.ExecutionDate
.MoveEventsType = eMoveEventsType.StorageInFinal
End With
_ocur.CommitChanges()
End If
End Sub
Private Sub StorageInRows_Split_PopUp_DetailView_AcceptAction_Executing(sender As Object, e As CancelEventArgs)
Try
Dim _StorageInRows_Split_PopUp As StorageInRows_Split_PopUp = TryCast(View.SelectedObjects(0), StorageInRows_Split_PopUp)
If _StorageInRows_Split_PopUp.StorageInRows.QTT < _StorageInRows_Split_PopUp.QTT_Max Then Throw New Exception("*A beírt érték meghaladja a maximális értéket!")
If _StorageInRows_Split_PopUp.QTT_Max = 0 Then Throw New Exception("*Nulla mennyiséggel nem lehet sort bontani!")
If _StorageInRows_Split_PopUp.QTT_Max < 0 Then Throw New Exception("*Negatív mennyiséggel nem lehet sort bontani!")
If _StorageInRows_Split_PopUp.QTT_Max - _StorageInRows_Split_PopUp.StorageInRows.QTT = 0 Then Throw New Exception("*Nem maradhat nulla értékű sor a sorbontás után!")
Catch ex As Exception
e.Cancel = True
MsgBox(ex.Message, MsgBoxStyle.OkOnly)
End Try
End Sub
Private Sub aStorageInHeader_InsertInventoryTransfer_FIFO_CustomizePopupWindowParams(sender As Object, e As CustomizePopupWindowParamsEventArgs) Handles aStorageInHeader_InsertInventoryTransfer_FIFO.CustomizePopupWindowParams
Dim _onew As Xpo.XPObjectSpace = Application.CreateObjectSpace
Dim _StorageOutRowsInRows_Collection As New CollectionSource(_onew, GetType(StorageOutRowsInRows))
Dim _StorageInHeader As StorageInHeader = TryCast(View.SelectedObjects(0), StorageInHeader)
Dim _StorageOutRowsInRows As StorageOutRowsInRows = Nothing
_StorageOutRowsInRows_Collection.BeginUpdateCriteria()
_StorageOutRowsInRows_Collection.Criteria("ByNotOverstored") = CriteriaOperator.Parse("StorageOutRows.StorageOutHeader.StorageTo.Oid=? and " _
+ "[StorageOutRows.StorageOutHeader.IsStorno] = False and [StorageOutRows.StorageOutHeader.IsEditable] = False And" _
+ "[StorageOutRows.StorageOutHeader.StorageMoveType.MoveType] = ##Enum#Nuvolar.Module.eMoveType,InventoryTransfer# And " _
+ "Round([StorageInRows.QTT_Overstor], 4) > Round([StorageInRows.QTT_Overstored], 4)", _
_StorageInHeader.Storage.Oid)
_StorageOutRowsInRows_Collection.EndUpdateCriteria()
e.View = Application.CreateListView("StorageOutRowsInRows_ListView_Overstored", _StorageOutRowsInRows_Collection, False)
End Sub
Private Sub aStorageInHeader_InsertInventoryTransfer_FIFO_Execute(sender As Object, e As PopupWindowShowActionExecuteEventArgs) Handles aStorageInHeader_InsertInventoryTransfer_FIFO.Execute
Dim _onew As Xpo.XPObjectSpace = Application.CreateObjectSpace
Dim _uow As New UnitOfWork(_onew.Session.DataLayer)
Dim _ocur As Xpo.XPObjectSpace = TryCast(View.ObjectSpace, Xpo.XPObjectSpace)
Dim _uow_lock As New UnitOfWork(_onew.Session.DataLayer)
Dim _User As User = _onew.GetObject(TryCast(SecuritySystem.CurrentUser, User))
Try
If Not LockingModule.LockObject(_uow_lock, GetType(StorageComputed), "-", _User) Then
Dim _LockingObject As LockingObject = _onew.FindObject(Of LockingObject)(CriteriaOperator.Parse("TableName=?", GetType(StorageComputed).Name + "-" + "-"))
Dim _Prompt As String = DevExpress.ExpressApp.Utils.CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions\StorageComputed", "CanNotStorageInByLocking")
Dim _Title As String = DevExpress.ExpressApp.Utils.CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions", "MsgBoxError")
MsgBox(String.Format(_Prompt, _LockingObject.User.FullName, _LockingObject.ObjectCreated), MsgBoxStyle.Information + MsgBoxStyle.OkOnly, _Title)
Exit Sub
Else
Dim _StorageInHeader As StorageInHeader = TryCast(View.SelectedObjects(0), StorageInHeader)
If _StorageInHeader Is Nothing Then Throw New Exception("*Váratlan hiba történt, a folyamat megszakadt!")
For Each _StorageOutRowsInRows As StorageOutRowsInRows In e.PopupWindow.View.SelectedObjects
If _StorageOutRowsInRows.QTT_Will > 0 Then
Dim _QTT_Will As Double = _StorageOutRowsInRows.QTT_Will
_StorageOutRowsInRows = _ocur.GetObject(_StorageOutRowsInRows)
Dim _StorageComputed As StorageComputed = _ocur.FindObject(Of StorageComputed)(CriteriaOperator.Parse("Products=? and Storage=?", _
_ocur.GetObject(_StorageOutRowsInRows.StorageInRows.Products), _ocur.GetObject(_StorageInHeader.Storage)))
If _StorageComputed Is Nothing Then
_StorageComputed = _ocur.CreateObject(Of StorageComputed)()
_StorageComputed.Storage = _StorageInHeader.Storage
_StorageComputed.Products = _ocur.GetObject(_StorageOutRowsInRows.StorageInRows.Products)
_StorageComputed.QTTReservedIn = _QTT_Will
Else
_StorageComputed.QTTReservedIn += _QTT_Will
End If
Dim _StorageInRows As New StorageInRows(_ocur.Session)
With _StorageInRows
.StorageInHeader = _StorageInHeader
.Products = _ocur.GetObject(_StorageOutRowsInRows.StorageInRows.Products)
.QTT_Will = _QTT_Will
.PacketNumber = _StorageOutRowsInRows.StorageInRows.PacketNumber
.SerialNumber = _StorageOutRowsInRows.StorageInRows.SerialNumber
.WeightMode = _StorageOutRowsInRows.StorageInRows.WeightMode
.Weight = .QTT_Will * (_StorageOutRowsInRows.StorageInRows.Weight / _StorageOutRowsInRows.StorageInRows.QTT)
.RowIndex = _StorageInHeader.StorageInRows.Count
If _StorageOutRowsInRows.StorageInRows.StorageInRowsFrom Is Nothing Then
.StorageInRowsFrom = _StorageOutRowsInRows.StorageInRows
Else
.StorageInRowsFrom = _StorageOutRowsInRows.StorageInRows.StorageInRowsFrom
End If
.DeliveryNoteInRows = _ocur.GetObject(_StorageOutRowsInRows.StorageInRows.DeliveryNoteInRows)
End With
End If
Next
_ocur.CommitChanges()
If _StorageInHeader.StorageMoveType.MoveType = eMoveType.InventoryTransfer Then
CheckInventoryTransferStorageInRows(_uow, _StorageInHeader.StorageInRows)
End If
End If
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.OkOnly + MsgBoxStyle.Critical, String.Format(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions", "MsgBoxCheckItAgain")))
Finally
LockingModule.UnLockObject(_uow_lock, GetType(StorageComputed), "-", _User)
End Try
End Sub
Private Sub aCheckInventoryTransfer_Execute(sender As Object, e As SimpleActionExecuteEventArgs) Handles aCheckInventoryTransfer.Execute
CheckInventoryTransfer()
End Sub
Private Sub StorageOutRowsInRows_ListView_Overstored_AcceptAction_Executing(sender As Object, e As CancelEventArgs)
For Each _StorageOutRowsInRows As StorageOutRowsInRows In View.SelectedObjects
If _StorageOutRowsInRows.QTT_Will > 0 Then
If _StorageOutRowsInRows.QTT < (_StorageOutRowsInRows.StorageInRows.QTT_Overstored_Will + _StorageOutRowsInRows.StorageInRows.QTT_Overstored + _StorageOutRowsInRows.QTT_Will) Then
e.Cancel = True
MsgBox("A fogadni kívánt mennyiség meghaladja a maximálisan fogadható mennyiséget!")
End If
End If
Next
End Sub
Public Sub CheckInventoryTransfer()
Dim _onew As Xpo.XPObjectSpace = Application.CreateObjectSpace
Select Case GLOBAL_SQLType
Case eSQLType.MSSQL, eSQLType.MySQL
_onew.Session.ExecuteNonQuery("update StorageInRows set QTT_Overstor=0,QTT_Overstor_Will=0,QTT_Overstored=0,QTT_Overstored_Will=0")
Case eSQLType.PostgreSQL
_onew.Session.ExecuteNonQuery("update ""StorageInRows"" set ""QTT_Overstor""=0,""QTT_Overstor_Will""=0,""QTT_Overstored""=0,""QTT_Overstored_Will""=0")
End Select
_onew.CommitChanges()
Dim _StorageOutRowsInRows_XPQuery As New XPQuery(Of StorageOutRowsInRows)(_onew.Session)
Dim query = From _StorageOutRowsInRows In _StorageOutRowsInRows_XPQuery
Where _StorageOutRowsInRows.StorageOutRows.StorageOutHeader.StorageMoveType.MoveType = eMoveType.InventoryTransfer And
_StorageOutRowsInRows.StorageOutRows.StorageOutHeader.IsEditable = False And
String.IsNullOrEmpty(_StorageOutRowsInRows.StorageOutRows.StorageOutHeader.DocumentNumber) = False And
_StorageOutRowsInRows.StorageOutRows.StorageOutHeader IsNot Nothing
Group _StorageOutRowsInRows By _StorageOutRowsInRows.StorageInRows.Oid Into g = Group
Select New With {.StorageInRows = Oid,
.QTT_Sum = g.Sum(Function(inv) inv.QTT)}
RaiseEvent InitWork(1, 1, query.Count)
For Each item In query
RaiseEvent DoWork()
Dim _StorageInRows As StorageInRows = _onew.FindObject(Of StorageInRows)(CriteriaOperator.Parse("Oid=?", item.StorageInRows.ToString))
If _StorageInRows IsNot Nothing Then
_StorageInRows.QTT_Overstor = item.QTT_Sum
_onew.CommitChanges()
End If
Next
RaiseEvent FinalWork
query = From _StorageOutRowsInRows In _StorageOutRowsInRows_XPQuery
Where _StorageOutRowsInRows.StorageOutRows.StorageOutHeader.StorageMoveType.MoveType = eMoveType.InventoryTransfer And
_StorageOutRowsInRows.StorageOutRows.StorageOutHeader.IsEditable = True And
_StorageOutRowsInRows.StorageOutRows.StorageOutHeader IsNot Nothing
Group _StorageOutRowsInRows By _StorageOutRowsInRows.StorageInRows.Oid Into g = Group
Select New With {.StorageInRows = Oid,
.QTT_Sum = g.Sum(Function(inv) inv.QTT_Will)}
RaiseEvent InitWork(1, 1, query.Count)
For Each item In query
RaiseEvent DoWork()
Dim _StorageInRows As StorageInRows = _onew.FindObject(Of StorageInRows)(CriteriaOperator.Parse("Oid=?", item.StorageInRows.ToString))
If _StorageInRows IsNot Nothing Then
_StorageInRows.QTT_Overstor_Will = item.QTT_Sum
_onew.CommitChanges()
End If
Next
RaiseEvent FinalWork
'__Overstored renberakása
Dim _StorageInRows_XPQuery As New XPQuery(Of StorageInRows)(_onew.Session)
Dim query1 = From _StorageInRows In _StorageInRows_XPQuery
Where _StorageInRows.StorageInHeader IsNot Nothing And
String.IsNullOrEmpty(_StorageInRows.StorageInHeader.DocumentNumber) = False And
_StorageInRows.StorageInHeader.StorageMoveType.MoveType = eMoveType.InventoryTransfer And
_StorageInRows.StorageInHeader.IsEditable = False
Group _StorageInRows By _StorageInRows.StorageInRowsFrom.Oid Into g = Group
Select New With {.StorageInRows = Oid,
.QTT_Sum = g.Sum(Function(inv) inv.QTT)}
RaiseEvent InitWork(1, 1, query1.Count)
For Each item In query1
RaiseEvent DoWork()
Dim _StorageInRows As StorageInRows = _onew.FindObject(Of StorageInRows)(CriteriaOperator.Parse("Oid=?", item.StorageInRows.ToString))
If _StorageInRows IsNot Nothing Then
_StorageInRows.QTT_Overstored = item.QTT_Sum
_onew.CommitChanges()
End If
Next
RaiseEvent FinalWork
query1 = From _StorageInRows In _StorageInRows_XPQuery
Where _StorageInRows.StorageInHeader IsNot Nothing And
String.IsNullOrEmpty(_StorageInRows.StorageInHeader.DocumentNumber) = False And
_StorageInRows.StorageInHeader.StorageMoveType.MoveType = eMoveType.InventoryTransfer And
_StorageInRows.StorageInHeader.IsEditable = True
Group _StorageInRows By _StorageInRows.StorageInRowsFrom.Oid Into g = Group
Select New With {.StorageInRows = Oid,
.QTT_Sum = g.Sum(Function(inv) inv.QTT_Will)}
RaiseEvent InitWork(1, 1, query1.Count)
For Each item In query1
RaiseEvent DoWork()
Dim _StorageInRows As StorageInRows = _onew.FindObject(Of StorageInRows)(CriteriaOperator.Parse("Oid=?", item.StorageInRows.ToString))
If _StorageInRows IsNot Nothing Then
_StorageInRows.QTT_Overstored_Will = item.QTT_Sum
_onew.CommitChanges()
End If
Next
RaiseEvent FinalWork
End Sub
End Class