ProductsGant vol2

This commit is contained in:
2018-05-11 16:02:29 +02:00
parent 6cd9efe671
commit 9f329664f5
13 changed files with 198 additions and 306 deletions
@@ -9,20 +9,27 @@ Imports DevExpress.Persistent.Base
Imports DevExpress.Persistent.BaseImpl
Imports DevExpress.Persistent.Validation
Imports DevExpress.ExpressApp.ConditionalAppearance
Imports DevExpress.ExpressApp.Editors
<DefaultClassOptions(), NavigationItem(False), CreatableItem(False)> _
<Appearance("ProductsGant - CustomersFrom all time", TargetItems:="CustomersFrom", Criteria:="1=1", Enabled:=False, Context:="Any")> _
''' <summary>
''' Termék GANTT !!!
''' </summary>
<DefaultClassOptions(), NavigationItem(False), CreatableItem(False)>
<Appearance("ProductsGant - CustomersFrom all time", TargetItems:="CustomersFrom", Criteria:="IsNull(CustomersFrom)=False", Enabled:=False, Context:="Any")>
Public Class ProductsGant
Inherits BaseObject
Private _CustomersFrom As CustomersFrom
Private _G2antt As String
Private _Criteria As String
Private _PGR As ProductsGantRows
Private _DateExecution As DateTime
Public Sub New(ByVal session As Session)
MyBase.New(session)
End Sub
Public Overrides Sub AfterConstruction()
MyBase.AfterConstruction()
DateExecution = GetSQLTime(Session)
End Sub
Property CustomersFrom As CustomersFrom
@@ -33,7 +40,34 @@ Public Class ProductsGant
SetPropertyValue("CustomersFrom", _CustomersFrom, value)
End Set
End Property
<Size(-1)> _
<CriteriaOptionsAttribute("ObjectType"), Size(-1), ImmediatePostData(True)>
Property Criteria As String
Get
Return _Criteria
End Get
Set(value As String)
SetPropertyValue("Criteria", _Criteria, value)
End Set
End Property
<NonPersistent(), MemberDesignTimeVisibility(False)>
Public Property ObjectType() As Type
Get
Return GetType(ProductsGantRows)
End Get
Set(ByVal value As Type)
End Set
End Property
<NonPersistent>
Public Property DateExecution As DateTime
Get
Return _DateExecution
End Get
Set(value As DateTime)
SetPropertyValue("DateExecution", _DateExecution, value)
End Set
End Property
<Size(-1)>
Property G2antt As String
Get
Return _G2antt
@@ -44,12 +78,17 @@ Public Class ProductsGant
End Property
'ReadOnly
<VisibleInListView(False)> _
<VisibleInLookupListView(False)> _
<Association("ProductsGant - ProductsGantRows", GetType(ProductsGantRows))> _
<VisibleInListView(False)>
<VisibleInLookupListView(False)>
ReadOnly Property ProductsGantRows As XPCollection(Of ProductsGantRows)
Get
Return GetCollection(Of ProductsGantRows)("ProductsGantRows")
Dim _CC As String = " ProductsGant.Oid = '" & Me.Oid.ToString() & "'"
If String.IsNullOrEmpty(Criteria) = False Then
_CC += " AND " & CriteriaOperator.Parse(Criteria).ToString()
End If
Return New XPCollection(Of ProductsGantRows)(Session, CriteriaOperator.Parse(_CC))
End Get
End Property
End Class
@@ -9,7 +9,7 @@ Imports DevExpress.Persistent.Base
Imports DevExpress.Persistent.BaseImpl
Imports DevExpress.Persistent.Validation
<DefaultClassOptions(), NavigationItem(False), CreatableItem(False)> _
<DefaultClassOptions(), NavigationItem(False), CreatableItem(False)>
Public Class ProductsGantRows
Inherits BaseObject
@@ -25,8 +25,6 @@ Public Class ProductsGantRows
Public Overrides Sub AfterConstruction()
MyBase.AfterConstruction()
End Sub
<Association("ProductsGant - ProductsGantRows", GetType(ProductsGant))> _
Property ProductsGant As ProductsGant
Get
Return _ProductsGant
@@ -69,9 +67,9 @@ Public Class ProductsGantRows
End Property
'ReadOnly
<VisibleInListView(False)> _
<VisibleInLookupListView(False)> _
<Association("ProductsGantRows - ProductsGantRowsBar", GetType(ProductsGantRowsBar))> _
<VisibleInListView(False)>
<VisibleInLookupListView(False)>
<Association("ProductsGantRows - ProductsGantRowsBar", GetType(ProductsGantRowsBar))>
ReadOnly Property ProductsGantRowsBar As XPCollection(Of ProductsGantRowsBar)
Get
Return GetCollection(Of ProductsGantRowsBar)("ProductsGantRowsBar")
@@ -14,6 +14,8 @@ Imports System.Linq
Imports DevExpress.ExpressApp.Editors
Imports DevExpress.Persistent.BaseImpl
Imports DevExpress.ExpressApp.Utils
Imports DevExpress.ExpressApp.Xpo
Imports DevExpress.Xpo.DB
Public Class ProductsGant_VC
Inherits DevExpress.ExpressApp.ViewController
@@ -26,29 +28,45 @@ Public Class ProductsGant_VC
Public Event InitWork(ByVal _Minimum As Long, ByVal _Step As Long, ByVal _Maximum As Long)
Public Event DoWork()
Public Event FinalWork
Public Event FinalWork()
#Region "Overrides"
Protected Overrides Sub OnActivated()
MyBase.OnActivated()
If View.Id = "ProductsGant_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)
End If
End Sub
Protected Overrides Sub OnDeactivated()
MyBase.OnDeactivated()
If View.Id = "ProductsGant_ListView" Then
Frame.GetController(Of DeleteObjectsViewController)()?.Active.SetItemValue("", True)
Frame.GetController(Of LinkUnlinkController)()?.Active.SetItemValue("", True)
Frame.GetController(Of NewObjectViewController)()?.Active.SetItemValue("", True)
Frame.GetController(Of CloneObject.CloneObjectViewController)()?.Active.SetItemValue("", True)
End If
End Sub
#End Region
Public Function CountLast16Week(ByVal _Products_Oid As String, ByVal _Customers_Oid As String) As Double
Dim _onew As XPObjectSpace = TryCast(Application.CreateObjectSpace(), XPObjectSpace)
Dim _CalculatedRotation As Double = 0
Dim _SQL As String
_SQL = " SELECT ROUND(SUM(t1.QTT)/16,2) As CalculatedRotation"
_SQL = _SQL + " FROM InvoiceRows t1 JOIN OrderInRows t2 On"
_SQL = _SQL + " t1.OrderInRows=t2.Oid JOIN Products t3 On"
_SQL = _SQL + " t2.Products=t3.Oid JOIN InvoiceHeader t4 On"
_SQL = _SQL + " t1.InvoiceHeader=t4.Oid JOIN Organization t5 On"
_SQL = _SQL + " t4.Customers=t5.Oid"
_SQL = _SQL + " WHERE t4.IsEditable=0 And t4.DocumentNumber!='' AND "
_SQL = _SQL + " t3.Oid='" & _Products_Oid & "' AND t5.Oid = '" & _Customers_Oid & "' AND "
_SQL = _SQL + " DATE_ADD(NOW(),INTERVAL -16 WEEK)<t4.DateExecution"
Dim _SelectedData As SelectedData = _onew.Session.ExecuteQuery(_SQL)
For Each row As SelectStatementResultRow In _SelectedData.ResultSet(0).Rows
If row.Values(0) IsNot Nothing Then
_CalculatedRotation = Double.Parse(row.Values(0))
End If
Next row
Return _CalculatedRotation
End Function
Private Sub aProductsGant_GerenrateProductsGantRows_Execute(sender As Object, e As SimpleActionExecuteEventArgs) Handles aProductsGant_GerenrateProductsGantRows.Execute
Dim _ocur As Xpo.XPObjectSpace = TryCast(View.ObjectSpace, Xpo.XPObjectSpace)
Dim _uow As New UnitOfWork(_ocur.Session.DataLayer)
@@ -75,14 +93,13 @@ Public Class ProductsGant_VC
_InvoiceRowsXPQ.InvoiceHeader IsNot Nothing And
_InvoiceRowsXPQ.InvoiceHeader.IsEditable = False And
_InvoiceRowsXPQ.InvoiceHeader.CustomersFrom.Oid = _ProductsGant.CustomersFrom.Oid
Group _InvoiceRowsXPQ By _InvoiceRowsXPQ.InvoiceHeader.Customers, _
_InvoiceRowsXPQ.OrderInRows.Products Into g = Group _
Select New With {Key .Customers = Customers, _
Group _InvoiceRowsXPQ By _InvoiceRowsXPQ.InvoiceHeader.Customers,
_InvoiceRowsXPQ.OrderInRows.Products Into g = Group
Select New With {Key .Customers = Customers,
Key .Products = Products}
' _InvoiceRowsXPQ.InvoiceHeader.DateExecution.Date > #7/1/2013#
Try
GeneralFunction.GLOBAL_HAS_Audit = False
RaiseEvent InitWork(1, 1, IRXPQ.Count)
For Each item In IRXPQ
RaiseEvent DoWork()
@@ -91,12 +108,12 @@ Public Class ProductsGant_VC
.ProductsGant = _ProductsGant
.Customers = item.Customers
.Products = item.Products
.CalculatedRotation = 0
.CalculatedRotation = CountLast16Week(item.Products.Oid.ToString, item.Customers.Oid.ToString)
.ManualRotation = 0
End With
'Számlázott mennyiségekhez ProductsGantRowsBar
Dim _InvoiceRows_Collection As New XPCollection(Of InvoiceRows)(_ocur.Session, CriteriaOperator.Parse("InvoiceHeader.Customers=? AND OrderInRows.Products=? AND InvoiceHeader.IsEditable=False AND " + _
Dim _InvoiceRows_Collection As New XPCollection(Of InvoiceRows)(_ocur.Session, CriteriaOperator.Parse("InvoiceHeader.Customers=? AND OrderInRows.Products=? AND InvoiceHeader.IsEditable=False AND " +
"InvoiceHeader.IsStorno=False AND (IsNull(InvoiceHeader.DocumentNumber)=False OR InvoiceHeader.DocumentNumber<>'')", item.Customers, item.Products))
If _InvoiceRows_Collection.Count > 0 Then
@@ -176,7 +193,8 @@ Public Class ProductsGant_VC
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.OkOnly + MsgBoxStyle.Critical, String.Format(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions", "MsgBoxCheckItAgain")))
Finally
RaiseEvent FinalWork
RaiseEvent FinalWork()
GLOBAL_HAS_Audit = True
End Try
End Sub
@@ -194,13 +212,14 @@ Public Class ProductsGant_VC
_InvoiceRowsXPQ.InvoiceHeader IsNot Nothing And
_InvoiceRowsXPQ.InvoiceHeader.IsEditable = False And
_InvoiceRowsXPQ.InvoiceHeader.CustomersFrom.Oid = _ProductsGant.CustomersFrom.Oid
Group _InvoiceRowsXPQ By _InvoiceRowsXPQ.InvoiceHeader.Customers, _
_InvoiceRowsXPQ.OrderInRows.Products Into g = Group _
Select New With {Key .Customers = Customers, _
Group _InvoiceRowsXPQ By _InvoiceRowsXPQ.InvoiceHeader.Customers,
_InvoiceRowsXPQ.OrderInRows.Products Into g = Group
Select New With {Key .Customers = Customers,
Key .Products = Products}
' _InvoiceRowsXPQ.InvoiceHeader.DateExecution.Date > #7/1/2013#
Try
GLOBAL_HAS_Audit = False
RaiseEvent InitWork(1, 1, IRXPQ.Count)
For Each item In IRXPQ
RaiseEvent DoWork()
@@ -212,13 +231,13 @@ Public Class ProductsGant_VC
.ProductsGant = _ProductsGant
.Customers = item.Customers
.Products = item.Products
.CalculatedRotation = 0
.CalculatedRotation = CountLast16Week(item.Products.Oid.ToString, item.Customers.Oid.ToString)
.ManualRotation = 0
End With
End If
'Számlázott mennyiségekhez ProductsGantRowsBar
Dim _InvoiceRows_Collection As New XPCollection(Of InvoiceRows)(_ocur.Session, CriteriaOperator.Parse("InvoiceHeader.Customers=? AND OrderInRows.Products=? AND InvoiceHeader.IsEditable=False AND " + _
Dim _InvoiceRows_Collection As New XPCollection(Of InvoiceRows)(_ocur.Session, CriteriaOperator.Parse("InvoiceHeader.Customers=? AND OrderInRows.Products=? AND InvoiceHeader.IsEditable=False AND " +
"InvoiceHeader.IsStorno=False AND (IsNull(InvoiceHeader.DocumentNumber)=False OR InvoiceHeader.DocumentNumber<>'')", item.Customers, item.Products))
If _InvoiceRows_Collection.Count > 0 Then
_InvoiceRows_Collection.Sorting.Add(New SortProperty("DateExecution", DB.SortingDirection.Ascending))
@@ -226,7 +245,7 @@ Public Class ProductsGant_VC
Dim _FromDate As New Date(_InvoiceRows.InvoiceHeader.DateExecution.Year, _InvoiceRows.InvoiceHeader.DateExecution.Month, _InvoiceRows.InvoiceHeader.DateExecution.Day, 0, 0, 0)
Dim _ToDate = New Date(_InvoiceRows.InvoiceHeader.DateExecution.Year, _InvoiceRows.InvoiceHeader.DateExecution.Month, _InvoiceRows.InvoiceHeader.DateExecution.Day, 23, 59, 59)
Dim _ProductsGantRowsBar_InvoiceRows As ProductsGantRowsBar = _ocur.FindObject(Of ProductsGantRowsBar)(CriteriaOperator.Parse("ProductsGantRows=? AND FromDate=? AND ToDate=? AND BarType=0", _
Dim _ProductsGantRowsBar_InvoiceRows As ProductsGantRowsBar = _ocur.FindObject(Of ProductsGantRowsBar)(CriteriaOperator.Parse("ProductsGantRows=? AND FromDate=? AND ToDate=? AND BarType=0",
_ProductsGantRows, _FromDate, _ToDate))
If _ProductsGantRowsBar_InvoiceRows Is Nothing Then
_ProductsGantRowsBar_InvoiceRows = New ProductsGantRowsBar(_ocur.Session)
@@ -283,7 +302,7 @@ Public Class ProductsGant_VC
End If
Dim _ProductsGantRowsBar_Reported As ProductsGantRowsBar = _ocur.FindObject(Of ProductsGantRowsBar)(CriteriaOperator.Parse("ProductsGantRows=? AND FromDate=? AND ToDate=? AND BarType=2", _
Dim _ProductsGantRowsBar_Reported As ProductsGantRowsBar = _ocur.FindObject(Of ProductsGantRowsBar)(CriteriaOperator.Parse("ProductsGantRows=? AND FromDate=? AND ToDate=? AND BarType=2",
_ProductsGantRows, _FromDate, _ToDate))
If _ProductsGantRowsBar_Reported Is Nothing Then
_ProductsGantRowsBar_Reported = New ProductsGantRowsBar(_ocur.Session)
@@ -308,7 +327,7 @@ Public Class ProductsGant_VC
Dim _FromDate As New Date(_OrderInRows.OrderInHeader.DateExecution.Year, _OrderInRows.OrderInHeader.DateExecution.Month, _OrderInRows.OrderInHeader.DateExecution.Day, 0, 0, 0)
Dim _ToDate As New Date(_OrderInRows.OrderInHeader.DateExecution.Year, _OrderInRows.OrderInHeader.DateExecution.Month, _OrderInRows.OrderInHeader.DateExecution.Day, 23, 59, 59)
Dim _ProductsGantRowsBar As ProductsGantRowsBar = _ocur.FindObject(Of ProductsGantRowsBar)(CriteriaOperator.Parse("ProductsGantRows=? AND FromDate=? AND ToDate=? AND BarType=1", _
Dim _ProductsGantRowsBar As ProductsGantRowsBar = _ocur.FindObject(Of ProductsGantRowsBar)(CriteriaOperator.Parse("ProductsGantRows=? AND FromDate=? AND ToDate=? AND BarType=1",
_ProductsGantRows, _FromDate, _ToDate))
If _ProductsGantRowsBar Is Nothing Then
@@ -329,7 +348,8 @@ Public Class ProductsGant_VC
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.OkOnly + MsgBoxStyle.Critical, String.Format(CaptionHelper.GetLocalizedText("Exceptions\NuvolarExceptions", "MsgBoxCheckItAgain")))
Finally
RaiseEvent FinalWork
RaiseEvent FinalWork()
GLOBAL_HAS_Audit = True
End Try
End Sub
End Class
+1 -1
View File
@@ -24201,7 +24201,7 @@
<ColumnInfo Id="DateExecution" InLineEdit="True" InLineEditAutoCommit="True" />
</Columns>
</ListView>
<DetailView Id="ProductsGant_DetailView" AllowDelete="False" AllowNew="False">
<DetailView Id="ProductsGant_DetailView">
<Layout>
<LayoutItem Id="CustomersFrom" ViewItem="CustomersFrom" SizeConstraintsType="Default" Index="0" RelativeSize="3" IsNewNode="True" />
<LayoutItem Id="G2antt" ShowCaption="False" ViewItem="G2antt" SizeConstraintsType="Default" Index="1" RelativeSize="96" IsNewNode="True" />