document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. \'============================== The Beginning of the Copyright Notice =================================
  2. \' THE AULIX.COMMON7 LIBRARY SOFTWARE PRODUCT
  3. \' The AUTHOR of this file is Alexander Borisovich Prokopyev, Kurgan, Russia
  4. \' More info can be found at the AUTHOR\'s website: http://www.aulix.com/resume
  5. \' Contact: alexander.prokopyev at aulix dot com
  6. \'
  7. \' Copyright (c) Alexander Prokopyev, 2006-2013
  8. \'
  9. \' All materials contained in this file are protected by copyright law.
  10. \' Nobody except the AUTHOR may alter or remove this copyright notice from copies of the content.
  11. \'
  12. \' The AUTHOR explicitly prohibits to use this content by any method without a prior
  13. \' written hand-signed permission of the AUTHOR.
  14. \'================================= The End of the Copyright Notice ====================================
  15.  
  16.  
  17. Imports System.Windows.Forms
  18. Imports DevExpress.XtraEditors
  19. Imports Microsoft.Reporting.WinForms
  20. Imports System.Reflection
  21.  
  22. <Obfuscation(Feature:="Apply to member * when method: virtualization", Exclude:=False)> _
  23. Public Class AdvancedForm
  24.     Inherits DevExpress.XtraEditors.XtraForm
  25.  
  26.     Private Sub AdvancedForm_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
  27.         EnsureDataIsSaved()
  28.     End Sub
  29.  
  30.     Public Overridable Sub EnsureDataIsSaved()
  31.         Dim F As Form
  32.         For Each F In MdiChildren
  33.             Try
  34.                 CType(F, AdvancedForm).EnsureDataIsSaved()
  35.             Catch ex As System.Exception
  36.             End Try
  37.         Next
  38.         For Each C As Windows.Forms.Control In Me.Controls
  39.             If TypeOf C Is AdvancedGrid Then
  40.                 CType(C, AdvancedGrid).EnsureDataIsSaved()
  41.             End If
  42.         Next
  43.     End Sub
  44.  
  45.     Function TryToOpenChildForm(ByVal FormName As String, ByVal AssemblyName As String) As Form
  46.         Try
  47.             TryToOpenChildForm = CType(DotNetBridge.CreateObject(AssemblyName, AssemblyName & "." & FormName), Form)
  48.         Catch ex As System.Exception
  49.         End Try
  50.     End Function
  51.  
  52.     \'Function OpenChildForm(ByVal FormName As String) As Form \', Optional ByVal Modal As Boolean = False
  53.    \'    OpenChildForm = TryToOpenChildForm(FormName, My.Application.Info.AssemblyName)
  54.    \'    If IsNothing(OpenChildForm) Then
  55.    \'        OpenChildForm = TryToOpenChildForm(FormName, "Aulix.Common7.WinForms")
  56.    \'    End If
  57.    \'    If IsNothing(OpenChildForm) Then
  58.    \'        OpenChildForm = TryToOpenChildForm(FormName, "Aulix.Common7.BL")
  59.    \'    End If
  60.    \'    If IsNothing(OpenChildForm) Then
  61.    \'        MsgBox("Cannot find a form: " & FormName)
  62.    \'    Else
  63.    \'        OpenChildForm.MdiParent = Me
  64.    \'        OpenChildForm.Show()
  65.    \'    End If
  66.    \'End Function
  67.  
  68.     Function OpenChildForm(ByVal FormType As Type, ByVal ParamArray PA() As Object) As Form \', Optional ByVal Modal As Boolean = False
  69.        OpenChildForm = CType(Activator.CreateInstance(FormType, PA), Form)
  70.         With OpenChildForm
  71.             .MdiParent = Me
  72.             .Show()
  73.         End With
  74.     End Function
  75.  
  76.     Function FindChildFormByName(ByVal FormName As String) As Windows.Forms.Form
  77.         For Each F As Windows.Forms.Form In MdiChildren
  78.             If F.Name = FormName Then
  79.                 FindChildFormByName = F
  80.                 Exit Function
  81.             End If
  82.         Next
  83.     End Function
  84.  
  85. End Class
  86.  
  87. <Obfuscation(Feature:="Apply to member * when method: virtualization", Exclude:=False)> _
  88. Public Class AdvancedGrid
  89.     Inherits DevExpress.XtraGrid.GridControl
  90.     Private WithEvents CN As DevExpress.XtraEditors.ControlNavigator
  91.     Event DeleteRowBtnClicked(ByVal sender As Object, ByVal e As DevExpress.XtraEditors.NavigatorButtonClickEventArgs)
  92.     Event AddRowBtnClicked(ByVal sender As Object, ByVal e As DevExpress.XtraEditors.NavigatorButtonClickEventArgs)
  93.  
  94.     Private Sub AdvancedGrid_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  95.         If Not DesignMode Then
  96.             UseEmbeddedNavigator = True
  97.             CN = EmbeddedNavigator
  98.         End If
  99.     End Sub
  100.  
  101.     Sub EnsureDataIsSaved()
  102.         CloseEditors()
  103.         If CType(DS, AdvancedDataSet).HasChanges Then
  104.             If MsgBox(Messages.GetMessage("DataNotSaved"), MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
  105.                 SaveData()
  106.             End If
  107.         End If
  108.     End Sub
  109.  
  110.     Sub CloseEditors()
  111.         For Each V As DevExpress.XtraGrid.Views.Base.BaseView In ViewCollection
  112.             V.CloseEditor()
  113.             V.UpdateCurrentRow()
  114.         Next
  115.     End Sub
  116.  
  117.     Sub SaveData()
  118.         CloseEditors()
  119.         If DS IsNot Nothing AndAlso TypeOf DS Is DataSet Then
  120.             With CType(DS, AdvancedDataSet)
  121.                 Dim Ch = .GetChanges(DataRowState.Deleted)
  122.                 .Save()
  123.             End With
  124.         End If
  125.     End Sub
  126.  
  127.     Private Sub CN_ButtonClick(ByVal sender As Object, ByVal e As DevExpress.XtraEditors.NavigatorButtonClickEventArgs) Handles CN.ButtonClick
  128.         If e.Button.ButtonType = DevExpress.XtraEditors.NavigatorButtonType.Append Then
  129.             RaiseEvent AddRowBtnClicked(sender, e)
  130.         End If
  131.         If e.Button.ButtonType = DevExpress.XtraEditors.NavigatorButtonType.Remove Then
  132.             If MsgBox(Messages.GetMessage("AreYouSureToDelete"), MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
  133.                 Dim V As Aulix.Common7.WinForms.AdvancedGridView = CType(FocusedView, AdvancedGridView) \'Dim V As DevExpress.XtraGrid.Views.BandedGrid.AdvBandedGridView = FocusedView
  134.                V.EnsureAtLeastOneFocusedRowIsSelected()
  135.                 RaiseEvent DeleteRowBtnClicked(sender, e)
  136.                 If Not e.Handled Then
  137.                     V.DeleteSelectedRows()
  138.                     If DS IsNot Nothing AndAlso TypeOf DS Is DataSet Then
  139.                         With CType(DS, AdvancedDataSet)
  140.                             Dim Ch = .GetChanges(DataRowState.Deleted)
  141.                             .Save()
  142.                         End With
  143.                         \'ElseIf TypeOf DS Is DataTable Then
  144.                        \'!!!ElseIf TypeOf DS Is AdvancedBindingSource Then
  145.                        \'    CType(DS, AdvancedBindingSource).Flush()
  146.                    End If
  147.                     e.Handled = True
  148.                 End If
  149.             Else
  150.                 e.Handled = True
  151.             End If
  152.         End If
  153.     End Sub
  154.  
  155.     Public ReadOnly Property DS() As Object
  156.         Get
  157.             \'If TypeOf DataSource Is AdvancedDataSet Then
  158.            \'DS = CType(DataSource, AdvancedDataSet)
  159.            DS = DataSource
  160.             \'End If
  161.        End Get
  162.     End Property
  163.  
  164.     Public ReadOnly Property ADS() As AdvancedDataSet
  165.         Get
  166.             \'If TypeOf DataSource Is AdvancedDataSet Then
  167.            \'DS = CType(DataSource, AdvancedDataSet)
  168.            ADS = CType(DataSource, AdvancedDataSet)
  169.             \'End If
  170.        End Get
  171.     End Property
  172.  
  173.     Protected Overrides Sub RegisterAvailableViewsCore(ByVal C As DevExpress.XtraGrid.Registrator.InfoCollection)
  174.         MyBase.RegisterAvailableViewsCore(C)
  175.         C.Add(New AdvancedGridViewInfoRegistrator)
  176.     End Sub
  177.  
  178.     Protected Overrides Function CreateDefaultView() As DevExpress.XtraGrid.Views.Base.BaseView
  179.         Return CreateView("AdvancedGridView")
  180.     End Function
  181.  
  182.     Public Sub SwitchMainView(ByVal NewView As AdvancedGridView)
  183.         MainView = NewView
  184.     End Sub
  185.  
  186. End Class
  187.  
  188. <Obfuscation(Feature:="Apply to member * when method: virtualization", Exclude:=False)> _
  189. Public Class AdvancedGridViewInfoRegistrator
  190.     Inherits DevExpress.XtraGrid.Registrator.AdvBandedGridInfoRegistrator
  191.  
  192.     Public Overrides ReadOnly Property ViewName() As String
  193.         Get
  194.             Return "AdvancedGridView"
  195.         End Get
  196.     End Property
  197.  
  198.     Public Overrides Function CreateView(ByVal Grid As DevExpress.XtraGrid.GridControl) As DevExpress.XtraGrid.Views.Base.BaseView
  199.         Return New AdvancedGridView(Grid)
  200.     End Function
  201. End Class
  202.  
  203. <Obfuscation(Feature:="Apply to member * when method: virtualization", Exclude:=False)> _
  204. Public Class AdvancedGridView
  205.     Inherits DevExpress.XtraGrid.Views.BandedGrid.AdvBandedGridView
  206.     \'!!!Public UpdatedRowState As System.Data.DataRowState
  207.  
  208.     Public ReadOnly Property T() As AdvancedDataTable
  209.         Get
  210.             If TypeOf Grid.DataSource Is AdvancedDataSet Then
  211.                 T = CType(Grid.DataSource, AdvancedDataSet).T(Name)
  212.             ElseIf TypeOf Grid.DataSource Is AdvancedDataTable Then
  213.                 T = CType(Grid.DataSource, AdvancedDataTable)
  214.             End If
  215.         End Get
  216.     End Property
  217.  
  218.     Public Sub New()
  219.         MyClass.New(Nothing)
  220.         Init_()
  221.     End Sub
  222.  
  223.     Public Sub New(ByVal Grid As DevExpress.XtraGrid.GridControl)
  224.         MyBase.New(Grid)
  225.         Init_()
  226.     End Sub
  227.  
  228.     Public Sub New(ByVal Grid As AdvancedGrid)
  229.         MyBase.New(Grid)
  230.         Init_()
  231.     End Sub
  232.  
  233.     Function OpenMasterTable(ByVal SQLTextOrCmd As Object) As AdvancedDataTable
  234.         With Grid()
  235.             .DataSource = Nothing
  236.             .RefreshDataSource()
  237.             .DataSource = SharedCon.CreateDataSet()
  238.             OpenMasterTable = .ADS.OpenTable(SQLTextOrCmd, , Name)
  239.             .DataMember = Name
  240.         End With
  241.     End Function
  242.  
  243.     Function OpenDetailTable(ByVal SQLTextOrCmd As Object, ByVal DetailForeignKeyName As String, Optional ByVal MasterPrimaryKeyName As String = "Id") As AdvancedDataTable
  244.         With Grid.ADS
  245.             OpenDetailTable = .OpenTable(SQLTextOrCmd, , Name)
  246.         End With
  247.         Dim LevelName2 = LevelNode.Parent.LevelTemplate.Name
  248.         Dim C1 = Grid.ADS.Tables(LevelName2).Columns(MasterPrimaryKeyName)
  249.         Dim C2 = Grid.ADS.Tables(Name).Columns(DetailForeignKeyName)
  250.         Grid.ADS.Relations.Add(LevelName, C1, C2)
  251.     End Function
  252.  
  253.     \'PEVerify error!
  254.    \'Function OpenDetailTable2(ByVal SQLTextOrCmd As Object, ByVal DetailForeignKeyName As String, Optional ByVal MasterPrimaryKeyName As String = "Id") As AdvancedDataTable
  255.    \'    With Grid.DS
  256.    \'        OpenDetailTable2 = .OpenTable(SQLTextOrCmd, , Name)
  257.    \'        .Relations.Add(LevelName, .Tables(LevelNode.Parent.LevelTemplate.Name).Columns(MasterPrimaryKeyName), .Tables(Name).Columns(DetailForeignKeyName))
  258.    \'    End With
  259.    \'End Function
  260.  
  261.  
  262.     Private Sub Init_()
  263.         If Not DesignMode Then
  264.             OptionsSelection.MultiSelect = True
  265.             OptionsDetail.AllowExpandEmptyDetails = True
  266.             With OptionsView
  267.                 .EnableAppearanceEvenRow = True
  268.                 .EnableAppearanceOddRow = True
  269.             End With
  270.         End If
  271.     End Sub
  272.  
  273.     Protected Overrides ReadOnly Property ViewName() As String
  274.         Get
  275.             Return "AdvancedGridView"
  276.         End Get
  277.     End Property
  278.  
  279.     Public ReadOnly Property Grid() As AdvancedGrid
  280.         Get
  281.             Grid = CType(GridControl, AdvancedGrid)
  282.         End Get
  283.     End Property
  284.  
  285.     Private Sub AdvancedGridView_RowUpdated(ByVal sender As Object, ByVal e As DevExpress.XtraGrid.Views.Base.RowObjectEventArgs) Handles MyBase.RowUpdated
  286.         \'!!!UpdatedRowState = e.Row.row.RowState
  287.        Grid.SaveData()
  288.     End Sub
  289.  
  290.     \'Private Function EnsureAtLeastFocusedRowIsSelected(ByVal V As DevExpress.XtraGrid.Views.BandedGrid.AdvBandedGridView)
  291.    Friend Sub EnsureAtLeastOneFocusedRowIsSelected()
  292.         If SelectedRowsCount = 0 Then
  293.             SelectRow(FocusedRowHandle)
  294.         End If
  295.     End Sub
  296.  
  297.     Function GetFocusedRowEx() As Object \'DataRow or List item; similar to the GetFocusedRow
  298.        If RowCount > 0 Then
  299.             EnsureAtLeastOneFocusedRowIsSelected()
  300.             GetFocusedRowEx = GetRow(GetSelectedRows()(0))
  301.         End If
  302.     End Function
  303.  
  304.     Function GetFocusedRowId() As Long
  305.         If RowCount > 0 Then
  306.             GetFocusedRowId = CLng(CType(GetFocusedRowEx(), DataRowView).Item("Id"))
  307.         End If
  308.     End Function
  309.  
  310.     Function GetRowHandleById(ByVal Id As Long) As Integer
  311.         Dim Row As DataRow
  312.         For I As Integer = 0 To RowCount - 1
  313.             Row = CType(GetRow(I), DataRow)
  314.             If Not IsNothing(Row) Then
  315.                 If CLng(Row.Item("Id")) = Id Then
  316.                     GetRowHandleById = I
  317.                     Exit For
  318.                 End If
  319.             End If
  320.         Next
  321.     End Function
  322.  
  323.     Sub FocusRowById(ByVal Id As Long)
  324.         FocusedRowHandle = GetRowHandleById(Id)
  325.     End Sub
  326.  
  327.     Function GetSelectedRowsTable() As DataTable
  328.  
  329.         EnsureAtLeastOneFocusedRowIsSelected()
  330.  
  331.         \'GetSelectedRowsTable = New DataTable(Name & "_SelectedRows")
  332.        \'For Each C As DataColumn In T.Columns
  333.        \'    GetSelectedRowsTable.Columns.Add(C.ColumnName, C.DataType)
  334.        \'Next
  335.  
  336.         GetSelectedRowsTable = T.Clone()
  337.  
  338.         For Each RowHandle As Integer In GetSelectedRows()
  339.             Dim R As DataRow = CType(GetRow(RowHandle), DataRowView).Row
  340.             Dim NewR = GetSelectedRowsTable.Rows.Add()
  341.             For I As Integer = 0 To T.Columns.Count - 1
  342.                 NewR.Item(I) = R.Item(I)
  343.             Next
  344.         Next
  345.     End Function
  346.  
  347.     Sub FillRow(ByVal ForId As Long)
  348.         Dim PV As AdvancedGridView
  349.         If IsNothing(SourceView) Then \'If it is already a root or pattern view then use it
  350.            PV = Me \'This view
  351.        Else
  352.             PV = CType(SourceView, AdvancedGridView) \'Pattern view which is a design time template
  353.        End If
  354.         Dim SavedCmd As System.Data.Common.DbCommand = CType(PV.T.Adapter.SelectCommand, System.Data.Common.DbCommand) \' Save the command
  355.  
  356.         \'Reload a single row
  357.        PV.T.Adapter.SelectCommand = PV.T.Con.CreateCommand("select * from (" & PV.T.Adapter.SelectCommand.CommandText & ") LoadNewRowTable where Id=" & ForId)
  358.         CType(PV.T.Adapter, System.Data.SqlClient.SqlDataAdapter).Fill(PV.T)
  359.  
  360.         PV.T.Adapter.SelectCommand = SavedCmd \' restore old command
  361.  
  362.         FocusRowById(ForId)
  363.     End Sub
  364.  
  365.     Function FindColumnByFieldName(ByVal FieldName As String) As DevExpress.XtraGrid.Columns.GridColumn
  366.         For Each C As DevExpress.XtraGrid.Columns.GridColumn In Columns
  367.             If C.FieldName = FieldName Then
  368.                 FindColumnByFieldName = C
  369.                 Exit Function
  370.             End If
  371.         Next
  372.     End Function
  373.  
  374.     Public Function SpecifyLookupEdit(ByVal ForFieldName As String, ByVal DisplayMember As String, Optional ByVal ValueMember As String = "Id", Optional ByVal TableName As String = "") As DevExpress.XtraEditors.Repository.RepositoryItemLookUpEdit
  375.         If TableName = "" Then
  376.             TableName = ForFieldName.Substring(0, Len(ForFieldName) - 2)
  377.         End If
  378.         SpecifyLookupEdit = CType(Grid.RepositoryItems.Add("LookUpEdit"), DevExpress.XtraEditors.Repository.RepositoryItemLookUpEdit)
  379.         SpecifyLookupEdit.Name = ForFieldName & "Lookup"
  380.         AdvancedLookupEdit.FillLookupEdit(Grid.ADS.Con, SpecifyLookupEdit, DisplayMember, ValueMember, TableName)
  381.         FindColumnByFieldName(ForFieldName).ColumnEdit = SpecifyLookupEdit
  382.     End Function
  383.  
  384.     Public Function SpecifyLookupEdit(ByVal ForFieldName As String, ByVal EnumType As Type) As DevExpress.XtraEditors.Repository.RepositoryItemLookUpEdit
  385.         SpecifyLookupEdit = CType(Grid.RepositoryItems.Add("LookUpEdit"), DevExpress.XtraEditors.Repository.RepositoryItemLookUpEdit)
  386.         SpecifyLookupEdit.Name = ForFieldName & "Lookup"
  387.         AdvancedLookupEdit.FillLookupEdit(SpecifyLookupEdit, EnumType)
  388.         FindColumnByFieldName(ForFieldName).ColumnEdit = SpecifyLookupEdit
  389.     End Function
  390.  
  391.     Public Function SpecifyComboBox(ByVal ForFieldName As String, ByVal Items As Object()) As DevExpress.XtraEditors.Repository.RepositoryItemComboBox
  392.         SpecifyComboBox = New Repository.RepositoryItemComboBox
  393.         Grid.RepositoryItems.Add(SpecifyComboBox)
  394.         SpecifyComboBox.Name = ForFieldName & "ComboBox"
  395.         SpecifyComboBox.Items.AddRange(Items)
  396.         AdvancedLookupEdit.SetDefaultProperties(SpecifyComboBox)
  397.         SpecifyComboBox.PopupFormWidth = 200
  398.         FindColumnByFieldName(ForFieldName).ColumnEdit = SpecifyComboBox
  399.     End Function
  400.  
  401.     \'Fills a combobox in a detail view, SQLText shall have a @MasterId formal parameter replaced within MasterId
  402.    Function SpecifyRelatedLookupEdit(ByVal MasterId As Long, ByVal ForFieldName As String, _
  403.         ByVal DisplayMember As String, Optional ByVal ValueMember As String = "Id", _
  404.         Optional ByVal SQLText As String = "") As DevExpress.XtraEditors.Repository.RepositoryItemLookUpEdit
  405.  
  406.         \' MasterId of a master record substituted instead of the @MasterId in the SpecifyLookupEdit SQLText
  407.        If MasterId <> 0 Then
  408.             SpecifyLookupEdit(ForFieldName, DisplayMember, ValueMember, _
  409.                 "(" & Replace(SQLText, "@MasterId", MasterId.ToString) & ") " & CreateTempName())
  410.         End If
  411.  
  412.         \'Static MasterId As Long = 0
  413.        \'If NewMasterId <> MasterId Then
  414.        \'    MasterId = NewMasterId
  415.        \'    SpecifyLookupEdit(ForFieldName, DisplayMember, ValueMember, _
  416.         \'        "(" & Replace(SQLText, "@MasterId", MasterId) & ") " & CreateTempName())
  417.        \'End If
  418.    End Function
  419.  
  420. End Class
  421.  
  422. <Obfuscation(Feature:="Apply to member * when method: virtualization", Exclude:=False)> _
  423. Public Class AdvancedLookupEdit
  424.     Inherits DevExpress.XtraEditors.LookUpEdit
  425.  
  426.     Sub Specify(ByVal TableName As String, Optional ByVal DisplayMember As String = "Name", Optional ByVal ValueMember As String = "Id")
  427.         FillLookupEdit(SharedCon, Me.Properties, DisplayMember, ValueMember, TableName)
  428.     End Sub
  429.  
  430.     Sub Specify(ByVal EnumType As Type)
  431.         FillLookupEdit(Properties, EnumType)
  432.     End Sub
  433.  
  434.     Shared Sub FillLookupEdit(ByVal Con As AdvancedConnection, ByVal RILE As DevExpress.XtraEditors.Repository.RepositoryItemLookUpEdit, ByVal DisplayMember As String, Optional ByVal ValueMember As String = "Id", Optional ByVal TableName As String = "")
  435.         With RILE
  436.             RILE.ValueMember = ValueMember
  437.             RILE.DisplayMember = DisplayMember
  438.             RILE.DataSource = Con.OpenTable("select " & ValueMember & ", " & DisplayMember & " from " & TableName & " order by " & DisplayMember)
  439.         End With
  440.     End Sub
  441.  
  442.     Public Shared Function FillLookupEdit(ByVal RILE As DevExpress.XtraEditors.Repository.RepositoryItemLookUpEdit, ByVal EnumType As Type) As DevExpress.XtraEditors.Repository.RepositoryItemLookUpEdit
  443.         With RILE
  444.             .ValueMember = "Id"
  445.             .DisplayMember = "Name"
  446.             .DataSource = Enum2BindableArray(EnumType)
  447.         End With
  448.     End Function
  449.  
  450.     Public Shared Sub SetDefaultProperties(ByVal RI As DevExpress.XtraEditors.Repository.RepositoryItemLookUpEdit)
  451.         With RI
  452.             .AllowNullInput = DevExpress.Utils.DefaultBoolean.True
  453.             .DropDownRows = 20
  454.         End With
  455.     End Sub
  456.  
  457.     Public Shared Sub SetDefaultProperties(ByVal RI As DevExpress.XtraEditors.Repository.RepositoryItemComboBox)
  458.         With RI
  459.             .AllowNullInput = DevExpress.Utils.DefaultBoolean.True
  460.             .DropDownRows = 20
  461.         End With
  462.     End Sub
  463.  
  464.  
  465.     Public Sub New()
  466.         SetDefaultProperties(Properties)
  467.         Properties.PopupFormWidth = 300
  468.     End Sub
  469. End Class
  470.  
  471. <Obfuscation(Feature:="Apply to member * when method: virtualization", Exclude:=False)> _
  472. Public Class AdvancedReport
  473.     Public LR As New LocalReport
  474.     Public RDS As Microsoft.Reporting.WinForms.ReportDataSource
  475.     Public Parameters As ReportParameter()
  476.     Public Form As AdvancedReportForm
  477.  
  478.     Public Sub New(ByVal RDLCFileName As String, ByVal T As Aulix.Common7.Data.AdvancedDataTable, ByVal ReportParameters As ReportParameter())
  479.         With LR
  480.             If Not IO.File.Exists(RDLCFileName) Then
  481.                 RDLCFileName = IO.Path.Combine(IO.Directory.GetParent(RDLCFileName).Parent.FullName, IO.Path.GetFileName(RDLCFileName))
  482.             End If
  483.             .ReportPath = RDLCFileName  \'.ReportEmbeddedResource = RDLCName
  484.            RDS = New Microsoft.Reporting.WinForms.ReportDataSource("RDS", T)
  485.             .DataSources.Add(RDS)
  486.             If Not IsNothing(ReportParameters) Then
  487.                 Me.Parameters = ReportParameters
  488.                 .SetParameters(ReportParameters)
  489.             End If
  490.         End With
  491.     End Sub
  492.  
  493.     Public Sub New(ByVal RDLCFileName As String, ByVal T As Aulix.Common7.Data.AdvancedDataTable)
  494.         MyClass.New(RDLCFileName, T, Nothing)
  495.     End Sub
  496.  
  497.     Public Sub InitAnotherLocalReport(ByVal ALR As LocalReport)
  498.         ALR.ReportPath = LR.ReportPath
  499.         ALR.DataSources.Add(RDS)
  500.         If Not IsNothing(Parameters) Then
  501.             ALR.SetParameters(Parameters)
  502.         End If
  503.     End Sub
  504.  
  505.     Public Sub SaveToPDF(ByVal PDFFileName As String)
  506.         Dim mimeType, encoding, filenameExtension, streamids() As String
  507.         Dim warnings As Microsoft.Reporting.WinForms.Warning()
  508.         Dim ReportResult() As Byte = LR.Render("PDF", Nothing, mimeType, encoding, filenameExtension, streamids, warnings)
  509.         Using FS As New IO.FileStream(PDFFileName, IO.FileMode.Create)
  510.             FS.Write(ReportResult, 0, ReportResult.Length)
  511.         End Using
  512.     End Sub
  513.  
  514.     Public Function OpenForm() As AdvancedReportForm
  515.         Form = New AdvancedReportForm
  516.         With Form.RV
  517.             InitAnotherLocalReport(.LocalReport)
  518.             .RefreshReport()
  519.         End With
  520.         Form.Text = Form.RV.LocalReport.ReportPath
  521.         OpenForm = Form
  522.         Form.ShowDialog() \'Form.Visible = True
  523.    End Function
  524. End Class
  525.  
  526. <Obfuscation(Feature:="Apply to member * when method: virtualization", Exclude:=False)> _
  527. Public Module Declarations
  528.     Sub SetDERILocale(ByVal DERI As DevExpress.XtraEditors.Repository.RepositoryItemDateEdit, Optional ByVal C As System.Globalization.CultureInfo = Nothing)
  529.         If IsNothing(C) Then
  530.             C = System.Threading.Thread.CurrentThread.CurrentCulture
  531.         End If
  532.         DERI.Mask.Culture = C
  533.         DERI.Mask.UseMaskAsDisplayFormat = True
  534.     End Sub
  535.     Sub FillComboBoxFromEnum(ByVal CB As DevExpress.XtraEditors.ComboBoxEdit, ByVal E As [Enum])
  536.         Dim Names As System.Array = E.GetNames(E.GetType)
  537.         Dim Values As System.Array = E.GetValues(E.GetType)
  538.         For I As Integer = 0 To Names.Length - 1
  539.             CB.Properties.Items.Add(Names.GetValue(I).ToString)
  540.         Next
  541.     End Sub
  542.  
  543.     Sub RunMainForm(ByVal AppGUID As String, ByVal MainForm As System.Windows.Forms.Form)
  544.         Dim M As New System.Threading.Mutex(False, "Global\\" & AppGUID)
  545.         If (Not M.WaitOne(0, False)) Then
  546.             MsgBox(Messages.GetMessage("AppIsAlreadyRunning"))
  547.             Exit Sub
  548.         End If
  549.         Try
  550.             System.Windows.Forms.Application.Run(MainForm)
  551.             GC.Collect()
  552.         Catch ex As System.Exception
  553.             MsgBox(ex.ToString)
  554.         End Try
  555.         If Not M Is Nothing Then
  556.             M.Close()
  557.             CType(M, IDisposable).Dispose()
  558.         End If
  559.     End Sub
  560.  
  561. End Module
');