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.ExpressApp.Editors Imports DevExpress.Data.Filtering Imports DevExpress.Xpo Imports DevExpress.Persistent.Validation Imports DevExpress.ExpressApp.SystemModule Imports DevExpress.ExpressApp.CloneObject Imports DevExpress.ExpressApp.Model Imports DevExpress.Persistent.BaseImpl Imports DevExpress.ExpressApp.Utils Public Class OrderInVC Inherits DevExpress.ExpressApp.ViewController Protected _selection As New ArrayList Protected _noselect As Boolean = False Private _getAlertFromOrderIn As String Public Sub New() MyBase.New() InitializeComponent() RegisterActions(components) End Sub Private Enum eInvoiceRows_Mode_DeliveryNoteOutRows_Or_OrderInRows eDeliveryNoteOutRows = 0 eOrderInRows = 1 End Enum #Region "Overrides" Protected Overrides Sub OnActivated() MyBase.OnActivated() ' Frame.GetController(Of OrderInVC).aORI_RegenerateValues.Active.SetItemValue("", False) Frame.GetController(Of OrderInVC)().aFinalizeOrderIn.Active.SetItemValue("", False) ' -- Véglegesít egy bejövõ megrendelést Frame.GetController(Of OrderInVC)().aStornoOrderIn.Active.SetItemValue("", False) ' -- Stornírozz egy bejövõ megrendelést Frame.GetController(Of OrderInVC)().aUp_OrderIn.Active.SetItemValue("", False) ' -- Bejövõ megrendelés sorainak a row indexét csökkentjük Frame.GetController(Of OrderInVC)().aDown_OrderIn.Active.SetItemValue("", False) ' -- Bejövõ megrendelés sorainak a row indexét növeljük Frame.GetController(Of OrderInVC)().aGenerateStorageOutFromOrderIn.Active.SetItemValue("", False) ' -- Létrehoz egy kitárolást egy rendelésbõl betárolás soraiból Frame.GetController(Of OrderInVC)().aToTable_OrderIn.Active.SetItemValue("", False) Frame.GetController(Of OrderInVC)().aToTableD_OrderIn.Active.SetItemValue("", False) Frame.GetController(Of OrderInVC)().aGenerateStorageOutFromOrderInFIFO.Active.SetItemValue("", False) Frame.GetController(Of OrderInVC)().aBackToEdit_OrderInHeader.Active.SetItemValue("", False) Frame.GetController(Of OrderInVC).aORI_RegenerateValues.Active.SetItemValue("", False) Frame.GetController(Of OrderInVC).aProductFinder.Active.SetItemValue("", False) Frame.GetController(Of OrderInVC).aOrderIn_ChangeRows.Active.SetItemValue("", False) '--------- LISTVIEWS ------------------------------------------------------------------------------------------------------------------------------- If View.Id = "OrderInHeader_OrderInRows_ListView" Then '--- Bejövõ megrendelések sorai Frame.GetController(Of DeleteObjectsViewController)()?.Active.SetItemValue("", False) Frame.GetController(Of LinkUnlinkController)()?.Active.SetItemValue("", False) Frame.GetController(Of NewObjectViewController)()?.Active.SetItemValue("", False) Frame.GetController(Of OrderInVC)().aUp_OrderIn.Active.SetItemValue("", True) Frame.GetController(Of OrderInVC)().aDown_OrderIn.Active.SetItemValue("", True) Dim nv As ListView = CType(View, ListView) Dim cs As PropertyCollectionSource = CType(nv.CollectionSource, PropertyCollectionSource) AddHandler cs.MasterObjectChanged, AddressOf cs_MasterObjectChanged 'Dim _OrderInHeader As OrderInHeader = TryCast(cs.MasterObject, OrderInHeader) 'If _OrderInHeader IsNot Nothing Then ' If _OrderInHeader.OrderInParameters.CurrencyName.ShortName <> "HUF" Then ' Dim _ModelListView As IModelListView ' _ModelListView = TryCast(View.Model.Application.Views.Item(View.Id), IModelListView) ' _ModelListView.Columns.Item("ListPriceDEV").Index = -1 ' _ModelListView.Columns.Item("DiscountPriceDEV").Index = -1 ' _ModelListView.Columns.Item("FinalPriceDEV").Index = -1 ' End If 'End If End If If View.Id = "OrderInHeader_ListView" Then Frame.GetController(Of DeleteObjectsViewController)()?.Active.SetItemValue("", False) Frame.GetController(Of CloneObjectViewController)()?.Active.SetItemValue("", False) Frame.GetController(Of OrderInVC)().aStornoOrderIn.Active.SetItemValue("", True) Frame.GetController(Of OrderInVC)().aBackToEdit_OrderInHeader.Active.SetItemValue("", True) End If If View.Id = "OrderInHeader_ListView_Editable" Then AddHandler Frame.GetController(Of DeleteObjectsViewController).DeleteAction.Executing, AddressOf OrderInHeader_ListView_Editable_DeleteAction_Executing End If If View.Id = "OrderInRows_StorageComputed_Collection_ListView" Then Frame.GetController(Of ListViewProcessCurrentObjectController)()?.Active.SetItemValue("", False) End If If View.Id = "OrderInHeader_OrderInHeaderVAT_ListView" Then Frame.GetController(Of DeleteObjectsViewController)()?.Active.SetItemValue("", False) Frame.GetController(Of LinkUnlinkController)()?.Active.SetItemValue("", False) Frame.GetController(Of NewObjectViewController)()?.Active.SetItemValue("", False) Frame.GetController(Of CloneObject.CloneObjectViewController)?.Active.SetItemValue("", False) Frame.GetController(Of ListViewProcessCurrentObjectController)?.Active.SetItemValue("", False) End If If View.Id = "OrderInHeader_OrderInTo_ListView" Then Frame.GetController(Of DeleteObjectsViewController)()?.Active.SetItemValue("", False) Frame.GetController(Of LinkUnlinkController)()?.Active.SetItemValue("", False) Frame.GetController(Of NewObjectViewController)()?.Active.SetItemValue("", False) Frame.GetController(Of CloneObjectViewController)()?.Active.SetItemValue("", False) End If If View.Id = "OrderInHeader_OrderInRows_ListView" Then Frame.GetController(Of OrderInVC).aOrderIn_ChangeRows.Active.SetItemValue("", True) AddHandler View.SelectionChanged, AddressOf OrderInHeader_OrderInRows_ListView_SelectionChanged 'AddHandler Frame.GetController(Of DialogController)().PropertyChangedEventArgs, AddressOf OrderInHeader_OrderInRows_ListView_PropertyChangedEventArgs End If If View.Id = "OrderInHeader_OrderInRowsOther_ListView" Then Frame.GetController(Of OrderInVC).aOrderInOther_ChangeRows.Active.SetItemValue("", True) AddHandler View.SelectionChanged, AddressOf OrderInHeader_OrderInRowsOther_ListView_SelectionChanged End If If View.Id = "OrderInRowsOther_ListView" Then AddHandler View.SelectionChanged, AddressOf OrderInHeader_OrderInRowsOther_ListView_SelectionChanged End If If View.Id = "OrderInRows_StorageOutRowsInRows_Collection_ListView" Then 'Frame.GetController(Of DeleteObjectsViewController)()?.Active.SetItemValue("", False) Frame.GetController(Of LinkUnlinkController)()?.Active.SetItemValue("", False) Frame.GetController(Of NewObjectViewController)()?.Active.SetItemValue("", False) Frame.GetController(Of CloneObjectViewController)()?.Active.SetItemValue("", False) End If '--------- DETAILVIEWS ------------------------------------------------------------------------------------------------------------------------------- If View.Id = "OrderInHeader_DetailView" Then '---Véglegesíteni és Sztornózni csak a megfelelõ elemeket lehessen Frame.GetController(Of OrderInVC)().aRecalculateOrder.Active.SetItemValue("", True) Frame.GetController(Of OrderInVC)().aToTable_OrderIn.Active.SetItemValue("", True) Frame.GetController(Of OrderInVC)().aToTableD_OrderIn.Active.SetItemValue("", True) Frame.GetController(Of OrderInVC)().aGenerateStorageOutFromOrderIn.Active.SetItemValue("", True) Frame.GetController(Of OrderInVC).aGenerateStorageOutFromOrderInFIFO.Active.SetItemValue("", True) Frame.GetController(Of OrderInVC)().aStornoOrderIn.Active.SetItemValue("", False) Frame.GetController(Of CloneObjectViewController)()?.Active.SetItemValue("", False) Frame.GetController(Of OrderInVC).aProductFinder.Active.SetItemValue("", True) If View.SelectedObjects.Count <> 0 Then Dim _OrderInHeader As OrderInHeader = TryCast(View.SelectedObjects(0), OrderInHeader) If _OrderInHeader.IsEditable = True And _OrderInHeader.IsStorno = False Then Frame.GetController(Of OrderInVC)().aFinalizeOrderIn.Active.SetItemValue("", True) Frame.GetController(Of OrderInVC)().aStornoOrderIn.Active.SetItemValue("", False) End If If _OrderInHeader.IsEditable = False Then Frame.GetController(Of DeleteObjectsViewController)()?.Active.SetItemValue("", False) Frame.GetController(Of OrderInVC)().aFinalizeOrderIn.Active.SetItemValue("", False) Frame.GetController(Of ModificationsController)().SaveAction.Active.SetItemValue("", False) Frame.GetController(Of ModificationsController)().SaveAndCloseAction.Active.SetItemValue("", False) Frame.GetController(Of ModificationsController)().SaveAndNewAction.Active.SetItemValue("", False) End If End If End If If View.Id = "ORI_Invoice_Popup_DetailView" Then AddHandler Frame.GetController(Of DialogController)().AcceptAction.Executing, AddressOf AcceptAction_Executing End If If View.Id = "StorageOutFromOrderInFIFO_PopUp_DetailView" Then AddHandler Frame.GetController(Of DevExpress.ExpressApp.SystemModule.DialogController)().AcceptAction.Executing, AddressOf StorageOutFromOrderInFIFO_PopUp_DetailView_AcceptActionExecuting End If If View.Id = "ORI_Invoice_Popup_DetailView" Then AddHandler Frame.GetController(Of DevExpress.ExpressApp.SystemModule.DialogController)().AcceptAction.Executing, AddressOf ORI_Invoice_Popup_DetailView_AcceptActionExecuting End If If View.Id = "OrderInHeader_ListView_Deleted" Then If TryCast(View, ListView) IsNot Nothing Then If TryCast(View, ListView).CollectionSource IsNot Nothing Then If TryCast(View, ListView).CollectionSource.Collection IsNot Nothing Then If TryCast(TryCast(View, ListView).CollectionSource.Collection, ProxyCollection) IsNot Nothing Then If TryCast(TryCast(View, ListView).CollectionSource.Collection, ProxyCollection).OriginalCollection IsNot Nothing Then If TryCast(TryCast(TryCast(View, ListView).CollectionSource.Collection, ProxyCollection).OriginalCollection, XPCollection) IsNot Nothing Then TryCast(TryCast(TryCast(View, ListView).CollectionSource.Collection, ProxyCollection).OriginalCollection, XPCollection).SelectDeleted = True End If End If End If End If End If End If End If End Sub Protected Overrides Sub OnDeactivated() MyBase.OnDeactivated() If View.Id = "OrderInHeader_OrderInRows_ListView" Then '--- Bejövõ megrendelések sorai Frame.GetController(Of DeleteObjectsViewController)()?.Active.SetItemValue("", True) Frame.GetController(Of LinkUnlinkController)()?.Active.SetItemValue("", True) Frame.GetController(Of NewObjectViewController)()?.Active.SetItemValue("", True) Frame.GetController(Of CloneObjectViewController)()?.Active.SetItemValue("", True) Dim nv As ListView = CType(View, ListView) Dim cs As PropertyCollectionSource = CType(nv.CollectionSource, PropertyCollectionSource) RemoveHandler cs.MasterObjectChanged, AddressOf cs_MasterObjectChanged End If If View.Id = "OrderInRows_StorageComputed_Collection_ListView" Then Frame.GetController(Of ListViewProcessCurrentObjectController)()?.Active.SetItemValue("", True) End If If View.Id = "ORI_Invoice_Popup_DetailView" Then RemoveHandler Frame.GetController(Of DialogController)().AcceptAction.Executing, AddressOf AcceptAction_Executing End If If View.Id = "OrderInHeader_OrderInHeaderVAT_ListView" Then Frame.GetController(Of DeleteObjectsViewController)()?.Active.SetItemValue("", True) Frame.GetController(Of LinkUnlinkController)()?.Active.SetItemValue("", True) Frame.GetController(Of NewObjectViewController)()?.Active.SetItemValue("", True) End If If View.Id = "OrderInHeader_OrderInTo_ListView" Then Frame.GetController(Of DeleteObjectsViewController)()?.Active.SetItemValue("", True) Frame.GetController(Of LinkUnlinkController)()?.Active.SetItemValue("", True) Frame.GetController(Of NewObjectViewController)()?.Active.SetItemValue("", True) End If If View.Id = "OrderInHeader_ListView" Then Frame.GetController(Of DeleteObjectsViewController)()?.Active.SetItemValue("", True) Frame.GetController(Of CloneObjectViewController)()?.Active.SetItemValue("", True) Frame.GetController(Of OrderInVC)().aStornoOrderIn.Active.SetItemValue("", False) Frame.GetController(Of OrderInVC)().aBackToEdit_OrderInHeader.Active.SetItemValue("", False) End If If View.Id = "OrderInHeader_ListView_Editable" Then RemoveHandler Frame.GetController(Of DeleteObjectsViewController).DeleteAction.Executing, AddressOf OrderInHeader_ListView_Editable_DeleteAction_Executing End If '--------- DETAILVIEWS ------------------------------------------------------------------------------------------------------------------------------- If View.Id = "OrderInHeader_DetailView" Then '---Véglegesíteni és Sztornózni csak a megfelelõ elemeket lehessen Frame.GetController(Of OrderInVC)().aRecalculateOrder.Active.SetItemValue("", False) Frame.GetController(Of OrderInVC)().aToTable_OrderIn.Active.SetItemValue("", False) Frame.GetController(Of OrderInVC)().aToTableD_OrderIn.Active.SetItemValue("", False) Frame.GetController(Of OrderInVC).aGenerateStorageOutFromOrderInFIFO.Active.SetItemValue("", False) Frame.GetController(Of CloneObjectViewController)()?.Active.SetItemValue("", True) If View.SelectedObjects.Count <> 0 Then Dim _OrderInHeader As OrderInHeader = TryCast(View.SelectedObjects(0), OrderInHeader) If _OrderInHeader.IsEditable = True And _OrderInHeader.IsStorno = False Then Frame.GetController(Of OrderInVC)().aFinalizeOrderIn.Active.SetItemValue("", False) Frame.GetController(Of OrderInVC)().aStornoOrderIn.Active.SetItemValue("", False) End If If _OrderInHeader.IsEditable = False Then Frame.GetController(Of DeleteObjectsViewController)()?.Active.SetItemValue("", True) If _OrderInHeader.IsEditable = False Then Frame.GetController(Of DeleteObjectsViewController)()?.Active.SetItemValue("", False) Frame.GetController(Of OrderInVC)().aFinalizeOrderIn.Active.SetItemValue("", True) Frame.GetController(Of ModificationsController)().SaveAction.Active.SetItemValue("", True) Frame.GetController(Of ModificationsController)().SaveAndCloseAction.Active.SetItemValue("", True) Frame.GetController(Of ModificationsController)().SaveAndNewAction.Active.SetItemValue("", True) End If End If If _OrderInHeader.IsStorno = False AndAlso _OrderInHeader.IsEditable = False Then Frame.GetController(Of OrderInVC)().aStornoOrderIn.Active.SetItemValue("", True) End If If _OrderInHeader.DocumentNumber IsNot Nothing And _OrderInHeader.IsEditable = False Then Frame.GetController(Of OrderInVC)().aGenerateStorageOutFromOrderIn.Active.SetItemValue("", False) End If End If End If End Sub Protected Overrides Sub OnViewControlsCreated() MyBase.OnViewControlsCreated() End Sub #End Region Private Sub AcceptAction_Executing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Validator.RuleSet.ValidateAll(View.ObjectSpace, View.SelectedObjects, DefaultContexts.Save) End Sub Private Sub cs_MasterObjectChanged(ByVal sender As Object, ByVal e As EventArgs) Dim _OrderInHeader As OrderInHeader = TryCast((CType(sender, PropertyCollectionSource)).MasterObject, OrderInHeader) If _OrderInHeader Is Nothing Then Exit Sub If _OrderInHeader.DocumentNumber IsNot Nothing And _OrderInHeader.IsEditable = False Then Frame.GetController(Of OrderInVC)().aGenerateStorageOutFromOrderIn.Active.SetItemValue("", True) End If End Sub Private Sub aFinalizeOrderIn_Execute(sender As System.Object, e As DevExpress.ExpressApp.Actions.SimpleActionExecuteEventArgs) Handles aFinalizeOrderIn.Execute '---Az akció véglegesít egy bejövő megrendelést------------------------------------------------ Dim _ocur As Xpo.XPObjectSpace = TryCast(View.ObjectSpace, Xpo.XPObjectSpace) Dim _OrderInHeader As OrderInHeader = TryCast(View.SelectedObjects(0), OrderInHeader) _OrderInHeader.IsEditable = False _ocur.CommitChanges() If Frame.GetController(Of RefreshController).RefreshAction.Enabled Then Frame.GetController(Of RefreshController).RefreshAction.DoExecute() End If End Sub Private Sub aStornoOrderIn_Execute(sender As System.Object, e As DevExpress.ExpressApp.Actions.SimpleActionExecuteEventArgs) Handles aStornoOrderIn.Execute '---Az akció sztornóz egy véglegesített bejövő megrendelést---------------------------------------- Dim _ocur As Xpo.XPObjectSpace = TryCast(View.ObjectSpace, Xpo.XPObjectSpace) Dim _OrderInHeader As OrderInHeader = TryCast(View.SelectedObjects(0), OrderInHeader) Dim _OrderInRows As OrderInRows Dim _False As Boolean = False '--Ellenőrzés, hogy létezik-e olyan véglegesített kitárolási sor amelynek rendelési sora ehhez a fejléchez tartozik Dim _FinalizedStorageOutRowsFromOrder As StorageOutRows = TryCast(View.ObjectSpace, Xpo.XPObjectSpace).FindObject(Of StorageOutRows)(CriteriaOperator.Parse("OrderInRows.OrderInHeader=? And StorageOutHeader.IsEditable=?", _OrderInHeader, _False)) If _FinalizedStorageOutRowsFromOrder Is Nothing Then For Each _OrderInRows In _OrderInHeader.OrderInRows Dim _StorageOutRowsCollection As XPCollection = New XPCollection(_ocur.Session, GetType(StorageOutRows), CriteriaOperator.Parse("OrderInRows=?", _OrderInRows)) If _StorageOutRowsCollection.Count > 0 Then '-- Nem véglegesístet kitárolási sorok elviekben töröltehõek _ocur.Session.Delete(_StorageOutRowsCollection) End If Next Else '--Teszt Exception dobás ha létezik olyan sora a rendelésnek ami egy lezárt kitároslási sorhoz tartozik Throw New Exception("*Nem stornózható! A rendeléshez már tartozik véglegesített kitárolás!") End If _OrderInHeader.IsStorno = True _OrderInHeader.Save() _ocur.CommitChanges() End Sub Private Sub aUp_OrderIn_Execute(sender As System.Object, e As DevExpress.ExpressApp.Actions.SimpleActionExecuteEventArgs) Handles aUp_OrderIn.Execute ' A kiválaszott sort egy sorral feljebb helyezi Dim _ocur As Xpo.XPObjectSpace = TryCast(View.ObjectSpace, Xpo.XPObjectSpace) Dim _OrderInHeader As OrderInHeader Dim _OrderInRowsSelected As OrderInRows Dim _OrderInRowsMinus As OrderInRows Dim _OrderInrows As OrderInRows Try _OrderInRowsSelected = TryCast(View.SelectedObjects(0), OrderInRows) ' Kiveszi a kijelölt sorok közül az elsőt _OrderInHeader = _OrderInRowsSelected.OrderInHeader Catch ' TESZT MIATT!!!! ---------------------------------------------------------------- Throw New Exception("*Nincs sor kiválasztva, vagy nem a sor kijelölése az aktív!") End Try If _OrderInRowsSelected.RowIndex > 0 Then For Each _OrderInrows In _OrderInHeader.OrderInRows If _OrderInrows.RowIndex = _OrderInRowsSelected.RowIndex - 1 Then _OrderInRowsMinus = _OrderInrows Exit For End If Next If _OrderInRowsMinus IsNot Nothing Then _OrderInRowsSelected.RowIndex -= 1 _OrderInRowsMinus.RowIndex += 1 End If _OrderInRowsMinus.Save() _OrderInRowsSelected.Save() _ocur.CommitChanges() View.Refresh() End If End Sub Private Sub aDown_OrderIn_Execute(sender As System.Object, e As DevExpress.ExpressApp.Actions.SimpleActionExecuteEventArgs) Handles aDown_OrderIn.Execute ' A kiválaszott sort egy sorral lejebb helyezi Dim _ocur As Xpo.XPObjectSpace = TryCast(View.ObjectSpace, Xpo.XPObjectSpace) Dim _OrderInHeader As OrderInHeader Dim _OrderInRowsSelected As OrderInRows Dim _OrderInRowsPlus As OrderInRows Dim _OrderInrows As OrderInRows Try _OrderInRowsSelected = TryCast(View.SelectedObjects(0), OrderInRows) ' Kiveszi a kijelölt sorok közül az elsőt _OrderInHeader = _OrderInRowsSelected.OrderInHeader Catch ' TESZT MIATT!!!! ---------------------------------------------------------------- Throw New Exception("*Nincs sor kiválasztva, vagy nem a sor kijelölése az aktív!") End Try If _OrderInRowsSelected.RowIndex < _OrderInHeader.OrderInRows.Count - 1 Then For Each _OrderInrows In _OrderInHeader.OrderInRows If _OrderInrows.RowIndex = _OrderInRowsSelected.RowIndex + 1 Then _OrderInRowsPlus = _OrderInrows Exit For End If Next If _OrderInRowsPlus IsNot Nothing Then _OrderInRowsSelected.RowIndex += 1 _OrderInRowsPlus.RowIndex -= 1 End If _OrderInRowsPlus.Save() _OrderInRowsSelected.Save() _ocur.CommitChanges() View.Refresh() End If End Sub Private Sub aGenerateStorageOutFromOrder_CustomizePopupWindowParams(ByVal sender As System.Object, ByVal e As DevExpress.ExpressApp.Actions.CustomizePopupWindowParamsEventArgs) Handles aGenerateStorageOutFromOrderIn.CustomizePopupWindowParams '---Létrehoz egy ListView-t ahol a raktárat kell kiválasztani a rendelésből kitárolási akcióhoz Dim _ocur As Xpo.XPObjectSpace = TryCast(View.ObjectSpace, Xpo.XPObjectSpace) Dim _onew As Xpo.XPObjectSpace = Application.CreateObjectSpace Dim _OrderInRows_ListEditor As ListPropertyEditor = TryCast(View, DetailView).FindItem("OrderInRows") Dim _OrderInRows As OrderInRows Try _OrderInRows = _OrderInRows_ListEditor.ListView.SelectedObjects(0) Catch ' --------------- TESZT MIATT ------------------------ Throw New Exception("*Legalább egy sort ki kell választani!") End Try Dim Keys As New Collection Dim _In_StorageComputed As New XPCollection(Of StorageComputed)(_onew.Session, CriteriaOperator.Parse("Products=? AND QTTFree>0 AND Storage.CustomersFrom.Oid=?", _onew.GetObject(_OrderInRows.Products), _OrderInRows.OrderInHeader.CustomersFrom.Oid)) Dim _StorageComputed As StorageComputed Keys.Clear() For Each _StorageComputed In _In_StorageComputed Keys.Add(_StorageComputed.Storage.Oid) Next Dim _InOperator As InOperator = New InOperator("Oid", Keys) Dim _CollectionSource As CollectionSource = New CollectionSource(_onew, GetType(Storage)) _CollectionSource.BeginUpdateCriteria() _CollectionSource.Criteria("1") = _InOperator _CollectionSource.EndUpdateCriteria() e.View = Application.CreateListView("Storage_ListView_OrderIn", _CollectionSource, True) End Sub Private Sub aReCalculatePricing_OrderInRows_Execute(sender As System.Object, e As DevExpress.ExpressApp.Actions.SimpleActionExecuteEventArgs) Handles aReCalculatePricing_OrderInRows.Execute ' Vizsgáljuk. hogy van e árkalkulációja az ügyfélnek, ha van kalkulálunk Dim _OrderInHeader As OrderInHeader = TryCast(View.SelectedObjects(0), OrderInRows).OrderInHeader Dim _OrderInRows As OrderInRows If _OrderInHeader.Customers.Pricing IsNot Nothing Then For Each _OrderInRows In _OrderInHeader.OrderInRows If _OrderInHeader.OrderInParameters.CurrencyName.ShortName = "HUF" Then ' Ha a Deviza HUF _OrderInRows.ListPriceHUF = _OrderInHeader.Customers.Pricing.GetCurrentPriceNettoHUF(_OrderInRows.Products, _OrderInRows.QTT) ' A kedvezményt tartalmazó listaár HUF-ban _OrderInRows.DiscountPriceHUF = 0 '_OrderInRows.Products.ListPriceOutHUF - _OrderInRows.ListPriceHUF ' A kedvezmény összege HUF-ban Else ' Ha a deviza nem HUF _OrderInRows.ListPriceDEV = _OrderInHeader.Customers.Pricing.GetCurrentPriceNettoDEV(_OrderInRows.Products, _OrderInRows.QTT) ' A kedvezményt tartalmazó listaár DEV-ben _OrderInRows.DiscountPriceDEV = 0 '_OrderInRows.Products.ListPriceOutDEV - _OrderInRows.ListPriceDEV ' A kedvezmény összege DEV-ben End If _OrderInRows.Save() Next View.Refresh() End If End Sub Private Sub aRecalculateOrder_Execute(sender As System.Object, e As DevExpress.ExpressApp.Actions.SimpleActionExecuteEventArgs) Handles aRecalculateOrder.Execute Dim _OrderInHeader As OrderInHeader = TryCast(View.SelectedObjects(0), OrderInHeader) Dim _ocur As Xpo.XPObjectSpace = TryCast(View.ObjectSpace, Xpo.XPObjectSpace) _OrderInHeader.RecalculateOrder(_OrderInHeader, _ocur) _ocur.CommitChanges() End Sub Private Sub aGenerateOrderOutTempFromOrderIn_Execute(sender As System.Object, e As DevExpress.ExpressApp.Actions.SimpleActionExecuteEventArgs) Handles aGenerateOrderOutTempFromOrderIn.Execute '// Az eljárás továbbrendeli a kiválasztott tételt Dim _ocur As Xpo.XPObjectSpace = TryCast(View.ObjectSpace, Xpo.XPObjectSpace) Dim _OrderInHeader As OrderInHeader = TryCast(View.SelectedObjects(0), OrderInHeader) Dim _ListPropertyEditor As ListPropertyEditor = TryCast(View, DetailView).FindItem("OrderInRows") Dim _OrderInRows As OrderInRows Dim _OrderInTo As OrderInTo Dim _OrderInTo_Collection As XPCollection(Of OrderInTo) Dim _QTT_To As Double = 0 For i = 0 To _ListPropertyEditor.ListView.SelectedObjects.Count - 1 _OrderInRows = TryCast(_ListPropertyEditor.ListView.SelectedObjects(i), OrderInRows) If _OrderInRows.QTT_Process <> 0 Then _OrderInTo = _ocur.FindObject(Of OrderInTo)(CriteriaOperator.Parse("OrderInRows=? and OrderOutRows is NULL", _OrderInRows), True) If _OrderInTo Is Nothing Then _OrderInTo = _ocur.CreateObject(Of OrderInTo)() _OrderInTo.QTT_To = _OrderInRows.QTT_Process _OrderInTo.OrderInRows = _OrderInRows Else _OrderInTo.QTT_To += _OrderInRows.QTT_Process End If _ocur.CommitChanges() _OrderInTo_Collection = New XPCollection(Of OrderInTo)(_ocur.Session, CriteriaOperator.Parse("OrderInRows=?", _OrderInRows)) _QTT_To = 0 For Each _OrderInTo In _OrderInTo_Collection _QTT_To += _OrderInTo.QTT_To Next _OrderInRows.QTT_To = _QTT_To End If Next i _ocur.CommitChanges() End Sub Private Sub aGenerateStorageOutFromOrderInFIFO_CustomizePopupWindowParams(sender As System.Object, e As DevExpress.ExpressApp.Actions.CustomizePopupWindowParamsEventArgs) Handles aGenerateStorageOutFromOrderInFIFO.CustomizePopupWindowParams Try Dim _onew As Xpo.XPObjectSpace = Application.CreateObjectSpace Dim _OrderInHeader_ListEditor As ListPropertyEditor = TryCast(View, DetailView).FindItem("OrderInRows") Dim _OrderInRows As OrderInRows = TryCast(_OrderInHeader_ListEditor.ListView.SelectedObjects(0), OrderInRows) If _OrderInRows Is Nothing Then Throw New Exception("*Nincs kiválsztva egy sor sem a bejövő megrendelésen!") Dim _StorageOutFromOrderInFIFO_PopUp As StorageOutFromOrderInFIFO_PopUp = _onew.CreateObject(Of StorageOutFromOrderInFIFO_PopUp)() _StorageOutFromOrderInFIFO_PopUp.Products = _onew.GetObject(_OrderInRows.Products) _StorageOutFromOrderInFIFO_PopUp.QTT_Full = _OrderInRows.QTT e.View = Application.CreateDetailView(_onew, "StorageOutFromOrderInFIFO_PopUp_DetailView", True, _StorageOutFromOrderInFIFO_PopUp) Catch ex As Exception MsgBox(ex.Message, MsgBoxStyle.OkOnly + MsgBoxStyle.Critical, String.Format(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions", "MsgBoxCheckItAgain"))) End Try End Sub Private Sub aGenerateStorageOutFromOrderInFIFO_Execute(sender As System.Object, e As DevExpress.ExpressApp.Actions.PopupWindowShowActionExecuteEventArgs) Handles aGenerateStorageOutFromOrderInFIFO.Execute Try If e.PopupWindow.View.SelectedObjects.Count = 0 Then _ Throw New Exception("*Nincs kiválsztva egy betárolási bizonylati sor sem!") Dim _ocur As Xpo.XPObjectSpace = View.ObjectSpace Dim _OrderInHeader As OrderInHeader = TryCast(View.SelectedObjects(0), OrderInHeader) Dim _OrderInHeader_ListEditor As ListPropertyEditor = TryCast(View, DetailView).FindItem("OrderInRows") Dim _OrderInRows As OrderInRows = TryCast(_OrderInHeader_ListEditor.ListView.SelectedObjects(0), OrderInRows) Dim _onew As Xpo.XPObjectSpace = e.PopupWindow.View.ObjectSpace Dim _StorageOutFromOrderInFIFO_PopUp As StorageOutFromOrderInFIFO_PopUp = TryCast(e.PopupWindow.View.SelectedObjects(0), StorageOutFromOrderInFIFO_PopUp) Dim _StorageInRows_ListEditor As ListPropertyEditor = TryCast(e.PopupWindow.View, DetailView).FindItem("StorageInRows") For Each _StorageInRows_PopUp As StorageInRows In _StorageInRows_ListEditor.ListView.CollectionSource.Collection If _StorageInRows_PopUp.QTT_Will > _OrderInRows.QTT Then _ Throw New Exception(String.Format("A {0} termék esetében a rendelet mennyiség {1} volt, így ennél többet nem lehet kitárolni!", _OrderInRows.Products.ShortName, _OrderInRows.QTT) + vbNewLine + String.Format("A kitárolásszándék: {0}", _StorageInRows_PopUp.QTT_Will) + vbNewLine + String.Format("Maximálisan kitárolható: {0}", _OrderInRows.QTT)) Next Dim _StorageOutHeader As StorageOutHeader = _ocur.FindObject(Of StorageOutHeader)(CriteriaOperator.Parse("Customers=? AND CustomersFrom=? AND StorageMoveType=? AND IsEditable=?", _OrderInHeader.Customers, _OrderInHeader.CustomersFrom, _OrderInHeader.OrderInParameters.StorageMoveType, True)) If _StorageOutHeader Is Nothing Then _StorageOutHeader = _ocur.CreateObject(Of StorageOutHeader)() _StorageOutHeader.Customers = _OrderInHeader.Customers _StorageOutHeader.CustomersFrom = _OrderInHeader.CustomersFrom _StorageOutHeader.StorageMoveType = _OrderInHeader.OrderInParameters.StorageMoveType End If For Each _StorageInRows_PopUp As StorageInRows In _StorageInRows_ListEditor.ListView.CollectionSource.Collection If _StorageOutHeader.Storage Is Nothing Then _StorageOutHeader.Storage = _ocur.GetObjectByKey(Of Storage)(_StorageInRows_PopUp.StorageInHeader.Storage.Oid) End If Dim _StorageOutRows As StorageOutRows = _ocur.FindObject(Of StorageOutRows) _ (CriteriaOperator.Parse("OrderInRows=? and StorageOutHeader.IsEditable=True and StorageOutHeader.IsStorno=False and Products=?", _OrderInRows, _OrderInRows.Products), True) If _StorageInRows_PopUp.QTT_Will > 0 Then Dim _StorageOutRowsInRows As StorageOutRowsInRows = _ocur.CreateObject(Of StorageOutRowsInRows)() Dim _StorageComputed As StorageComputed = _ocur.FindObject(Of StorageComputed)(CriteriaOperator.Parse("Products=? and Storage=?", _ocur.GetObjectByKey(Of Products)(_StorageInRows_PopUp.Products.Oid), _ocur.GetObjectByKey(Of Storage)(_StorageInRows_PopUp.StorageInHeader.Storage.Oid))) _StorageComputed.QTTFree -= _StorageInRows_PopUp.QTT_Will _StorageComputed.QTTReservedOut += _StorageInRows_PopUp.QTT_Will If _StorageOutRows Is Nothing Then _StorageOutRows = _ocur.CreateObject(Of StorageOutRows)() _StorageOutRows.StorageOutHeader = _StorageOutHeader _StorageOutRows.RowIndex = _StorageOutHeader.StorageOutRows.Count _StorageOutRows.StorageComputed = _StorageComputed _StorageOutRows.OrderInRows = _OrderInRows _StorageOutRows.QTT = _StorageInRows_PopUp.QTT_Will _StorageOutRows.Products = _ocur.GetObject(_StorageInRows_PopUp.Products) Else _StorageOutRows.QTT += _StorageInRows_PopUp.QTT_Will End If _StorageOutRowsInRows.QTT = _StorageInRows_PopUp.QTT_Will _StorageOutRowsInRows.StorageInRows = _ocur.GetObjectByKey(Of StorageInRows)(_StorageInRows_PopUp.Oid) _StorageOutRowsInRows.StorageOutRows = _StorageOutRows _StorageOutRowsInRows.RowIndex = 0 'Itt irreleváns, majd később lehet állítani _OrderInRows.QTT_Storaged_Will += _StorageInRows_PopUp.QTT_Will _OrderInRows.QTT_Process -= _StorageInRows_PopUp.QTT_Will _StorageInRows_PopUp.QTT_Out_Will += _StorageInRows_PopUp.QTT_Will _StorageInRows_PopUp.QTT_Will = 0 Else MsgBox(String.Format("A {0} termék sorában a szándék mező nulla volt!", _StorageInRows_PopUp.Products.ShortName), MsgBoxStyle.OkOnly, "Figyelem!") End If Next _ocur.CommitChanges() Catch ex As Exception MsgBox(ex.Message, MsgBoxStyle.OkOnly + MsgBoxStyle.Critical, String.Format(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions", "MsgBoxCheckItAgain"))) End Try End Sub Private Sub aGenerateStorageOutFromOrderIn_Execute(sender As System.Object, e As DevExpress.ExpressApp.Actions.PopupWindowShowActionExecuteEventArgs) Handles aGenerateStorageOutFromOrderIn.Execute Dim _ocur_original As Xpo.XPObjectSpace = TryCast(View.ObjectSpace, Xpo.XPObjectSpace) Dim _onew As Xpo.XPObjectSpace = Application.CreateObjectSpace Dim _uow_lock As New UnitOfWork(_onew.Session.DataLayer) Dim _User As DevExpress.Persistent.BaseImpl.User = _onew.GetObject(Of DevExpress.Persistent.BaseImpl.User)(TryCast(SecuritySystem.CurrentUser, DevExpress.Persistent.BaseImpl.User)) Dim _OrderInHeader As OrderInHeader = _onew.GetObjectByKey(Of OrderInHeader)(TryCast(View.SelectedObjects(0), OrderInHeader).Oid) Dim _OrderInRows As OrderInRows Dim _OrderInRows_Exists As OrderInRows Dim _OrderInRows_Collection As XPCollection(Of OrderInRows) Dim _StorageInRows As StorageInRows Dim _StorageInRows_Collection As XPCollection(Of StorageInRows) Dim _StorageOutRows As StorageOutRows Dim _StorageOutRows_Collection As XPCollection(Of StorageOutRows) = Nothing Dim _StorageOutRows_R As StorageOutRows Dim _StorageOutRows_Collection_R As XPCollection(Of StorageOutRows) Dim _StorageOutRows_Exists As StorageOutRows Dim _StorageOutHeader As StorageOutHeader = Nothing Dim _Storage As Storage = _onew.GetObjectByKey(Of Storage)(TryCast(e.PopupWindow.View.SelectedObjects(0), Storage).Oid) Dim _QTT_Mod As Double = 0 Dim _QTT_Free As Double = 0 Dim _StorageOutRowsInRows As StorageOutRowsInRows Dim _ExistsStorageOutHeader As Boolean = False Dim _StorageComputed As StorageComputed Dim _QTT_ReservedOut As Double = 0 Dim _QTT_Will_Out As Double = 0 If _Storage Is Nothing Then Exit Sub 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 For Each _OrderInRows In _OrderInHeader.OrderInRows If _OrderInRows.QTT_Process > 0 Then _StorageComputed = _onew.FindObject(Of StorageComputed)(CriteriaOperator.Parse("Storage=? and Products=?", _Storage, _OrderInRows.Products), True) If _StorageComputed IsNot Nothing Then If _StorageComputed.QTTFree >= _OrderInRows.QTT_Process Then _StorageInRows_Collection = New XPCollection(Of StorageInRows)(PersistentCriteriaEvaluationBehavior.InTransaction, _onew.Session, CriteriaOperator.Parse("StorageInHeader.Storage=? and StorageInHeader.IsEditable=False and StorageInHeader.IsStorno=False and Products=?", _Storage, _OrderInRows.Products)) _StorageInRows_Collection.Sorting.Add(New SortProperty("StorageInHeader.CreateDate", DB.SortingDirection.Ascending)) _StorageOutRows = _onew.FindObject(Of StorageOutRows) _ (CriteriaOperator.Parse("OrderInRows=? and StorageOutHeader.IsEditable=True and StorageOutHeader.IsStorno=False and Products=?", _OrderInRows, _OrderInRows.Products), True) If _StorageOutRows Is Nothing Then '--- Új kitárolási sor !!!! _StorageOutRows = _onew.CreateObject(Of StorageOutRows)() _StorageOutRows.OrderInRows = _OrderInRows _StorageOutRows.Products = _OrderInRows.Products _OrderInRows_Collection = New XPCollection(Of OrderInRows)(PersistentCriteriaEvaluationBehavior.InTransaction, _onew.Session, CriteriaOperator.Parse("OrderInHeader.Oid=?", _OrderInRows.OrderInHeader.Oid)) For Each _OrderInRows_Exists In _OrderInRows_Collection _StorageOutRows_Exists = _onew.FindObject(Of StorageOutRows) _ (CriteriaOperator.Parse("OrderInRows=? and StorageOutHeader.IsEditable=True and StorageOutHeader.IsStorno=False", _OrderInRows_Exists), True) If _StorageOutRows_Exists IsNot Nothing Then _StorageOutHeader = _StorageOutRows_Exists.StorageOutHeader _ExistsStorageOutHeader = True Exit For End If Next If _ExistsStorageOutHeader = False Then ' Új kitárolási fejléc !!! _StorageOutHeader = _onew.CreateObject(Of StorageOutHeader)() _StorageOutHeader.StorageMoveType = _OrderInRows.OrderInHeader.OrderInParameters.StorageMoveType _StorageOutHeader.Storage = _Storage _StorageOutHeader.CustomersFrom = _Storage.CustomersFrom _StorageOutHeader.Customers = _OrderInRows.OrderInHeader.Customers End If _StorageOutRows.StorageOutHeader = _StorageOutHeader End If '--- FIFO FOGLALÁS ------------------------------------------------------------------------------------------------------------------------------- _QTT_Mod = _OrderInRows.QTT_Process For Each _StorageInRows In _StorageInRows_Collection _QTT_Free = _StorageInRows.QTT - _StorageInRows.QTT_Out - _StorageInRows.QTT_Out_Will If _QTT_Free <= _QTT_Mod Then _StorageInRows.QTT_Out_Will += _QTT_Free _StorageOutRows.QTT_Will += _QTT_Free _QTT_Mod -= _QTT_Free '------- FIFO sor beszúrása _StorageOutRowsInRows = _onew.FindObject(Of StorageOutRowsInRows)(CriteriaOperator.Parse("StorageInRows=? and StorageOutRows=?", _StorageInRows, _StorageOutRows), True) If _StorageOutRowsInRows IsNot Nothing Then _StorageOutRowsInRows.QTT += _QTT_Free Else _StorageOutRowsInRows = _onew.CreateObject(Of StorageOutRowsInRows)() _StorageOutRowsInRows.StorageInRows = _StorageInRows _StorageOutRowsInRows.StorageOutRows = _StorageOutRows _StorageOutRowsInRows.QTT = _QTT_Free End If Else _StorageInRows.QTT_Out_Will += _QTT_Mod _StorageOutRows.QTT_Will += _QTT_Mod '------- FIFO sor beszúrása _StorageOutRowsInRows = _onew.FindObject(Of StorageOutRowsInRows)(CriteriaOperator.Parse("StorageInRows=? and StorageOutRows=?", _StorageInRows, _StorageOutRows), True) If _StorageOutRowsInRows IsNot Nothing Then _StorageOutRowsInRows.QTT += _QTT_Mod Else _StorageOutRowsInRows = _onew.CreateObject(Of StorageOutRowsInRows)() _StorageOutRowsInRows.StorageInRows = _StorageInRows _StorageOutRowsInRows.StorageOutRows = _StorageOutRows _StorageOutRowsInRows.QTT = _QTT_Mod End If Exit For End If Next '-------------------------------------------------------------------------------------------------------------------------------------------------- _OrderInRows.QTT_Storaged_Will += _OrderInRows.QTT_Process _OrderInRows.QTT_Process = 0 '--- StorageComputed újraszámolása _StorageComputed = _onew.FindObject(Of StorageComputed)(CriteriaOperator.Parse("Storage=? and Products=?", _Storage, _OrderInRows.Products), True) _QTT_ReservedOut = _StorageComputed.QTTReservedOut _StorageOutRows_Collection_R = New XPCollection(Of StorageOutRows)(PersistentCriteriaEvaluationBehavior.InTransaction, _onew.Session, CriteriaOperator.Parse("QTT_Will>0 and StorageOutHeader.Storage=? and Products=?", _Storage, _OrderInRows.Products)) For Each _StorageOutRows_R In _StorageOutRows_Collection_R _QTT_Will_Out += _StorageOutRows_R.QTT_Will Next _StorageComputed.QTTFree = _StorageComputed.QTTFree - (_QTT_Will_Out - _QTT_ReservedOut) _StorageComputed.QTTReservedOut += _QTT_Will_Out End If End If End If Next _onew.CommitChanges() Frame.GetController(Of RefreshController).RefreshAction.DoExecute() End If Catch ex As Exception Throw New Exception(ex.Message) Finally LockingModule.UnLockObject(_uow_lock, GetType(StorageComputed), "-", _User) End Try End Sub Private Sub aBackToEdit_OrderInHeader_Execute(sender As System.Object, e As DevExpress.ExpressApp.Actions.SimpleActionExecuteEventArgs) Handles aBackToEdit_OrderInHeader.Execute Dim _ocur As Xpo.XPObjectSpace = TryCast(View.ObjectSpace, Xpo.XPObjectSpace) Dim _OrderInHeader As OrderInHeader = TryCast(View.SelectedObjects(0), OrderInHeader) If _OrderInHeader IsNot Nothing Then _OrderInHeader.IsEditable = True _ocur.CommitChanges() View.Refresh() End If End Sub Private Sub OrderInHeader_ListView_Editable_DeleteAction_Executing(sender As Object, e As CancelEventArgs) ' Throw New NotImplementedException 'nem lehet olyan sora ami ki van tárolva orderinrow or orderinrowother van akkor nem lehet törölni. End Sub Private Sub aProductFinder_CustomizePopupWindowParams(sender As Object, e As DevExpress.ExpressApp.Actions.CustomizePopupWindowParamsEventArgs) Handles aProductFinder.CustomizePopupWindowParams Dim _onew As Xpo.XPObjectSpace = Application.CreateObjectSpace Dim _ProductFinder As ProductFinder = _onew.CreateObject(Of ProductFinder)() _ProductFinder.MasterKey = View.SelectedObjects(0).Oid e.View = Application.CreateDetailView(_onew, "ProductFinder_DetailView", False, _ProductFinder) End Sub Private Sub aProductFinder_Execute(sender As System.Object, e As DevExpress.ExpressApp.Actions.PopupWindowShowActionExecuteEventArgs) Handles aProductFinder.Execute Dim _ocur As Xpo.XPObjectSpace = TryCast(View.ObjectSpace, Xpo.XPObjectSpace) Dim _OrderInHeader As OrderInHeader = TryCast(View.SelectedObjects(0), OrderInHeader) Dim _ProductSelected_Collection As New XPCollection(Of ProductSelected)(_ocur.Session, CriteriaOperator.Parse("MasterKey=?", _OrderInHeader.Oid)) Dim _ProductSelected As ProductSelected If _ProductSelected_Collection.Count <= 0 Then Exit Sub For Each _ProductSelected In _ProductSelected_Collection _OrderInHeader = TryCast(View.SelectedObjects(0), OrderInHeader) _OrderInHeader.row_Products = _ocur.FindObject(Of ProductSelect)(CriteriaOperator.Parse("Products.Oid=?", _ProductSelected.Products.Oid)) _OrderInHeader.row_QTT = _ProductSelected.QTT Frame.GetController(Of OrderInVC).aToTable_OrderIn.DoExecute() Next _ProductSelected_Collection = New XPCollection(Of ProductSelected)(_ocur.Session, CriteriaOperator.Parse("MasterKey=?", _OrderInHeader.Oid)) _ocur.Delete(_ProductSelected_Collection) _ocur.CommitChanges() End Sub Private Sub aOrderIn_ChangeRows_CustomizePopupWindowParams(sender As Object, e As DevExpress.ExpressApp.Actions.CustomizePopupWindowParamsEventArgs) Handles aOrderIn_ChangeRows.CustomizePopupWindowParams _noselect = True Dim _onew As Xpo.XPObjectSpace = Application.CreateObjectSpace Dim _OrderInRows_ChangeGroup As OrderInRows_ChangeGroup = _onew.CreateObject(Of OrderInRows_ChangeGroup)() If View.SelectedObjects.Count > 0 Then Dim _OrderInRows As OrderInRows = TryCast(View.SelectedObjects(0), OrderInRows) _OrderInRows_ChangeGroup.RowGroup1 = _onew.GetObject(_OrderInRows.RowGroup1) _OrderInRows_ChangeGroup.RowGroup2 = _onew.GetObject(_OrderInRows.RowGroup2) _OrderInRows_ChangeGroup.QualityOption = _onew.GetObject(_OrderInRows.QualityOption) _OrderInRows_ChangeGroup.FinalPricePercent = 0 _OrderInRows_ChangeGroup.Description = _onew.GetObject(_OrderInRows.Description) e.View = Application.CreateDetailView(_onew, "OrderInRows_ChangeGroup_DetailView", False, _OrderInRows_ChangeGroup) Else Throw New UserFriendlyException("Nincs kijelölt elem!") End If End Sub Private Sub aOrderIn_ChangeRows_Execute(sender As System.Object, e As DevExpress.ExpressApp.Actions.PopupWindowShowActionExecuteEventArgs) Handles aOrderIn_ChangeRows.Execute Dim _ocur As Xpo.XPObjectSpace = TryCast(View.ObjectSpace, Xpo.XPObjectSpace) Dim _OrderInRows_ChangeGroup As OrderInRows_ChangeGroup = TryCast(e.PopupWindow.View.SelectedObjects(0), OrderInRows_ChangeGroup) Dim _OrderInRows As OrderInRows '= TryCast(View.SelectedObjects(0), OrderInRows) 'If _OrderInRows IsNot Nothing Then If _OrderInRows_ChangeGroup.Change_Description Then For Each _OrderInRows In _selection _OrderInRows.Description = _OrderInRows_ChangeGroup.Description _OrderInRows.Save() Next End If If _OrderInRows_ChangeGroup.Change_FinalPricePercent Then For Each _OrderInRows In _selection '_OrderInRows.FinalPriceHUF = _OrderInRows.FinalPriceHUF - (_OrderInRows.FinalPriceHUF * (_OrderInRows_ChangeGroup.FinalPricePercent / 100)) '_OrderInRows.DiscountPercent = _OrderInRows_ChangeGroup.FinalPricePercent '_OrderInRows.RecalculateRow() '_OrderInRows.CanChangeProperty = False 'If _OrderInRows.OfferOutHeader.CurrencyName.ShortName = "HUF" Then ' _OrderInRows.FinalPriceHUF = _OrderInRows.ListPriceHUF - _OrderInRows.DiscountPriceHUF 'Else ' _OrderInRows.FinalPriceDEV = _OrderInRows.ListPriceDEV - _OrderInRows.FinalPriceDEV 'End If '_OrderInRows.CanChangeProperty = True '_OrderInRows.Save() Next End If If _OrderInRows_ChangeGroup.Change_QualityOption Then For Each _OrderInRows In _selection _OrderInRows.QualityOption = _ocur.GetObjectByKey(Of QualityOption)(_OrderInRows.QualityOption.Oid) _OrderInRows.Save() Next End If If _OrderInRows_ChangeGroup.Change_RowGroup1 Then For Each _OrderInRows In _selection _OrderInRows.RowGroup1 = _OrderInRows_ChangeGroup.RowGroup1 _OrderInRows.Save() Next End If If _OrderInRows_ChangeGroup.Change_RowGroup2 Then For Each _OrderInRows In _selection _OrderInRows.RowGroup2 = _OrderInRows_ChangeGroup.RowGroup2 _OrderInRows.Save() Next End If If _OrderInRows_ChangeGroup.Change_DiscountPercent Then For Each _OrderInRows In _selection _OrderInRows.DiscountPriceHUF = _OrderInRows.ListPriceHUF * (_OrderInRows_ChangeGroup.DiscountPercent / 100) _OrderInRows.DiscountPriceDEV = _OrderInRows.ListPriceDEV * (_OrderInRows_ChangeGroup.DiscountPercent / 100) Next End If _ocur.CommitChanges() _noselect = False End Sub Private Sub OrderInHeader_OrderInRows_ListView_SelectionChanged(sender As Object, e As EventArgs) Dim _OrderInRows As OrderInRows If View Is Nothing Then Exit Sub If View.SelectedObjects.Count > 0 Then _selection.Clear() For Each _OrderInRows In View.SelectedObjects _selection.Add(_OrderInRows) Next End If End Sub Private Sub OrderInHeader_OrderInRowsOther_ListView_SelectionChanged(sender As Object, e As EventArgs) Dim _OrderInRowsOther As OrderInRowsOther If View Is Nothing Then Exit Sub If View.SelectedObjects.Count > 0 Then _selection.Clear() For Each _OrderInRowsOther In View.SelectedObjects _selection.Add(_OrderInRowsOther) Next End If End Sub Private Sub aOrderInOther_ChangeRows_CustomizePopupWindowParams(sender As Object, e As DevExpress.ExpressApp.Actions.CustomizePopupWindowParamsEventArgs) Handles aOrderInOther_ChangeRows.CustomizePopupWindowParams _noselect = True Dim _onew As Xpo.XPObjectSpace = Application.CreateObjectSpace Dim _OrderInRowsOther_ChangeGroup As OrderInRowsOther_ChangeGroup = _onew.CreateObject(Of OrderInRowsOther_ChangeGroup)() If View.SelectedObjects.Count > 0 Then Dim _OrderInRowsOther As OrderInRowsOther = TryCast(View.SelectedObjects(0), OrderInRowsOther) _OrderInRowsOther_ChangeGroup.VAT = _onew.GetObject(_OrderInRowsOther.VAT) _OrderInRowsOther_ChangeGroup.Units = _onew.GetObject(_OrderInRowsOther.Units) _OrderInRowsOther_ChangeGroup.RowGroup1 = _onew.GetObject(_OrderInRowsOther.RowGroup1) _OrderInRowsOther_ChangeGroup.RowGroup2 = _onew.GetObject(_OrderInRowsOther.RowGroup2) _OrderInRowsOther_ChangeGroup.QualityOption = _onew.GetObject(_OrderInRowsOther.QualityOption) _OrderInRowsOther_ChangeGroup.FinalPricePercent = 0 _OrderInRowsOther_ChangeGroup.ShortName = _onew.GetObject(_OrderInRowsOther.ShortName) _OrderInRowsOther_ChangeGroup.Description = _onew.GetObject(_OrderInRowsOther.Description) e.View = Application.CreateDetailView(_onew, "OrderInRowsOther_ChangeGroup_DetailView", False, _OrderInRowsOther_ChangeGroup) Else Throw New UserFriendlyException("Nincs kijelölt elem!") End If End Sub Private Sub aOrderInOther_ChangeRows_Execute(sender As System.Object, e As DevExpress.ExpressApp.Actions.PopupWindowShowActionExecuteEventArgs) Handles aOrderInOther_ChangeRows.Execute Dim _ocur As Xpo.XPObjectSpace = TryCast(View.ObjectSpace, Xpo.XPObjectSpace) Dim _OrderInRowsOther_ChangeGroup As OrderInRowsOther_ChangeGroup = TryCast(e.PopupWindow.View.SelectedObjects(0), OrderInRowsOther_ChangeGroup) Dim _OrderInRowsOther As OrderInRowsOther '= TryCast(View.SelectedObjects(0), OrderInRowsOther) 'If _OrderInRowsOther IsNot Nothing Then If _OrderInRowsOther_ChangeGroup.Change_Description Then For Each _OrderInRowsOther In _selection _OrderInRowsOther.Description = _OrderInRowsOther_ChangeGroup.Description _OrderInRowsOther.Save() Next End If If _OrderInRowsOther_ChangeGroup.Change_FinalPricePercent Then For Each _OrderInRowsOther In _selection '_OrderInRowsOther.FinalPriceHUF = _OrderInRowsOther.FinalPriceHUF - (_OrderInRowsOther.FinalPriceHUF * (_OrderInRowsOther_ChangeGroup.FinalPricePercent / 100)) '_OrderInRowsOther.DiscountPercent = _OrderInRowsOther_ChangeGroup.FinalPricePercent '_OrderInRowsOther.RecalculateRow() '_OrderInRowsOther.CanChangeProperty = False 'If _OrderInRowsOther.OfferOutHeader.CurrencyName.ShortName = "HUF" Then ' _OrderInRowsOther.FinalPriceHUF = _OrderInRowsOther.ListPriceHUF - _OrderInRowsOther.DiscountPriceHUF 'Else ' _OrderInRowsOther.FinalPriceDEV = _OrderInRowsOther.ListPriceDEV - _OrderInRowsOther.FinalPriceDEV 'End If '_OrderInRowsOther.CanChangeProperty = True '_OrderInRowsOther.Save() Next End If If _OrderInRowsOther_ChangeGroup.Change_QualityOption Then For Each _OrderInRowsOther In _selection _OrderInRowsOther.QualityOption = _ocur.GetObjectByKey(Of QualityOption)(_OrderInRowsOther.QualityOption.Oid) _OrderInRowsOther.Save() Next End If If _OrderInRowsOther_ChangeGroup.Change_RowGroup1 Then For Each _OrderInRowsOther In _selection _OrderInRowsOther.RowGroup1 = _OrderInRowsOther_ChangeGroup.RowGroup1 _OrderInRowsOther.Save() Next End If If _OrderInRowsOther_ChangeGroup.Change_RowGroup2 Then For Each _OrderInRowsOther In _selection _OrderInRowsOther.RowGroup2 = _OrderInRowsOther_ChangeGroup.RowGroup2 _OrderInRowsOther.Save() Next End If If _OrderInRowsOther_ChangeGroup.Change_ShortName Then For Each _OrderInRowsOther In _selection _OrderInRowsOther.ShortName = _OrderInRowsOther_ChangeGroup.ShortName _OrderInRowsOther.Save() Next End If If _OrderInRowsOther_ChangeGroup.Change_Units Then For Each _OrderInRowsOther In _selection _OrderInRowsOther.Units = _ocur.GetObjectByKey(Of Units)(_OrderInRowsOther_ChangeGroup.Units.Oid) _OrderInRowsOther.Save() Next End If If _OrderInRowsOther_ChangeGroup.Change_VAT Then For Each _OrderInRowsOther In _selection _OrderInRowsOther.VAT = _ocur.GetObjectByKey(Of VAT)(_OrderInRowsOther_ChangeGroup.VAT.Oid) _OrderInRowsOther.Save() Next End If If _OrderInRowsOther_ChangeGroup.Change_WorkState Then For Each _OrderInRowsOther In _selection _OrderInRowsOther.WorkState = _ocur.GetObjectByKey(Of WorkState)(_OrderInRowsOther_ChangeGroup.WorkState.Oid) _OrderInRowsOther.Save() Next End If If _OrderInRowsOther_ChangeGroup.Change_WorkStateGroup Then For Each _OrderInRowsOther In _selection _OrderInRowsOther.WorkStateGroup = _OrderInRowsOther_ChangeGroup.WorkStateGroup _OrderInRowsOther.Save() Next End If If _OrderInRowsOther_ChangeGroup.Change_WorkStateExpiration Then For Each _OrderInRowsOther In _selection _OrderInRowsOther.WorkStateExpiration = _OrderInRowsOther_ChangeGroup.WorkStateExpiration _OrderInRowsOther.Save() Next End If If _OrderInRowsOther_ChangeGroup.Change_WorkStateStatus Then For Each _OrderInRowsOther In _selection _OrderInRowsOther.WorkStateStatus = _OrderInRowsOther_ChangeGroup.WorkStateStatus _OrderInRowsOther.Save() Next End If 'End If _ocur.CommitChanges() _noselect = False End Sub Private Sub StorageOutFromOrderInFIFO_PopUp_DetailView_AcceptActionExecuting(sender As Object, e As CancelEventArgs) Dim _ActQTT = 0 Dim _StorageOutFromOrderInFIFO_PopUp As StorageOutFromOrderInFIFO_PopUp = View.SelectedObjects(0) For Each _StorageInRows As StorageInRows In _StorageOutFromOrderInFIFO_PopUp.StorageInRows _ActQTT += _StorageInRows.QTT_Will If _StorageInRows.QTT < _StorageInRows.QTT_Will Then Throw New Exception("*Egy vagy több sorban a foglalni kívánt mennyiség meghaladja a szabad készlet mennyiségét!" _ + vbNewLine + vbNewLine + "Kérem, ellenőrizze!") If _StorageInRows.QTT_Will < 0 Then Throw New Exception("*Egy vagy több sorban negatív értékű foglalási szándék szerepel!" _ + vbNewLine + vbNewLine + "Kérem, ellenőrizze!") Next If _ActQTT <> _StorageOutFromOrderInFIFO_PopUp.QTT_Full Then Throw New Exception("*Nem végezhető el a foglalás, mert a foglalási szándék és a foglalás(ok) értéke nem egyezik meg!" _ + vbNewLine + vbNewLine + "Kérem, ellenőrizze!") End Sub Private Sub InvoiceHeaderSavedSettings(ByVal _InvoiceHeader As InvoiceHeader) On Error GoTo CheckError With _InvoiceHeader .Saved_Customers_Name = _InvoiceHeader.Customers.Name.ToString .Saved_Customers_Address_Country = _InvoiceHeader.Customers.Address1.Country.ToString .Saved_Customers_Address_ZipPostal = _InvoiceHeader.Customers.Address1.ZipPostal.ToString .Saved_Customers_Address_Street = _InvoiceHeader.Customers.Address1.Street.ToString .Saved_Customers_Address_City = _InvoiceHeader.Customers.Address1.City.ToString .Saved_Customers_Address_StateProvince = _InvoiceHeader.Customers.Address1.StateProvince.ToString .Saved_Customers_VATNumber = _InvoiceHeader.Customers.VATNumber.ToString .Saved_Customers_VATNumberEU = _InvoiceHeader.Customers.VATNumberEU.ToString .Saved_CustomersFrom_Name = _InvoiceHeader.CustomersFrom.Name.ToString .Saved_CustomersFrom_Address_ZipPostal = _InvoiceHeader.CustomersFrom.Address1.ZipPostal.ToString .Saved_CustomersFrom_Address_Street = _InvoiceHeader.CustomersFrom.Address1.Street.ToString .Saved_CustomersFrom_Address_City = _InvoiceHeader.CustomersFrom.Address1.City.ToString .Saved_CustomersFrom_Address_StateProvince = _InvoiceHeader.CustomersFrom.Address1.StateProvince.ToString .Saved_CustomersFrom_VATNumber = _InvoiceHeader.CustomersFrom.VATNumber.ToString .Saved_CustomersFrom_VATNumberEU = _InvoiceHeader.CustomersFrom.VATNumberEU.ToString .Saved_CustomersFrom_Address_Country = _InvoiceHeader.CustomersFrom.Address1.Country.Name .Saved_CustomersFrom_Bank_ShortName = _InvoiceHeader.BankInformation.FullBankAccount.ToString .Saved_CustomersFrom_Bank_IBAN = _InvoiceHeader.BankInformation.IBAN.ToString .Saved_CustomersFrom_Bank_SWIFT = _InvoiceHeader.BankInformation.SWIFT.ToString .Saved_CustomersFrom_Bank_AccountNumber = _InvoiceHeader.BankInformation.AccountNumber.ToString End With CheckError: If Err.Number = 91 Then Resume Next If Err.Number = 13 Then Resume Next End Sub Private Sub StornoInvoice(_onew As Xpo.XPObjectSpace, _InvoiceHeaderNew_Collection As ArrayList, _InvoiceRows_Collection As ArrayList) ' Stornózandó fejlécek meghatározása '_______________________________________________________ Dim _InvoiceHeaderOrig_Collection As New ArrayList For Each _InvoiceRows As InvoiceRows In _InvoiceRows_Collection Dim _InvoiceHeader As InvoiceHeader = _onew.GetObject(_InvoiceRows.InvoiceHeader) If _InvoiceHeaderOrig_Collection.Count = 0 Then _InvoiceHeaderOrig_Collection.Add(_InvoiceHeader) Else Dim _IsNeed As Boolean = True For Each _InvoiceHeaderInCollection As InvoiceHeader In _InvoiceHeaderOrig_Collection If _InvoiceHeaderInCollection.Oid = _InvoiceRows.InvoiceHeader.Oid Then _IsNeed = False Next If _IsNeed Then _InvoiceHeaderOrig_Collection.Add(_InvoiceHeader) End If Next If _InvoiceHeaderOrig_Collection.Count = 0 Then Return For Each _InvoiceHeaderOrig As InvoiceHeader In _InvoiceHeaderOrig_Collection _InvoiceHeaderOrig = _onew.GetObjectByKey(Of InvoiceHeader)(_InvoiceHeaderOrig.Oid) _InvoiceHeaderOrig.IsStorno = True Dim _InvoiceHeaderNew As New InvoiceHeader(_onew.Session) With _InvoiceHeaderNew .IsStorno = True .BankInformation = _InvoiceHeaderOrig.BankInformation .ConnectInfo = _InvoiceHeaderOrig.DocumentNumber .CurrencyName = _InvoiceHeaderOrig.CurrencyName .CurrencyRate = _InvoiceHeaderOrig.CurrencyRate .Customers = _InvoiceHeaderOrig.Customers .CustomersFrom = _InvoiceHeaderOrig.CustomersFrom .DateCreated = GetSQLTime(_onew.Session) .PaymentOption = _InvoiceHeaderOrig.PaymentOption .DateExecution = _InvoiceHeaderOrig.DateExecution .DatePayment = _InvoiceHeaderOrig.DatePayment .DocumentNumber = _InvoiceHeaderOrig.InvoiceType.NumberGenerator.GetNewNumber(_InvoiceHeaderOrig.InvoiceType.NumberGenerator) .HUNumberToText = _InvoiceHeaderOrig.HUNumberToText .InvoiceType = _InvoiceHeaderOrig.InvoiceType .IsEditable = False .IsProforma = False .QualityOption = _InvoiceHeaderOrig.QualityOption .Saved_Customers_Address_City = _InvoiceHeaderOrig.Saved_Customers_Address_City .Saved_Customers_Address_Country = _InvoiceHeaderOrig.Saved_Customers_Address_Country .Saved_Customers_Address_StateProvince = _InvoiceHeaderOrig.Saved_Customers_Address_StateProvince .Saved_Customers_Address_Street = _InvoiceHeaderOrig.Saved_Customers_Address_Street .Saved_Customers_Address_ZipPostal = _InvoiceHeaderOrig.Saved_Customers_Address_ZipPostal .Saved_Customers_Name = _InvoiceHeaderOrig.Saved_Customers_Name .Saved_Customers_VATNumber = _InvoiceHeaderOrig.Saved_Customers_VATNumber .Saved_Customers_VATNumberEU = _InvoiceHeaderOrig.Saved_Customers_VATNumberEU .Saved_CustomersFrom_Address_City = _InvoiceHeaderOrig.Saved_CustomersFrom_Address_City .Saved_CustomersFrom_Address_Country = _InvoiceHeaderOrig.Saved_CustomersFrom_Address_Country .Saved_CustomersFrom_Address_StateProvince = _InvoiceHeaderOrig.Saved_CustomersFrom_Address_StateProvince .Saved_CustomersFrom_Address_Street = _InvoiceHeaderOrig.Saved_CustomersFrom_Address_Street .Saved_CustomersFrom_Address_ZipPostal = _InvoiceHeaderOrig.Saved_CustomersFrom_Address_ZipPostal .Saved_CustomersFrom_Bank_AccountNumber = _InvoiceHeaderOrig.Saved_CustomersFrom_Bank_AccountNumber .Saved_CustomersFrom_Bank_IBAN = _InvoiceHeaderOrig.Saved_CustomersFrom_Bank_IBAN .Saved_CustomersFrom_Bank_ShortName = _InvoiceHeaderOrig.Saved_CustomersFrom_Bank_ShortName .Saved_CustomersFrom_Bank_SWIFT = _InvoiceHeaderOrig.Saved_CustomersFrom_Bank_SWIFT .Saved_CustomersFrom_Name = _InvoiceHeaderOrig.Saved_CustomersFrom_Name .Saved_CustomersFrom_VATNumber = _InvoiceHeaderOrig.Saved_CustomersFrom_VATNumber .Saved_CustomersFrom_VATNumberEU = _InvoiceHeaderOrig.Saved_CustomersFrom_VATNumberEU .ShipmentOption = _InvoiceHeaderOrig.ShipmentOption End With For Each _InvoiceRowsOrig As InvoiceRows In _InvoiceHeaderOrig.InvoiceRows Dim _InvoiceRowsNew As New InvoiceRows(_onew.Session) With _InvoiceRowsNew .InvoiceHeader = _InvoiceHeaderNew .Controlling = _InvoiceRowsOrig.Controlling .CostHolder = _InvoiceRowsOrig.CostHolder .CostPlace = _InvoiceRowsOrig.CostPlace .CustomsTariffs = _InvoiceRowsOrig.CustomsTariffs .Description = _InvoiceRowsOrig.Description .DiscountPriceDEV = _InvoiceRowsOrig.DiscountPriceDEV .DiscountPriceHUF = _InvoiceRowsOrig.DiscountPriceHUF .InvoiceRowtype = _InvoiceRowsOrig.InvoiceRowtype .JobNumberObjects = _InvoiceRowsOrig.JobNumberObjects .ListPriceDEV = _InvoiceRowsOrig.ListPriceDEV .ListPriceHUF = _InvoiceRowsOrig.ListPriceHUF .QTT = _InvoiceRowsOrig.QTT * (-1) .QualityOption = _InvoiceRowsOrig.QualityOption .RowIndex = _InvoiceRowsOrig.RowIndex .ShortName = _InvoiceRowsOrig.ShortName .UniqueObjects = _InvoiceRowsOrig.UniqueObjects .Units = _InvoiceRowsOrig.Units .VAT = _InvoiceRowsOrig.VAT If _InvoiceRowsOrig.ContractRows IsNot Nothing Then .ContractRows = _InvoiceRowsOrig.ContractRows End If If _InvoiceRowsOrig.OrderInRows IsNot Nothing Then .OrderInRows = _InvoiceRowsOrig.OrderInRows _InvoiceRowsOrig.OrderInRows.QTT_Invoiced -= _InvoiceRowsOrig.QTT End If If _InvoiceRowsOrig.DeliveryNoteOutRows IsNot Nothing Then .DeliveryNoteOutRows = _InvoiceRowsOrig.DeliveryNoteOutRows _InvoiceRowsOrig.DeliveryNoteOutRows.QTT_Invoiced -= _InvoiceRowsOrig.QTT _InvoiceRowsOrig.DeliveryNoteOutRows.QTT_Will += _InvoiceRowsOrig.QTT End If .ChartOfAccounts = _InvoiceRowsOrig.ChartOfAccounts .InvoiceRows = _InvoiceRowsOrig.InvoiceRows .InvoiceRowsAdvance = _InvoiceRowsOrig.InvoiceRowsAdvance .OrderInRows = _InvoiceRowsOrig.OrderInRows .DeliveryNoteOutRows = _InvoiceRowsOrig.DeliveryNoteOutRows .OrderInRowsOther = _InvoiceRowsOrig.OrderInRowsOther End With Next _InvoiceHeaderNew_Collection.Add(_InvoiceHeaderNew) Next End Sub Private Sub StornoDeliveryNoteOut(_onew As Xpo.XPObjectSpace, _DeliveryNoteOutHeader_Collection As ArrayList, _DeliveryNoteOutHeaderNew_Collection As ArrayList) For Each _DeliveryNoteOutHeader As DeliveryNoteOutHeader In _DeliveryNoteOutHeader_Collection _DeliveryNoteOutHeader.IsEditable = False _DeliveryNoteOutHeader.IsStorno = True Dim _DeliveryNoteOutHeaderNew As New DeliveryNoteOutHeader(_onew.Session) With _DeliveryNoteOutHeaderNew .ConnectInfo = _DeliveryNoteOutHeader.DocumentNumber .CurrencyName = _onew.GetObject(_DeliveryNoteOutHeader.CurrencyName) .Customers = _onew.GetObject(_DeliveryNoteOutHeader.Customers) .CustomersFrom = _onew.GetObject(_DeliveryNoteOutHeader.CustomersFrom) .DateCreated = GetSQLTime(_onew.Session) .DateExecution = _onew.GetObject(_DeliveryNoteOutHeader.DateExecution) .Note = _onew.GetObject(_DeliveryNoteOutHeader.Note) .QualityOption = _onew.GetObject(_DeliveryNoteOutHeader.QualityOption) .ShipmentOption = _onew.GetObject(_DeliveryNoteOutHeader.ShipmentOption) .TransportAddress = _onew.GetObject(_DeliveryNoteOutHeader.TransportAddress) .DeliveryNoteOutType = _onew.GetObject(_DeliveryNoteOutHeader.DeliveryNoteOutType) .IsStorno = True .IsEditable = False End With For Each _DeliveryNoteOutRows As DeliveryNoteOutRows In _DeliveryNoteOutHeader.DeliveryNoteOutRows Dim _DeliveryNoteOutRowsNew As New DeliveryNoteOutRows(_onew.Session) With _DeliveryNoteOutRowsNew .DeliveryNoteOutHeader = _DeliveryNoteOutHeaderNew .RowIndex = _DeliveryNoteOutHeaderNew.DeliveryNoteOutRows.Count .QTT = _DeliveryNoteOutRows.QTT * (-1) .QTT_Will = 0 .StorageOutRowsInRows = _DeliveryNoteOutRows.StorageOutRowsInRows End With _DeliveryNoteOutRows.StorageOutRowsInRows.QTT_To_DeliveryOut -= _DeliveryNoteOutRows.QTT _DeliveryNoteOutRows.StorageOutRowsInRows.StorageOutRows.OrderInRows.QTT_DeliveryNoted -= _DeliveryNoteOutRows.QTT Next _DeliveryNoteOutHeaderNew_Collection.Add(_DeliveryNoteOutHeaderNew) Next End Sub Private Sub StornoDeliveryNoteOutStorageOut(_onew As Xpo.XPObjectSpace, _DeliveryNoteOutHeader_Collection As ArrayList, _StorageOutHeader_Collection As ArrayList, _DeliveryNoteOutHeaderNew_Collection As ArrayList, _StorageOutHeaderNew_Collection As ArrayList) StornoDeliveryNoteOut(_onew, _DeliveryNoteOutHeader_Collection, _DeliveryNoteOutHeaderNew_Collection) Dim _uow_lock As New UnitOfWork(_onew.Session.DataLayer) Dim _User As User = _onew.GetObject(TryCast(SecuritySystem.CurrentUser, User)) If _StorageOutHeader_Collection.Count = 0 Then Return 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 _StorageOutHeader As StorageOutHeader In _StorageOutHeader_Collection Dim _StorageOutHeaderNew As New StorageOutHeader(_onew.Session) With _StorageOutHeaderNew .ConnectInfo = _StorageOutHeader.DocumentNumber .Storage = _onew.GetObject(_StorageOutHeader.Storage) .StorageMoveType = _onew.GetObject(_StorageOutHeader.StorageMoveType) .CustomersFrom = _onew.GetObject(_StorageOutHeader.CustomersFrom) .Customers = _onew.GetObject(_StorageOutHeader.Customers) .Active = False .IsStorno = True .IsEditable = False End With _StorageOutHeader.IsEditable = False _StorageOutHeader.IsStorno = True _StorageOutHeader.Active = False For Each _StorageOutRows As StorageOutRows In _StorageOutHeader.StorageOutRows Dim _StorageOutRowsNew As New StorageOutRows(_onew.Session) With _StorageOutRowsNew .RowIndex = _StorageOutRows.RowIndex .StorageOutHeader = _StorageOutHeaderNew .StorageComputed = _onew.GetObject(_StorageOutRows.StorageComputed) .OrderInRows = _onew.GetObject(_StorageOutRows.OrderInRows) .QTT = _StorageOutRows.QTT * (-1) .QTT_Will = 0 .QTT_To_DeliveryOut = 0 .Products = _onew.GetObject(_StorageOutRows.Products) .OnStorno = True End With '----Vissza raktárba + mozgástábla '____________________________________________________ Dim _StorageOutRowsInRows_Collection As New XPCollection(Of StorageOutRowsInRows)(PersistentCriteriaEvaluationBehavior.InTransaction, _onew.Session, CriteriaOperator.Parse("StorageOutRows=?", _onew.GetObject(_StorageOutRows))) For Each _StorageOutRowsInRows As StorageOutRowsInRows In _StorageOutRowsInRows_Collection Dim _StorageComputed As StorageComputed = _onew.FindObject(Of StorageComputed)(CriteriaOperator.Parse("Storage=? AND Products=?", _onew.GetObject(_StorageOutHeader.Storage), _onew.GetObject(_StorageOutRows.Products))) Dim _StorageMoveEvents_Collection As New XPCollection(Of StorageMoveEvents)(_onew.Session, CriteriaOperator.Parse("StorageInRows=? AND StorageOutRows=?", _onew.GetObject(_StorageOutRowsInRows.StorageInRows), _onew.GetObject(_StorageOutRows))) _StorageMoveEvents_Collection.Sorting.Add(New SortProperty("ObjectCreated", DB.SortingDirection.Descending)) _StorageComputed.QTTFree += _StorageOutRowsInRows.QTT Dim _StorageOutRowsInRowsNew As New StorageOutRowsInRows(_onew.Session) With _StorageOutRowsInRowsNew .StorageInRows = _StorageOutRowsInRows.StorageInRows .StorageOutRows = _StorageOutRowsInRows.StorageOutRows .QTT = _StorageOutRowsInRows.QTT * (-1) .QTT_Will = 0 .QTT_To_DeliveryOut = 0 .StorageInRows.QTT_Out -= _StorageOutRowsInRows.QTT End With If _StorageOutRowsInRows.StorageOutRows.OrderInRows IsNot Nothing Then _StorageOutRowsInRows.StorageOutRows.OrderInRows.QTT_Storaged -= _StorageOutRowsInRows.QTT End If Dim _StorageMoveEvents As New StorageMoveEvents(_onew.Session) _StorageMoveEvents.QTT = _StorageOutRowsInRows.QTT _StorageMoveEvents.StorageOutRows = _onew.GetObject(_StorageOutRows) _StorageMoveEvents.StorageInRows = _onew.GetObject(_StorageOutRowsInRows.StorageInRows) _StorageMoveEvents.QTT_Free_Before = _StorageMoveEvents_Collection(0).QTT_Free_After _StorageMoveEvents.QTT_Free_After = _StorageMoveEvents.QTT_Free_Before + _StorageMoveEvents.QTT _StorageMoveEvents.MoveEventsType = eMoveEventsType.StorageOutStorno _StorageMoveEvents.ExecutionDate = GetSQLTime(_onew.Session) _StorageOutRows.QTT = 0 Next Next _StorageOutHeaderNew_Collection.Add(_StorageOutHeaderNew) Next End If End Sub Private Sub StornoDelivery(_onew As Xpo.XPObjectSpace, _DeliveryHeaderNew_Collection As ArrayList, _InvoiceRows_Collection As ArrayList) ' Stornózandó fejlécek meghatározása '_______________________________________________________ Dim _DeliveryOutHeaderOrig_Collection As New ArrayList For Each _InvoiceRows As InvoiceRows In _InvoiceRows_Collection If _DeliveryOutHeaderOrig_Collection.Count = 0 Then _DeliveryOutHeaderOrig_Collection.Add(_onew.GetObject(_InvoiceRows.DeliveryNoteOutRows.DeliveryNoteOutHeader)) Else Dim _IsNeed As Boolean = True For Each _DeliveryNoteOutHeader As DeliveryNoteOutHeader In _DeliveryOutHeaderOrig_Collection If _DeliveryNoteOutHeader.Oid = _InvoiceRows.DeliveryNoteOutRows.DeliveryNoteOutHeader.Oid Then _IsNeed = False Next If _IsNeed Then _DeliveryOutHeaderOrig_Collection.Add(_onew.GetObject(_InvoiceRows.DeliveryNoteOutRows.DeliveryNoteOutHeader)) End If Next If _DeliveryOutHeaderOrig_Collection.Count = 0 Then Return StornoDeliveryNoteOut(_onew, _DeliveryOutHeaderOrig_Collection, _DeliveryHeaderNew_Collection) End Sub Private Sub StornoStorage(_onew As Xpo.XPObjectSpace, _StorageOutHeaderNew_Collection As ArrayList, _InvoiceRows_Collection As ArrayList) Dim _uow_lock As New UnitOfWork(_onew.Session.DataLayer) Dim _User As User = _onew.GetObject(TryCast(SecuritySystem.CurrentUser, User)) Dim _StorageOutHeaderOrig_Collection As New ArrayList For Each _InvoiceRows As InvoiceRows In _InvoiceRows_Collection If _StorageOutHeaderOrig_Collection.Count = 0 Then _StorageOutHeaderOrig_Collection.Add(_onew.GetObject(_InvoiceRows.DeliveryNoteOutRows.StorageOutRowsInRows.StorageOutRows.StorageOutHeader)) Else Dim _IsNeed As Boolean = True For Each _StorageOutHeader As StorageOutHeader In _StorageOutHeaderOrig_Collection If _StorageOutHeader.Oid = _InvoiceRows.DeliveryNoteOutRows.StorageOutRowsInRows.StorageOutRows.StorageOutHeader.Oid Then _IsNeed = False Next If _IsNeed Then _StorageOutHeaderOrig_Collection.Add(_onew.GetObject(_InvoiceRows.DeliveryNoteOutRows.StorageOutRowsInRows.StorageOutRows.StorageOutHeader)) End If Next If _StorageOutHeaderOrig_Collection.Count = 0 Then Return 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 _StorageOutHeader As StorageOutHeader In _StorageOutHeaderOrig_Collection Dim _StorageOutHeaderNew As New StorageOutHeader(_onew.Session) With _StorageOutHeaderNew .ConnectInfo = _StorageOutHeader.DocumentNumber .Storage = _onew.GetObject(_StorageOutHeader.Storage) .StorageMoveType = _onew.GetObject(_StorageOutHeader.StorageMoveType) .CustomersFrom = _onew.GetObject(_StorageOutHeader.CustomersFrom) .Customers = _onew.GetObject(_StorageOutHeader.Customers) .Active = False .IsStorno = True .IsEditable = False End With _StorageOutHeader.IsEditable = False _StorageOutHeader.IsStorno = True _StorageOutHeader.Active = False For Each _StorageOutRows As StorageOutRows In _StorageOutHeader.StorageOutRows Dim _StorageOutRowsNew As New StorageOutRows(_onew.Session) With _StorageOutRowsNew .RowIndex = _StorageOutRows.RowIndex .StorageOutHeader = _StorageOutHeaderNew .StorageComputed = _onew.GetObject(_StorageOutRows.StorageComputed) .OrderInRows = _onew.GetObject(_StorageOutRows.OrderInRows) .QTT = _StorageOutRows.QTT * (-1) .QTT_Will = 0 .QTT_To_DeliveryOut = 0 .Products = _onew.GetObject(_StorageOutRows.Products) .OnStorno = True End With '----Vissza raktárba + mozgástábla '____________________________________________________ Dim _StorageOutRowsInRows_Collection As New XPCollection(Of StorageOutRowsInRows)(PersistentCriteriaEvaluationBehavior.InTransaction, _onew.Session, CriteriaOperator.Parse("StorageOutRows=?", _onew.GetObject(_StorageOutRows))) For Each _StorageOutRowsInRows As StorageOutRowsInRows In _StorageOutRowsInRows_Collection Dim _StorageComputed As StorageComputed = _onew.FindObject(Of StorageComputed)(CriteriaOperator.Parse("Storage=? AND Products=?", _onew.GetObject(_StorageOutHeader.Storage), _onew.GetObject(_StorageOutRows.Products))) Dim _StorageMoveEvents_Collection As New XPCollection(Of StorageMoveEvents)(_onew.Session, CriteriaOperator.Parse("StorageInRows=? AND StorageOutRows=?", _onew.GetObject(_StorageOutRowsInRows.StorageInRows), _onew.GetObject(_StorageOutRows))) _StorageMoveEvents_Collection.Sorting.Add(New SortProperty("ObjectCreated", DB.SortingDirection.Descending)) _StorageComputed.QTTFree += _StorageOutRowsInRows.QTT Dim _StorageOutRowsInRowsNew As New StorageOutRowsInRows(_onew.Session) With _StorageOutRowsInRowsNew .StorageInRows = _StorageOutRowsInRows.StorageInRows .StorageOutRows = _StorageOutRowsInRows.StorageOutRows .QTT = _StorageOutRowsInRows.QTT * (-1) .QTT_Will = 0 .QTT_To_DeliveryOut = 0 .StorageInRows.QTT_Out -= _StorageOutRowsInRows.QTT End With If _StorageOutRowsInRows.StorageOutRows.OrderInRows IsNot Nothing Then _StorageOutRowsInRows.StorageOutRows.OrderInRows.QTT_Storaged -= _StorageOutRowsInRows.QTT End If Dim _StorageMoveEvents As New StorageMoveEvents(_onew.Session) _StorageMoveEvents.QTT = _StorageOutRowsInRows.QTT _StorageMoveEvents.StorageOutRows = _onew.GetObject(_StorageOutRows) _StorageMoveEvents.StorageInRows = _onew.GetObject(_StorageOutRowsInRows.StorageInRows) _StorageMoveEvents.QTT_Free_Before = _StorageMoveEvents_Collection(0).QTT_Free_After _StorageMoveEvents.QTT_Free_After = _StorageMoveEvents.QTT_Free_Before + _StorageMoveEvents.QTT _StorageMoveEvents.MoveEventsType = eMoveEventsType.StorageOutStorno _StorageMoveEvents.ExecutionDate = GetSQLTime(_onew.Session) _StorageOutRows.QTT = 0 Next Next _StorageOutHeaderNew_Collection.Add(_StorageOutHeaderNew) Next End If End Sub Private Sub aGenerateStorageOutFromOrderInBack_CustomizePopupWindowParams(sender As Object, e As CustomizePopupWindowParamsEventArgs) Handles aGenerateStorageOutFromOrderInBack.CustomizePopupWindowParams Try Dim _onew As Xpo.XPObjectSpace = Application.CreateObjectSpace Dim _OrderInHeader As OrderInHeader = TryCast(View.SelectedObjects(0), OrderInHeader) Dim _StorageOutRowsInRows_CollectionSource As CollectionSource = New CollectionSource(_onew, GetType(StorageOutRowsInRows)) _StorageOutRowsInRows_CollectionSource.BeginUpdateCriteria() _StorageOutRowsInRows_CollectionSource.Criteria("1") = CriteriaOperator.Parse("StorageOutRows.OrderInRows.OrderInHeader=? AND StorageOutRows.StorageOutHeader.IsEditable=True AND QTT_To_DeliveryOut=0 AND QTT>0", _onew.GetObject(_OrderInHeader)) _StorageOutRowsInRows_CollectionSource.EndUpdateCriteria() e.View = Application.CreateListView("StorageOutRowsInRows_ListView", _StorageOutRowsInRows_CollectionSource, True) Catch ex As Exception MsgBox(ex.Message, MsgBoxStyle.OkOnly + MsgBoxStyle.Critical, String.Format(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions", "MsgBoxCheckItAgain"))) End Try End Sub Private Sub aGenerateStorageOutFromOrderInBack_Execute(sender As Object, e As PopupWindowShowActionExecuteEventArgs) Handles aGenerateStorageOutFromOrderInBack.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 Dim _OrderInHeader As OrderInHeader = _onew.GetObjectByKey(Of OrderInHeader)(TryCast(View.SelectedObjects(0), OrderInHeader).Oid) If _OrderInHeader Is Nothing Then Throw New Exception("*Váratlan hiba történt, a folyamat megszakadt!") Dim _StorageOutRowsInRows_Collection As ArrayList = e.PopupWindow.View.SelectedObjects If _StorageOutRowsInRows_Collection.Count = 0 Then Throw New Exception("*Nem lett kijelölve egy sor sem!") 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 _StorageOutRowsInRows As StorageOutRowsInRows In _StorageOutRowsInRows_Collection If _StorageOutRowsInRows.QTT > 0 Then _StorageOutRowsInRows = _onew.GetObject(_StorageOutRowsInRows) Dim _QTTMod As Double = _StorageOutRowsInRows.QTT Dim _StorageOutRowsInRowsC As New XPCollection(Of StorageOutRowsInRows)(_onew.Session, CriteriaOperator.Parse("")) _StorageOutRowsInRows.StorageOutRows.OrderInRows.QTT_Storaged_Will -= _QTTMod _StorageOutRowsInRows.StorageInRows.QTT_Out_Will -= _QTTMod _StorageOutRowsInRows.QTT -= _QTTMod Dim _StorageComputed As StorageComputed = _onew.FindObject(Of StorageComputed)(CriteriaOperator.Parse("Storage=? and Products=?", _StorageOutRowsInRows.StorageOutRows.StorageOutHeader.Storage, _StorageOutRowsInRows.StorageInRows.Products)) _StorageComputed.QTTReservedOut -= _QTTMod _StorageComputed.QTTFree += _QTTMod End If Next _onew.CommitChanges() Frame.GetController(Of RefreshController).RefreshAction.DoExecute() 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 aOrderIn_RecalculateDEV_CustomizePopupWindowParams(sender As Object, e As CustomizePopupWindowParamsEventArgs) Handles aOrderIn_RecalculateDEV.CustomizePopupWindowParams Dim _onew As Xpo.XPObjectSpace = Application.CreateObjectSpace Dim _OrderInHeader As OrderInHeader = TryCast(View.SelectedObjects(0), OrderInHeader) Dim _RecalcDEV As RecalcDEV = _onew.CreateObject(Of RecalcDEV)() _RecalcDEV.CurrencyName = _onew.GetObject(_OrderInHeader.OrderInParameters.CurrencyName) _RecalcDEV.DateExecution = GetSQLTime(_onew.Session) e.View = Application.CreateDetailView(_onew, "RecalcDEV_DetailView", True, _RecalcDEV) End Sub Private Sub aOrderIn_RecalculateDEV_Execute(sender As Object, e As PopupWindowShowActionExecuteEventArgs) Handles aOrderIn_RecalculateDEV.Execute Dim _ocur As Xpo.XPObjectSpace = TryCast(View.ObjectSpace, Xpo.XPObjectSpace) Dim _RecalcDEV As RecalcDEV = TryCast(e.PopupWindow.View.SelectedObjects(0), RecalcDEV) Dim _OrderInHeader As OrderInHeader = TryCast(View.SelectedObjects(0), OrderInHeader) 'Dim _OrderInRows As OrderInRows 'Dim _OrderInRowsOther As OrderInRowsOther RecalculateDEV(_RecalcDEV, _OrderInHeader) _ocur.CommitChanges() 'If _OrderInHeader IsNot Nothing Then ' If _OrderInHeader.OrderInParameters.CurrencyName.ShortName <> "HUF" Then ' For Each _OrderInRows In _OrderInHeader.OrderInRows ' If _RecalcDEV.PriceMode = ePriceMode.eDEVToHUF Then ' _OrderInRows.ListPriceHUF = Math.Round(_OrderInRows.ListPriceDEV * _RecalcDEV.CurrencyRate, 0, MidpointRounding.AwayFromZero) ' _OrderInRows.DiscountPriceHUF = Math.Round(_OrderInRows.DiscountPriceDEV * _RecalcDEV.CurrencyRate, 0, MidpointRounding.AwayFromZero) ' Else ' If _RecalcDEV.CurrencyRate <> 0 Then ' _OrderInRows.ListPriceDEV = Math.Round(_OrderInRows.ListPriceHUF / _RecalcDEV.CurrencyRate, 2, MidpointRounding.AwayFromZero) ' _OrderInRows.DiscountPriceDEV = Math.Round(_OrderInRows.DiscountPriceHUF / _RecalcDEV.CurrencyRate, 2, MidpointRounding.AwayFromZero) ' End If ' End If ' _OrderInRows.RecalculateRows() ' Next ' For Each _OrderInRowsOther In _OrderInHeader.OrderInRowsOther ' If _RecalcDEV.PriceMode = ePriceMode.eDEVToHUF Then ' _OrderInRowsOther.ListPriceHUF = Math.Round(_OrderInRowsOther.ListPriceDEV * _RecalcDEV.CurrencyRate, 0, MidpointRounding.AwayFromZero) ' _OrderInRowsOther.DiscountPriceHUF = Math.Round(_OrderInRowsOther.DiscountPriceDEV * _RecalcDEV.CurrencyRate, 0, MidpointRounding.AwayFromZero) ' Else ' If _RecalcDEV.CurrencyRate <> 0 Then ' _OrderInRowsOther.ListPriceDEV = Math.Round(_OrderInRowsOther.ListPriceHUF / _RecalcDEV.CurrencyRate, 2, MidpointRounding.AwayFromZero) ' _OrderInRowsOther.DiscountPriceDEV = Math.Round(_OrderInRowsOther.DiscountPriceHUF / _RecalcDEV.CurrencyRate, 2, MidpointRounding.AwayFromZero) ' End If ' End If ' _OrderInRowsOther.RecalculateRows() ' Next ' _ocur.CommitChanges() ' End If 'End If End Sub Private Sub ORI_Invoice_Popup_DetailView_AcceptActionExecuting(sender As Object, e As CancelEventArgs) Validator.RuleSet.ValidateAll(View.ObjectSpace, View.SelectedObjects, DefaultContexts.Save) End Sub Private Sub aORI_RegenerateValues_CustomizePopupWindowParams(sender As Object, e As CustomizePopupWindowParamsEventArgs) Handles aORI_RegenerateValues.CustomizePopupWindowParams Dim _onew As Xpo.XPObjectSpace = Application.CreateObjectSpace Dim _OrderInHeader As OrderInHeader = TryCast(View.SelectedObjects(0), OrderInHeader) Dim _OrderInRegenerator_PopUp_Collection As New ArrayList Dim _ProductsList As New ArrayList 'Összes Products a rendelésen For Each _OrderInRows As OrderInRows In _OrderInHeader.OrderInRows If _ProductsList.Count = 0 Then _ProductsList.Add(_OrderInRows.Products) Else Dim _Need As Boolean = True For Each _Products As Products In _ProductsList If _Products.Oid = _OrderInRows.Products.Oid Then _Need = False Exit For Next If _Need Then _ProductsList.Add(_OrderInRows.Products) End If End If Next If _ProductsList.Count > 0 Then For Each _Products As Products In _ProductsList Dim _OrderInRows As OrderInRows = _onew.FindObject(Of OrderInRows)(CriteriaOperator.Parse("OrderInHeader=? AND Products=?", _onew.GetObject(_OrderInHeader), _onew.GetObject(_Products))) 'Kitárolás Dim _StorageOutRowsInRows_Collection As New XPCollection(Of StorageOutRowsInRows)(_onew.Session, CriteriaOperator.Parse("StorageOutRows.OrderInRows=?", _OrderInRows)) Dim _StoragedOut_QTT As Double = 0 Dim _StorageOutHeader_Collection As New ArrayList For Each _StorageOutRowsInRows As StorageOutRowsInRows In _StorageOutRowsInRows_Collection _StoragedOut_QTT += _StorageOutRowsInRows.QTT If _StorageOutHeader_Collection.Count = 0 Then _StorageOutHeader_Collection.Add(_StorageOutRowsInRows.StorageOutRows.StorageOutHeader) Else Dim _Need As Boolean = True For Each _StorageOutHeader As StorageOutHeader In _StorageOutHeader_Collection If _StorageOutHeader.Oid = _StorageOutRowsInRows.StorageOutRows.StorageOutHeader.Oid Then _Need = False Exit For Next If _Need Then _StorageOutHeader_Collection.Add(_StorageOutRowsInRows.StorageOutRows.StorageOutHeader) End If End If Next If _StoragedOut_QTT <> _OrderInRows.QTT_Storaged Then 'Kitárolás probléma... Dim _OrderInRegenerator_PopUp As New OrderInRegenerator_PopUp(_onew.Session) With _OrderInRegenerator_PopUp .RowIndex = _OrderInRows.RowIndex .ResultString = _OrderInRows.Products.ShortName .RegeneratorErrorType = eRegeneratorErrorType.eStorageError End With _OrderInRegenerator_PopUp_Collection.Add(_OrderInRegenerator_PopUp) End If 'Szállítólevél Dim _StorageOutRowsInRows_Filter As String = "" For Each _StorageOutRowsInRows As StorageOutRowsInRows In _StorageOutRowsInRows_Collection _StorageOutRowsInRows_Filter += "StorageOutRowsInRows.Oid='" + _StorageOutRowsInRows.Oid.ToString + "' OR " Next _StorageOutRowsInRows_Filter = _StorageOutRowsInRows_Filter.Remove(_StorageOutRowsInRows_Filter.Length - 4, 4) If _StorageOutRowsInRows_Filter.Length < 8 Then _StorageOutRowsInRows_Filter = "1=2" 'Biztonsági False criteria :) Dim _DeliveryNoteOutRows_Collection As New XPCollection(Of DeliveryNoteOutRows)(_onew.Session, CriteriaOperator.Parse(_StorageOutRowsInRows_Filter)) Dim _DeliveredOut_QTT As Double = 0 Dim _DeliveryNoteOutHeader_Collection As New ArrayList For Each _DeliveryNoteOutRows As DeliveryNoteOutRows In _DeliveryNoteOutRows_Collection _DeliveredOut_QTT += _DeliveryNoteOutRows.QTT If _DeliveryNoteOutHeader_Collection.Count = 0 Then _DeliveryNoteOutHeader_Collection.Add(_DeliveryNoteOutRows.DeliveryNoteOutHeader) Else Dim _Need As Boolean = True For Each _DeliveryNoteOutHeader As DeliveryNoteOutHeader In _DeliveryNoteOutHeader_Collection If _DeliveryNoteOutHeader.Oid = _DeliveryNoteOutRows.DeliveryNoteOutHeader.Oid Then _Need = False Exit For Next If _Need Then _DeliveryNoteOutHeader_Collection.Add(_DeliveryNoteOutRows.DeliveryNoteOutHeader) End If End If Next If _DeliveredOut_QTT <> _OrderInRows.QTT_DeliveryNoted Then 'Kiszállítás probléma Dim _OrderInRegenerator_PopUp As New OrderInRegenerator_PopUp(_onew.Session) With _OrderInRegenerator_PopUp .RowIndex = _OrderInRows.RowIndex .ResultString = _OrderInRows.Products.ShortName .RegeneratorErrorType = eRegeneratorErrorType.eDeliveryError End With _OrderInRegenerator_PopUp_Collection.Add(_OrderInRegenerator_PopUp) End If 'Számla Dim _InvoiceRows_Collection As New XPCollection(Of InvoiceRows)(_onew.Session, CriteriaOperator.Parse("OrderInRows=?", _OrderInRows)) Dim _Invoiced_QTT As Double = 0 Dim _InvoiceHeader_Collection As New ArrayList For Each _InvoiceRows As InvoiceRows In _InvoiceRows_Collection _Invoiced_QTT += _InvoiceRows.QTT If _InvoiceHeader_Collection.Count = 0 Then _InvoiceHeader_Collection.Add(_InvoiceRows.InvoiceHeader) Else Dim _Need As Boolean = True For Each _InvoiceHeader As InvoiceHeader In _InvoiceHeader_Collection If _InvoiceHeader.Oid = _InvoiceRows.InvoiceHeader.Oid Then _Need = False Exit For Next If _Need Then _InvoiceHeader_Collection.Add(_InvoiceRows.InvoiceHeader) End If End If Next If _Invoiced_QTT <> _OrderInRows.QTT_Invoiced Then 'Számla probléma Dim _OrderInRegenerator_PopUp As New OrderInRegenerator_PopUp(_onew.Session) With _OrderInRegenerator_PopUp .RowIndex = _OrderInRows.RowIndex .ResultString = _OrderInRows.Products.ShortName + " megrendelés sorban mennyiségi probléma van." .RegeneratorErrorType = eRegeneratorErrorType.eInvoiceError End With _OrderInRegenerator_PopUp_Collection.Add(_OrderInRegenerator_PopUp) End If '----------------------------------- If _StoragedOut_QTT < _DeliveredOut_QTT Then 'Kitárolás-szállítólevél probléma Dim _OrderInRegenerator_PopUp As New OrderInRegenerator_PopUp(_onew.Session) With _OrderInRegenerator_PopUp .RowIndex = _OrderInRows.RowIndex .ResultString = _OrderInRows.Products.ShortName + " megrendelés sorban van olyan kiszállítás, melyhez nem tartozik kitárolás." .RegeneratorErrorType = eRegeneratorErrorType.eDeliveryError End With _OrderInRegenerator_PopUp_Collection.Add(_OrderInRegenerator_PopUp) If _StoragedOut_QTT = 0 And _OrderInHeader.StorageOutRowsInRows.Count > 0 Then _OrderInRegenerator_PopUp = New OrderInRegenerator_PopUp(_onew.Session) With _OrderInRegenerator_PopUp .RowIndex = _OrderInRows.RowIndex .ResultString = _OrderInRows.Products.ShortName + " megrendelés sorban stornózott kitároláshoz tartozik kiszállítás." .RegeneratorErrorType = eRegeneratorErrorType.eDeliveryError End With _OrderInRegenerator_PopUp = New OrderInRegenerator_PopUp(_onew.Session) With _OrderInRegenerator_PopUp .RowIndex = _OrderInRows.RowIndex .ResultString = _OrderInRows.Products.ShortName + " megrendelés sorban stornózott kitároláshoz tartozik számla." .RegeneratorErrorType = eRegeneratorErrorType.eInvoiceError End With _OrderInRegenerator_PopUp_Collection.Add(_OrderInRegenerator_PopUp) End If End If Next Dim _OrderInRegenerator_PopUp_CollectionSource As New CollectionSource(_onew, GetType(OrderInRegenerator_PopUp)) For Each _OrderInRegenerator_PopUp As OrderInRegenerator_PopUp In _OrderInRegenerator_PopUp_Collection _OrderInRegenerator_PopUp_CollectionSource.Add(_OrderInRegenerator_PopUp) Next e.View = Application.CreateListView("OrderInRegenerator_PopUp_ListView", _OrderInRegenerator_PopUp_CollectionSource, True) End If End Sub Private Sub aORI_RegenerateValues_Execute(sender As Object, e As PopupWindowShowActionExecuteEventArgs) Handles aORI_RegenerateValues.Execute Dim _ocur As Xpo.XPObjectSpace = TryCast(View.ObjectSpace, Xpo.XPObjectSpace) End Sub Private Function GetAlertFromOrderIn(_OrderInHeader As OrderInHeader, _onew As Xpo.XPObjectSpace) As String Dim _AlertMessage As String = "" Dim _uow As New UnitOfWork(TryCast(View.ObjectSpace, Xpo.XPObjectSpace).Session.DataLayer) For Each _OrderInRows As OrderInRows In _OrderInHeader.OrderInRows If _OrderInRows.QTT_Process <> 0 Then If _OrderInRows.ListPriceHUF <= 1 Then _AlertMessage += Chr(13) & Chr(10) & " Nullánál kisebb eladási ár a " & Format(_OrderInRows.RowIndex, "#,##0") & ". sorban !" End If Dim _StorageComputed As StorageComputed = _uow.FindObject(Of StorageComputed)(CriteriaOperator.Parse("Products.Oid=?", _OrderInRows.Products.Oid)) If _StorageComputed IsNot Nothing Then If _OrderInRows.ListPriceHUF < _StorageComputed.MimumumPriceOutHUF Then _AlertMessage += Chr(13) & Chr(10) & " Minimum ár alatti eladás a " & Format(_OrderInRows.RowIndex, "#,##0") & ". sorban !" End If End If End If Next '//Termeltetési szerződés átnézése Dim _FundingAmountHUF_Sum As Double = 0 For Each _OrderInRows As OrderInRows In _OrderInHeader.OrderInRows If _OrderInRows.APCSheetByProducts IsNot Nothing Then Dim _APCSheetByProducts_Collection As New XPCollection(Of APCSheetByProducts)(_onew.Session, CriteriaOperator.Parse("APCSheetHeader=? AND GetDate(ProductExpirationDate)=?", _onew.GetObject(_OrderInRows.APCSheetByProducts.APCSheetHeader), _OrderInRows.APCSheetByProducts.ProductExpirationDate.Date)) Dim _InvoiceRows_Collection As New XPCollection(Of InvoiceRows)(_onew.Session, CriteriaOperator.Parse("OrderInRows=?", _onew.GetObject(_OrderInRows))) For Each _APCSheetByProducts As APCSheetByProducts In _APCSheetByProducts_Collection _FundingAmountHUF_Sum += Math.Round(_APCSheetByProducts.FundingAmountHUF, 0, MidpointRounding.AwayFromZero) If _APCSheetByProducts.Contracts IsNot Nothing Then Dim _ContractRows_Collection As New XPCollection(Of ContractRows)(_onew.Session, CriteriaOperator.Parse("Contracts=?", _APCSheetByProducts.Contracts)) End If Next End If Next For Each _OrderInRowsOther As OrderInRowsOther In _OrderInHeader.OrderInRowsOther If _OrderInRowsOther.APCSheetByProducts IsNot Nothing Then Dim _APCSheetByProducts_Collection As New XPCollection(Of APCSheetByProducts)(_onew.Session, CriteriaOperator.Parse("APCSheetHeader=? AND GetDate(ProductExpirationDate)=?", _onew.GetObject(_OrderInRowsOther.APCSheetByProducts.APCSheetHeader), _OrderInRowsOther.APCSheetByProducts.ProductExpirationDate.Date)) Dim _InvoiceRows_Collection As New XPCollection(Of InvoiceRows)(_onew.Session, CriteriaOperator.Parse("OrderInRowsOther=?", _onew.GetObject(_OrderInRowsOther))) End If Next Return _AlertMessage End Function #Region "Invoice_Popup" Private Sub aORI_Invoice_Popup_Description_CustomizePopupWindowParams(sender As Object, e As CustomizePopupWindowParamsEventArgs) Handles aORI_Invoice_Popup_Description.CustomizePopupWindowParams Try Dim _onew As Xpo.XPObjectSpace = Application.CreateObjectSpace Dim _InvoiceHeader_Collection As New XPCollection(Of InvoiceHeader)(_onew.Session) Dim _ORI_Invoice_Description_PopUp_CollectionSource As New CollectionSource(_onew, GetType(ORI_Invoice_Description_PopUp)) If _InvoiceHeader_Collection.Count > 0 Then Dim _Description_Array As New ArrayList For Each _InvoiceHeader As InvoiceHeader In _InvoiceHeader_Collection If Not String.IsNullOrEmpty(_InvoiceHeader.Description) Then If _Description_Array.Count = 0 Then _Description_Array.Add(_InvoiceHeader.Description) Else If Not _Description_Array.Contains(_InvoiceHeader.Description) Then _Description_Array.Add(_InvoiceHeader.Description) End If End If Next For Each _Description As String In _Description_Array Dim _ORI_Invoice_Description_PopUp As New ORI_Invoice_Description_PopUp(_onew.Session) With _ORI_Invoice_Description_PopUp .Description = _Description End With _ORI_Invoice_Description_PopUp_CollectionSource.Add(_ORI_Invoice_Description_PopUp) Next End If e.View = Application.CreateListView("ORI_Invoice_Description_PopUp_ListView", _ORI_Invoice_Description_PopUp_CollectionSource, True) Catch ex As Exception MsgBox(ex.Message, MsgBoxStyle.OkOnly + MsgBoxStyle.Critical, String.Format(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions", "MsgBoxCheckItAgain"))) End Try End Sub Private Sub aORI_Invoice_Popup_Description_Execute(sender As Object, e As PopupWindowShowActionExecuteEventArgs) Handles aORI_Invoice_Popup_Description.Execute Try If e.PopupWindow.View.SelectedObjects.Count > 0 Then Dim _ocur As Xpo.XPObjectSpace = TryCast(View.ObjectSpace, Xpo.XPObjectSpace) Dim _ORI_Invoice_Popup As ORI_Invoice_Popup = TryCast(View.SelectedObjects(0), ORI_Invoice_Popup) If _ORI_Invoice_Popup Is Nothing Then Throw New Exception("*Váratlan hiba történt a folyamat megszakadt!") If String.IsNullOrEmpty(_ORI_Invoice_Popup.Description) Then _ORI_Invoice_Popup.Description = TryCast(e.PopupWindow.View.SelectedObjects(0), ORI_Invoice_Description_PopUp).Description Else _ORI_Invoice_Popup.Description += vbNewLine _ORI_Invoice_Popup.Description += TryCast(e.PopupWindow.View.SelectedObjects(0), ORI_Invoice_Description_PopUp).Description End If End If Catch ex As Exception MsgBox(ex.Message, MsgBoxStyle.OkOnly + MsgBoxStyle.Critical, String.Format(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions", "MsgBoxCheckItAgain"))) End Try End Sub Private Sub aORI_Invoice_Popup_DescriptionHeader_CustomizePopupWindowParams(sender As Object, e As CustomizePopupWindowParamsEventArgs) Handles aORI_Invoice_Popup_DescriptionHeader.CustomizePopupWindowParams Try Dim _onew As Xpo.XPObjectSpace = Application.CreateObjectSpace Dim _InvoiceHeader_Collection As New XPCollection(Of InvoiceHeader)(_onew.Session) Dim _ORI_Invoice_Description_PopUp_CollectionSource As New CollectionSource(_onew, GetType(ORI_Invoice_Description_PopUp)) If _InvoiceHeader_Collection.Count > 0 Then Dim _Description_Array As New ArrayList For Each _InvoiceHeader As InvoiceHeader In _InvoiceHeader_Collection If Not String.IsNullOrEmpty(_InvoiceHeader.DescriptionHeader) Then If _Description_Array.Count = 0 Then _Description_Array.Add(_InvoiceHeader.DescriptionHeader) Else If Not _Description_Array.Contains(_InvoiceHeader.DescriptionHeader) Then _Description_Array.Add(_InvoiceHeader.DescriptionHeader) End If End If Next For Each _Description As String In _Description_Array Dim _ORI_Invoice_Description_PopUp As New ORI_Invoice_Description_PopUp(_onew.Session) With _ORI_Invoice_Description_PopUp .Description = _Description End With _ORI_Invoice_Description_PopUp_CollectionSource.Add(_ORI_Invoice_Description_PopUp) Next End If e.View = Application.CreateListView("ORI_Invoice_Description_PopUp_ListView", _ORI_Invoice_Description_PopUp_CollectionSource, True) Catch ex As Exception MsgBox(ex.Message, MsgBoxStyle.OkOnly + MsgBoxStyle.Critical, String.Format(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions", "MsgBoxCheckItAgain"))) End Try End Sub Private Sub aORI_Invoice_Popup_DescriptionHeader_Execute(sender As Object, e As PopupWindowShowActionExecuteEventArgs) Handles aORI_Invoice_Popup_DescriptionHeader.Execute Try If e.PopupWindow.View.SelectedObjects.Count > 0 Then Dim _ocur As Xpo.XPObjectSpace = TryCast(View.ObjectSpace, Xpo.XPObjectSpace) Dim _ORI_Invoice_Popup As ORI_Invoice_Popup = TryCast(View.SelectedObjects(0), ORI_Invoice_Popup) If _ORI_Invoice_Popup Is Nothing Then Throw New Exception("*Váratlan hiba történt a folyamat megszakadt!") If String.IsNullOrEmpty(_ORI_Invoice_Popup.Description_Header) Then _ORI_Invoice_Popup.Description_Header = TryCast(e.PopupWindow.View.SelectedObjects(0), ORI_Invoice_Description_PopUp).Description Else _ORI_Invoice_Popup.Description_Header += vbNewLine _ORI_Invoice_Popup.Description_Header += TryCast(e.PopupWindow.View.SelectedObjects(0), ORI_Invoice_Description_PopUp).Description End If End If Catch ex As Exception MsgBox(ex.Message, MsgBoxStyle.OkOnly + MsgBoxStyle.Critical, String.Format(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions", "MsgBoxCheckItAgain"))) End Try End Sub #End Region #Region "Sorok" Private Sub aToTable_OrderIn_Execute(sender As System.Object, e As DevExpress.ExpressApp.Actions.SimpleActionExecuteEventArgs) Handles aToTable_OrderIn.Execute Dim _ocur As Xpo.XPObjectSpace = TryCast(View.ObjectSpace, Xpo.XPObjectSpace) Dim _OrderInHeader As OrderInHeader = CType(View.SelectedObjects(0), OrderInHeader) If _OrderInHeader IsNot Nothing Then '// Termeltetési szerződés ellenőrzés lejárati időre csoportosítva és a szabad mennyiséget szummolva nincs elég keret !!!! 'If _OrderInHeader.row_APCSheetByProducts IsNot Nothing Then ' If _OrderInHeader.row_APCSheetByProducts.FundingAmountAvailableHUF - (_OrderInHeader.row_Products.Products.ListPriceOutHUF * _OrderInHeader.row_QTT) < 0 Then ' MsgBox("Nincs ennyi termeltetési keret !", MsgBoxStyle.Critical + MsgBoxStyle.OkOnly) ' Exit Sub ' End If 'End If '/// -------------------------------------------------------------------- Dim _OrderInRows As OrderInRows = New OrderInRows(_ocur.Session) _OrderInRows.AddRows(_OrderInHeader) _ocur.CommitChanges() Dim ItemToFocus As ViewItem = TryCast(View, DetailView).FindItem("row_Products") If ItemToFocus IsNot Nothing Then Dim ItemControl As Object ItemControl = ItemToFocus.Control ItemControl.Focus() End If _OrderInHeader.row_Products = Nothing _OrderInHeader.row_QTT = 0 If Frame.GetController(Of RefreshController).RefreshAction.Enabled Then Frame.GetController(Of RefreshController).RefreshAction.DoExecute() End If End If End Sub Private Sub aToTableD_OrderIn_Execute(sender As System.Object, e As DevExpress.ExpressApp.Actions.SimpleActionExecuteEventArgs) Handles aToTableD_OrderIn.Execute Dim _ocur As Xpo.XPObjectSpace = View.ObjectSpace Dim _OrderInHeader As OrderInHeader = TryCast(View.SelectedObjects(0), OrderInHeader) Dim _OrderInRows_Del_Collection As New ArrayList Dim _OrderInRows_ListEditor As ListPropertyEditor = TryCast(View, DetailView).FindItem("OrderInRows") For Each _OrderInRows As OrderInRows In _OrderInRows_ListEditor.ListView.SelectedObjects If _OrderInRows.QTT_To = 0 And _OrderInRows.QTT_DeliveryNoted = 0 And _OrderInRows.QTT_Invoiced = 0 And _OrderInRows.QTT_Storaged = 0 And _OrderInRows.QTT_Storaged_Will = 0 Then _OrderInRows.RemoveRows(_OrderInHeader, _ocur) _OrderInRows_Del_Collection.Add(_OrderInRows) End If Next _ocur.Delete(_OrderInRows_Del_Collection) _OrderInHeader.Save() _ocur.CommitChanges() If Frame.GetController(Of RefreshController).RefreshAction.Enabled Then Frame.GetController(Of RefreshController).RefreshAction.DoExecute() End If End Sub #End Region #Region "Egyéb sorok" #End Region #Region "Továbbrendelt tételek" Private Sub aORI_OrderToIncoming_CustomizePopupWindowParams(sender As Object, e As CustomizePopupWindowParamsEventArgs) Handles aORI_OrderToIncoming.CustomizePopupWindowParams Try Catch ex As Exception MsgBox(ex.Message, MsgBoxStyle.OkOnly + MsgBoxStyle.Critical, String.Format(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions", "MsgBoxCheckItAgain"))) End Try End Sub Private Sub aORI_OrderToIncoming_Execute(sender As Object, e As PopupWindowShowActionExecuteEventArgs) Handles aORI_OrderToIncoming.Execute Try Catch ex As Exception MsgBox(ex.Message, MsgBoxStyle.OkOnly + MsgBoxStyle.Critical, String.Format(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions", "MsgBoxCheckItAgain"))) End Try End Sub Private Sub aORI_OrderToSetCustomerOrder_CustomizePopupWindowParams(sender As Object, e As CustomizePopupWindowParamsEventArgs) Handles aORI_OrderToSetCustomerOrder.CustomizePopupWindowParams Try Catch ex As Exception MsgBox(ex.Message, MsgBoxStyle.OkOnly + MsgBoxStyle.Critical, String.Format(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions", "MsgBoxCheckItAgain"))) End Try End Sub Private Sub aORI_OrderToSetCustomerOrder_Execute(sender As Object, e As PopupWindowShowActionExecuteEventArgs) Handles aORI_OrderToSetCustomerOrder.Execute Try Catch ex As Exception MsgBox(ex.Message, MsgBoxStyle.OkOnly + MsgBoxStyle.Critical, String.Format(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions", "MsgBoxCheckItAgain"))) End Try End Sub #End Region #Region "Transactions" '// Invoice customization Private Sub InvoiceCustomization(sender As Object, e As CustomizePopupWindowParamsEventArgs) _ Handles aORI_Create_DeliveryInvoice.CustomizePopupWindowParams, aOrderInStorageOutDeliveryNoteOutInvoice.CustomizePopupWindowParams, aORI_Create_Invoice.CustomizePopupWindowParams, aGenerateInvoicefromOrderIn.CustomizePopupWindowParams, aOrderInInvoiceAdvanceAsk.CustomizePopupWindowParams, aOrderInInvoiceAdvance.CustomizePopupWindowParams, aGenerateInvoiceFromOrderInFinal.CustomizePopupWindowParams Try Dim _onew As Xpo.XPObjectSpace = Application.CreateObjectSpace Dim _OrderInHeader As OrderInHeader = TryCast(View.SelectedObjects(0), OrderInHeader) Dim _ORI_Invoice_Popup As New ORI_Invoice_Popup(_onew.Session) '// APCSheet ---------------------------------------------------------------------------------- Dim _IsAPCSheet As Boolean = False Dim _DatePayment As Date Dim _PaymentOption As PaymentOption If _OrderInHeader.OrderInRows.Count > 0 Then For Each _OrderInRows As OrderInRows In _OrderInHeader.OrderInRows If _OrderInRows.APCSheetByProducts IsNot Nothing Then _IsAPCSheet = True _DatePayment = _OrderInRows.APCSheetByProducts.FundingDate Exit For End If Next End If If _OrderInHeader.OrderInRowsOther.Count > 0 And Not (_IsAPCSheet) Then For Each _OrderInRowsOther As OrderInRowsOther In _OrderInHeader.OrderInRowsOther If _OrderInRowsOther.APCSheetByProducts IsNot Nothing Then _IsAPCSheet = True _DatePayment = _OrderInRowsOther.APCSheetByProducts.FundingDate Exit For End If Next End If If _IsAPCSheet Then _PaymentOption = _onew.FindObject(Of PaymentOption)(CriteriaOperator.Parse("PayMode=1 AND PayDay=0 and ShortName like 'Átutalás%'")) If _PaymentOption Is Nothing Then Dim _onew_paymentoption = Application.CreateObjectSpace _PaymentOption = _onew_paymentoption.CreateObject(Of PaymentOption)() With _PaymentOption .PayMode = ePayMode.InTransfer .PayDay = 0 .ShortName = "Átutalás, 0 nap" End With _onew_paymentoption.CommitChanges() End If End If '--------------------------------------------------------------------------------------------------------------------------- With _ORI_Invoice_Popup .AlertMessage = GetAlertFromOrderIn(_OrderInHeader, _onew) .InvoiceType = _onew.GetObject(_OrderInHeader.OrderInParameters.InvoiceType) .StorageMoveType = _onew.GetObject(_OrderInHeader.OrderInParameters.StorageMoveType) .IsAPCSheet = _IsAPCSheet .CustomersFrom = _onew.GetObject(_OrderInHeader.CustomersFrom) .Customers = _onew.GetObject(_OrderInHeader.Customers) .DateExecution = GetSQLTime(_onew.Session) .CurrencyName = _onew.GetObjectByKey(Of CurrencyName)(_OrderInHeader.OrderInParameters.CurrencyName_Invoice.Oid) .DateCreated = GetSQLTime(_onew.Session) .DateExecution = _OrderInHeader.DateExecution .DatePayment = _DatePayment .QualityOption = _onew.GetObject(_OrderInHeader.QualityOption) If _OrderInHeader.OrderInParameters.BankInformation IsNot Nothing Then .BankInformation = _onew.GetObject(_OrderInHeader.OrderInParameters.BankInformation) End If If _OrderInHeader.OrderInParameters.DeliveryNoteOutType IsNot Nothing Then .DeliveryNoteOutType = _onew.GetObject(_OrderInHeader.OrderInParameters.DeliveryNoteOutType) End If If _OrderInHeader.OrderInParameters.LiquidAssets IsNot Nothing Then .LiquidAssets = _onew.GetObject(_OrderInHeader.OrderInParameters.LiquidAssets) End If If _IsAPCSheet Then .PaymentOption = _onew.GetObject(_PaymentOption) Else .PaymentOption = _onew.GetObject(_OrderInHeader.PaymentOption) End If Select Case sender.id Case "aORI_Create_DeliveryInvoice" .InvoiceStrategy = eInvoiceStrategy.eDeliveryNoteOutAndInvoice Case "aOrderInStorageOutDeliveryNoteOutInvoice" .InvoiceStrategy = eInvoiceStrategy.eStorageOutAndDeliveryNoteOutAndInvoice Case "aORI_Create_Invoice" .InvoiceStrategy = eInvoiceStrategy.eInvoice Case "aGenerateInvoicefromOrderIn" .InvoiceStrategy = eInvoiceStrategy.eInvoice Case "aOrderInInvoiceAdvanceAsk" .InvoiceStrategy = eInvoiceStrategy.eInvoiceAdvanceAsk .InvoiceType = _onew.GetObject(_OrderInHeader.OrderInParameters.InvoiceTypeAdvanced) Case "aGenerateInvoiceFromOrderInFinal" .InvoiceStrategy = eInvoiceStrategy.eInvoiceFinal Case "aOrderInInvoiceAdvance" .InvoiceStrategy = eInvoiceStrategy.eInvoiceAdvance .InvoiceType = _onew.GetObject(_OrderInHeader.OrderInParameters.InvoiceTypeAdvanced) Dim _PCIDetail_ListEditor As ListPropertyEditor = TryCast(View, DetailView).FindItem("PCIDetail") Dim _PCIDetail As PCIDetail = TryCast(_PCIDetail_ListEditor.ListView.SelectedObjects(0), PCIDetail) If _PCIDetail IsNot Nothing Then Select Case _PCIDetail.MainType Case "03-Cassa" If _PCIDetail.DateExecution.Date = GetSQLTime(_onew.Session).Date Then .DateCreated = _PCIDetail.DateExecution .DatePayment = _PCIDetail.DateExecution .DateExecution = _PCIDetail.DateExecution .PaymentOption = _onew.FindObject(Of PaymentOption)(CriteriaOperator.Parse("PayMode=0")) Else .DateExecution = _PCIDetail.DateExecution .PaymentOption = _onew.FindObject(Of PaymentOption)(CriteriaOperator.Parse("PayMode=1 AND PayDay=0 and ShortName like 'Átutalás%'")) .DatePayment = _PCIDetail.DateExecution End If Case "02-Bank" .DateExecution = _PCIDetail.DateExecution .PaymentOption = _onew.FindObject(Of PaymentOption)(CriteriaOperator.Parse("PayMode=1 AND PayDay=0 and ShortName like 'Átutalás%'")) .DatePayment = _PCIDetail.DateExecution If TryCast(_PCIDetail.GLRows.GLHeader, GLBank) IsNot Nothing Then .BankInformation = _onew.FindObject(Of BankInformation)(CriteriaOperator.Parse("LiquidAssests.Oid = ?", TryCast(_PCIDetail.GLRows.GLHeader, GLBank).LiquidAssets_Main.Oid)) End If End Select End If End Select .ShipmentOption = _onew.GetObject(_OrderInHeader.ShipmentOption) .QualityOption = _onew.GetObject(_OrderInHeader.QualityOption) If .Customers IsNot Nothing Then If .Customers.ShipmentOption IsNot Nothing And _OrderInHeader.ShipmentOption Is Nothing Then .ShipmentOption = _onew.GetObjectByKey(Of ShipmentOption)(.Customers.ShipmentOption.Oid) If .Customers.Address1 IsNot Nothing Then .TransportAddress = _onew.GetObjectByKey(Of Address)(.Customers.Address1.Oid) End If End With e.View = Application.CreateDetailView(_onew, "ORI_Invoice_Popup_DetailView", False, _ORI_Invoice_Popup) Catch ex As Exception MsgBox(ex.Message, MsgBoxStyle.OkOnly + MsgBoxStyle.Critical, String.Format(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions", "MsgBoxCheckItAgain"))) End Try End Sub '// DeliveryNoteOut customization Private Sub DeliveryNoteOutCustomization(sender As Object, e As CustomizePopupWindowParamsEventArgs) _ Handles aOrderInStorageOutDeliveryNoteOut.CustomizePopupWindowParams, aORI_Create_Delivery.CustomizePopupWindowParams Try Dim _onew As Xpo.XPObjectSpace = Application.CreateObjectSpace Dim _OrderInHeader As OrderInHeader = TryCast(View.SelectedObjects(0), OrderInHeader) Dim _DeliveryNoteView As DeliveryNoteView = _onew.CreateObject(Of DeliveryNoteView)() With _DeliveryNoteView Select Case sender.id Case "aOrderInStorageOutDeliveryNoteOut" .StorageNeed = True Case "aORI_Create_Delivery" End Select .DeliveryNoteOutTypeNeed = True .CustomersFrom = _onew.GetObjectByKey(Of CustomersFrom)(_OrderInHeader.CustomersFrom.Oid) .Customers = _onew.GetObjectByKey(Of Customers)(_OrderInHeader.Customers.Oid) .DateExecution = GetSQLTime(_onew.Session) .CurrencyName = _onew.GetObjectByKey(Of CurrencyName)(_OrderInHeader.OrderInParameters.CurrencyName.Oid) .ShipmentOption = _onew.GetObject(Of ShipmentOption)(_OrderInHeader.ShipmentOption) .QualityOption = _onew.GetObject(Of QualityOption)(_OrderInHeader.QualityOption) .StorageMoveType = _onew.GetObject(_OrderInHeader.OrderInParameters.StorageMoveType) .DeliveryNoteOutType = _onew.GetObject(_OrderInHeader.OrderInParameters.DeliveryNoteOutType) If .Customers IsNot Nothing Then If .Customers.Address1 IsNot Nothing Then .TransportAddress = _onew.GetObjectByKey(Of Address)(.Customers.Address1.Oid) If .Customers.Address2 IsNot Nothing Then .TransportAddress = _onew.GetObjectByKey(Of Address)(.Customers.Address2.Oid) If .Customers.ShipmentOption IsNot Nothing And _OrderInHeader.ShipmentOption Is Nothing Then .ShipmentOption = _onew.GetObjectByKey(Of ShipmentOption)(.Customers.ShipmentOption.Oid) If .Customers.QualityOption IsNot Nothing And _OrderInHeader.QualityOption Is Nothing Then .QualityOption = _onew.GetObjectByKey(Of QualityOption)(.Customers.QualityOption.Oid) End If End With e.View = Application.CreateDetailView(_onew, "DeliveryNoteView_DetailView", False, _DeliveryNoteView) Catch ex As Exception MsgBox(ex.Message, MsgBoxStyle.OkOnly + MsgBoxStyle.Critical, String.Format(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions", "MsgBoxCheckItAgain"))) End Try End Sub #Region "DetailView" Private Sub aOrderInInvoiceAdvanceAsk_Execute(sender As Object, e As PopupWindowShowActionExecuteEventArgs) Handles aOrderInInvoiceAdvanceAsk.Execute '//Előlegbekérő készítése bejövő megrendelés alapján aGenerateInvoicefromOrderIn_Execute(sender, e) End Sub Private Sub aOrderInStorageOutDeliveryNoteOut_Execute(sender As Object, e As PopupWindowShowActionExecuteEventArgs) Handles aOrderInStorageOutDeliveryNoteOut.Execute '//Kitárolás és kiszállítás egyben 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)) Dim _StorageComputed As StorageComputed Try '--==Ellenőrzések==-- '____________________________________________________________________________________________________________________ Dim _OrderInHeader As OrderInHeader = _onew.GetObjectByKey(Of OrderInHeader)(TryCast(View.SelectedObjects(0), OrderInHeader).Oid) Dim _DeliveryNoteView As DeliveryNoteView = _onew.GetObject(TryCast(e.PopupWindow.View.SelectedObjects(0), DeliveryNoteView)) If _OrderInHeader.OrderInRows.Count <= 0 Then Throw New Exception(String.Format(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions\OrderInRows", "NoRowsInOrder"), String.Format(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions", "MsgBoxCheckItAgain")))) End If Dim _OrderInRows_Collection As New ArrayList For Each _OrderInRows As OrderInRows In _OrderInHeader.OrderInRows If _OrderInRows.QTT_Process > 0 Then If _OrderInRows.QTT_Process + _OrderInRows.QTT_Storaged + _OrderInRows.QTT_Storaged_Will > _OrderInRows.QTT Then '// Ha meghaladja a kitárolás a rendelteket Throw New Exception(String.Format(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions\OrderInRows", "TooMutchQuantityInOrderIn"), _OrderInRows.RowIndex.ToString + String.Format(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions", "MsgBoxCheckItAgain")))) End If If _OrderInRows.QTT_Process + _OrderInRows.QTT_DeliveryNoted > _OrderInRows.QTT Then '// Ha meghaladja a kiszállítás a rendelteket Throw New Exception(String.Format(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions\OrderInRows", "TooMutchQuantityInOrderIn"), _OrderInRows.RowIndex.ToString + String.Format(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions", "MsgBoxCheckItAgain")))) End If '// Szabad készlet ellenőrzése _StorageComputed = _onew.FindObject(Of StorageComputed)(CriteriaOperator.Parse("Storage.Oid=? AND Products.Oid=?", _DeliveryNoteView.Storage.Oid, _OrderInRows.Products.Oid)) If _StorageComputed Is Nothing Then Throw New Exception(String.Format(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions\StorageComputed", "NoProductsInStorage"), _OrderInRows.RowIndex, _OrderInRows.Products.ShortName, _DeliveryNoteView.Storage.ShortName) + vbNewLine + String.Format(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions", "MsgBoxCheckItAgain"))) End If If (_StorageComputed.QTTFree < _OrderInRows.QTT_Process) Then Throw New Exception(String.Format(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions\StorageComputed", "NoProductsInStorage"), _OrderInRows.RowIndex, _OrderInRows.Products.ShortName, _DeliveryNoteView.Storage.ShortName) + vbNewLine + String.Format(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions", "MsgBoxCheckItAgain"))) End If If _StorageComputed IsNot Nothing Then '// Mimimum ár ellenőrzés If TryCast(Application.Model.Options, IModelOptionsExtender).RequreMinimumPriceCheck Then If _StorageComputed.MimumumPriceOutHUF < _OrderInRows.FinalPriceHUF Then Throw New Exception(String.Format(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions\StorageComputed", "BadMinimumPrice"), _OrderInRows.RowIndex, _OrderInRows.Products.ShortName, _StorageComputed.MimumumPriceOutHUF, _OrderInRows.FinalPriceHUF) + vbNewLine + String.Format(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions", "MsgBoxCheckItAgain"))) End If End If End If _OrderInRows_Collection.Add(_onew.GetObjectByKey(Of OrderInRows)(_OrderInRows.Oid)) End If Next If _OrderInRows_Collection.Count = 0 Then Throw New Exception(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions\OrderInRows", "NoSelectionforStorageOutandDeliveryNoteOut") + vbNewLine + String.Format(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions", "MsgBoxCheckItAgain"))) '--==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 '--==Kitárolás==-- '____________________________________________________________________________________________________________________ Dim _StorageOutHeader As New StorageOutHeader(_onew.Session) With _StorageOutHeader .Active = True .CustomersFrom = _onew.GetObjectByKey(Of CustomersFrom)(_OrderInHeader.CustomersFrom.Oid) .Customers = _onew.GetObjectByKey(Of Customers)(_OrderInHeader.Customers.Oid) .StorageMoveType = _onew.GetObjectByKey(Of StorageMoveType)(_DeliveryNoteView.StorageMoveType.Oid) .Storage = _onew.GetObjectByKey(Of Storage)(_DeliveryNoteView.Storage.Oid) End With For Each _OrderInRows As OrderInRows In _OrderInRows_Collection Dim _QTT_Mod As Double = 0 Dim _QTT_Free As Double = 0 Dim _QTT_ReservedOut As Double = 0 Dim _QTT_Will_Out As Double = 0 Dim _StorageOutRows As New StorageOutRows(_onew.Session) With _StorageOutRows .StorageOutHeader = _StorageOutHeader .Products = _onew.GetObjectByKey(Of Products)(_OrderInRows.Products.Oid) .OrderInRows = _onew.GetObjectByKey(Of OrderInRows)(_OrderInRows.Oid) End With Dim _StorageInRows_Collection As New XPCollection(Of StorageInRows)(PersistentCriteriaEvaluationBehavior.InTransaction, _onew.Session, CriteriaOperator.Parse("StorageInHeader.Storage=? and StorageInHeader.IsEditable=False and StorageInHeader.IsStorno=False and Products=?", _StorageOutHeader.Storage, _onew.GetObjectByKey(Of Products)(_OrderInRows.Products.Oid))) _StorageInRows_Collection.Sorting.Add(New SortProperty("StorageInHeader.CreateDate", DB.SortingDirection.Ascending)) _QTT_Mod = _OrderInRows.QTT_Process For Each _StorageInRows As StorageInRows In _StorageInRows_Collection _QTT_Free = _StorageInRows.QTT - _StorageInRows.QTT_Out - _StorageInRows.QTT_Out_Will If _QTT_Free > 0 Then If _QTT_Free < _QTT_Mod Then _StorageInRows.QTT_Out_Will += _QTT_Free _StorageOutRows.QTT_Will += _QTT_Free _QTT_Mod -= _QTT_Free '------- FIFO sor beszúrása Dim _StorageOutRowsInRows As StorageOutRowsInRows = _onew.FindObject(Of StorageOutRowsInRows)(CriteriaOperator.Parse("StorageInRows=? and StorageOutRows=?", _StorageInRows, _StorageOutRows), True) If _StorageOutRowsInRows IsNot Nothing Then _StorageOutRowsInRows.QTT += _QTT_Free Else _StorageOutRowsInRows = New StorageOutRowsInRows(_onew.Session) _StorageOutRowsInRows.StorageInRows = _StorageInRows _StorageOutRowsInRows.StorageOutRows = _StorageOutRows _StorageOutRowsInRows.QTT = _QTT_Free End If Else _StorageInRows.QTT_Out_Will += _QTT_Mod _StorageOutRows.QTT_Will += _QTT_Mod '------- FIFO sor beszúrása Dim _StorageOutRowsInRows As StorageOutRowsInRows = _onew.FindObject(Of StorageOutRowsInRows)(CriteriaOperator.Parse("StorageInRows=? and StorageOutRows=?", _StorageInRows, _StorageOutRows), True) If _StorageOutRowsInRows IsNot Nothing Then _StorageOutRowsInRows.QTT += _QTT_Mod Else _StorageOutRowsInRows = New StorageOutRowsInRows(_onew.Session) _StorageOutRowsInRows.StorageInRows = _StorageInRows _StorageOutRowsInRows.StorageOutRows = _StorageOutRows _StorageOutRowsInRows.QTT = _QTT_Mod End If Exit For End If End If Next _StorageOutRows.RowIndex = _StorageOutHeader.StorageOutRows.Count _StorageComputed = _onew.FindObject(Of StorageComputed)(CriteriaOperator.Parse("Storage=? and Products=?", _StorageOutHeader.Storage, _onew.GetObjectByKey(Of Products)(_OrderInRows.Products.Oid)), True) _QTT_ReservedOut = _StorageComputed.QTTReservedOut Dim _StorageOutRows_Collection_R As New XPCollection(Of StorageOutRows)(PersistentCriteriaEvaluationBehavior.InTransaction, _onew.Session, CriteriaOperator.Parse("QTT_Will>0 and StorageOutHeader.Storage=? and Products=?", _StorageOutHeader.Storage, _onew.GetObjectByKey(Of Products)(_OrderInRows.Products.Oid))) For Each _StorageOutRows_R In _StorageOutRows_Collection_R _QTT_Will_Out += _StorageOutRows_R.QTT_Will Next _StorageComputed.QTTFree = _StorageComputed.QTTFree - (_QTT_Will_Out - _QTT_ReservedOut) _StorageComputed.QTTReservedOut = _QTT_Will_Out Next '--Kitárolás véglegesítése-- '____________________________________________________________________________________________________________________ For Each _StorageOutRows As StorageOutRows In _StorageOutHeader.StorageOutRows Dim _StorageOutRowsInRows_Collection As New XPCollection(Of StorageOutRowsInRows)(PersistentCriteriaEvaluationBehavior.InTransaction, _onew.Session, CriteriaOperator.Parse("StorageOutRows=?", _StorageOutRows)) For Each _StorageOutRowsInRows In _StorageOutRowsInRows_Collection If _StorageOutRowsInRows.QTT > 0 Then Dim _StorageMoveEvents_Collection As New XPCollection(Of StorageMoveEvents)(PersistentCriteriaEvaluationBehavior.InTransaction, _onew.Session, CriteriaOperator.Parse("StorageInRows=?", _StorageOutRowsInRows.StorageInRows)) _StorageMoveEvents_Collection.Sorting.Add(New SortProperty("ObjectCreated", DB.SortingDirection.Descending)) _StorageOutRowsInRows.StorageInRows.QTT_Out += _StorageOutRowsInRows.QTT _StorageOutRowsInRows.StorageInRows.QTT_Out_Will -= _StorageOutRowsInRows.QTT Dim _StorageMoveEvents As New StorageMoveEvents(_onew.Session) _StorageMoveEvents.StorageInRows = _StorageOutRowsInRows.StorageInRows _StorageMoveEvents.StorageOutRows = _StorageOutRowsInRows.StorageOutRows If _StorageMoveEvents_Collection.Count > 0 Then _StorageMoveEvents.QTT_Free_Before = _StorageMoveEvents_Collection(0).QTT_Free_After Else _StorageMoveEvents.QTT_Free_Before = 0 End If _StorageMoveEvents.QTT = (-1) * _StorageOutRowsInRows.QTT _StorageMoveEvents.QTT_Free_After = _StorageMoveEvents.QTT_Free_Before + _StorageMoveEvents.QTT _StorageMoveEvents.MoveEventsType = eMoveEventsType.StorageOutFinal _StorageMoveEvents.ExecutionDate = _StorageOutRowsInRows.StorageOutRows.StorageOutHeader.CreateDate End If Next _StorageOutRows.QTT += _StorageOutRows.QTT_Will If _StorageOutRows.OrderInRows IsNot Nothing Then Dim _QTT_WillOrug As Double = _StorageOutRows.QTT_Will Dim _OrderInRows As OrderInRows = _onew.GetObjectByKey(Of OrderInRows)(_StorageOutRows.OrderInRows.Oid) _OrderInRows.QTT_Storaged += _StorageOutRows.QTT_Will _OrderInRows.QTT_Process = 0 End If _StorageComputed = _onew.FindObject(Of StorageComputed)(CriteriaOperator.Parse("Products=? and Storage=?", _StorageOutRows.Products, _StorageOutRows.StorageOutHeader.Storage), True) _StorageComputed.QTTReservedOut -= _StorageOutRows.QTT_Will _StorageOutRows.QTT_Will = 0 Next _StorageOutHeader.IsEditable = False _StorageOutHeader.IsFinalized = True '--==Szállítólevél==-- '____________________________________________________________________________________________________________________ Dim _DeliveryNoteOutHeader As New DeliveryNoteOutHeader(_onew.Session) With _DeliveryNoteOutHeader .CurrencyName = _onew.GetObject(_DeliveryNoteView.CurrencyName) .Customers = _onew.GetObject(_DeliveryNoteView.Customers) .CustomersFrom = _onew.GetObject(_DeliveryNoteView.CustomersFrom) .DateCreated = GetSQLTime(_onew.Session) .DateExecution = _onew.GetObject(_DeliveryNoteView.DateExecution) .Note = _onew.GetObject(_DeliveryNoteView.Note) .QualityOption = _onew.GetObject(_DeliveryNoteView.QualityOption) .ShipmentOption = _onew.GetObject(_DeliveryNoteView.ShipmentOption) .TransportAddress = _onew.GetObject(_DeliveryNoteView.TransportAddress) .DeliveryNoteOutType = _onew.GetObject(_DeliveryNoteView.DeliveryNoteOutType) .IsEditable = False End With For Each _StorageOutRows As StorageOutRows In _StorageOutHeader.StorageOutRows Dim _StorageOutRowsInRows_Collection As New XPCollection(Of StorageOutRowsInRows)(PersistentCriteriaEvaluationBehavior.InTransaction, _onew.Session, CriteriaOperator.Parse("StorageOutRows=?", _StorageOutRows)) For Each _StorageOutRowsInRows As StorageOutRowsInRows In _StorageOutRowsInRows_Collection Dim _DeliveryNoteOutRows As New DeliveryNoteOutRows(_onew.Session) With _DeliveryNoteOutRows .DeliveryNoteOutHeader = _DeliveryNoteOutHeader .RowIndex = _DeliveryNoteOutHeader.DeliveryNoteOutRows.Count .QTT = _StorageOutRowsInRows.QTT .StorageOutRowsInRows = _StorageOutRowsInRows End With Dim _QTT_Will_Orig = _StorageOutRowsInRows.QTT _StorageOutRowsInRows.QTT_To_DeliveryOut += _QTT_Will_Orig _StorageOutRowsInRows.QTT_Will = 0 Dim _OrderInRows As OrderInRows = _onew.GetObjectByKey(Of OrderInRows)(_StorageOutRowsInRows.StorageOutRows.OrderInRows.Oid) _OrderInRows.QTT_DeliveryNoted += _QTT_Will_Orig Next Next _onew.CommitChanges() Frame.GetController(Of RefreshController).RefreshAction.DoExecute() End If Catch ex As Exception MsgBox(ex.Message, MsgBoxStyle.OkOnly + MsgBoxStyle.Critical, CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions", "MsgBoxError")) Finally LockingModule.UnLockObject(_uow_lock, GetType(StorageComputed), "-", _User) End Try End Sub Private Sub aOrderInStorageOutDeliveryNoteOutInvoice_Execute(sender As Object, e As PopupWindowShowActionExecuteEventArgs) Handles aOrderInStorageOutDeliveryNoteOutInvoice.Execute '// Kitárolás + kiszállítás + számla egyben 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)) Dim _StorageComputed As StorageComputed Try '--==Ellenőrzések==-- '____________________________________________________________________________________________________________________ Dim _OrderInHeader As OrderInHeader = _onew.GetObjectByKey(Of OrderInHeader)(TryCast(View.SelectedObjects(0), OrderInHeader).Oid) Dim _ORI_Invoice_Popup As ORI_Invoice_Popup = _onew.GetObject(TryCast(e.PopupWindow.View.SelectedObjects(0), ORI_Invoice_Popup)) If _OrderInHeader.OrderInRows.Count <= 0 Then Throw New Exception("*A megrendelésnek nincs egyetlen sora sem!") Dim _OrderInRows_Collection As New ArrayList For Each _OrderInRows As OrderInRows In _OrderInHeader.OrderInRows If _OrderInRows.QTT_Process > 0 Then If _OrderInRows.QTT_Process + _OrderInRows.QTT_Storaged + _OrderInRows.QTT_Storaged_Will > _OrderInRows.QTT Then '// Ha meghaladja a kitárolás a rendelteket MsgBox(String.Format(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions\OrderInRows", "TooMutchQuantityInOrderIn"), _OrderInRows.RowIndex, _OrderInRows.QTT_Process + _OrderInRows.QTT_Storaged + _OrderInRows.QTT_Storaged_Will, _OrderInRows.QTT), MsgBoxStyle.Information + MsgBoxStyle.OkOnly, String.Format(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions", "MsgBoxCheckItAgain"))) Exit Sub End If If _OrderInRows.QTT_Process + _OrderInRows.QTT_DeliveryNoted > _OrderInRows.QTT Then '// Ha meghaladja a kiszállítás a rendelteket MsgBox(String.Format(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions\OrderInRows", "TooMutchQuantityInOrderIn"), _OrderInRows.RowIndex, _OrderInRows.QTT_Process + _OrderInRows.QTT_DeliveryNoted, _OrderInRows.QTT), MsgBoxStyle.Information + MsgBoxStyle.OkOnly, String.Format(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions", "MsgBoxCheckItAgain"))) Exit Sub End If If _OrderInRows.QTT_Process + _OrderInRows.QTT_Invoiced > _OrderInRows.QTT Then '// Ha meghaladja a számlázás a rendelteket MsgBox(String.Format(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions\OrderInRows", "TooMutchQuantityInOrderIn"), _OrderInRows.RowIndex, _OrderInRows.QTT_Process + _OrderInRows.QTT_Invoiced, _OrderInRows.QTT), MsgBoxStyle.Information + MsgBoxStyle.OkOnly, String.Format(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions", "MsgBoxCheckItAgain"))) Exit Sub End If '// Szabad készlet ellenőrzése _StorageComputed = _onew.FindObject(Of StorageComputed)(CriteriaOperator.Parse("Storage=? AND Products=?", _onew.GetObjectByKey(Of Storage)(_ORI_Invoice_Popup.Storage.Oid), _onew.GetObjectByKey(Of Products)(_OrderInRows.Products.Oid))) If _StorageComputed Is Nothing Then MsgBox(String.Format(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions\StorageComputed", "NoProductsInStorage"), _OrderInRows.RowIndex, _OrderInRows.Products.ShortName, _ORI_Invoice_Popup.Storage.ShortName), MsgBoxStyle.Information + MsgBoxStyle.OkOnly, String.Format(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions", "MsgBoxCheckItAgain"))) Exit Sub End If If (_StorageComputed.QTTFree < _OrderInRows.QTT_Process) Then MsgBox(String.Format(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions\StorageComputed", "NoProductsInStorage"), _OrderInRows.RowIndex, _OrderInRows.Products.ShortName, _ORI_Invoice_Popup.Storage.ShortName), MsgBoxStyle.Information + MsgBoxStyle.OkOnly, String.Format(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions", "MsgBoxCheckItAgain"))) Exit Sub End If If _StorageComputed IsNot Nothing Then '// Mimimum ár ellenőrzés If TryCast(Application.Model.Options, IModelOptionsExtender).RequreMinimumPriceCheck Then If _StorageComputed.MimumumPriceOutHUF < _OrderInRows.FinalPriceHUF Then MsgBox(String.Format(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions\StorageComputed", "BadMinimumPrice"), _OrderInRows.RowIndex, _OrderInRows.Products.ShortName, _StorageComputed.MimumumPriceOutHUF, _OrderInRows.FinalPriceHUF), MsgBoxStyle.Information + MsgBoxStyle.OkOnly, String.Format(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions", "MsgBoxCheckItAgain"))) Exit Sub End If End If End If _OrderInRows_Collection.Add(_onew.GetObjectByKey(Of OrderInRows)(_OrderInRows.Oid)) End If Next If _OrderInRows_Collection.Count = 0 Then MsgBox(String.Format(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions\OrderInRows", "NoSelectionforStorageOutandDeliveryNoteOut")), MsgBoxStyle.Information + MsgBoxStyle.OkOnly, String.Format(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions", "MsgBoxCheckItAgain"))) Exit Sub End If '--==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", "CanNotStorageOutByLocking") 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 ' RecalculateDEV(_ORI_Invoice_Popup, _OrderInHeader) '--==Kitárolás==-- '____________________________________________________________________________________________________________________ Dim _StorageOutHeader As New StorageOutHeader(_onew.Session) With _StorageOutHeader .Active = True .CustomersFrom = _onew.GetObjectByKey(Of CustomersFrom)(_OrderInHeader.CustomersFrom.Oid) .Customers = _onew.GetObjectByKey(Of Customers)(_OrderInHeader.Customers.Oid) .StorageMoveType = _onew.GetObjectByKey(Of StorageMoveType)(_ORI_Invoice_Popup.StorageMoveType.Oid) .Storage = _onew.GetObjectByKey(Of Storage)(_ORI_Invoice_Popup.StorageMoveType.Storage.Oid) End With For Each _OrderInRows As OrderInRows In _OrderInRows_Collection Dim _QTT_Mod As Double = 0 Dim _QTT_Free As Double = 0 Dim _QTT_ReservedOut As Double = 0 Dim _QTT_Will_Out As Double = 0 Dim _StorageOutRows As New StorageOutRows(_onew.Session) With _StorageOutRows .StorageOutHeader = _StorageOutHeader .Products = _onew.GetObjectByKey(Of Products)(_OrderInRows.Products.Oid) .OrderInRows = _onew.GetObjectByKey(Of OrderInRows)(_OrderInRows.Oid) End With Dim _StorageInRows_Collection As New XPCollection(Of StorageInRows)(PersistentCriteriaEvaluationBehavior.InTransaction, _onew.Session, CriteriaOperator.Parse("StorageInHeader.Storage=? and StorageInHeader.IsEditable=False and StorageInHeader.IsStorno=False and Products=?", _StorageOutHeader.Storage, _onew.GetObjectByKey(Of Products)(_OrderInRows.Products.Oid))) _StorageInRows_Collection.Sorting.Add(New SortProperty("StorageInHeader.CreateDate", DB.SortingDirection.Ascending)) _QTT_Mod = _OrderInRows.QTT_Process For Each _StorageInRows As StorageInRows In _StorageInRows_Collection _QTT_Free = _StorageInRows.QTT - _StorageInRows.QTT_Out - _StorageInRows.QTT_Out_Will If _QTT_Free > 0 Then If _QTT_Free < _QTT_Mod Then _StorageInRows.QTT_Out_Will += _QTT_Free _StorageOutRows.QTT_Will += _QTT_Free _StorageInRows.Save() _QTT_Mod -= _QTT_Free '------- FIFO sor beszúrása Dim _StorageOutRowsInRows As StorageOutRowsInRows = _onew.FindObject(Of StorageOutRowsInRows)(CriteriaOperator.Parse("StorageInRows=? and StorageOutRows=?", _StorageInRows, _StorageOutRows), True) If _StorageOutRowsInRows IsNot Nothing Then _StorageOutRowsInRows.QTT += _QTT_Free Else _StorageOutRowsInRows = New StorageOutRowsInRows(_onew.Session) _StorageOutRowsInRows.StorageInRows = _StorageInRows _StorageOutRowsInRows.StorageOutRows = _StorageOutRows _StorageOutRowsInRows.QTT = _QTT_Free End If Else _StorageInRows.QTT_Out_Will += _QTT_Mod _StorageOutRows.QTT_Will += _QTT_Mod '------- FIFO sor beszúrása Dim _StorageOutRowsInRows As StorageOutRowsInRows = _onew.FindObject(Of StorageOutRowsInRows)(CriteriaOperator.Parse("StorageInRows=? and StorageOutRows=?", _StorageInRows, _StorageOutRows), True) If _StorageOutRowsInRows IsNot Nothing Then _StorageOutRowsInRows.QTT += _QTT_Mod Else _StorageOutRowsInRows = New StorageOutRowsInRows(_onew.Session) _StorageOutRowsInRows.StorageInRows = _StorageInRows _StorageOutRowsInRows.StorageOutRows = _StorageOutRows _StorageOutRowsInRows.QTT = _QTT_Mod End If Exit For End If End If Next _StorageOutRows.RowIndex = _StorageOutHeader.StorageOutRows.Count _StorageComputed = _onew.FindObject(Of StorageComputed)(CriteriaOperator.Parse("Storage=? and Products=?", _StorageOutHeader.Storage, _onew.GetObjectByKey(Of Products)(_OrderInRows.Products.Oid)), True) _QTT_ReservedOut = _StorageComputed.QTTReservedOut Dim _StorageOutRows_Collection_R As New XPCollection(Of StorageOutRows)(PersistentCriteriaEvaluationBehavior.InTransaction, _onew.Session, CriteriaOperator.Parse("QTT_Will>0 and StorageOutHeader.Storage=? and Products=?", _StorageOutHeader.Storage, _onew.GetObjectByKey(Of Products)(_OrderInRows.Products.Oid))) For Each _StorageOutRows_R In _StorageOutRows_Collection_R _QTT_Will_Out += _StorageOutRows_R.QTT_Will Next _StorageComputed.QTTFree = _StorageComputed.QTTFree - (_QTT_Will_Out - _QTT_ReservedOut) _StorageComputed.QTTReservedOut = _QTT_Will_Out Next '--Kitárolás véglegesítése-- '____________________________________________________________________________________________________________________ For Each _StorageOutRows As StorageOutRows In _StorageOutHeader.StorageOutRows Dim _StorageOutRowsInRows_Collection As New XPCollection(Of StorageOutRowsInRows)(PersistentCriteriaEvaluationBehavior.InTransaction, _onew.Session, CriteriaOperator.Parse("StorageOutRows=?", _StorageOutRows)) For Each _StorageOutRowsInRows In _StorageOutRowsInRows_Collection If _StorageOutRowsInRows.QTT > 0 Then Dim _StorageMoveEvents_Collection As New XPCollection(Of StorageMoveEvents)(PersistentCriteriaEvaluationBehavior.InTransaction, _onew.Session, CriteriaOperator.Parse("StorageInRows=?", _StorageOutRowsInRows.StorageInRows)) _StorageMoveEvents_Collection.Sorting.Add(New SortProperty("ObjectCreated", DB.SortingDirection.Descending)) _StorageOutRowsInRows.StorageInRows.QTT_Out += _StorageOutRowsInRows.QTT _StorageOutRowsInRows.StorageInRows.QTT_Out_Will -= _StorageOutRowsInRows.QTT Dim _StorageMoveEvents As New StorageMoveEvents(_onew.Session) _StorageMoveEvents.StorageInRows = _StorageOutRowsInRows.StorageInRows _StorageMoveEvents.StorageOutRows = _StorageOutRowsInRows.StorageOutRows If _StorageMoveEvents_Collection.Count > 0 Then _StorageMoveEvents.QTT_Free_Before = _StorageMoveEvents_Collection(0).QTT_Free_After Else _StorageMoveEvents.QTT_Free_Before = 0 End If _StorageMoveEvents.QTT = (-1) * _StorageOutRowsInRows.QTT _StorageMoveEvents.QTT_Free_After = _StorageMoveEvents.QTT_Free_Before + _StorageMoveEvents.QTT _StorageMoveEvents.MoveEventsType = eMoveEventsType.StorageOutFinal _StorageMoveEvents.ExecutionDate = _StorageOutRowsInRows.StorageOutRows.StorageOutHeader.CreateDate End If Next _StorageOutRows.QTT += _StorageOutRows.QTT_Will If _StorageOutRows.OrderInRows IsNot Nothing Then Dim _QTT_WillOrug As Double = _StorageOutRows.QTT_Will Dim _OrderInRows As OrderInRows = _onew.GetObjectByKey(Of OrderInRows)(_StorageOutRows.OrderInRows.Oid) _OrderInRows.QTT_Storaged += _StorageOutRows.QTT_Will _OrderInRows.QTT_Process = 0 End If _StorageComputed = _onew.FindObject(Of StorageComputed)(CriteriaOperator.Parse("Products=? and Storage=?", _StorageOutRows.Products, _StorageOutRows.StorageOutHeader.Storage), True) _StorageComputed.QTTReservedOut -= _StorageOutRows.QTT_Will _StorageOutRows.QTT_Will = 0 Next _StorageOutHeader.IsEditable = False _StorageOutHeader.IsFinalized = True '--==Szállítólevél==-- '____________________________________________________________________________________________________________________ Dim _DeliveryNoteOutHeader As New DeliveryNoteOutHeader(_onew.Session) With _DeliveryNoteOutHeader .CurrencyName = _onew.GetObject(_ORI_Invoice_Popup.CurrencyName) .Customers = _onew.GetObject(_ORI_Invoice_Popup.Customers) .CustomersFrom = _onew.GetObject(_ORI_Invoice_Popup.CustomersFrom) .DateCreated = GetSQLTime(_onew.Session) .DateExecution = _onew.GetObject(_ORI_Invoice_Popup.DateExecution) .Note = _onew.GetObject(_ORI_Invoice_Popup.Description) .QualityOption = _onew.GetObject(_ORI_Invoice_Popup.QualityOption) .ShipmentOption = _onew.GetObject(_ORI_Invoice_Popup.ShipmentOption) .TransportAddress = _onew.GetObject(_ORI_Invoice_Popup.TransportAddress) .DeliveryNoteOutType = _onew.GetObject(_ORI_Invoice_Popup.DeliveryNoteOutType) End With For Each _StorageOutRows As StorageOutRows In _StorageOutHeader.StorageOutRows Dim _StorageOutRowsInRows_Collection As New XPCollection(Of StorageOutRowsInRows)(PersistentCriteriaEvaluationBehavior.InTransaction, _onew.Session, CriteriaOperator.Parse("StorageOutRows=?", _StorageOutRows)) For Each _StorageOutRowsInRows As StorageOutRowsInRows In _StorageOutRowsInRows_Collection Dim _DeliveryNoteOutRows As New DeliveryNoteOutRows(_onew.Session) With _DeliveryNoteOutRows .DeliveryNoteOutHeader = _DeliveryNoteOutHeader .RowIndex = _DeliveryNoteOutHeader.DeliveryNoteOutRows.Count .QTT = _StorageOutRowsInRows.QTT .StorageOutRowsInRows = _StorageOutRowsInRows End With Dim _QTT_Will_Orig = _StorageOutRowsInRows.QTT _StorageOutRowsInRows.QTT_To_DeliveryOut += _QTT_Will_Orig _StorageOutRowsInRows.QTT_Will = 0 Dim _OrderInRows As OrderInRows = _onew.GetObjectByKey(Of OrderInRows)(_StorageOutRowsInRows.StorageOutRows.OrderInRows.Oid) _OrderInRows.QTT_DeliveryNoted += _QTT_Will_Orig Next Next '--==Szállítólevél véglegesítés==-- '____________________________________________________________________________________________________________________ 'For Each _DeliveryNoteOutRows As DeliveryNoteOutRows In _DeliveryNoteOutHeader.DeliveryNoteOutRows ' _DeliveryNoteOutRows.StorageOutRowsInRows.StorageOutRows.OrderInRows.QTT_DeliveryNoted += _DeliveryNoteOutRows.QTT 'Next _DeliveryNoteOutHeader.IsEditable = False '--==Számla==-- '____________________________________________________________________________________________________________________ Dim _InvoiceHeader As New InvoiceHeader(_onew.Session) With _InvoiceHeader .InvoiceType = _onew.GetObjectByKey(Of InvoiceType)(_ORI_Invoice_Popup.InvoiceType.Oid) .CustomersFrom = _onew.GetObjectByKey(Of CustomersFrom)(_ORI_Invoice_Popup.CustomersFrom.Oid) .Customers = _onew.GetObjectByKey(Of Customers)(_ORI_Invoice_Popup.Customers.Oid) .DateCreated = _ORI_Invoice_Popup.DateCreated .DateExecution = _ORI_Invoice_Popup.DateExecution .PaymentOption = _onew.GetObjectByKey(Of PaymentOption)(_ORI_Invoice_Popup.PaymentOption.Oid) .DatePaymentMode = .PaymentOption.DatePaymentMode 'Javítva lett .ShipmentOption = _onew.GetObjectByKey(Of ShipmentOption)(_ORI_Invoice_Popup.ShipmentOption.Oid) .CurrencyName = _onew.GetObjectByKey(Of CurrencyName)(_ORI_Invoice_Popup.CurrencyName.Oid) If .PaymentOption.PayMode = ePayMode.InCash Then Else .BankInformation = _onew.GetObjectByKey(Of BankInformation)(_ORI_Invoice_Popup.BankInformation.Oid) End If .Description = _ORI_Invoice_Popup.Description InvoiceHeaderSavedSettings(_InvoiceHeader) If .PaymentOption.PayMode = ePayMode.InContinuous Then .DatePayment = _InvoiceHeader.DateExecution Else If _ORI_Invoice_Popup.IsAPCSheet Then .DatePayment = _ORI_Invoice_Popup.DatePayment Else If .PaymentOption.DatePaymentMode = eDatePaymentMode.eDateCreated Then .DatePayment = _InvoiceHeader.DateCreated.AddDays(_InvoiceHeader.PaymentOption.PayDay) Else .DatePayment = _InvoiceHeader.DateExecution.AddDays(_InvoiceHeader.PaymentOption.PayDay) End If End If End If If .InvoiceType.NumberGeneratorProforma IsNot Nothing Then _InvoiceHeader.DocumentNumberProforma = _InvoiceHeader.InvoiceType.NumberGeneratorProforma.GetNewNumber(_InvoiceHeader.InvoiceType.NumberGeneratorProforma) End If If .CurrencyName.ShortName <> "HUF" Then .CurrencyRate = _ORI_Invoice_Popup.CurrencyRate End If End With '--==Végszámla / Proforma számal ==-- '____________________________________________________________________________________________________________________ If _ORI_Invoice_Popup.IsFinalInvoice Then _InvoiceHeader.IsEditable = False _InvoiceHeader.IsProforma = False _InvoiceHeader.IsStorno = False _InvoiceHeader.ConnectInfo = _InvoiceHeader.InvoiceType.NumberGenerator.GetNewNumber(_InvoiceHeader.InvoiceType.NumberGenerator) _InvoiceHeader.DocumentNumber = _InvoiceHeader.ConnectInfo If _ORI_Invoice_Popup.PaymentOption.PayMode = ePayMode.InCash Then If _ORI_Invoice_Popup.IsLiquidAssets Then End If End If Else _InvoiceHeader.IsEditable = False _InvoiceHeader.IsProforma = True _InvoiceHeader.IsStorno = False _InvoiceHeader.ConnectInfo = _InvoiceHeader.InvoiceType.NumberGeneratorProforma.GetNewNumber(_InvoiceHeader.InvoiceType.NumberGeneratorProforma) End If For Each _DeliveryNoteOutRows As DeliveryNoteOutRows In _DeliveryNoteOutHeader.DeliveryNoteOutRows Dim _InvoiceRows As New InvoiceRows(_onew.Session) With _InvoiceRows .InvoiceHeader = _InvoiceHeader .RowIndex = _InvoiceHeader.InvoiceRows.Count .OrderInRows = _onew.GetObject(_DeliveryNoteOutRows.StorageOutRowsInRows.StorageOutRows.OrderInRows) .InvoiceRowtype = eInvoiceRowType.FromOrder .DiscountPriceDEV = _DeliveryNoteOutRows.StorageOutRowsInRows.StorageOutRows.OrderInRows.DiscountPriceDEV .DiscountPriceHUF = _DeliveryNoteOutRows.StorageOutRowsInRows.StorageOutRows.OrderInRows.DiscountPriceHUF .ListPriceDEV = _DeliveryNoteOutRows.StorageOutRowsInRows.StorageOutRows.OrderInRows.ListPriceDEV .ListPriceHUF = _DeliveryNoteOutRows.StorageOutRowsInRows.StorageOutRows.OrderInRows.ListPriceHUF .QTT = _DeliveryNoteOutRows.QTT .QualityOption = _onew.GetObject(_DeliveryNoteOutRows.StorageOutRowsInRows.StorageOutRows.OrderInRows.QualityOption) .ShortName = _DeliveryNoteOutRows.StorageOutRowsInRows.StorageOutRows.OrderInRows.Products.ShortName '_DeliveryNoteOutRows.StorageOutRowsInRows.StorageOutRows.OrderInRows.Products.ProductNumber(+vbNewLine + _ ' _DeliveryNoteOutRows.StorageOutRowsInRows.StorageOutRows.OrderInRows.Products.ShortName) .Units = _onew.GetObject(_DeliveryNoteOutRows.StorageOutRowsInRows.StorageOutRows.OrderInRows.Products.Units) .VAT = _onew.GetObject(_DeliveryNoteOutRows.StorageOutRowsInRows.StorageOutRows.OrderInRows.VAT) .Description = _DeliveryNoteOutRows.StorageOutRowsInRows.StorageOutRows.OrderInRows.Description .CustomsTariffs = _onew.GetObject(_DeliveryNoteOutRows.StorageOutRowsInRows.StorageOutRows.OrderInRows.Products.CustomsTariff) .DeliveryNoteOutRows = _onew.GetObject(_DeliveryNoteOutRows) End With Dim _QTT_Will_Orig As Double = _DeliveryNoteOutRows.QTT _DeliveryNoteOutRows = _DeliveryNoteOutRows _DeliveryNoteOutRows.QTT_Invoiced += _QTT_Will_Orig _DeliveryNoteOutRows.QTT_Will = 0 Dim _OrderInRows As OrderInRows = _onew.GetObject(_DeliveryNoteOutRows.StorageOutRowsInRows.StorageOutRows.OrderInRows) _OrderInRows.QTT_Invoiced += _QTT_Will_Orig Next If _OrderInHeader.OrderInRowsOther.Count > 0 Then For Each _OrderInRowsOther As OrderInRowsOther In _OrderInHeader.OrderInRowsOther Dim _InvoiceRows As New InvoiceRows(_onew.Session) With _InvoiceRows .InvoiceHeader = _InvoiceHeader .OrderInRowsOther = _OrderInRowsOther .QTT = _OrderInRowsOther.QTT_Process _OrderInRowsOther.QTT_Invoiced += _OrderInRowsOther.QTT_Process If _InvoiceHeader.CurrencyName.ShortName = "HUF" Then .DiscountPriceHUF = _OrderInRowsOther.DiscountPriceHUF .ListPriceHUF = _OrderInRowsOther.ListPriceHUF Else .DiscountPriceDEV = _OrderInRowsOther.DiscountPriceDEV .DiscountPriceHUF = _OrderInRowsOther.DiscountPriceDEV * _ORI_Invoice_Popup.CurrencyRate .ListPriceDEV = _OrderInRowsOther.ListPriceDEV .ListPriceHUF = _OrderInRowsOther.ListPriceDEV * _ORI_Invoice_Popup.CurrencyRate End If .InvoiceRowtype = eInvoiceRowType.FromOrder .VAT = _OrderInRowsOther.VAT .Units = _OrderInRowsOther.Units .UniqueObjects = _OrderInRowsOther.UniqueObjects .CostHolder = _OrderInRowsOther.CostHolder .CostPlace = _OrderInRowsOther.CostPlace .QualityOption = _OrderInRowsOther.QualityOption .Description = _OrderInRowsOther.Description .ShortName = _OrderInRowsOther.ShortName .CustomsTariffs = _OrderInRowsOther.CustomsTariffs .RowIndex = _InvoiceHeader.InvoiceRows.Count End With Next End If _onew.CommitChanges() _InvoiceHeader.RecalculateInvoice(_InvoiceHeader, _onew) _onew.CommitChanges() If _ORI_Invoice_Popup.IsLiquidAssets AndAlso _ORI_Invoice_Popup.PaymentOption.PayMode = ePayMode.InCash And _ORI_Invoice_Popup.IsFinalInvoice Then CreateGLCassa(_InvoiceHeader, _onew, _ORI_Invoice_Popup) End If Application.ShowViewStrategy.ShowMessage("Sikeres tranzakció !", InformationType.Success, 3000, InformationPosition.Bottom) Frame.GetController(Of RefreshController).RefreshAction.DoExecute() '--==Nyomtatványok==-- ''____________________________________________________________________________________________________________________ 'Dim _XAFPrintHelper_D As New XAFPrintHelper(_onew, Frame, _DeliveryNoteOutHeader.DeliveryNoteOutType.ReportDataV2, CriteriaOperator.Parse("DeliveryNoteOutHeader.Oid = ?", _DeliveryNoteOutHeader.Oid)) '_XAFPrintHelper_D.ShowPreviewV2() 'Dim _XAFPrintHelper_I As New XAFPrintHelper(_onew, Frame, _InvoiceHeader.InvoiceType.ReportDataV2, CriteriaOperator.Parse("InvoiceHeader.Oid = ?", _InvoiceHeader.Oid)) '_XAFPrintHelper_I.ShowPreviewV2() 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 CreateGLCassa(_InvoiceHeader As InvoiceHeader, _onew As Xpo.XPObjectSpace, _ORI_Invoice_Popup As ORI_Invoice_Popup) '--== Végszámla esetére pénztári bizonylat ==-- If _InvoiceHeader.CurrencyName.ShortName = "HUF" Then Dim _DebitChartOfAccounts As ChartOfAccounts Dim _CreditChartOfAccounts As ChartOfAccounts Dim _GLCassa As GLCassa = _onew.CreateObject(Of GLCassa) Dim _GLRows As GLRows = _onew.CreateObject(Of GLRows) If _InvoiceHeader.TotalBruttoHUF > 0 Then _GLCassa.LiquidAssets_Cassa = _onew.GetObject(_ORI_Invoice_Popup.LiquidAssets) _GLCassa.CashHandler = _InvoiceHeader.Customers.FullName _GLCassa.CashMoveType = eCashMoveType.eIn _GLCassa.CurrencyName = _onew.GetObject(_InvoiceHeader.CurrencyName) _GLCassa.CurrencyRate = 1 _GLCassa.CustomersFrom = _onew.GetObject(_InvoiceHeader.CustomersFrom) _GLCassa.DateCreated = _InvoiceHeader.DateCreated _GLCassa.DateExecution = _InvoiceHeader.DateCreated _GLCassa.DatePayment = _InvoiceHeader.DatePayment _GLCassa.DocumentNumber = _GLCassa.LiquidAssets_Cassa.NumberGeneratorOut.GetNewNumber(_GLCassa.LiquidAssets_Cassa.NumberGeneratorIn, _InvoiceHeader.DateCreated.Year.ToString) _GLCassa.GLDocumentType = eGLDocumentType.eGLCassa _GLCassa.HUNumberToText = _InvoiceHeader.HUNumberToText _GLCassa.IsEditable = False _GLRows.InAmountHUF = _InvoiceHeader.TotalBruttoHUF _GLRows.InAmountDEV = 0 _GLRows.InAmountDEV2 = 0 _GLRows.CurrencyRate2 = 1 _DebitChartOfAccounts = _onew.GetObject(_ORI_Invoice_Popup.LiquidAssets.GetChartOfAccounts(_InvoiceHeader.DateExecution.Year, 0)) _CreditChartOfAccounts = _onew.GetObject(_InvoiceHeader.Customers.CustomersGLParameters.GetChartOfAccounts(_InvoiceHeader.DateExecution.Year, eVATMode.eOut)) _GLRows.CreditAmountHUF = _InvoiceHeader.TotalBruttoHUF _GLRows.CreditAmountDEV = 0 _GLRows.DebitAmountHUF = 0 _GLRows.DebitAmountDEV = 0 _GLRows.DateVAT = _InvoiceHeader.DateCreated _GLRows.AddGLRows(_GLCassa, _DebitChartOfAccounts, _CreditChartOfAccounts, 0, _InvoiceHeader.TotalBruttoHUF, _onew.GetObject(_ORI_Invoice_Popup.LiquidAssets), _onew.GetObject(_InvoiceHeader.Customers), _InvoiceHeader.DateExecution, Nothing, "", Nothing, Nothing, Nothing, Nothing, Nothing, _InvoiceHeader.DocumentNumber, Nothing, Guid.NewGuid, eTransactionType.ePartnerCredit, eCashType.ePartner, ePartnerType.eReceivables) _onew.CommitChanges() _GLCassa.RecalculateTotal(_GLCassa, _onew, True) _GLCassa.CreateRoundingRow(_GLCassa, _onew) _GLCassa.RecalculateTotal(_GLCassa, _onew, True) _onew.CommitChanges() If _GLCassa.LiquidAssets_Cassa.ReportData IsNot Nothing Then Frame.GetController(Of Reports.ReportServiceController).ShowPreview(_GLCassa.LiquidAssets_Cassa.ReportData, CriteriaOperator.Parse("GLHeader.Oid=?", _GLCassa.Oid), True) End If ElseIf _InvoiceHeader.TotalBruttoHUF < 0 Then _GLCassa.LiquidAssets_Cassa = _onew.GetObject(_ORI_Invoice_Popup.LiquidAssets) _GLCassa.CashHandler = _InvoiceHeader.Customers.FullName _GLCassa.CashMoveType = eCashMoveType.eOut _GLCassa.CurrencyName = _onew.GetObject(_InvoiceHeader.CurrencyName) _GLCassa.CurrencyRate = 1 _GLCassa.CustomersFrom = _onew.GetObject(_InvoiceHeader.CustomersFrom) _GLCassa.DateCreated = _InvoiceHeader.DateCreated _GLCassa.DateExecution = _InvoiceHeader.DateCreated _GLCassa.DatePayment = _InvoiceHeader.DatePayment _GLCassa.DocumentNumber = _GLCassa.LiquidAssets_Cassa.NumberGeneratorOut.GetNewNumber(_GLCassa.LiquidAssets_Cassa.NumberGeneratorOut, _InvoiceHeader.DateCreated.Year.ToString) _GLCassa.GLDocumentType = eGLDocumentType.eGLCassa _GLCassa.HUNumberToText = _InvoiceHeader.HUNumberToText _GLCassa.IsEditable = False _GLRows.OutAmountHUF = Math.Abs(_InvoiceHeader.TotalBruttoHUF) _GLRows.OutAmountDEV = 0 _GLRows.OutAmountDEV2 = 0 _GLRows.CurrencyRate2 = 1 _CreditChartOfAccounts = _onew.GetObject(_ORI_Invoice_Popup.LiquidAssets.GetChartOfAccounts(_InvoiceHeader.DateExecution.Year, 0)) _DebitChartOfAccounts = _onew.GetObject(_InvoiceHeader.Customers.CustomersGLParameters.GetChartOfAccounts(_InvoiceHeader.DateExecution.Year, eVATMode.eOut)) _GLRows.CreditAmountHUF = 0 _GLRows.CreditAmountDEV = 0 _GLRows.DebitAmountHUF = Math.Abs(_InvoiceHeader.TotalBruttoHUF) _GLRows.DebitAmountDEV = 0 _GLRows.DateVAT = _InvoiceHeader.DateCreated _GLRows.AddGLRows(_GLCassa, _DebitChartOfAccounts, _CreditChartOfAccounts, 0, Math.Abs(_InvoiceHeader.TotalBruttoHUF), _onew.GetObject(_ORI_Invoice_Popup.LiquidAssets), _onew.GetObject(_InvoiceHeader.Customers), _InvoiceHeader.DateExecution, Nothing, "", Nothing, Nothing, Nothing, Nothing, Nothing, _InvoiceHeader.DocumentNumber, Nothing, Guid.NewGuid, eTransactionType.ePartnerDebit, eCashType.ePartner, ePartnerType.eReceivables) _onew.CommitChanges() _GLCassa.RecalculateTotal(_GLCassa, _onew, True) _GLCassa.CreateRoundingRow(_GLCassa, _onew) _GLCassa.RecalculateTotal(_GLCassa, _onew, True) _onew.CommitChanges() If _GLCassa.LiquidAssets_Cassa.ReportData IsNot Nothing Then Frame.GetController(Of Reports.ReportServiceController).ShowPreview(_GLCassa.LiquidAssets_Cassa.ReportData, CriteriaOperator.Parse("GLHeader.Oid=?", _GLCassa.Oid), True) End If End If End If Dim _uow As New UnitOfWork(_onew.Session.DataLayer) GLFunctions.ReconfigurePCI(_uow, _InvoiceHeader.CustomersFrom, _InvoiceHeader.Customers, 0, _InvoiceHeader.ConnectInfo) End Sub Private Sub aGenerateInvoicefromOrderIn_Execute(sender As System.Object, e As DevExpress.ExpressApp.Actions.PopupWindowShowActionExecuteEventArgs) Handles aGenerateInvoicefromOrderIn.Execute Dim _ocur As Xpo.XPObjectSpace = TryCast(View.ObjectSpace, Xpo.XPObjectSpace) Dim _InvoiceHeader As InvoiceHeader = _ocur.CreateObject(Of InvoiceHeader)() Dim _OrderInHeader As OrderInHeader = _ocur.GetObject(TryCast(View.SelectedObjects(0), OrderInHeader)) Dim _CurrencyRate As Double = _ocur.GetObject(TryCast(e.PopupWindow.View.SelectedObjects(0), ORI_Invoice_Popup).CurrencyRate) Dim _NG As NumberGenerator On Error GoTo CheckError ' --- Ellenőrzés, hogy kell-e engedély ! -------------------------------------------------------------------------------------------------- If _ocur.GetObject(TryCast(e.PopupWindow.View.SelectedObjects(0), ORI_Invoice_Popup).PaymentOption).PayMode <> ePayMode.InCash Then If _OrderInHeader.SubjectToApproval(_OrderInHeader, _ocur) And _OrderInHeader.PermissionAllowed = False Then MsgBox(String.Format(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions\OrderInHeader", "PermissionNotAllowedToCreateInvoice")), MsgBoxStyle.Exclamation + MsgBoxStyle.OkOnly, String.Format(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions", "MsgBoxCheckItAgain"))) Exit Sub End If End If ' ---- FEJLÉC ADATOK MEGADÁSA ------------------------------------------------------------------------------------------------------------- _InvoiceHeader.IsProforma = True _InvoiceHeader.IsEditable = False _InvoiceHeader.CustomersFrom = _OrderInHeader.CustomersFrom _InvoiceHeader.Customers = _OrderInHeader.Customers _InvoiceHeader.InvoiceType = _OrderInHeader.OrderInParameters.InvoiceType If _InvoiceHeader.InvoiceType.NumberGeneratorProforma IsNot Nothing Then _NG = _InvoiceHeader.InvoiceType.NumberGeneratorProforma _InvoiceHeader.DocumentNumberProforma = _NG.GetNewNumber(_NG) End If _InvoiceHeader.DateCreated = _ocur.GetObject(TryCast(e.PopupWindow.View.SelectedObjects(0), ORI_Invoice_Popup).DateCreated) _InvoiceHeader.DateExecution = _ocur.GetObject(TryCast(e.PopupWindow.View.SelectedObjects(0), ORI_Invoice_Popup).DateExecution) _InvoiceHeader.Description = _ocur.GetObject(TryCast(e.PopupWindow.View.SelectedObjects(0), ORI_Invoice_Popup).Description) _InvoiceHeader.DescriptionHeader = _ocur.GetObject(TryCast(e.PopupWindow.View.SelectedObjects(0), ORI_Invoice_Popup).Description_Header) _InvoiceHeader.BankInformation = _ocur.GetObject(TryCast(e.PopupWindow.View.SelectedObjects(0), ORI_Invoice_Popup).BankInformation) _InvoiceHeader.CurrencyName = _ocur.GetObject(TryCast(e.PopupWindow.View.SelectedObjects(0), ORI_Invoice_Popup).CurrencyName) _InvoiceHeader.CurrencyRate = _ocur.GetObject(TryCast(e.PopupWindow.View.SelectedObjects(0), ORI_Invoice_Popup).CurrencyRate) _InvoiceHeader.PaymentOption = _ocur.GetObject(TryCast(e.PopupWindow.View.SelectedObjects(0), ORI_Invoice_Popup).PaymentOption) _InvoiceHeader.DatePaymentMode = _InvoiceHeader.PaymentOption.DatePaymentMode 'Javítva lett If _InvoiceHeader.PaymentOption.DatePaymentMode = eDatePaymentMode.eDateCreated Then _InvoiceHeader.DatePayment = _InvoiceHeader.DateCreated.AddDays(_InvoiceHeader.PaymentOption.PayDay) Else _InvoiceHeader.DatePayment = _InvoiceHeader.DateExecution.AddDays(_InvoiceHeader.PaymentOption.PayDay) End If If _OrderInHeader.OrderInParameters.IsAPCSheet Then _InvoiceHeader.DatePayment = _ocur.GetObject(TryCast(e.PopupWindow.View.SelectedObjects(0), ORI_Invoice_Popup).DatePayment) '-- Próbaszámla miatt el kell menteni a tényleges adatokat -------------------------------------------------------- _InvoiceHeader.Saved_Customers_Name = _OrderInHeader.Customers.Name.ToString _InvoiceHeader.Saved_Customers_Address_Country = _OrderInHeader.Customers.Address1.Country.ToString _InvoiceHeader.Saved_Customers_Address_ZipPostal = _OrderInHeader.Customers.Address1.ZipPostal.ToString _InvoiceHeader.Saved_Customers_Address_Street = _OrderInHeader.Customers.Address1.Street.ToString _InvoiceHeader.Saved_Customers_Address_City = _OrderInHeader.Customers.Address1.City.ToString _InvoiceHeader.Saved_Customers_Address_StateProvince = _OrderInHeader.Customers.Address1.StateProvince.ToString _InvoiceHeader.Saved_Customers_VATNumber = _OrderInHeader.Customers.VATNumber.ToString _InvoiceHeader.Saved_Customers_VATNumberEU = _OrderInHeader.Customers.VATNumberEU.ToString _InvoiceHeader.Saved_CustomersFrom_Name = _OrderInHeader.CustomersFrom.Name.ToString _InvoiceHeader.Saved_CustomersFrom_Address_ZipPostal = _OrderInHeader.CustomersFrom.Address1.ZipPostal.ToString _InvoiceHeader.Saved_CustomersFrom_Address_Street = _OrderInHeader.CustomersFrom.Address1.Street.ToString _InvoiceHeader.Saved_CustomersFrom_Address_City = _OrderInHeader.CustomersFrom.Address1.City.ToString _InvoiceHeader.Saved_CustomersFrom_Address_StateProvince = _OrderInHeader.CustomersFrom.Address1.StateProvince.ToString _InvoiceHeader.Saved_CustomersFrom_VATNumber = _OrderInHeader.CustomersFrom.VATNumber.ToString _InvoiceHeader.Saved_CustomersFrom_VATNumberEU = _OrderInHeader.CustomersFrom.VATNumberEU.ToString _InvoiceHeader.Saved_CustomersFrom_Bank_ShortName = _InvoiceHeader.BankInformation.FullBankAccount.ToString _InvoiceHeader.Saved_CustomersFrom_Bank_IBAN = _InvoiceHeader.BankInformation.IBAN.ToString _InvoiceHeader.Saved_CustomersFrom_Bank_SWIFT = _InvoiceHeader.BankInformation.SWIFT.ToString _InvoiceHeader.Saved_CustomersFrom_Bank_AccountNumber = _InvoiceHeader.BankInformation.AccountNumber.ToString _InvoiceHeader.Save() ' ---- FEJLÉC ADATOK MEGADÁSÁNAK VÉGE ---------------------------------------------------------------------------------------------------- '------ A fejléchez tartozó sorok (termék és egyéb típusok) rendezése sorindex alapján --------------- _OrderInHeader.OrderInRows.Sorting.Add(New SortProperty("RowIndex", DB.SortingDirection.Ascending)) _OrderInHeader.OrderInRowsOther.Sorting.Add(New SortProperty("RowIndex", DB.SortingDirection.Ascending)) '----------------------------------------------------------------------------------------------------- ' A fejléchez tartozó sorok átadása ----------------------------------------------------------------- Dim _InvoiceRows As InvoiceRows Dim _OrderInRows As OrderInRows Dim _OrderInRowsOther As OrderInRowsOther Dim i As Int16 = 0 '----------------------------- Átadjuk az összes termék típusú sort -------------------------------------- For Each _OrderInRows In _OrderInHeader.OrderInRows If _OrderInRows.QTT_Process > 0 Then If _OrderInRows.QTT - (_OrderInRows.QTT_Process + _OrderInRows.QTT_Invoiced) >= 0 Then _InvoiceRows = _ocur.CreateObject(Of InvoiceRows)() _InvoiceRows.InvoiceHeader = _InvoiceHeader _InvoiceRows.OrderInRows = _OrderInRows _InvoiceRows.QTT = _OrderInRows.QTT_Process _OrderInRows.QTT_Invoiced += _OrderInRows.QTT_Process If _InvoiceHeader.CurrencyName.ShortName = "HUF" Then _InvoiceRows.DiscountPriceHUF = _OrderInRows.DiscountPriceHUF _InvoiceRows.ListPriceHUF = _OrderInRows.ListPriceHUF Else _InvoiceRows.DiscountPriceDEV = _OrderInRows.DiscountPriceDEV _InvoiceRows.DiscountPriceHUF = _OrderInRows.DiscountPriceDEV * _CurrencyRate ' A kerekítést még meg kell beszélni _InvoiceRows.ListPriceDEV = _OrderInRows.ListPriceDEV _InvoiceRows.ListPriceHUF = _OrderInRows.ListPriceDEV * _CurrencyRate ' A kerekítést még meg kell beszélni End If _InvoiceRows.InvoiceRowtype = eInvoiceRowType.FromOrder _InvoiceRows.VAT = _OrderInRows.VAT _InvoiceRows.Units = _OrderInRows.Products.Units _InvoiceRows.ShortName = _OrderInRows.Products.ShortName _InvoiceRows.Description = _OrderInRows.Products.Description _InvoiceRows.CustomsTariffs = _OrderInRows.Products.CustomsTariff If _OrderInHeader.OrderInParameters IsNot Nothing Then If _OrderInHeader.OrderInParameters.Controlling_Rows_Default IsNot Nothing Then _InvoiceRows.Controlling = _OrderInHeader.OrderInParameters.Controlling_Rows_Default End If End If _InvoiceRows.RowIndex = i i += 1 End If End If Next '----------------------------- Átadjuk az összes egyéb típusú sort -------------------------------------- For Each _OrderInRowsOther In _OrderInHeader.OrderInRowsOther If _OrderInRowsOther.QTT_Process <> 0 Then If _OrderInRowsOther.QTT - (_OrderInRowsOther.QTT_Process + _OrderInRowsOther.QTT_Invoiced) >= 0 Then _InvoiceRows = _ocur.CreateObject(Of InvoiceRows)() _InvoiceRows.InvoiceHeader = _InvoiceHeader _InvoiceRows.OrderInRowsOther = _OrderInRowsOther _InvoiceRows.QTT = _OrderInRowsOther.QTT_Process _OrderInRowsOther.QTT_Invoiced += _OrderInRowsOther.QTT_Process If _InvoiceHeader.CurrencyName.ShortName = "HUF" Then _InvoiceRows.DiscountPriceHUF = _OrderInRowsOther.DiscountPriceHUF _InvoiceRows.ListPriceHUF = _OrderInRowsOther.ListPriceHUF Else _InvoiceRows.DiscountPriceDEV = _OrderInRowsOther.DiscountPriceDEV _InvoiceRows.DiscountPriceHUF = _OrderInRowsOther.DiscountPriceDEV * _CurrencyRate ' A kerekítést még meg kell beszélni _InvoiceRows.ListPriceDEV = _OrderInRowsOther.ListPriceDEV _InvoiceRows.ListPriceHUF = _OrderInRowsOther.ListPriceDEV * _CurrencyRate ' A kerekítést még meg kell beszélni End If _InvoiceRows.InvoiceRowtype = eInvoiceRowType.FromOrder _InvoiceRows.VAT = _OrderInRowsOther.VAT _InvoiceRows.Units = _OrderInRowsOther.Units _InvoiceRows.UniqueObjects = _OrderInRowsOther.UniqueObjects _InvoiceRows.CostHolder = _OrderInRowsOther.CostHolder _InvoiceRows.CostPlace = _OrderInRowsOther.CostPlace _InvoiceRows.QualityOption = _OrderInRowsOther.QualityOption _InvoiceRows.Description = _OrderInRowsOther.Description _InvoiceRows.ShortName = _OrderInRowsOther.ShortName _InvoiceRows.CustomsTariffs = _OrderInRowsOther.CustomsTariffs If _OrderInHeader.OrderInParameters IsNot Nothing Then If _OrderInHeader.OrderInParameters.Controlling_OtherRows_Default IsNot Nothing Then _InvoiceRows.Controlling = _OrderInHeader.OrderInParameters.Controlling_OtherRows_Default End If End If _InvoiceRows.RowIndex = i i += 1 End If End If Next If _OrderInHeader.OrderInRows.Count = 0 And _OrderInHeader.OrderInRowsOther.Count = 0 Then ' --------------------- TESZT MIATT!!! ------------------------------------------------------------------------------------ Throw New UserFriendlyException("Nincs egy sor sem a kiválasztott bejövő megrendelés fejlécén, így nem készül el a számla!") End If _ocur.CommitChanges() _InvoiceHeader.RecalculateInvoice(_InvoiceHeader, _ocur) _ocur.CommitChanges() Exit Sub CheckError: If Err.Number = 91 Then Resume Next If Err.Number = 13 Then Resume Next If Err.Number = 5 Then Throw New UserFriendlyException(Err.Description) End Sub #End Region #Region "Kitárolások fül" Private Sub aORI_Storno_StorageOut_Execute(sender As Object, e As SimpleActionExecuteEventArgs) Handles aORI_Storno_StorageOut.Execute '// Kitárolás stornó 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 _OrderInHeader As OrderInHeader = _onew.GetObject(TryCast(View.SelectedObjects(0), OrderInHeader)) If _OrderInHeader Is Nothing Then Throw New Exception("*Váratlan hiba történt, a folyamat megszakadt!") Dim _StorageOutRowsInRows_ListEditor As ListPropertyEditor = TryCast(View, DetailView).FindItem("StorageOutRowsInRows") If _StorageOutRowsInRows_ListEditor Is Nothing Then Throw New Exception("*Váratlan hiba történt, a folyamat megszakadt!") If _StorageOutRowsInRows_ListEditor.ListView.SelectedObjects.Count = 0 Then Throw New Exception("*nincs kijelölve egyetlen kitárolási sor sem!") Dim _StorageOutRowsInRowsError As New ArrayList For Each _StorageOutRowsInRows As StorageOutRowsInRows In _StorageOutRowsInRows_ListEditor.ListView.SelectedObjects If _StorageOutRowsInRows.QTT_To_DeliveryOut > 0 Then _StorageOutRowsInRowsError.Add(_StorageOutRowsInRows) If _StorageOutRowsInRows.StorageOutRows.StorageOutHeader.IsStorno = True Then _StorageOutRowsInRowsError.Add(_StorageOutRowsInRows) Next If _StorageOutRowsInRowsError.Count > 0 Then Dim _ErrorMessage As String = "Probléma merült fel a következő kitárolásokkal:" + vbNewLine For Each _StorageOutRowsInRows As StorageOutRowsInRows In _StorageOutRowsInRowsError _ErrorMessage += _StorageOutRowsInRows.StorageOutRows.RowIndex.ToString + " " + _StorageOutRowsInRows.StorageOutRows.Products.ShortName _ + " " + _StorageOutRowsInRows.StorageOutRows.QTT.ToString + vbNewLine Next _ErrorMessage += "Kérem, ellenőrizze!" Throw New Exception(_ErrorMessage) End If ' Kitárolás fejléc kollekció '__________________________________________________________________________ Dim _StorageOutHeader_Collection As New ArrayList For Each _StorageOutRowsInRows As StorageOutRowsInRows In _StorageOutRowsInRows_ListEditor.ListView.SelectedObjects If _StorageOutHeader_Collection.Count = 0 Then _StorageOutHeader_Collection.Add(_StorageOutRowsInRows.StorageOutRows.StorageOutHeader) Else Dim _IsNeed As Boolean = True For Each _StorageOutHeader As StorageOutHeader In _StorageOutHeader_Collection If _StorageOutHeader.Oid = _StorageOutRowsInRows.StorageOutRows.StorageOutHeader.Oid Then _IsNeed = False Next If _IsNeed Then _StorageOutHeader_Collection.Add(_StorageOutRowsInRows.StorageOutRows.StorageOutHeader) End If Next ' Kitárolás(ok) stornózása '__________________________________________________________________________ If _StorageOutHeader_Collection.Count > 0 Then ' 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 For Each _StorageOutHeader As StorageOutHeader In _StorageOutHeader_Collection Dim _StorageOutHeaderNew As New StorageOutHeader(_onew.Session) With _StorageOutHeaderNew .ConnectInfo = _StorageOutHeader.DocumentNumber .Storage = _onew.GetObject(_StorageOutHeader.Storage) .StorageMoveType = _onew.GetObject(_StorageOutHeader.StorageMoveType) .CustomersFrom = _onew.GetObject(_StorageOutHeader.CustomersFrom) .Customers = _onew.GetObject(_StorageOutHeader.Customers) .Active = False .IsStorno = True .IsEditable = False End With _StorageOutHeader = _onew.GetObject(_StorageOutHeader) _StorageOutHeader.IsEditable = False _StorageOutHeader.IsStorno = True _StorageOutHeader.Active = False For Each _StorageOutRows As StorageOutRows In _StorageOutHeader.StorageOutRows Dim _StorageOutRowsNew As New StorageOutRows(_onew.Session) With _StorageOutRowsNew .RowIndex = _StorageOutRows.RowIndex .StorageOutHeader = _StorageOutHeaderNew .StorageComputed = _onew.GetObject(_StorageOutRows.StorageComputed) .OrderInRows = _onew.GetObject(_StorageOutRows.OrderInRows) .QTT = _StorageOutRows.QTT * (-1) .QTT_Will = 0 .QTT_To_DeliveryOut = 0 .Products = _onew.GetObject(_StorageOutRows.Products) .OnStorno = True End With '----Vissza raktárba + mozgástábla '____________________________________________________ Dim _StorageOutRowsInRows_Collection As New XPCollection(Of StorageOutRowsInRows)(PersistentCriteriaEvaluationBehavior.InTransaction, _onew.Session, CriteriaOperator.Parse("StorageOutRows=?", _onew.GetObject(_StorageOutRows))) For Each _StorageOutRowsInRows As StorageOutRowsInRows In _StorageOutRowsInRows_Collection Dim _StorageComputed As StorageComputed = _onew.FindObject(Of StorageComputed)(CriteriaOperator.Parse("Storage=? AND Products=?", _onew.GetObject(_StorageOutHeader.Storage), _onew.GetObject(_StorageOutRows.Products))) Dim _StorageMoveEvents_Collection As New XPCollection(Of StorageMoveEvents)(_onew.Session, CriteriaOperator.Parse("StorageInRows=? AND StorageOutRows=?", _onew.GetObject(_StorageOutRowsInRows.StorageInRows), _onew.GetObject(_StorageOutRows))) _StorageMoveEvents_Collection.Sorting.Add(New SortProperty("ObjectCreated", DB.SortingDirection.Descending)) _StorageComputed.QTTFree += _StorageOutRowsInRows.QTT Dim _StorageOutRowsInRowsNew As New StorageOutRowsInRows(_onew.Session) With _StorageOutRowsInRowsNew .StorageInRows = _StorageOutRowsInRows.StorageInRows .StorageOutRows = _StorageOutRowsNew .QTT = _StorageOutRowsInRows.QTT * (-1) .QTT_Will = 0 .QTT_To_DeliveryOut = 0 .StorageInRows.QTT_Out -= _StorageOutRowsInRows.QTT End With If _StorageOutRowsInRows.StorageOutRows.OrderInRows IsNot Nothing Then _StorageOutRowsInRows.StorageOutRows.OrderInRows.QTT_Storaged -= _StorageOutRowsInRows.QTT End If Dim _StorageMoveEvents As New StorageMoveEvents(_onew.Session) _StorageMoveEvents.QTT = _StorageOutRowsInRows.QTT _StorageMoveEvents.StorageOutRows = _onew.GetObject(_StorageOutRows) _StorageMoveEvents.StorageInRows = _onew.GetObject(_StorageOutRowsInRows.StorageInRows) _StorageMoveEvents.QTT_Free_Before = _StorageMoveEvents_Collection(0).QTT_Free_After _StorageMoveEvents.QTT_Free_After = _StorageMoveEvents.QTT_Free_Before + _StorageMoveEvents.QTT _StorageMoveEvents.MoveEventsType = eMoveEventsType.StorageOutStorno _StorageMoveEvents.ExecutionDate = GetSQLTime(_onew.Session) _StorageOutRows.QTT = 0 Next Next Next End If 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 aORI_Create_Delivery_Execute(sender As Object, e As PopupWindowShowActionExecuteEventArgs) Handles aORI_Create_Delivery.Execute '// Kitárolásról szállítólevél készítése 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 Dim _OrderInHeader As OrderInHeader = _onew.GetObject(TryCast(View.SelectedObjects(0), OrderInHeader)) If _OrderInHeader Is Nothing Then Throw New Exception("*Váratlan hiba történt, a folyamat megszakadt!") Dim _DeliveryNoteView As DeliveryNoteView = TryCast(e.PopupWindow.View.SelectedObjects(0), DeliveryNoteView) If _DeliveryNoteView Is Nothing Then Throw New Exception("*Váratlan hiba történt, a folyamat megszakadt!") Dim _StorageOutRowsInRows_ListEditor As ListPropertyEditor = TryCast(View, DetailView).FindItem("StorageOutRowsInRows") If _StorageOutRowsInRows_ListEditor Is Nothing Then Throw New Exception("*Váratlan hiba történt, a folyamat megszakadt!") Dim _StorageOutRowsInRows_Collection As New ArrayList For Each _StorageOutRowsInRows As StorageOutRowsInRows In _OrderInHeader.StorageOutRowsInRows If _StorageOutRowsInRows.StorageOutRows.StorageOutHeader.IsStorno = False Then If _StorageOutRowsInRows.QTT_Will > 0 Then If _StorageOutRowsInRows_Collection.Count = 0 Then _StorageOutRowsInRows_Collection.Add(_StorageOutRowsInRows) Else Dim _IsNeed As Boolean = True For Each _StorageOutRowsInRowsInCollection As StorageOutRowsInRows In _StorageOutRowsInRows_Collection If _StorageOutRowsInRows.Oid = _StorageOutRowsInRowsInCollection.Oid Then _IsNeed = False Next If _IsNeed Then _StorageOutRowsInRows_Collection.Add(_StorageOutRowsInRows) End If End If End If Next If _StorageOutRowsInRows_Collection.Count = 0 Then Throw New Exception("*Nincs egyetlen olyan kitárolás sem kijelölve, amelyről kiszállítást lehetne készíteni" + vbNewLine + "Ez abban az esetben fordulhat elő, ha a kiszállítási szándék érétke nulla." + vbNewLine + "Kérem, ellenőrizze!") '--==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 Dim _DeliveryNoteOutHeader As New DeliveryNoteOutHeader(_onew.Session) With _DeliveryNoteOutHeader .CurrencyName = _onew.GetObject(_DeliveryNoteView.CurrencyName) .Customers = _onew.GetObject(_DeliveryNoteView.Customers) .CustomersFrom = _onew.GetObject(_DeliveryNoteView.CustomersFrom) .DateCreated = GetSQLTime(_onew.Session) .DateExecution = _onew.GetObject(_DeliveryNoteView.DateExecution) .Note = _onew.GetObject(_DeliveryNoteView.Note) .QualityOption = _onew.GetObject(_DeliveryNoteView.QualityOption) .ShipmentOption = _onew.GetObject(_DeliveryNoteView.ShipmentOption) .TransportAddress = _onew.GetObject(_DeliveryNoteView.TransportAddress) .DeliveryNoteOutType = _onew.GetObject(_DeliveryNoteView.DeliveryNoteOutType) .IsEditable = False End With For Each _StorageOutRowsInRows As StorageOutRowsInRows In _OrderInHeader.StorageOutRowsInRows If _StorageOutRowsInRows.QTT_Will > 0 Then Dim _DeliveryNoteOutRows As New DeliveryNoteOutRows(_onew.Session) With _DeliveryNoteOutRows .DeliveryNoteOutHeader = _DeliveryNoteOutHeader .RowIndex = _DeliveryNoteOutHeader.DeliveryNoteOutRows.Count .QTT = _StorageOutRowsInRows.QTT_Will .StorageOutRowsInRows = _onew.GetObject(_StorageOutRowsInRows) End With Dim _QTT_Will_Orig As Double = _StorageOutRowsInRows.QTT_Will _StorageOutRowsInRows = _onew.GetObjectByKey(Of StorageOutRowsInRows)(_StorageOutRowsInRows.Oid) _StorageOutRowsInRows.QTT_To_DeliveryOut += _QTT_Will_Orig _StorageOutRowsInRows.QTT_Will = 0 Dim _OrderInRows As OrderInRows = _onew.GetObjectByKey(Of OrderInRows)(_StorageOutRowsInRows.StorageOutRows.OrderInRows.Oid) _OrderInRows.QTT_DeliveryNoted += _QTT_Will_Orig End If Next _onew.CommitChanges() Frame.GetController(Of RefreshController).RefreshAction.DoExecute() 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 aORI_Create_DeliveryInvoice_Execute(sender As Object, e As PopupWindowShowActionExecuteEventArgs) Handles aORI_Create_DeliveryInvoice.Execute '// Kitárolt tételekről szállítólevél és számla Try Dim _onew As Xpo.XPObjectSpace = Application.CreateObjectSpace '--==Ellenőrzések==-- Dim _OrderInHeader As OrderInHeader = _onew.GetObject(TryCast(View.SelectedObjects(0), OrderInHeader)) If _OrderInHeader Is Nothing Then Throw New Exception("*Váratlan hiba történt, a folyamat megszakadt!") Dim _StorageOutRowsInRows_ListEditor As ListPropertyEditor = TryCast(View, DetailView).FindItem("StorageOutRowsInRows") If _StorageOutRowsInRows_ListEditor Is Nothing Then Throw New Exception("*Váratlan hiba történt, a folyamat megszakadt!") If _StorageOutRowsInRows_ListEditor.ListView.SelectedObjects.Count = 0 Then Throw New Exception("*nincs kijelölve egyetlen kitárolási sor sem!") Dim _ORI_Invoice_Popup As ORI_Invoice_Popup = _onew.GetObject(TryCast(e.PopupWindow.View.SelectedObjects(0), ORI_Invoice_Popup)) ' --- Ellenőrzés, hogy kell-e engedély ! -------------------------------------------------------------------------------------------------- If _onew.GetObject(TryCast(e.PopupWindow.View.SelectedObjects(0), ORI_Invoice_Popup).PaymentOption).PayMode <> ePayMode.InCash Then If _OrderInHeader.SubjectToApproval(_OrderInHeader, _onew) And _OrderInHeader.PermissionAllowed = False Then MsgBox(String.Format(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions\OrderInHeader", "PermissionNotAllowedToCreateInvoice")), MsgBoxStyle.Exclamation + MsgBoxStyle.OkOnly, String.Format(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions", "MsgBoxCheckItAgain"))) Exit Sub End If End If Dim _StorageOutRowsInRows_Collection As New ArrayList For Each _StorageOutRowsInRows As StorageOutRowsInRows In _OrderInHeader.StorageOutRowsInRows If _StorageOutRowsInRows.StorageOutRows.StorageOutHeader.IsStorno = False Then If _StorageOutRowsInRows.QTT_Will > 0 Then If _StorageOutRowsInRows_Collection.Count = 0 Then _StorageOutRowsInRows_Collection.Add(_StorageOutRowsInRows) Else Dim _IsNeed As Boolean = True For Each _StorageOutRowsInRowsInCollection As StorageOutRowsInRows In _StorageOutRowsInRows_Collection If _StorageOutRowsInRows.Oid = _StorageOutRowsInRowsInCollection.Oid Then _IsNeed = False Next If _IsNeed Then _StorageOutRowsInRows_Collection.Add(_StorageOutRowsInRows) End If End If End If Next If _StorageOutRowsInRows_Collection.Count = 0 Then Throw New Exception("*Nincs egyetlen olyan kitárolás sem kijelölve, amelyről kiszállítást lehetne készíteni" + vbNewLine + "Ez abban az esetben fordulhat elő, ha a kiszállítási szándék érétke nulla." + vbNewLine + "Kérem, ellenőrizze!") '--==Szállítólevél==-- '____________________________________________________________________________________________________________________ Dim _DeliveryNoteOutHeader As New DeliveryNoteOutHeader(_onew.Session) With _DeliveryNoteOutHeader .CurrencyName = _onew.GetObject(_ORI_Invoice_Popup.CurrencyName) .Customers = _onew.GetObject(_ORI_Invoice_Popup.Customers) .CustomersFrom = _onew.GetObject(_ORI_Invoice_Popup.CustomersFrom) .DateCreated = GetSQLTime(_onew.Session) .DateExecution = _onew.GetObject(_ORI_Invoice_Popup.DateExecution) .Note = _onew.GetObject(_ORI_Invoice_Popup.Description) .QualityOption = _onew.GetObject(_ORI_Invoice_Popup.QualityOption) .ShipmentOption = _onew.GetObject(_ORI_Invoice_Popup.ShipmentOption) .TransportAddress = _onew.GetObject(_ORI_Invoice_Popup.TransportAddress) .DeliveryNoteOutType = _onew.GetObject(_ORI_Invoice_Popup.DeliveryNoteOutType) End With For Each _StorageOutRowsInRows As StorageOutRowsInRows In _OrderInHeader.StorageOutRowsInRows If _StorageOutRowsInRows.QTT_Will > 0 Then Dim _DeliveryNoteOutRows As New DeliveryNoteOutRows(_onew.Session) With _DeliveryNoteOutRows .DeliveryNoteOutHeader = _DeliveryNoteOutHeader .RowIndex = _DeliveryNoteOutHeader.DeliveryNoteOutRows.Count .QTT = _StorageOutRowsInRows.QTT_Will .StorageOutRowsInRows = _onew.GetObject(_StorageOutRowsInRows) End With Dim _QTT_Will_Orig = _StorageOutRowsInRows.QTT_Will _StorageOutRowsInRows.QTT_To_DeliveryOut += _QTT_Will_Orig _StorageOutRowsInRows.QTT_Will = 0 Dim _OrderInRows As OrderInRows = _onew.GetObjectByKey(Of OrderInRows)(_StorageOutRowsInRows.StorageOutRows.OrderInRows.Oid) _OrderInRows.QTT_DeliveryNoted += _QTT_Will_Orig End If Next '--==Szállítólevél véglegesítés==-- '____________________________________________________________________________________________________________________ _DeliveryNoteOutHeader.IsEditable = False '--==Számla==-- '____________________________________________________________________________________________________________________ Dim _InvoiceHeader As New InvoiceHeader(_onew.Session) With _InvoiceHeader .InvoiceType = _onew.GetObjectByKey(Of InvoiceType)(_ORI_Invoice_Popup.InvoiceType.Oid) .CustomersFrom = _onew.GetObjectByKey(Of CustomersFrom)(_ORI_Invoice_Popup.CustomersFrom.Oid) .Customers = _onew.GetObjectByKey(Of Customers)(_ORI_Invoice_Popup.Customers.Oid) .DateCreated = _ORI_Invoice_Popup.DateCreated .DateExecution = _ORI_Invoice_Popup.DateExecution .DatePayment = _ORI_Invoice_Popup.DatePayment .PaymentOption = _onew.GetObjectByKey(Of PaymentOption)(_ORI_Invoice_Popup.PaymentOption.Oid) .DatePaymentMode = .PaymentOption.DatePaymentMode .ShipmentOption = _onew.GetObjectByKey(Of ShipmentOption)(_ORI_Invoice_Popup.ShipmentOption.Oid) .CurrencyName = _onew.GetObjectByKey(Of CurrencyName)(_ORI_Invoice_Popup.CurrencyName.Oid) If .PaymentOption.PayMode = ePayMode.InCash Then Else .BankInformation = _onew.GetObjectByKey(Of BankInformation)(_ORI_Invoice_Popup.BankInformation.Oid) End If .Description = _ORI_Invoice_Popup.Description InvoiceHeaderSavedSettings(_InvoiceHeader) If .PaymentOption.PayMode = ePayMode.InContinuous Then .DatePayment = _InvoiceHeader.DateExecution Else If _ORI_Invoice_Popup.IsAPCSheet Then Else If .PaymentOption.DatePaymentMode = eDatePaymentMode.eDateCreated Then .DatePayment = _InvoiceHeader.DateCreated.AddDays(_InvoiceHeader.PaymentOption.PayDay) Else .DatePayment = _InvoiceHeader.DateExecution.AddDays(_InvoiceHeader.PaymentOption.PayDay) End If End If End If If .InvoiceType.NumberGeneratorProforma IsNot Nothing Then _InvoiceHeader.DocumentNumberProforma = _InvoiceHeader.InvoiceType.NumberGeneratorProforma.GetNewNumber(_InvoiceHeader.InvoiceType.NumberGeneratorProforma) End If End With '--==Végszámla / Proforma számal ==-- '____________________________________________________________________________________________________________________ If _ORI_Invoice_Popup.IsFinalInvoice Then _InvoiceHeader.IsEditable = False _InvoiceHeader.IsProforma = False _InvoiceHeader.IsStorno = False _InvoiceHeader.ConnectInfo = _InvoiceHeader.InvoiceType.NumberGenerator.GetNewNumber(_InvoiceHeader.InvoiceType.NumberGenerator) _InvoiceHeader.DocumentNumber = _InvoiceHeader.ConnectInfo If _ORI_Invoice_Popup.PaymentOption.PayMode = ePayMode.InCash Then If _ORI_Invoice_Popup.IsLiquidAssets Then End If End If Else _InvoiceHeader.IsEditable = False _InvoiceHeader.IsProforma = True _InvoiceHeader.IsStorno = False _InvoiceHeader.ConnectInfo = _InvoiceHeader.InvoiceType.NumberGeneratorProforma.GetNewNumber(_InvoiceHeader.InvoiceType.NumberGeneratorProforma) End If For Each _DeliveryNoteOutRows As DeliveryNoteOutRows In _DeliveryNoteOutHeader.DeliveryNoteOutRows Dim _InvoiceRows As New InvoiceRows(_onew.Session) With _InvoiceRows .InvoiceHeader = _InvoiceHeader .RowIndex = _InvoiceHeader.InvoiceRows.Count .OrderInRows = _onew.GetObject(_DeliveryNoteOutRows.StorageOutRowsInRows.StorageOutRows.OrderInRows) .InvoiceRowtype = eInvoiceRowType.FromOrder .DiscountPriceDEV = _DeliveryNoteOutRows.StorageOutRowsInRows.StorageOutRows.OrderInRows.DiscountPriceDEV .DiscountPriceHUF = _DeliveryNoteOutRows.StorageOutRowsInRows.StorageOutRows.OrderInRows.DiscountPriceHUF .ListPriceDEV = _DeliveryNoteOutRows.StorageOutRowsInRows.StorageOutRows.OrderInRows.ListPriceDEV .ListPriceHUF = _DeliveryNoteOutRows.StorageOutRowsInRows.StorageOutRows.OrderInRows.ListPriceHUF .QTT = _DeliveryNoteOutRows.QTT .QualityOption = _onew.GetObject(_DeliveryNoteOutRows.StorageOutRowsInRows.StorageOutRows.OrderInRows.QualityOption) .ShortName = _DeliveryNoteOutRows.StorageOutRowsInRows.StorageOutRows.OrderInRows.Products.ProductNumber + vbNewLine + _DeliveryNoteOutRows.StorageOutRowsInRows.StorageOutRows.OrderInRows.Products.ShortName .Units = _onew.GetObject(_DeliveryNoteOutRows.StorageOutRowsInRows.StorageOutRows.OrderInRows.Products.Units) .VAT = _onew.GetObject(_DeliveryNoteOutRows.StorageOutRowsInRows.StorageOutRows.OrderInRows.VAT) .Description = _DeliveryNoteOutRows.StorageOutRowsInRows.StorageOutRows.OrderInRows.Description .CustomsTariffs = _onew.GetObject(_DeliveryNoteOutRows.StorageOutRowsInRows.StorageOutRows.OrderInRows.Products.CustomsTariff) .DeliveryNoteOutRows = _onew.GetObject(_DeliveryNoteOutRows) If _OrderInHeader.OrderInParameters IsNot Nothing Then If _OrderInHeader.OrderInParameters.Controlling_Rows_Default IsNot Nothing Then .Controlling = _OrderInHeader.OrderInParameters.Controlling_Rows_Default End If End If End With Dim _QTT_Will_Orig As Double = _DeliveryNoteOutRows.QTT _DeliveryNoteOutRows = _DeliveryNoteOutRows _DeliveryNoteOutRows.QTT_Invoiced += _QTT_Will_Orig _DeliveryNoteOutRows.QTT_Will = 0 Dim _OrderInRows As OrderInRows = _onew.GetObject(_DeliveryNoteOutRows.StorageOutRowsInRows.StorageOutRows.OrderInRows) _OrderInRows.QTT_Invoiced += _QTT_Will_Orig Next If _OrderInHeader.OrderInRowsOther.Count > 0 Then For Each _OrderInRowsOther As OrderInRowsOther In _OrderInHeader.OrderInRowsOther If _OrderInRowsOther.QTT_Process > 0 Then Dim _InvoiceRows As New InvoiceRows(_onew.Session) With _InvoiceRows .InvoiceHeader = _InvoiceHeader .OrderInRowsOther = _OrderInRowsOther .QTT = _OrderInRowsOther.QTT_Process _OrderInRowsOther.QTT_Invoiced += _OrderInRowsOther.QTT_Process If _InvoiceHeader.CurrencyName.ShortName = "HUF" Then .DiscountPriceHUF = _OrderInRowsOther.DiscountPriceHUF .ListPriceHUF = _OrderInRowsOther.ListPriceHUF Else .DiscountPriceDEV = _OrderInRowsOther.DiscountPriceDEV .DiscountPriceHUF = _OrderInRowsOther.DiscountPriceDEV * _ORI_Invoice_Popup.CurrencyRate .ListPriceDEV = _OrderInRowsOther.ListPriceDEV .ListPriceHUF = _OrderInRowsOther.ListPriceDEV * _ORI_Invoice_Popup.CurrencyRate End If .InvoiceRowtype = eInvoiceRowType.FromOrder .VAT = _OrderInRowsOther.VAT .Units = _OrderInRowsOther.Units .UniqueObjects = _OrderInRowsOther.UniqueObjects .CostHolder = _OrderInRowsOther.CostHolder .CostPlace = _OrderInRowsOther.CostPlace .QualityOption = _OrderInRowsOther.QualityOption .Description = _OrderInRowsOther.Description .ShortName = _OrderInRowsOther.ShortName .CustomsTariffs = _OrderInRowsOther.CustomsTariffs .RowIndex = _InvoiceHeader.InvoiceRows.Count End With End If Next End If _onew.CommitChanges() _InvoiceHeader.RecalculateInvoice(_InvoiceHeader, _onew) _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"))) End Try End Sub #End Region #Region "Kiszállítások fül" Private Sub aORI_Storno_DeliveryNoteOut_CustomizePopupWindowParams(sender As Object, e As CustomizePopupWindowParamsEventArgs) Handles aORI_Storno_DeliveryNoteOut.CustomizePopupWindowParams Try Dim _onew As Xpo.XPObjectSpace = Application.CreateObjectSpace Dim _ORI_Storno_DeliveryNoteOut_PopUp As New ORI_Storno_DeliveryNoteOut_PopUp(_onew.Session) e.View = Application.CreateDetailView(_onew, "ORI_Storno_DeliveryNoteOut_PopUp_DetailView", False, _ORI_Storno_DeliveryNoteOut_PopUp) Catch ex As Exception MsgBox(ex.Message, MsgBoxStyle.OkOnly + MsgBoxStyle.Critical, String.Format(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions", "MsgBoxCheckItAgain"))) End Try End Sub Private Sub aORI_Storno_DeliveryNoteOut_Execute(sender As Object, e As PopupWindowShowActionExecuteEventArgs) Handles aORI_Storno_DeliveryNoteOut.Execute Try Dim _onew As Xpo.XPObjectSpace = Application.CreateObjectSpace Dim _OrderInHeader As OrderInHeader = _onew.GetObject(TryCast(View.SelectedObjects(0), OrderInHeader)) If _OrderInHeader Is Nothing Then Throw New Exception("*Váratlan hiba történt, a folyamat megszakadt!") Dim _ORI_Storno_DeliveryNoteOut_PopUp As ORI_Storno_DeliveryNoteOut_PopUp = TryCast(e.PopupWindow.View.SelectedObjects(0), ORI_Storno_DeliveryNoteOut_PopUp) If _ORI_Storno_DeliveryNoteOut_PopUp Is Nothing Then Throw New Exception("*Váratlan hiba történt, a folyamat megszakadt!") Dim _DeliveryNoteOutRows_ListEditor As ListPropertyEditor = TryCast(View, DetailView).FindItem("DeliveryNoteOutRows") If _DeliveryNoteOutRows_ListEditor Is Nothing Then Throw New Exception("*Váratlan hiba történt, a folyamat megszakadt!") If _DeliveryNoteOutRows_ListEditor.ListView.SelectedObjects.Count = 0 Then Throw New Exception("*Nincs kijelölve egyetlen kitárolási sor sem!") For Each _DeliveryNoteOutRows As DeliveryNoteOutRows In _DeliveryNoteOutRows_ListEditor.ListView.SelectedObjects If _DeliveryNoteOutRows.QTT_Invoiced > 0 Then Throw New Exception("*A kiválaszott kiszállítási sorok közt szerepel olyan, melyről készült számal!" _ + vbNewLine + "Számlázott kiszállítás stornózása nem lehetséges!" + vbNewLine + vbNewLine + "Kérem, ellenőrizze!") If _DeliveryNoteOutRows.DeliveryNoteOutHeader.IsStorno = True Then Throw New Exception("*A kiválaszott kiszállítási sor már stornózva lett!" + vbNewLine + "Kérem, ellenőrizze!") Next Dim _DeliveryNoteOutHeader_Collection As New ArrayList For Each _DeliveryNoteOutRows As DeliveryNoteOutRows In _DeliveryNoteOutRows_ListEditor.ListView.SelectedObjects If _DeliveryNoteOutHeader_Collection.Count = 0 Then _DeliveryNoteOutHeader_Collection.Add(_onew.GetObjectByKey(Of DeliveryNoteOutHeader)(_DeliveryNoteOutRows.DeliveryNoteOutHeader.Oid)) Else Dim _IsNeed As Boolean = True For Each _DeliveryNoteOutHeader As DeliveryNoteOutHeader In _DeliveryNoteOutHeader_Collection If _DeliveryNoteOutRows.DeliveryNoteOutHeader.Oid = _DeliveryNoteOutHeader.Oid Then _IsNeed = False Next If _IsNeed Then _DeliveryNoteOutHeader_Collection.Add(_onew.GetObjectByKey(Of DeliveryNoteOutHeader)(_DeliveryNoteOutRows.DeliveryNoteOutHeader.Oid)) End If Next Dim _StorageOutHeader_Collection As New ArrayList For Each _DeliveryNoteOutRows As DeliveryNoteOutRows In _DeliveryNoteOutRows_ListEditor.ListView.SelectedObjects If _StorageOutHeader_Collection.Count = 0 Then _StorageOutHeader_Collection.Add(_onew.GetObject(_DeliveryNoteOutRows.StorageOutRowsInRows.StorageOutRows.StorageOutHeader)) Else Dim _IsNeed As Boolean = True For Each _StorageOutHeader As StorageOutHeader In _StorageOutHeader_Collection If _DeliveryNoteOutRows.StorageOutRowsInRows.StorageOutRows.StorageOutHeader.Oid = _StorageOutHeader.Oid Then _IsNeed = False Next If _IsNeed Then _StorageOutHeader_Collection.Add(_onew.GetObject(_DeliveryNoteOutRows.StorageOutRowsInRows.StorageOutRows.StorageOutHeader.Oid)) End If Next If _DeliveryNoteOutHeader_Collection.Count = 0 Then Throw New Exception("*A kiválaszott kiszállítási sorok közt nem szerepel olyan, melyet stornózni lehetne!" _ + vbNewLine + vbNewLine + "Kérem, ellenőrizze!") Dim _DeliveryNoteOutHeaderNew_Collection As New ArrayList Dim _StorageOutHeaderNew_Collection As New ArrayList Select Case _ORI_Storno_DeliveryNoteOut_PopUp.ORIStornoDeliveryNoteOutType Case eORIStornoDeliveryNoteOutType.eStornoDeliveryNoteOut StornoDeliveryNoteOut(_onew, _DeliveryNoteOutHeader_Collection, _DeliveryNoteOutHeaderNew_Collection) If _DeliveryNoteOutHeaderNew_Collection.Count = 0 Then Throw New Exception("*Váratlan hiba történt, a folyamat megszakadt!") Case eORIStornoDeliveryNoteOutType.eStornoDeliveryNoteOutStorageOut StornoDeliveryNoteOutStorageOut(_onew, _DeliveryNoteOutHeader_Collection, _StorageOutHeader_Collection, _DeliveryNoteOutHeaderNew_Collection, _StorageOutHeaderNew_Collection) If _DeliveryNoteOutHeaderNew_Collection.Count = 0 Then Throw New Exception("*Váratlan hiba történt, a folyamat megszakadt!") If _StorageOutHeaderNew_Collection.Count = 0 Then Throw New Exception("*Váratlan hiba történt, a folyamat megszakadt!") End Select _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"))) End Try End Sub Private Sub aORI_Create_Invoice_Execute(sender As Object, e As PopupWindowShowActionExecuteEventArgs) Handles aORI_Create_Invoice.Execute Try Dim _onew As Xpo.XPObjectSpace = Application.CreateObjectSpace Dim _OrderInHeader As OrderInHeader = _onew.GetObject(TryCast(View.SelectedObjects(0), OrderInHeader)) Dim _ORI_Invoice_Popup As ORI_Invoice_Popup = TryCast(e.PopupWindow.View.SelectedObjects(0), ORI_Invoice_Popup) ' --- Ellenőrzés, hogy kell-e engedély ! -------------------------------------------------------------------------------------------------- If _onew.GetObject(TryCast(e.PopupWindow.View.SelectedObjects(0), ORI_Invoice_Popup).PaymentOption).PayMode <> ePayMode.InCash Then If _OrderInHeader.SubjectToApproval(_OrderInHeader, _onew) And _OrderInHeader.PermissionAllowed = False Then MsgBox(String.Format(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions\OrderInHeader", "PermissionNotAllowedToCreateInvoice")), MsgBoxStyle.Exclamation + MsgBoxStyle.OkOnly, String.Format(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions", "MsgBoxCheckItAgain"))) Exit Sub End If End If Dim _DeliveryNoteOutRows_Error As New ArrayList _OrderInHeader.DeliveryNoteOutRows.Sorting.Add(New SortProperty("RowIndex", DB.SortingDirection.Ascending)) For Each _DeliveryNoteOutRows As DeliveryNoteOutRows In _OrderInHeader.DeliveryNoteOutRows If _DeliveryNoteOutRows.QTT_Will > 0 Then If (_DeliveryNoteOutRows.QTT < (_DeliveryNoteOutRows.QTT_Will + _DeliveryNoteOutRows.QTT_Invoiced)) Then _ _DeliveryNoteOutRows_Error.Add(_DeliveryNoteOutRows) End If Next If _DeliveryNoteOutRows_Error.Count > 0 Then MsgBox(String.Format(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions\OrderInRows", "TooMutchQuantityInOrderIn"), _DeliveryNoteOutRows_Error(0).RowIndex, _DeliveryNoteOutRows_Error(0).QTT_Will + _DeliveryNoteOutRows_Error(0).QTT_Invoiced, _DeliveryNoteOutRows_Error(0).QTT), MsgBoxStyle.Information + MsgBoxStyle.OkOnly, String.Format(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions", "MsgBoxCheckItAgain"))) Exit Sub End If Dim _DeliveryNoteOutRows_Collection As New ArrayList _OrderInHeader.DeliveryNoteOutRows.Sorting.Add(New SortProperty("RowIndex", DB.SortingDirection.Ascending)) For Each _DeliveryNoteOutRows As DeliveryNoteOutRows In _OrderInHeader.DeliveryNoteOutRows If _DeliveryNoteOutRows.QTT_Will > 0 Then If _DeliveryNoteOutRows_Collection.Count = 0 Then _DeliveryNoteOutRows_Collection.Add(_DeliveryNoteOutRows) Else Dim _IsNeed As Boolean = True For Each _DeliveryNoteOutRowsInCollection As DeliveryNoteOutRows In _DeliveryNoteOutRows_Collection If _DeliveryNoteOutRows.Oid = _DeliveryNoteOutRowsInCollection.Oid Then _IsNeed = False Next If _IsNeed Then _DeliveryNoteOutRows_Collection.Add(_DeliveryNoteOutRows) End If End If Next If _DeliveryNoteOutRows_Collection.Count = 0 Then MsgBox(String.Format(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions\OrderInRows", "NoSelectionforInvoice")), MsgBoxStyle.Information + MsgBoxStyle.OkOnly, String.Format(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions", "MsgBoxCheckItAgain"))) Exit Sub End If Dim _InvoiceHeader As New InvoiceHeader(_onew.Session) With _InvoiceHeader .InvoiceType = _onew.GetObjectByKey(Of InvoiceType)(_ORI_Invoice_Popup.InvoiceType.Oid) .CustomersFrom = _onew.GetObjectByKey(Of CustomersFrom)(_ORI_Invoice_Popup.CustomersFrom.Oid) .Customers = _onew.GetObjectByKey(Of Customers)(_ORI_Invoice_Popup.Customers.Oid) .DateCreated = _ORI_Invoice_Popup.DateCreated .DateExecution = _ORI_Invoice_Popup.DateExecution .PaymentOption = _onew.GetObjectByKey(Of PaymentOption)(_ORI_Invoice_Popup.PaymentOption.Oid) .DatePaymentMode = .PaymentOption.DatePaymentMode 'Javítva lett .ShipmentOption = _onew.GetObjectByKey(Of ShipmentOption)(_OrderInHeader.ShipmentOption.Oid) .CurrencyName = _onew.GetObjectByKey(Of CurrencyName)(_ORI_Invoice_Popup.CurrencyName.Oid) _InvoiceHeader.CurrencyRate = _ORI_Invoice_Popup.CurrencyRate If .PaymentOption.PayMode = ePayMode.InCash Then Else .BankInformation = _onew.GetObjectByKey(Of BankInformation)(_ORI_Invoice_Popup.BankInformation.Oid) End If .Description = _ORI_Invoice_Popup.Description InvoiceHeaderSavedSettings(_InvoiceHeader) If .PaymentOption.PayMode = ePayMode.InContinuous Then .DatePayment = _InvoiceHeader.DateExecution Else If _ORI_Invoice_Popup.IsAPCSheet Then .DatePayment = _ORI_Invoice_Popup.DatePayment Else If .PaymentOption.DatePaymentMode = eDatePaymentMode.eDateCreated Then .DatePayment = _InvoiceHeader.DateCreated.AddDays(_InvoiceHeader.PaymentOption.PayDay) Else .DatePayment = _InvoiceHeader.DateExecution.AddDays(_InvoiceHeader.PaymentOption.PayDay) End If End If End If End With If _ORI_Invoice_Popup.IsFinalInvoice Then _InvoiceHeader.IsEditable = False _InvoiceHeader.IsProforma = False _InvoiceHeader.IsStorno = False _InvoiceHeader.ConnectInfo = _InvoiceHeader.InvoiceType.NumberGenerator.GetNewNumber(_InvoiceHeader.InvoiceType.NumberGenerator) _InvoiceHeader.DocumentNumber = _InvoiceHeader.ConnectInfo If _ORI_Invoice_Popup.PaymentOption.PayMode = ePayMode.InCash Then If _ORI_Invoice_Popup.IsLiquidAssets Then 'Dim _GLCassa As New GLCassa(_onew.Session) 'With _GLCassa ' .CustomersFrom = _onew.GetObjectByKey(Of CustomersFrom)(_ORI_Invoice_Popup.CustomersFrom.Oid) ' .LiquidAssets_Cassa = _onew.GetObjectByKey(Of LiquidAssets)(_ORI_Invoice_Popup.LiquidAssets.Oid) ' .CashMoveType = eCashMoveType.eIn ' .CashHandler = _ORI_Invoice_Popup.Customers.FullName.ToString() ' .DateExecution = _onew.GetObjectByKey(Of Date)(_ORI_Invoice_Popup.DateExecution) ' .DateCreated = _onew.GetObjectByKey(Of Date)(_ORI_Invoice_Popup.DateCreated) ' .NoteHeader = "SZLA.BEFIZ" ' _GLCassa.Save() 'End With 'Dim _GLRows As New GLRows(_onew.Session) 'With _GLRows ' .GLHeader = _onew.GetObjectByKey(Of GLCassa)(_GLCassa.Oid) 'End With End If End If Else _InvoiceHeader.IsEditable = False _InvoiceHeader.IsProforma = True _InvoiceHeader.IsStorno = False If _InvoiceHeader.InvoiceType.NumberGeneratorProforma IsNot Nothing Then _InvoiceHeader.DocumentNumberProforma = _InvoiceHeader.InvoiceType.NumberGeneratorProforma.GetNewNumber(_InvoiceHeader.InvoiceType.NumberGeneratorProforma) End If End If For Each _DeliveryNoteOutRows As DeliveryNoteOutRows In _DeliveryNoteOutRows_Collection Dim _InvoiceRows As New InvoiceRows(_onew.Session) With _InvoiceRows .InvoiceHeader = _InvoiceHeader .RowIndex = _InvoiceHeader.InvoiceRows.Count .OrderInRows = _onew.GetObject(_DeliveryNoteOutRows.StorageOutRowsInRows.StorageOutRows.OrderInRows) .InvoiceRowtype = eInvoiceRowType.FromOrder .DiscountPriceDEV = _DeliveryNoteOutRows.StorageOutRowsInRows.StorageOutRows.OrderInRows.DiscountPriceDEV .DiscountPriceHUF = _DeliveryNoteOutRows.StorageOutRowsInRows.StorageOutRows.OrderInRows.DiscountPriceHUF .ListPriceDEV = _DeliveryNoteOutRows.StorageOutRowsInRows.StorageOutRows.OrderInRows.ListPriceDEV 'Ha a DEVIZA != HUF, akkor itt kell árfolyam alapján újragenerálás !!! If .InvoiceHeader.CurrencyName.ShortName <> "HUF" And _ORI_Invoice_Popup.PriceMode = ePriceMode.eDEVToHUF Then .DiscountPriceHUF = _DeliveryNoteOutRows.StorageOutRowsInRows.StorageOutRows.OrderInRows.DiscountPriceDEV * _ORI_Invoice_Popup.CurrencyRate, 2, MidpointRounding.AwayFromZero) .ListPriceHUF = Math.Round(_DeliveryNoteOutRows.StorageOutRowsInRows.StorageOutRows.OrderInRows.ListPriceDEV * _ORI_Invoice_Popup.CurrencyRate, 2, MidpointRounding.AwayFromZero) Else .ListPriceHUF = _DeliveryNoteOutRows.StorageOutRowsInRows.StorageOutRows.OrderInRows.ListPriceHUF End If .QTT = _DeliveryNoteOutRows.QTT_Will .QualityOption = _onew.GetObject(_DeliveryNoteOutRows.StorageOutRowsInRows.StorageOutRows.OrderInRows.QualityOption) .ShortName = _DeliveryNoteOutRows.StorageOutRowsInRows.StorageOutRows.OrderInRows.Products.ProductNumber + vbNewLine + _DeliveryNoteOutRows.StorageOutRowsInRows.StorageOutRows.OrderInRows.Products.ShortName .Units = _onew.GetObject(_DeliveryNoteOutRows.StorageOutRowsInRows.StorageOutRows.OrderInRows.Products.Units) .VAT = _onew.GetObject(_DeliveryNoteOutRows.StorageOutRowsInRows.StorageOutRows.OrderInRows.VAT) .Description = _DeliveryNoteOutRows.StorageOutRowsInRows.StorageOutRows.OrderInRows.Description .CustomsTariffs = _onew.GetObject(_DeliveryNoteOutRows.StorageOutRowsInRows.StorageOutRows.OrderInRows.Products.CustomsTariff) .DeliveryNoteOutRows = _onew.GetObject(_DeliveryNoteOutRows) If _OrderInHeader.OrderInParameters IsNot Nothing Then If _OrderInHeader.OrderInParameters.Controlling_Rows_Default IsNot Nothing Then .Controlling = _OrderInHeader.OrderInParameters.Controlling_Rows_Default End If End If End With Dim _QTT_Will_Orig = _DeliveryNoteOutRows.QTT_Will _DeliveryNoteOutRows = _onew.GetObject(_DeliveryNoteOutRows) _DeliveryNoteOutRows.QTT_Invoiced += _QTT_Will_Orig _DeliveryNoteOutRows.QTT_Will = 0 Dim _OrderInRows As OrderInRows = _onew.GetObject(_DeliveryNoteOutRows.StorageOutRowsInRows.StorageOutRows.OrderInRows) _OrderInRows.QTT_Invoiced += _QTT_Will_Orig Next _onew.CommitChanges() _InvoiceHeader.RecalculateInvoice(_InvoiceHeader, _onew) _onew.CommitChanges() 'Készpénz esetén pénztári bizonylat is !!! If _ORI_Invoice_Popup.IsLiquidAssets AndAlso _ORI_Invoice_Popup.PaymentOption.PayMode = ePayMode.InCash And _ORI_Invoice_Popup.IsFinalInvoice Then CreateGLCassa(_InvoiceHeader, _onew, _ORI_Invoice_Popup) End If If _InvoiceHeader IsNot Nothing Then Dim _XAFPrintHelper_I As New XAFPrintHelper(_onew, Frame, _InvoiceHeader.InvoiceType.ReportDataV2, CriteriaOperator.Parse("InvoiceHeader.Oid = ?", _InvoiceHeader.Oid)) _XAFPrintHelper_I.ShowPreviewV2() End If Frame.GetController(Of RefreshController).RefreshAction.DoExecute() Catch ex As Exception MsgBox(ex.Message, MsgBoxStyle.OkOnly + MsgBoxStyle.Critical, String.Format(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions", "MsgBoxCheckItAgain"))) End Try End Sub #End Region #Region "Kimenő számla sorok" Private Sub aORI_Storno_Invoice_CustomizePopupWindowParams(sender As Object, e As CustomizePopupWindowParamsEventArgs) Handles aORI_Storno_Invoice.CustomizePopupWindowParams Try Dim _onew As Xpo.XPObjectSpace = Application.CreateObjectSpace Dim _ORI_Storno_Invoice_PopUp As New ORI_Storno_Invoice_PopUp(_onew.Session) e.View = Application.CreateDetailView(_onew, "ORI_Storno_Invoice_PopUp_DetailView", False, _ORI_Storno_Invoice_PopUp) Catch ex As Exception MsgBox(ex.Message, MsgBoxStyle.OkOnly + MsgBoxStyle.Critical, String.Format(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions", "MsgBoxCheckItAgain"))) End Try End Sub Private Sub aORI_Storno_Invoice_Execute(sender As Object, e As PopupWindowShowActionExecuteEventArgs) Handles aORI_Storno_Invoice.Execute Try Dim _onew As Xpo.XPObjectSpace = Application.CreateObjectSpace Dim _OrderInHeader As OrderInHeader = _onew.GetObject(TryCast(View.SelectedObjects(0), OrderInHeader)) If _OrderInHeader Is Nothing Then Throw New Exception("*Váratlan hiba történt, a folyamat megszakadt!") Dim _ORI_Storno_Invoice_PopUp As ORI_Storno_Invoice_PopUp = TryCast(e.PopupWindow.View.SelectedObjects(0), ORI_Storno_Invoice_PopUp) If _ORI_Storno_Invoice_PopUp Is Nothing Then Throw New Exception("*Váratlan hiba történt, a folyamat megszakadt!") Dim _InvoiceRows_ListEditor As ListPropertyEditor = TryCast(View, DetailView).FindItem("InvoiceRows") If _InvoiceRows_ListEditor Is Nothing Then Throw New Exception("*Váratlan hiba történt, a folyamat megszakadt!") If _InvoiceRows_ListEditor.ListView.SelectedObjects.Count = 0 Then Throw New Exception("*Nincs kijelölve egyetlen kitárolási sor sem!") Dim _InvoiceRows_Collection As New ArrayList For Each _InvoiceRows As InvoiceRows In _InvoiceRows_ListEditor.ListView.SelectedObjects If _InvoiceRows.InvoiceHeader.IsStorno = False And _InvoiceRows.InvoiceHeader.IsEditable = False And _InvoiceRows.InvoiceHeader.IsProforma = False And String.IsNullOrEmpty(_InvoiceRows.InvoiceHeader.DocumentNumber) = False Then _ _InvoiceRows_Collection.Add(_InvoiceRows) Next If _InvoiceRows_Collection.Count = 0 Then Throw New Exception("*A kiválasztott számlasorok közt nincs egyetlen olyan sem, melyet stornozni lehetne!" _ + vbNewLine + "Kérem, ellenőrize!") Dim _InvoiceHeaderNew_Collection As New ArrayList Dim _DeliveryHeaderNew_Collection As New ArrayList Dim _StorageOutHeaderNew_Collection As New ArrayList Select Case _ORI_Storno_Invoice_PopUp.ORIStornoInvoiceType Case eORIStornoInvoiceType.eStornoInvoice StornoInvoice(_onew, _InvoiceHeaderNew_Collection, _InvoiceRows_Collection) If _InvoiceHeaderNew_Collection.Count = 0 Then Throw New Exception("*Váratlan hiba történt, a folyamat megszakadt!") Case eORIStornoInvoiceType.eStornoInvoiceDelivery StornoInvoice(_onew, _InvoiceHeaderNew_Collection, _InvoiceRows_Collection) StornoDelivery(_onew, _DeliveryHeaderNew_Collection, _InvoiceRows_Collection) If _InvoiceHeaderNew_Collection.Count = 0 Then Throw New Exception("*Váratlan hiba történt, a folyamat megszakadt!") If _DeliveryHeaderNew_Collection.Count = 0 Then Throw New Exception("*Váratlan hiba történt, a folyamat megszakadt!") Case eORIStornoInvoiceType.eStornoInvoiceDeliveryStorageOut StornoInvoice(_onew, _InvoiceHeaderNew_Collection, _InvoiceRows_Collection) StornoDelivery(_onew, _DeliveryHeaderNew_Collection, _InvoiceRows_Collection) StornoStorage(_onew, _StorageOutHeaderNew_Collection, _InvoiceRows_Collection) If _InvoiceHeaderNew_Collection.Count = 0 Then Throw New Exception("*Váratlan hiba történt, a folyamat megszakadt!") If _DeliveryHeaderNew_Collection.Count = 0 Then Throw New Exception("*Váratlan hiba történt, a folyamat megszakadt!") If _StorageOutHeaderNew_Collection.Count = 0 Then Throw New Exception("*Váratlan hiba történt, a folyamat megszakadt!") End Select _onew.CommitChanges() For Each _InvoiceHeader As InvoiceHeader In _InvoiceHeaderNew_Collection _InvoiceHeader.RecalculateInvoice(_InvoiceHeader, _onew) _onew.CommitChanges() Next Frame.GetController(Of RefreshController).RefreshAction.DoExecute() Catch ex As Exception MsgBox(ex.Message, MsgBoxStyle.OkOnly + MsgBoxStyle.Critical, String.Format(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions", "MsgBoxCheckItAgain"))) End Try End Sub Private Sub aOrderIn_InvoiceRowFinalize_CustomizePopupWindowParams(sender As Object, e As CustomizePopupWindowParamsEventArgs) Handles aOrderIn_InvoiceRowFinalize.CustomizePopupWindowParams Try Dim _onew As Xpo.XPObjectSpace = Application.CreateObjectSpace Dim _OrderInHeader As OrderInHeader = _onew.GetObject(TryCast(View.SelectedObjects(0), OrderInHeader)) If _OrderInHeader Is Nothing Then Throw New Exception("*Váratlan hiba történt, a folyamat megszakadt!") Dim _OrderInRows_ListEditor As ListPropertyEditor = TryCast(View, DetailView).FindItem("InvoiceRows") If _OrderInRows_ListEditor Is Nothing Then Throw New Exception("*Váratlan hiba történt, a folyamat megszakadt!") If _OrderInRows_ListEditor.ListView.SelectedObjects.Count = 0 Then Throw New Exception("*Nincs kiválasztva egyetlen számla sor sem!") Dim _InvoiceHeader As InvoiceHeader = _onew.GetObject(TryCast(TryCast(_OrderInRows_ListEditor.ListView.SelectedObjects(0), InvoiceRows).InvoiceHeader, InvoiceHeader)) If _InvoiceHeader Is Nothing Then Throw New Exception("*Váratlan hiba történt, a folyamat megszakadt!") If String.IsNullOrEmpty(_InvoiceHeader.DocumentNumberProforma) Then Throw New Exception("*A véglegesíteni kívánt számla nem proforma száma!") If Not String.IsNullOrEmpty(_InvoiceHeader.DocumentNumber) Then Throw New Exception("*A véglegesíteni kívánt számla már rendelkezik sorszámmal!") Dim _ORI_Invoice_Popup As ORI_Invoice_Popup = _onew.CreateObject(Of ORI_Invoice_Popup)() _ORI_Invoice_Popup.InvoiceStrategy = eInvoiceStrategy.eInvoice _ORI_Invoice_Popup.CurrencyName = _InvoiceHeader.CurrencyName _ORI_Invoice_Popup.CustomersFrom = _InvoiceHeader.CustomersFrom _ORI_Invoice_Popup.DateCreated = GetSQLTime(_onew.Session) _ORI_Invoice_Popup.DateExecution = _InvoiceHeader.DateExecution _ORI_Invoice_Popup.PaymentOption = _InvoiceHeader.PaymentOption _ORI_Invoice_Popup.DatePayment = _InvoiceHeader.DatePayment _ORI_Invoice_Popup.BankInformation = _InvoiceHeader.BankInformation _ORI_Invoice_Popup.Description = _InvoiceHeader.Description _ORI_Invoice_Popup.Description_Header = _InvoiceHeader.DescriptionHeader _ORI_Invoice_Popup.Customers = _InvoiceHeader.Customers _ORI_Invoice_Popup.InvoiceType = _InvoiceHeader.InvoiceType _ORI_Invoice_Popup.IsAPCSheet = _OrderInHeader.OrderInParameters.IsAPCSheet _ORI_Invoice_Popup.QualityOption = _InvoiceHeader.QualityOption If _OrderInHeader.OrderInParameters.LiquidAssets IsNot Nothing Then _ORI_Invoice_Popup.LiquidAssets = _OrderInHeader.OrderInParameters.LiquidAssets End If e.View = Application.CreateDetailView(_onew, "ORI_Invoice_Popup_DetailView", False, _ORI_Invoice_Popup) Catch ex As Exception MsgBox(ex.Message, MsgBoxStyle.OkOnly + MsgBoxStyle.Critical, String.Format(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions", "MsgBoxCheckItAgain"))) End Try End Sub Private Sub aOrderIn_InvoiceRowFinalize_Execute(sender As Object, e As PopupWindowShowActionExecuteEventArgs) Handles aOrderIn_InvoiceRowFinalize.Execute Try Dim _onew As Xpo.XPObjectSpace = Application.CreateObjectSpace Dim _OrderInRows_ListEditor As ListPropertyEditor = TryCast(View, DetailView).FindItem("InvoiceRows") If _OrderInRows_ListEditor Is Nothing Then Throw New Exception("*Váratlan hiba történt, a folyamat megszakadt!") If _OrderInRows_ListEditor.ListView.SelectedObjects.Count = 0 Then Throw New Exception("*Nincs kiválasztva egyetlen számla sor sem!") Dim _InvoiceHeader As InvoiceHeader = _onew.GetObject(TryCast(TryCast(_OrderInRows_ListEditor.ListView.SelectedObjects(0), InvoiceRows).InvoiceHeader, InvoiceHeader)) If _InvoiceHeader Is Nothing Then Throw New Exception("*Váratlan hiba történt, a folyamat megszakadt!") Dim _ORI_Invoice_Popup As ORI_Invoice_Popup = TryCast(e.PopupWindow.View.SelectedObjects(0), ORI_Invoice_Popup) _InvoiceHeader.IsEditable = False _InvoiceHeader.IsProforma = False _InvoiceHeader.ConnectInfo = _InvoiceHeader.InvoiceType.NumberGenerator.GetNewNumber(_InvoiceHeader.InvoiceType.NumberGenerator) _InvoiceHeader.DocumentNumber = _InvoiceHeader.ConnectInfo _InvoiceHeader.DateCreated = _ORI_Invoice_Popup.DateCreated _InvoiceHeader.DateExecution = _ORI_Invoice_Popup.DateExecution _InvoiceHeader.PaymentOption = _onew.GetObject(_ORI_Invoice_Popup.PaymentOption) If _InvoiceHeader.PaymentOption.PayMode = ePayMode.InCash Then Else _InvoiceHeader.BankInformation = _onew.GetObject(_ORI_Invoice_Popup.BankInformation) End If _InvoiceHeader.Description = _ORI_Invoice_Popup.Description _InvoiceHeader.DescriptionHeader = _ORI_Invoice_Popup.Description_Header _InvoiceHeader.CurrencyRate = _ORI_Invoice_Popup.CurrencyRate _InvoiceHeader.CurrencyName = _onew.GetObject(_ORI_Invoice_Popup.CurrencyName) If _InvoiceHeader.PaymentOption.PayMode = ePayMode.InContinuous Then _InvoiceHeader.DatePayment = _InvoiceHeader.DateExecution Else ' -- Egyébként számolja ki a fizetési opcióból, hogy hány nap van a kiállítás dátuma és a fizetési határidő között If _InvoiceHeader.PaymentOption.PayDay = 0 Then Else Select Case _InvoiceHeader.DatePaymentMode Case eDatePaymentMode.eDateCreated _InvoiceHeader.DatePayment = _InvoiceHeader.DateCreated.AddDays(_InvoiceHeader.PaymentOption.PayDay) Case eDatePaymentMode.eDateExecution _InvoiceHeader.DatePayment = _InvoiceHeader.DateExecution.AddDays(_InvoiceHeader.PaymentOption.PayDay) End Select End If If _ORI_Invoice_Popup.IsAPCSheet Then _InvoiceHeader.DatePayment = _ORI_Invoice_Popup.DatePayment End If End If ' -- Ha előleg típusú számla akkor a teljesítés és a fizetési határidő is megegyezik If _InvoiceHeader.InvoiceType.InvoiceTypeBase = eInvoiceTypeBase.eAdvancePayment Then _InvoiceHeader.DatePayment = _InvoiceHeader.DateExecution End If If String.IsNullOrEmpty(_InvoiceHeader.Customers.Name) Then _InvoiceHeader.Customers.Name = _InvoiceHeader.Customers.FullName End If _onew.CommitChanges() _InvoiceHeader.RecalculateInvoice(_InvoiceHeader, _onew) _onew.CommitChanges() Dim _uow_pci As New UnitOfWork(_onew.Session.DataLayer) GLFunctions.ReconfigurePCI(_uow_pci, _InvoiceHeader.CustomersFrom, _InvoiceHeader.Customers, 0, _InvoiceHeader.ConnectInfo) ' --- Pénztári bizonylat ---------------------------------------------------- If _ORI_Invoice_Popup.IsLiquidAssets AndAlso _ORI_Invoice_Popup.PaymentOption.PayMode = ePayMode.InCash And _ORI_Invoice_Popup.IsFinalInvoice Then CreateGLCassa(_InvoiceHeader, _onew, _ORI_Invoice_Popup) End If '---------------------------------------------------------------------------- Dim _XAFPrintHelper_I As New XAFPrintHelper(_onew, Frame, _InvoiceHeader.InvoiceType.ReportDataV2, CriteriaOperator.Parse("InvoiceHeader.Oid = ?", _InvoiceHeader.Oid)) _XAFPrintHelper_I.ShowPreviewV2() Frame.GetController(Of RefreshController).RefreshAction.DoExecute() Catch ex As Exception MsgBox(ex.Message, MsgBoxStyle.OkOnly + MsgBoxStyle.Critical, String.Format(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions", "MsgBoxCheckItAgain"))) End Try End Sub Private Sub aORI_DeleteInvoiceProforma_Execute(sender As Object, e As SimpleActionExecuteEventArgs) Handles aORI_DeleteInvoiceProforma.Execute '// proforma számla törlése Dim _ocur As Xpo.XPObjectSpace = TryCast(View.ObjectSpace, Xpo.XPObjectSpace) Dim _OrderInHeader As OrderInHeader = TryCast(View.SelectedObjects(0), OrderInHeader) Dim _InvoiceHeader_Collection As New XPCollection(Of InvoiceHeader)(_ocur.Session, CriteriaOperator.Parse("1=2")) If _OrderInHeader IsNot Nothing Then Dim _InvoiceRows_ListEditor As ListPropertyEditor = TryCast(View, DetailView).FindItem("InvoiceRows") If _InvoiceRows_ListEditor IsNot Nothing Then Dim _InvoiceHeaderExist_Collection As New ArrayList For Each _InvoiceRows As InvoiceRows In _InvoiceRows_ListEditor.ListView.SelectedObjects If _InvoiceHeaderExist_Collection.Count = 0 Then _InvoiceHeaderExist_Collection.Add(_InvoiceRows.InvoiceHeader) Else Dim _Need As Boolean = True For Each _InvoiceHeader As InvoiceHeader In _InvoiceHeaderExist_Collection If _InvoiceRows.InvoiceHeader.Oid = _InvoiceHeader.Oid Then _Need = False Exit For End If Next If _Need Then _InvoiceHeaderExist_Collection.Add(_InvoiceRows.InvoiceHeader) End If Next For Each _InvoiceHeader As InvoiceHeader In _InvoiceHeaderExist_Collection If _InvoiceHeader.IsProforma And String.IsNullOrEmpty(_InvoiceHeader.DocumentNumber) Then _InvoiceHeader_Collection.Add(_InvoiceHeader) For Each _InvoiceRows As InvoiceRows In _InvoiceHeader.InvoiceRows If _InvoiceRows.OrderInRows IsNot Nothing Then _InvoiceRows.OrderInRows.QTT_Invoiced -= _InvoiceRows.QTT _InvoiceRows.OrderInRows.Save() End If If _InvoiceRows.OrderInRowsOther IsNot Nothing Then _InvoiceRows.OrderInRowsOther.QTT_Invoiced -= _InvoiceRows.QTT _InvoiceRows.OrderInRowsOther.Save() End If If _InvoiceRows.DeliveryNoteOutRows IsNot Nothing Then _InvoiceRows.DeliveryNoteOutRows.QTT_Invoiced -= _InvoiceRows.QTT _InvoiceRows.DeliveryNoteOutRows.Save() End If Next End If Next _ocur.Delete(_InvoiceHeader_Collection) End If _ocur.CommitChanges() End If If Frame.GetController(Of RefreshController).RefreshAction.Enabled Then Frame.GetController(Of RefreshController).RefreshAction.DoExecute() End If End Sub Private Sub aOrderInInvoiceAdvance_Execute(sender As Object, e As PopupWindowShowActionExecuteEventArgs) Handles aOrderInInvoiceAdvance.Execute '//Előlegszámla készítése előlegbekérő és p.ü. teljesítés alapján On Error GoTo CheckError Dim _ocur As Xpo.XPObjectSpace = TryCast(View.ObjectSpace, Xpo.XPObjectSpace) Dim _OrderInHeader As OrderInHeader = TryCast(View.SelectedObjects(0), OrderInHeader) Dim _InvoiceHeader As InvoiceHeader = _ocur.CreateObject(Of InvoiceHeader)() Dim _InvoiceRows As InvoiceRows Dim _CurrencyRate As Double = _ocur.GetObject(TryCast(e.PopupWindow.View.SelectedObjects(0), ORI_Invoice_Popup).CurrencyRate) Dim _NG As NumberGenerator Dim _VAT As VAT Dim _ConnectInfo_Old As String = "" Dim _ORI_Invoice_Popup As ORI_Invoice_Popup = TryCast(e.PopupWindow.View.SelectedObjects(0), ORI_Invoice_Popup) If _OrderInHeader IsNot Nothing Then Dim _PCIDetail_ListEditor As ListPropertyEditor = TryCast(View, DetailView).FindItem("PCIDetail") Dim _PCIDetail As PCIDetail = TryCast(_PCIDetail_ListEditor.ListView.SelectedObjects(0), PCIDetail) If _PCIDetail IsNot Nothing Then Select Case _PCIDetail.MainType Case "03-Cassa", "02-Bank" '// Megvan a nyitott p.ü teljesítés, lehet kiállítani az előleg számlát _InvoiceHeader.IsProforma = False _InvoiceHeader.IsEditable = False _InvoiceHeader.CustomersFrom = _OrderInHeader.CustomersFrom _InvoiceHeader.Customers = _OrderInHeader.Customers _InvoiceHeader.InvoiceType = _OrderInHeader.OrderInParameters.InvoiceTypeAdvanced If _InvoiceHeader.InvoiceType.NumberGenerator IsNot Nothing Then _NG = _InvoiceHeader.InvoiceType.NumberGenerator _InvoiceHeader.DocumentNumber = _NG.GetNewNumber(_NG) _InvoiceHeader.ConnectInfo = _InvoiceHeader.DocumentNumber _PCIDetail.GLRows.ConnectInfo = _InvoiceHeader.DocumentNumber _PCIDetail.GLRows.Save() _ocur.Delete(_PCIDetail) End If _InvoiceHeader.DateCreated = _ocur.GetObject(TryCast(e.PopupWindow.View.SelectedObjects(0), ORI_Invoice_Popup).DateCreated) _InvoiceHeader.DateExecution = _ocur.GetObject(TryCast(e.PopupWindow.View.SelectedObjects(0), ORI_Invoice_Popup).DateExecution) _InvoiceHeader.Description = _ORI_Invoice_Popup.Description _InvoiceHeader.DescriptionHeader = _ORI_Invoice_Popup.Description_Header _InvoiceHeader.BankInformation = _ocur.GetObject(TryCast(e.PopupWindow.View.SelectedObjects(0), ORI_Invoice_Popup).BankInformation) _InvoiceHeader.CurrencyName = _ocur.GetObject(TryCast(e.PopupWindow.View.SelectedObjects(0), ORI_Invoice_Popup).CurrencyName) _InvoiceHeader.CurrencyRate = _ocur.GetObject(TryCast(e.PopupWindow.View.SelectedObjects(0), ORI_Invoice_Popup).CurrencyRate) _InvoiceHeader.PaymentOption = _ocur.GetObject(TryCast(e.PopupWindow.View.SelectedObjects(0), ORI_Invoice_Popup).PaymentOption) _InvoiceHeader.DatePayment = _InvoiceHeader.DateExecution '-- Próbaszámla miatt el kell menteni a tényleges adatokat -------------------------------------------------------- _InvoiceHeader.Saved_Customers_Name = _OrderInHeader.Customers.Name.ToString _InvoiceHeader.Saved_Customers_Address_Country = _OrderInHeader.Customers.Address1.Country.ToString _InvoiceHeader.Saved_Customers_Address_ZipPostal = _OrderInHeader.Customers.Address1.ZipPostal.ToString _InvoiceHeader.Saved_Customers_Address_Street = _OrderInHeader.Customers.Address1.Street.ToString _InvoiceHeader.Saved_Customers_Address_City = _OrderInHeader.Customers.Address1.City.ToString _InvoiceHeader.Saved_Customers_Address_StateProvince = _OrderInHeader.Customers.Address1.StateProvince.ToString _InvoiceHeader.Saved_Customers_VATNumber = _OrderInHeader.Customers.VATNumber.ToString _InvoiceHeader.Saved_Customers_VATNumberEU = _OrderInHeader.Customers.VATNumberEU.ToString _InvoiceHeader.Saved_CustomersFrom_Name = _OrderInHeader.CustomersFrom.Name.ToString _InvoiceHeader.Saved_CustomersFrom_Address_ZipPostal = _OrderInHeader.CustomersFrom.Address1.ZipPostal.ToString _InvoiceHeader.Saved_CustomersFrom_Address_Street = _OrderInHeader.CustomersFrom.Address1.Street.ToString _InvoiceHeader.Saved_CustomersFrom_Address_City = _OrderInHeader.CustomersFrom.Address1.City.ToString _InvoiceHeader.Saved_CustomersFrom_Address_StateProvince = _OrderInHeader.CustomersFrom.Address1.StateProvince.ToString _InvoiceHeader.Saved_CustomersFrom_VATNumber = _OrderInHeader.CustomersFrom.VATNumber.ToString _InvoiceHeader.Saved_CustomersFrom_VATNumberEU = _OrderInHeader.CustomersFrom.VATNumberEU.ToString _InvoiceHeader.Saved_CustomersFrom_Bank_ShortName = _InvoiceHeader.BankInformation.FullBankAccount.ToString _InvoiceHeader.Saved_CustomersFrom_Bank_IBAN = _InvoiceHeader.BankInformation.IBAN.ToString _InvoiceHeader.Saved_CustomersFrom_Bank_SWIFT = _InvoiceHeader.BankInformation.SWIFT.ToString _InvoiceHeader.Saved_CustomersFrom_Bank_AccountNumber = _InvoiceHeader.BankInformation.AccountNumber.ToString ' ---- FEJLÉC ADATOK MEGADÁSÁNAK VÉGE ---------------------------------------------------------------------------------------------------- '------ Egy darab sor az átvett előleg alapján ---------------------------------------------------------------------------- --------------- _OrderInHeader.OrderInRows.Sorting.Add(New SortProperty("RowIndex", DB.SortingDirection.Ascending)) _OrderInHeader.OrderInRowsOther.Sorting.Add(New SortProperty("RowIndex", DB.SortingDirection.Ascending)) '----------------------------------------------------------------------------------------------------- _InvoiceRows = _ocur.CreateObject(Of InvoiceRows)() _InvoiceRows.InvoiceHeader = _InvoiceHeader _InvoiceRows.QTT = 1 Select Case _OrderInHeader.OrderInParameters.ExportMode Case eExportMode.eInversVAT _VAT = _ocur.FindObject(Of VAT)(CriteriaOperator.Parse("DefaultForInversVAT")) Case eExportMode.eExternalEUwithVAT _VAT = _ocur.FindObject(Of VAT)(CriteriaOperator.Parse("DefaultForBusinnes")) Case eExportMode.eExternalEUNoVAT _VAT = _ocur.FindObject(Of VAT)(CriteriaOperator.Parse("DefaultForExternalEUNoVAT")) Case eExportMode.eExternalOther _VAT = _ocur.FindObject(Of VAT)(CriteriaOperator.Parse("DefaultForExternalOther")) Case eExportMode.eInternalwithVAT _VAT = _ocur.FindObject(Of VAT)(CriteriaOperator.Parse("DefaultForBusinnes")) Case Else _VAT = _ocur.FindObject(Of VAT)(CriteriaOperator.Parse("DefaultForBusinnes")) End Select If _InvoiceHeader.CurrencyName.ShortName = "HUF" Then _InvoiceRows.DiscountPriceHUF = 0 _InvoiceRows.ListPriceHUF = Math.Round(Math.Abs(_PCIDetail.BallanceHUF) / (1 + _VAT.KeyValue), 2) Else _InvoiceRows.DiscountPriceDEV = 0 _InvoiceRows.DiscountPriceHUF = 0 _InvoiceRows.ListPriceDEV = Math.Round(Math.Abs(_PCIDetail.BallanceDEV) / (1 + _VAT.KeyValue), 2) _InvoiceRows.ListPriceHUF = Math.Round(Math.Abs(_PCIDetail.BallanceHUF) / (1 + _VAT.KeyValue), 2) End If _InvoiceRows.InvoiceRowtype = eInvoiceRowType.FromManual _InvoiceRows.VAT = _VAT _InvoiceRows.Units = _ocur.FindObject(Of Units)(CriteriaOperator.Parse("DefaultForBusinnes=True")) _InvoiceRows.ShortName = _OrderInHeader.OrderInParameters.AdvanceShortNameIn _InvoiceRows.Description = String.Format(_OrderInHeader.OrderInParameters.AdvanceDescriptionIn, _OrderInHeader.DocumentNumber) If _OrderInHeader.OrderInParameters IsNot Nothing Then If _OrderInHeader.OrderInParameters.Controlling_InvoiceAdvance_Default IsNot Nothing Then _InvoiceRows.Controlling = _OrderInHeader.OrderInParameters.Controlling_InvoiceAdvance_Default End If End If _InvoiceRows.RowIndex = 1 _ocur.CommitChanges() _InvoiceHeader.RecalculateInvoice(_InvoiceHeader, _ocur) _ocur.CommitChanges() Dim _uow_pci As New UnitOfWork(_ocur.Session.DataLayer) GLFunctions.ReconfigurePCI(_uow_pci, _InvoiceHeader.CustomersFrom, _InvoiceHeader.Customers, 0, _InvoiceHeader.ConnectInfo) '// Előlegszámla nyomtatása Dim _ReportData As ReportData Dim _ReportData_DEV As ReportData Dim _ReportData_DEV_EU As ReportData Dim _CurrencyName As CurrencyName _CurrencyName = _InvoiceHeader.CurrencyName If _InvoiceHeader IsNot Nothing Then Dim _XAFPrintHelper_I As New XAFPrintHelper(_ocur, Frame, _InvoiceHeader.InvoiceType.ReportDataV2, CriteriaOperator.Parse("InvoiceHeader.Oid = ?", _InvoiceHeader.Oid)) _XAFPrintHelper_I.ShowPreviewV2() End If End Select End If End If If Frame.GetController(Of RefreshController).RefreshAction.Enabled Then Frame.GetController(Of RefreshController).RefreshAction.DoExecute() End If Exit Sub CheckError: Select Case Err.Number Case 91, 13 Resume Next Case Else Throw New UserFriendlyException(Err.Description) End Select End Sub Private Sub aGenerateInvoiceFromOrderInFinal_Execute(sender As Object, e As PopupWindowShowActionExecuteEventArgs) Handles aGenerateInvoiceFromOrderInFinal.Execute '// Végszámla készítése előlegek beszámításával Dim _ocur As Xpo.XPObjectSpace = TryCast(View.ObjectSpace, Xpo.XPObjectSpace) Dim _InvoiceHeader As InvoiceHeader = _ocur.CreateObject(Of InvoiceHeader)() Dim _OrderInHeader As OrderInHeader = _ocur.GetObject(TryCast(View.SelectedObjects(0), OrderInHeader)) Dim _CurrencyRate As Double = _ocur.GetObject(TryCast(e.PopupWindow.View.SelectedObjects(0), ORI_Invoice_Popup).CurrencyRate) Dim _NG As NumberGenerator Dim _InvoiceRows As InvoiceRows Dim _OrderInRows As OrderInRows Dim _OrderInRowsOther As OrderInRowsOther Dim _DeliveryNoteOutRows As DeliveryNoteOutRows Dim _InvoiceRows_Mode_DeliveryNoteOutRows_Or_OrderInRows As eInvoiceRows_Mode_DeliveryNoteOutRows_Or_OrderInRows = eInvoiceRows_Mode_DeliveryNoteOutRows_Or_OrderInRows.eOrderInRows Dim _ORI_Invoice_Popup As ORI_Invoice_Popup = TryCast(e.PopupWindow.View.SelectedObjects(0), ORI_Invoice_Popup) On Error GoTo CheckError ' --- Ellenőrzés, hogy kell-e engedély ! -------------------------------------------------------------------------------------------------- If _ocur.GetObject(TryCast(e.PopupWindow.View.SelectedObjects(0), ORI_Invoice_Popup).PaymentOption).PayMode <> ePayMode.InCash Then If _OrderInHeader.SubjectToApproval(_OrderInHeader, _ocur) And _OrderInHeader.PermissionAllowed = False Then MsgBox(String.Format(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions\OrderInHeader", "PermissionNotAllowedToCreateInvoice")), MsgBoxStyle.Exclamation + MsgBoxStyle.OkOnly, String.Format(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions", "MsgBoxCheckItAgain"))) Exit Sub End If End If '// Meg kell nézni, hogy van-e mindenütt szándék ! Dim _ReadyForFinalInvoice As Boolean = False '// Ha van kiállítva szállítólevél, akkor abból lesz a számla ! If _OrderInHeader.DeliveryNoteOutRows IsNot Nothing Then If _OrderInHeader.DeliveryNoteOutRows.Count > 0 Then _InvoiceRows_Mode_DeliveryNoteOutRows_Or_OrderInRows = eInvoiceRows_Mode_DeliveryNoteOutRows_Or_OrderInRows.eDeliveryNoteOutRows Else _InvoiceRows_Mode_DeliveryNoteOutRows_Or_OrderInRows = eInvoiceRows_Mode_DeliveryNoteOutRows_Or_OrderInRows.eOrderInRows End If Else _InvoiceRows_Mode_DeliveryNoteOutRows_Or_OrderInRows = eInvoiceRows_Mode_DeliveryNoteOutRows_Or_OrderInRows.eOrderInRows End If If _InvoiceRows_Mode_DeliveryNoteOutRows_Or_OrderInRows = eInvoiceRows_Mode_DeliveryNoteOutRows_Or_OrderInRows.eDeliveryNoteOutRows Then For Each _DeliveryNoteOutRows In _OrderInHeader.DeliveryNoteOutRows If Math.Round(_DeliveryNoteOutRows.QTT_Will, 4, MidpointRounding.AwayFromZero) > 0 Then _ReadyForFinalInvoice = True Exit For End If Next Else For Each _OrderInRows In _OrderInHeader.OrderInRows If Math.Round(_OrderInRows.QTT_Process, 4, MidpointRounding.AwayFromZero) > 0 Then _ReadyForFinalInvoice = True Exit For End If Next End If For Each _OrderInRowsOther In _OrderInHeader.OrderInRowsOther If Math.Round(_OrderInRowsOther.QTT_Process, 4, MidpointRounding.AwayFromZero) > 0 Then _ReadyForFinalInvoice = True Exit For End If Next If _ReadyForFinalInvoice = False Then MsgBox(String.Format(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions\OrderInHeader", "NoSelectionforFinalInvoice")), MsgBoxStyle.Exclamation + MsgBoxStyle.OkOnly, String.Format(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions", "MsgBoxCheckItAgain"))) Exit Sub End If '// Ha van proforma állapot akkor NE engedjen számlázni _ReadyForFinalInvoice = True For Each _InvoiceRows In _OrderInHeader.InvoiceRows If _InvoiceRows.InvoiceHeader.IsProforma And String.IsNullOrEmpty(_InvoiceRows.InvoiceHeader.DocumentNumber) Then _ReadyForFinalInvoice = False Exit For End If Next If _ReadyForFinalInvoice = False Then MsgBox(String.Format(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions\OrderInHeader", "YesProformaInOrderInHeader")), MsgBoxStyle.Exclamation + MsgBoxStyle.OkOnly, String.Format(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions", "MsgBoxCheckItAgain"))) Exit Sub End If ' ---- FEJLÉC ADATOK MEGADÁSA ------------------------------------------------------------------------------------------------------------- _InvoiceHeader.IsProforma = True _InvoiceHeader.IsEditable = False _InvoiceHeader.InvoiceType = _OrderInHeader.OrderInParameters.InvoiceType _InvoiceHeader.CustomersFrom = _OrderInHeader.CustomersFrom _InvoiceHeader.Customers = _OrderInHeader.Customers If TryCast(e.PopupWindow.View.SelectedObjects(0), ORI_Invoice_Popup).IsFinalInvoice Then _InvoiceHeader.IsEditable = False _InvoiceHeader.IsProforma = False _InvoiceHeader.IsStorno = False _InvoiceHeader.ConnectInfo = _InvoiceHeader.InvoiceType.NumberGenerator.GetNewNumber(_InvoiceHeader.InvoiceType.NumberGenerator) _InvoiceHeader.DocumentNumber = _InvoiceHeader.ConnectInfo Else If _InvoiceHeader.InvoiceType.NumberGeneratorProforma IsNot Nothing Then _NG = _InvoiceHeader.InvoiceType.NumberGeneratorProforma _InvoiceHeader.DocumentNumberProforma = _NG.GetNewNumber(_NG) End If End If _InvoiceHeader.DateCreated = _ocur.GetObject(TryCast(e.PopupWindow.View.SelectedObjects(0), ORI_Invoice_Popup).DateCreated) _InvoiceHeader.DateExecution = _ocur.GetObject(TryCast(e.PopupWindow.View.SelectedObjects(0), ORI_Invoice_Popup).DateExecution) _InvoiceHeader.PaymentOption = _ocur.GetObject(TryCast(e.PopupWindow.View.SelectedObjects(0), ORI_Invoice_Popup).PaymentOption) If _InvoiceHeader.PaymentOption.PayMode = ePayMode.InCash Then Else _InvoiceHeader.BankInformation = _ocur.GetObject(TryCast(e.PopupWindow.View.SelectedObjects(0), ORI_Invoice_Popup).BankInformation) End If _InvoiceHeader.Description = _ocur.GetObject(TryCast(e.PopupWindow.View.SelectedObjects(0), ORI_Invoice_Popup).Description) _InvoiceHeader.DescriptionHeader = _ocur.GetObject(TryCast(e.PopupWindow.View.SelectedObjects(0), ORI_Invoice_Popup).Description_Header) _InvoiceHeader.CurrencyRate = _ocur.GetObject(TryCast(e.PopupWindow.View.SelectedObjects(0), ORI_Invoice_Popup).CurrencyRate) _InvoiceHeader.CurrencyName = _ocur.GetObject(TryCast(e.PopupWindow.View.SelectedObjects(0), ORI_Invoice_Popup).CurrencyName) If _InvoiceHeader.PaymentOption.PayMode = ePayMode.InContinuous Then _InvoiceHeader.DatePayment = _InvoiceHeader.DateExecution Else ' -- Egyébként számolja ki a fizetési opcióból, hogy hány nap van a kiállítás dátuma és a fizetési határidő között If _InvoiceHeader.PaymentOption.PayDay = 0 Then Else Select Case _InvoiceHeader.DatePaymentMode Case eDatePaymentMode.eDateCreated _InvoiceHeader.DatePayment = _InvoiceHeader.DateCreated.AddDays(_InvoiceHeader.PaymentOption.PayDay) Case eDatePaymentMode.eDateExecution _InvoiceHeader.DatePayment = _InvoiceHeader.DateExecution.AddDays(_InvoiceHeader.PaymentOption.PayDay) End Select End If If _ocur.GetObject(TryCast(e.PopupWindow.View.SelectedObjects(0), ORI_Invoice_Popup).IsAPCSheet) Then _InvoiceHeader.DatePayment = _ocur.GetObject(TryCast(e.PopupWindow.View.SelectedObjects(0), ORI_Invoice_Popup).DatePayment) End If End If '-- Próbaszámla miatt el kell menteni a tényleges adatokat -------------------------------------------------------- _InvoiceHeader.Saved_Customers_Name = _OrderInHeader.Customers.Name.ToString _InvoiceHeader.Saved_Customers_Address_Country = _OrderInHeader.Customers.Address1.Country.ToString _InvoiceHeader.Saved_Customers_Address_ZipPostal = _OrderInHeader.Customers.Address1.ZipPostal.ToString _InvoiceHeader.Saved_Customers_Address_Street = _OrderInHeader.Customers.Address1.Street.ToString _InvoiceHeader.Saved_Customers_Address_City = _OrderInHeader.Customers.Address1.City.ToString _InvoiceHeader.Saved_Customers_Address_StateProvince = _OrderInHeader.Customers.Address1.StateProvince.ToString _InvoiceHeader.Saved_Customers_VATNumber = _OrderInHeader.Customers.VATNumber.ToString _InvoiceHeader.Saved_Customers_VATNumberEU = _OrderInHeader.Customers.VATNumberEU.ToString _InvoiceHeader.Saved_CustomersFrom_Name = _OrderInHeader.CustomersFrom.Name.ToString _InvoiceHeader.Saved_CustomersFrom_Address_ZipPostal = _OrderInHeader.CustomersFrom.Address1.ZipPostal.ToString _InvoiceHeader.Saved_CustomersFrom_Address_Street = _OrderInHeader.CustomersFrom.Address1.Street.ToString _InvoiceHeader.Saved_CustomersFrom_Address_City = _OrderInHeader.CustomersFrom.Address1.City.ToString _InvoiceHeader.Saved_CustomersFrom_Address_StateProvince = _OrderInHeader.CustomersFrom.Address1.StateProvince.ToString _InvoiceHeader.Saved_CustomersFrom_VATNumber = _OrderInHeader.CustomersFrom.VATNumber.ToString _InvoiceHeader.Saved_CustomersFrom_VATNumberEU = _OrderInHeader.CustomersFrom.VATNumberEU.ToString _InvoiceHeader.Saved_CustomersFrom_Bank_ShortName = _InvoiceHeader.BankInformation.FullBankAccount.ToString _InvoiceHeader.Saved_CustomersFrom_Bank_IBAN = _InvoiceHeader.BankInformation.IBAN.ToString _InvoiceHeader.Saved_CustomersFrom_Bank_SWIFT = _InvoiceHeader.BankInformation.SWIFT.ToString _InvoiceHeader.Saved_CustomersFrom_Bank_AccountNumber = _InvoiceHeader.BankInformation.AccountNumber.ToString _InvoiceHeader.Save() ' ---- FEJLÉC ADATOK MEGADÁSÁNAK VÉGE ---------------------------------------------------------------------------------------------------- '------ A fejléchez tartozó sorok (termék és egyéb típusok) rendezése sorindex alapján --------------- _OrderInHeader.OrderInRows.Sorting.Add(New SortProperty("RowIndex", DB.SortingDirection.Ascending)) _OrderInHeader.OrderInRowsOther.Sorting.Add(New SortProperty("RowIndex", DB.SortingDirection.Ascending)) _OrderInHeader.DeliveryNoteOutRows.Sorting.Add(New SortProperty("RowIndex", DB.SortingDirection.Ascending)) '----------------------------------------------------------------------------------------------------- ' A fejléchez tartozó sorok átadása ----------------------------------------------------------------- Dim i As Int16 = 0 '----------------------------- Átadjuk az összes termék típusú sort -------------------------------------- If _InvoiceRows_Mode_DeliveryNoteOutRows_Or_OrderInRows = eInvoiceRows_Mode_DeliveryNoteOutRows_Or_OrderInRows.eOrderInRows Then For Each _OrderInRows In _OrderInHeader.OrderInRows If _OrderInRows.QTT_Process > 0 Then If _OrderInRows.QTT - (_OrderInRows.QTT_Process + _OrderInRows.QTT_Invoiced) >= 0 Then _InvoiceRows = _ocur.CreateObject(Of InvoiceRows)() _InvoiceRows.InvoiceHeader = _InvoiceHeader _InvoiceRows.OrderInRows = _OrderInRows _InvoiceRows.QTT = _OrderInRows.QTT_Process _OrderInRows.QTT_Invoiced += _OrderInRows.QTT_Process If _InvoiceHeader.CurrencyName.ShortName = "HUF" Then _InvoiceRows.DiscountPriceHUF = _OrderInRows.DiscountPriceHUF _InvoiceRows.ListPriceHUF = _OrderInRows.ListPriceHUF Else _InvoiceRows.DiscountPriceDEV = _OrderInRows.DiscountPriceDEV _InvoiceRows.DiscountPriceHUF = _OrderInRows.DiscountPriceDEV * _CurrencyRate ' A kerekítést még meg kell beszélni _InvoiceRows.ListPriceDEV = _OrderInRows.ListPriceDEV _InvoiceRows.ListPriceHUF = _OrderInRows.ListPriceDEV * _CurrencyRate ' A kerekítést még meg kell beszélni End If _InvoiceRows.InvoiceRowtype = eInvoiceRowType.FromOrder _InvoiceRows.VAT = _OrderInRows.VAT _InvoiceRows.Units = _OrderInRows.Products.Units _InvoiceRows.ShortName = _OrderInRows.Products.ShortName _InvoiceRows.Description = _OrderInRows.Products.Description _InvoiceRows.CustomsTariffs = _OrderInRows.Products.CustomsTariff If _OrderInHeader.OrderInParameters IsNot Nothing Then If _OrderInHeader.OrderInParameters.Controlling_Rows_Default IsNot Nothing Then _InvoiceRows.Controlling = _OrderInHeader.OrderInParameters.Controlling_Rows_Default End If End If _InvoiceRows.RowIndex = i i += 1 End If End If Next Else For Each _DeliveryNoteOutRows In _OrderInHeader.DeliveryNoteOutRows If _DeliveryNoteOutRows.QTT_Will > 0 Then If Math.Round(_DeliveryNoteOutRows.QTT, 4, MidpointRounding.AwayFromZero) - Math.Round((_DeliveryNoteOutRows.QTT_Will + _DeliveryNoteOutRows.QTT_Invoiced), 4, MidpointRounding.AwayFromZero) >= 0 Then _InvoiceRows = _ocur.CreateObject(Of InvoiceRows)() _InvoiceRows.InvoiceHeader = _InvoiceHeader _InvoiceRows.OrderInRows = _DeliveryNoteOutRows.StorageOutRowsInRows.StorageOutRows.OrderInRows _InvoiceRows.QTT = _DeliveryNoteOutRows.QTT_Will _DeliveryNoteOutRows.StorageOutRowsInRows.StorageOutRows.OrderInRows.QTT_Invoiced += _DeliveryNoteOutRows.QTT_Will _DeliveryNoteOutRows.QTT_Invoiced += _DeliveryNoteOutRows.QTT_Invoiced + _DeliveryNoteOutRows.QTT_Will If _InvoiceHeader.CurrencyName.ShortName = "HUF" Then _InvoiceRows.DiscountPriceHUF = _DeliveryNoteOutRows.StorageOutRowsInRows.StorageOutRows.OrderInRows.DiscountPriceHUF _InvoiceRows.ListPriceHUF = _DeliveryNoteOutRows.StorageOutRowsInRows.StorageOutRows.OrderInRows.ListPriceHUF Else _InvoiceRows.DiscountPriceDEV = _DeliveryNoteOutRows.StorageOutRowsInRows.StorageOutRows.OrderInRows.DiscountPriceDEV _InvoiceRows.DiscountPriceHUF = _DeliveryNoteOutRows.StorageOutRowsInRows.StorageOutRows.OrderInRows.DiscountPriceDEV * _CurrencyRate ' A kerekítést még meg kell beszélni _InvoiceRows.ListPriceDEV = _DeliveryNoteOutRows.StorageOutRowsInRows.StorageOutRows.OrderInRows.ListPriceDEV _InvoiceRows.ListPriceHUF = _DeliveryNoteOutRows.StorageOutRowsInRows.StorageOutRows.OrderInRows.ListPriceDEV * _CurrencyRate ' A kerekítést még meg kell beszélni End If _InvoiceRows.InvoiceRowtype = eInvoiceRowType.FromOrder _InvoiceRows.VAT = _DeliveryNoteOutRows.StorageOutRowsInRows.StorageOutRows.OrderInRows.VAT _InvoiceRows.Units = _DeliveryNoteOutRows.StorageOutRowsInRows.StorageOutRows.OrderInRows.Products.Units _InvoiceRows.ShortName = _DeliveryNoteOutRows.StorageOutRowsInRows.StorageOutRows.OrderInRows.Products.ShortName _InvoiceRows.Description = _DeliveryNoteOutRows.StorageOutRowsInRows.StorageOutRows.OrderInRows.Products.Description _InvoiceRows.CustomsTariffs = _DeliveryNoteOutRows.StorageOutRowsInRows.StorageOutRows.OrderInRows.Products.CustomsTariff _InvoiceRows.DeliveryNoteOutRows = _DeliveryNoteOutRows If _OrderInHeader.OrderInParameters IsNot Nothing Then If _OrderInHeader.OrderInParameters.Controlling_Rows_Default IsNot Nothing Then _InvoiceRows.Controlling = _OrderInHeader.OrderInParameters.Controlling_Rows_Default End If End If _InvoiceRows.RowIndex = i i += 1 End If End If Next End If '----------------------------- Átadjuk az összes egyéb típusú sort -------------------------------------- For Each _OrderInRowsOther In _OrderInHeader.OrderInRowsOther If _OrderInRowsOther.QTT_Process > 0 Then If _OrderInRowsOther.QTT - (_OrderInRowsOther.QTT_Process + _OrderInRowsOther.QTT_Invoiced) >= 0 Then _InvoiceRows = _ocur.CreateObject(Of InvoiceRows)() _InvoiceRows.InvoiceHeader = _InvoiceHeader _InvoiceRows.OrderInRowsOther = _OrderInRowsOther _InvoiceRows.QTT = _OrderInRowsOther.QTT_Process _OrderInRowsOther.QTT_Invoiced += _OrderInRowsOther.QTT_Process If _InvoiceHeader.CurrencyName.ShortName = "HUF" Then _InvoiceRows.DiscountPriceHUF = _OrderInRowsOther.DiscountPriceHUF _InvoiceRows.ListPriceHUF = _OrderInRowsOther.ListPriceHUF Else _InvoiceRows.DiscountPriceDEV = _OrderInRowsOther.DiscountPriceDEV _InvoiceRows.DiscountPriceHUF = _OrderInRowsOther.DiscountPriceDEV * _CurrencyRate ' A kerekítést még meg kell beszélni _InvoiceRows.ListPriceDEV = _OrderInRowsOther.ListPriceDEV _InvoiceRows.ListPriceHUF = _OrderInRowsOther.ListPriceDEV * _CurrencyRate ' A kerekítést még meg kell beszélni End If _InvoiceRows.InvoiceRowtype = eInvoiceRowType.FromOrder _InvoiceRows.VAT = _OrderInRowsOther.VAT _InvoiceRows.Units = _OrderInRowsOther.Units _InvoiceRows.UniqueObjects = _OrderInRowsOther.UniqueObjects _InvoiceRows.CostHolder = _OrderInRowsOther.CostHolder _InvoiceRows.CostPlace = _OrderInRowsOther.CostPlace _InvoiceRows.QualityOption = _OrderInRowsOther.QualityOption _InvoiceRows.Description = _OrderInRowsOther.Description _InvoiceRows.ShortName = _OrderInRowsOther.ShortName _InvoiceRows.CustomsTariffs = _OrderInRowsOther.CustomsTariffs If _OrderInHeader.OrderInParameters IsNot Nothing Then If _OrderInHeader.OrderInParameters.Controlling_OtherRows_Default IsNot Nothing Then _InvoiceRows.Controlling = _OrderInHeader.OrderInParameters.Controlling_OtherRows_Default End If End If _InvoiceRows.RowIndex = i i += 1 End If End If Next '// Most mínusszal a beszámított előkegek Dim _ListView As ListPropertyEditor = TryCast(e.PopupWindow.View, DetailView).FindItem("InvoiceAdvance") If _ListView IsNot Nothing Then For Each _InvoiceHeader_Advance As InvoiceHeader In _ListView.ListView.SelectedObjects If _InvoiceHeader_Advance.TotalAdvancedWill > 0 Then For Each _InvoiceRows_Advance As InvoiceRows In _InvoiceHeader_Advance.InvoiceRows _InvoiceRows = _ocur.CreateObject(Of InvoiceRows)() _InvoiceRows.InvoiceHeader = _InvoiceHeader _InvoiceRows.InvoiceRowsAdvance = _ocur.GetObject(_InvoiceRows_Advance) _InvoiceRows.QTT = -1 _InvoiceRows.DiscountPriceDEV = 0 _InvoiceRows.DiscountPriceHUF = 0 If _InvoiceHeader.CurrencyName.ShortName = "HUF" Then _InvoiceRows.ListPriceDEV = 0 _InvoiceRows.ListPriceHUF = _InvoiceHeader_Advance.TotalAdvancedWill / (1 + _InvoiceRows_Advance.VAT.KeyValue) Else _InvoiceRows.ListPriceDEV = _ocur.GetObject(_InvoiceRows_Advance.ListPriceDEV) _InvoiceRows.ListPriceHUF = _ocur.GetObject(_InvoiceRows_Advance.ListPriceHUF) End If _InvoiceRows.InvoiceRowtype = eInvoiceRowType.FromOrder _InvoiceRows.VAT = _ocur.GetObject(_InvoiceRows_Advance.VAT) _InvoiceRows.Units = _ocur.GetObject(_InvoiceRows_Advance.Units) _InvoiceRows.UniqueObjects = _ocur.GetObject(_InvoiceRows_Advance.UniqueObjects) _InvoiceRows.CostHolder = _ocur.GetObject(_InvoiceRows_Advance.CostHolder) _InvoiceRows.CostPlace = _ocur.GetObject(_InvoiceRows_Advance.CostPlace) _InvoiceRows.QualityOption = _ocur.GetObject(_InvoiceRows_Advance.QualityOption) _InvoiceRows.Description = String.Format(_OrderInHeader.OrderInParameters.AdvanceDescriptionOut, _InvoiceRows_Advance.InvoiceHeader.DocumentNumber) _InvoiceRows.ShortName = _OrderInHeader.OrderInParameters.AdvanceShortNameOut '"ELŐLEG BESZÁMÍTÁSA" _InvoiceRows.CustomsTariffs = _ocur.GetObject(_InvoiceRows_Advance.CustomsTariffs) If _OrderInHeader.OrderInParameters IsNot Nothing Then If _OrderInHeader.OrderInParameters.Controlling_InvoiceAdvance_Default IsNot Nothing Then _InvoiceRows.Controlling = _OrderInHeader.OrderInParameters.Controlling_InvoiceAdvance_Default End If End If _InvoiceRows.RowIndex = i Next End If Next End If If _OrderInHeader.OrderInParameters.CostHolder IsNot Nothing Then For Each _IR As InvoiceRows In _InvoiceHeader.InvoiceRows If _IR.CostHolder Is Nothing Then _IR.CostHolder = _OrderInHeader.OrderInParameters.CostHolder End If Next End If If _OrderInHeader.OrderInParameters.CostPlace IsNot Nothing Then For Each _IR As InvoiceRows In _InvoiceHeader.InvoiceRows If _IR.CostPlace Is Nothing Then _IR.CostPlace = _OrderInHeader.OrderInParameters.CostPlace End If Next End If _ocur.CommitChanges() _InvoiceHeader.RecalculateInvoice(_InvoiceHeader, _ocur) _ocur.CommitChanges() 'Előleg javítás MySQL !!!! Dim _SQL As String = "" _SQL = "UPDATE InvoiceHeader t1 JOIN (" _SQL += " Select t3.Oid,t3.DocumentNumber,MAX(t3.TotalBruttoHUF) As TotalBruttoHUF,ROUND(ABS(SUM(t1.SumPriceBruttoHUF)),0) As TotalAdvancedBruttoHUF" _SQL += " FROM InvoiceRows t1 JOIN InvoiceRows t2 ON" _SQL += " t1.InvoiceRowsAdvance=t2.Oid JOIN InvoiceHeader t3 On" _SQL += " t2.InvoiceHeader=t3.Oid AND t3.IsEditable=0 AND t3.IsStorno=0 AND t3.DocumentNumber IS NOT NULL JOIN InvoiceHeader t4 ON " _SQL += " t1.InvoiceHeader=t4.Oid And t4.IsStorno=0 And t4.IsEditable=0 And t4.DocumentNumber Is Not NULL" _SQL += " GROUP BY t3.Oid,t3.DocumentNumber" _SQL += " ) t2 On" _SQL += " t1.Oid=t2.Oid" _SQL += " Set t1.TotalAdvancedBruttoHUF=t2.TotalAdvancedBruttoHUF" _SQL += " WHERE t1.Oid=t2.Oid" _ocur.Session.ExecuteNonQuery(_SQL) If TryCast(e.PopupWindow.View.SelectedObjects(0), ORI_Invoice_Popup).IsFinalInvoice Then Dim _uow_pci As New UnitOfWork(_ocur.Session.DataLayer) GLFunctions.ReconfigurePCI(_uow_pci, _InvoiceHeader.CustomersFrom, _InvoiceHeader.Customers, 0, _InvoiceHeader.ConnectInfo) ' --- Pénztári bizonylat ---------------------------------------------------- If _ORI_Invoice_Popup.IsLiquidAssets AndAlso _ORI_Invoice_Popup.PaymentOption.PayMode = ePayMode.InCash And _ORI_Invoice_Popup.IsFinalInvoice Then CreateGLCassa(_InvoiceHeader, _ocur, _ORI_Invoice_Popup) End If Dim _XAFPrintHelper_I As New XAFPrintHelper(_ocur, Frame, _InvoiceHeader.InvoiceType.ReportDataV2, CriteriaOperator.Parse("InvoiceHeader.Oid = ?", _InvoiceHeader.Oid)) _XAFPrintHelper_I.ShowPreviewV2() End If Frame.GetController(Of RefreshController).RefreshAction.DoExecute() Exit Sub CheckError: If Err.Number = 91 Then Resume Next If Err.Number = 13 Then Resume Next If Err.Number = 5 Then Throw New UserFriendlyException(Err.Description) End Sub #End Region #End Region Private Sub RecalculateDEV(_Object As Object, _OrderInHeader As OrderInHeader) Try Dim _OrderInRows As OrderInRows Dim _OrderInRowsOther As OrderInRowsOther If _OrderInHeader IsNot Nothing Then If _OrderInHeader.OrderInParameters.CurrencyName.ShortName <> "HUF" Then For Each _OrderInRows In _OrderInHeader.OrderInRows If _Object.PriceMode = ePriceMode.eDEVToHUF Then _OrderInRows.ListPriceHUF = Math.Round(_OrderInRows.ListPriceDEV * _Object.CurrencyRate, 0, MidpointRounding.AwayFromZero) _OrderInRows.DiscountPriceHUF = Math.Round(_OrderInRows.DiscountPriceDEV * _Object.CurrencyRate, 0, MidpointRounding.AwayFromZero) Else If _Object.CurrencyRate <> 0 Then _OrderInRows.ListPriceDEV = Math.Round(_OrderInRows.ListPriceHUF / _Object.CurrencyRate, 2, MidpointRounding.AwayFromZero) _OrderInRows.DiscountPriceDEV = Math.Round(_OrderInRows.DiscountPriceHUF / _Object.CurrencyRate, 2, MidpointRounding.AwayFromZero) End If End If _OrderInRows.RecalculateRows() Next For Each _OrderInRowsOther In _OrderInHeader.OrderInRowsOther If _Object.PriceMode = ePriceMode.eDEVToHUF Then _OrderInRowsOther.ListPriceHUF = Math.Round(_OrderInRowsOther.ListPriceDEV * _Object.CurrencyRate, 0, MidpointRounding.AwayFromZero) _OrderInRowsOther.DiscountPriceHUF = Math.Round(_OrderInRowsOther.DiscountPriceDEV * _Object.CurrencyRate, 0, MidpointRounding.AwayFromZero) Else If _Object.CurrencyRate <> 0 Then _OrderInRowsOther.ListPriceDEV = Math.Round(_OrderInRowsOther.ListPriceHUF / _Object.CurrencyRate, 2, MidpointRounding.AwayFromZero) _OrderInRowsOther.DiscountPriceDEV = Math.Round(_OrderInRowsOther.DiscountPriceHUF / _Object.CurrencyRate, 2, MidpointRounding.AwayFromZero) End If End If _OrderInRowsOther.RecalculateRows() Next End If End If Catch ex As Exception MsgBox(ex.Message, MsgBoxStyle.OkOnly + MsgBoxStyle.Critical, String.Format(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions", "MsgBoxCheckItAgain"))) End Try End Sub Private Sub aORI_RecalculateTotalBrutto_Execute(sender As Object, e As SimpleActionExecuteEventArgs) Handles aORI_RecalculateTotalBrutto.Execute 'Dim _ocur As Xpo.XPObjectSpace = TryCast(View.ObjectSpace, Xpo.XPObjectSpace) 'For Each _OrderInHeader As OrderInHeader In View.SelectedObjects ' _OrderInHeader.RecalculateHeaderTotalBrutto() 'Next '_ocur.CommitChanges() 'If Frame.GetController(Of RefreshController).RefreshAction.Enabled Then ' Frame.GetController(Of RefreshController).RefreshAction.DoExecute() 'End If End Sub End Class