Imports System.Collections
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports System.IO
Public Class FormRRWizard
Private DT As RS_RadarReport.dsSDFGeneral.aaAAARepWizSdfDataTable
Private DR As RS_RadarReport.dsSDFGeneral.aaAAARepWizSdfRow
Dim DSForArray As DataSet
Dim DTForArray As DataTable
Dim DRForArray As DataRow
Private sArrayCaption() As String
Private sArrayCtlType() As String
Private sArrayDefValue() As String
Private sArrayParamName() As String
Private sArrayParamVisible() As String
Private sArraySubSearch() As String
' Set the Parameter Value and Type to send for Reporting
Private sArrayParamValue() As String
Private sArrayParamType() As String
Private sCaption As String
Private sCtlType As String
Private sDefValue As String
Private sParamName As String
Private sParamVisible As String
Private sSubSearch As String
Private sRptPath As String
Private sRptDescription As String
Private sRptID As String
Private VisibleCount As Integer
Dim sArrayFields(5) As String
Private flag As Boolean = False
'''
''' To select the Report and show the settings in the Gridview by Calling the
''' GetReportWizardRecor, Initial and ArrayToTable procedure
''' Author: Omid Aghili
''' Starting Date: 3/2/2010
'''
'''
Private Sub BtnEditReportID_ButtonClick(ByVal sender As Object, ByVal e As DevExpress.XtraEditors.Controls.ButtonPressedEventArgs) Handles BtnEditReportID.ButtonClick
Dim F As New FormRRReportID
'BtnEditReportPath.Visible = False
TxtEditReportDes.Properties.ReadOnly = True
F.InitForm()
F.ShowDialog()
BtnEditReportID.Text = F.Value
F.Dispose()
GetReportWizardRecord(Trim(BtnEditReportID.Text))
TxtEditReportDes.Text = sRptDescription
LbSubTitle.Text = sRptDescription
TxtEditReportPath.Text = sRptPath
LblUpdateDate.Text = DR.KeyInDate.ToLongDateString
LblUpdateTime.Text = DR.KeyInDate.ToLongTimeString
LblUpdateBy.Text = DR.KeyInBy
Initial()
ArrayToTable()
End Sub
'''
''' To retrieve the Record from the RepWizardTable by Report ID and Convert it to Array
''' by calling ConvertToArray()
''' Author: Omid Aghili
''' Starting Date: 3/2/2010
'''
'''
'''
Public Sub GetReportWizardRecord(ByVal qRepID As String)
Try
DT = New RS_RadarReport.dsSDFGeneral.aaAAARepWizSdfDataTable
DT = RiskkServices.RadarReportService.GetReportWizardRecord(qRepID)
If DT.Count <> 0 Then
DR = DT(0)
sCaption = DR.ArrCaption
sCtlType = DR.ArrCtlType
sDefValue = DR.ArrDefValue
sParamName = DR.ArrParamName
sParamVisible = DR.Visible
sSubSearch = DR.SubSearchInfo
sRptPath = DR.RptPath
sRptDescription = DR.RepDesc
ConvertToArray()
Else
Throw New Exception("There is not any record in ReportWizard Table equivalent to ReportID.")
End If
Catch ex As Exception
Dim rethrow As Boolean = ExceptionPolicy.HandleException(ex, "PresentationPolicy")
If rethrow Then
Throw
End If
End Try
End Sub
'''
'''Conver the retrieved record to the array
''' Author: Omid Aghili
''' Starting Date: 3/2/2010
'''
'''
'''
Public Sub ConvertToArray()
If sCaption IsNot Nothing Then
sArrayCaption = sCaption.Split(CChar("|"))
End If
If sCtlType IsNot Nothing Then
sArrayCtlType = sCtlType.Split(CChar("|"))
End If
If sDefValue IsNot Nothing Then
sArrayDefValue = sDefValue.Split(CChar("|"))
End If
If sParamName IsNot Nothing Then
sArrayParamName = sParamName.Split(CChar("|"))
sArrayParamType = sParamName.Split(CChar("|"))
sArrayParamValue = sParamName.Split(CChar("|"))
End If
If sParamVisible IsNot Nothing Then
sArrayParamVisible = sParamVisible.Split(CChar("|"))
End If
If sSubSearch IsNot Nothing Then
sArraySubSearch = sSubSearch.Split(CChar("|"))
End If
sArraySubSearch = sSubSearch.Split(CChar("|"))
End Sub
'''
''' To initial the captions and fields
''' Author: Omid Aghili
''' Starting Date: 5/2/2010
'''
'''
'''
Public Sub Initial()
Try
Dim sArrayLable(5) As String
sArrayLable(0) = "Parameter Name"
sArrayLable(1) = "Lable Caption"
sArrayLable(2) = "Control Type"
sArrayLable(3) = "Defualt Value"
sArrayLable(4) = "Sub Search"
sArrayLable(5) = "Visible"
'sArrayFields(0) = DT.ArrParamNameColumn.ColumnName
'sArrayFields(1) = DT.ArrCaptionColumn.ColumnName
'sArrayFields(2) = DT.ArrCtlTypeColumn.ColumnName
'sArrayFields(3) = DT.ArrDefValueColumn.ColumnName
'sArrayFields(4) = DT.SubSearchInfoColumn.ColumnName
'sArrayFields(5) = DT.VisibleColumn.ColumnName
sArrayFields(0) = "ArrParamName"
sArrayFields(1) = "ArrCaption"
sArrayFields(2) = "ArrCtlType"
sArrayFields(3) = "ArrDefValue"
sArrayFields(4) = "SubSearchInfo"
sArrayFields(5) = "Visible"
BandedGridView1.OptionsBehavior.Editable = True
'Set the grid Columns
'Dim C As DevExpress.XtraGrid.Views.BandedGrid.BandedGridColumn
'Dim I As Integer
'For I = 0 To sArrayLable.Count - 1
' C = New DevExpress.XtraGrid.Views.BandedGrid.BandedGridColumn
' C.Caption = sArrayLable(I)
' C.Visible = True
' C.Name = sArrayLable(I)
' C.UnboundType = DevExpress.Data.UnboundColumnType.Bound
' C.Width = 200
' C.FieldName = sArrayFields(I)
' C.OptionsColumn.AllowEdit = True
' 'GridBand1.Columns.Add(C)
' 'The Follwoing 2 lines code are the same as one line code above
' C.OwnerBand = GridBand1
' BandedGridView1.Columns.Add(C)
'Next
'GridBand1.Columns(sArrayLable(0)).OptionsColumn.AllowEdit = False
'FillGrid()
'FillGridSample()
'GridMain.DataSource = DT(0)
Catch ex As Exception
Dim rethrow As Boolean = ExceptionPolicy.HandleException(ex, "PresentationPolicy")
If rethrow Then
Throw
End If
End Try
End Sub
'''
''' Date : 25-Jan-2010
''' Purpose : Get the Data From the DataBase according to the SubSearchInfo field in the
''' [aaAAARepWizSdf] table
''' Author : Omid Aghili
'''
'''
'''
''' Omid Aghili 25/01/2010 Created
'Private Sub FillGrid()
' ' Get Data From Database
' Try
' Dim SQL As String
' SQL = "Select * from aaAAARepWizSdf where qRepID = " + "'" + Trim(BtnEditReportID.Text) + "'"
' Dim DS As New DataSet
' DS = RiskkServices.CommonService.RunQuery(SQL)
' If DS.Tables.Count > 0 Then
' GridMain.DataSource = DS.Tables(0)
' End If
' Catch ex As Exception
' Dim rethrow As Boolean = ExceptionPolicy.HandleException(ex, "PresentationPolicy")
' If rethrow Then
' Throw
' End If
' End Try
'End Sub
'''
''' Convert Array to DataTable and Set the DataSource of the Grid to the Table
''' Author: Omid Aghili
''' Starting Date: 5/2/2010
'''
'''
'''
Private Sub ArrayToTable()
DSForArray = New DataSet
DTForArray = New DataTable
For i As Integer = 0 To sArrayFields.Count - 1
DTForArray.Columns.Add(sArrayFields(i))
DTForArray.Columns(sArrayFields(i)).DataType = Type.GetType("System.String")
Next
DTForArray.Columns(sArrayFields(5)).DataType = Type.GetType("System.Boolean")
For i As Integer = 0 To sArrayParamName.Count - 1
DRForArray = DTForArray.NewRow
DRForArray.Item(sArrayFields(0)) = sArrayParamName(i)
DRForArray.Item(sArrayFields(1)) = sArrayCaption(i)
DRForArray.Item(sArrayFields(2)) = sArrayCtlType(i)
DRForArray.Item(sArrayFields(3)) = sArrayDefValue(i)
DRForArray.Item(sArrayFields(4)) = sArraySubSearch(i)
DRForArray.Item(sArrayFields(5)) = sArrayParamVisible(i)
DTForArray.Rows.Add(DRForArray)
Next
DSForArray.Tables.Add(DTForArray)
GridMain.DataSource = DSForArray.Tables(0)
End Sub
'''
''' Conver the Table to the Array in order to save the changes in array
''' This Procuder is not used anymore due to the TableToSring Procuder
''' Author: Omid Aghili
''' Starting Date: 5/2/2010
'''
'''
'''
Private Sub TableToArray()
For i As Integer = 0 To sArrayParamName.Count - 1
sArrayParamName(i) = Trim(DTForArray.Rows(i).Item(sArrayFields(0)))
sArrayCaption(i) = Trim(DTForArray.Rows(i).Item(sArrayFields(1)))
sArrayCtlType(i) = Trim(DTForArray.Rows(i).Item(sArrayFields(2)))
sArrayDefValue(i) = Trim(DTForArray.Rows(i).Item(sArrayFields(3)))
sArraySubSearch(i) = Trim(DTForArray.Rows(i).Item(sArrayFields(4)))
sArrayParamVisible(i) = Trim(DTForArray.Rows(i).Item(sArrayFields(5)))
Next
End Sub
'''
''' Conver the Array to the String in order to save the changes in Database
''' This Procuder is not used anymore due to the TableToSring Procuder
''' Author: Omid Aghili
''' Starting Date: 5/2/2010
'''
'''
'''
Private Sub ArrayToString()
sCaption = ""
sCtlType = ""
sDefValue = ""
sParamName = ""
sParamVisible = ""
sSubSearch = ""
For i As Integer = 0 To sArrayParamName.Count - 1
sCaption += sArrayCaption(i) + "|"
sCtlType += sArrayCtlType(i) + "|"
sDefValue += sArrayDefValue(i) + "|"
sParamName += sArrayParamName(i) + "|"
sParamVisible += sArrayParamVisible(i) + "|"
sSubSearch += sArraySubSearch(i) + "|"
Next
sCaption = sCaption.Remove(sCaption.LastIndexOf(CChar("|")))
sCtlType = sCtlType.Remove(sCtlType.LastIndexOf(CChar("|")))
sDefValue = sDefValue.Remove(sDefValue.LastIndexOf(CChar("|")))
sParamName = sParamName.Remove(sParamName.LastIndexOf(CChar("|")))
sParamVisible = sParamVisible.Remove(sParamVisible.LastIndexOf(CChar("|")))
sSubSearch = sSubSearch.Remove(sSubSearch.LastIndexOf(CChar("|")))
End Sub
Private Sub FormRRWizard_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
TxtEditReportDes.Properties.ReadOnly = True
End Sub
'''
''' Save the changes which are made by the user or create a new record in the database
''' Author: Omid Aghili
''' Starting Date: 5/2/2010
'''
'''
'''
Private Sub BtnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnSave.Click
'TableToArray()
'ArrayToString()
TableToString()
If TxtEditReportDes.Properties.ReadOnly = True Then
RiskkServices.RadarReportService.UpdateReportWizardRecord(sCaption, sCtlType, sDefValue, sParamName, _
sSubSearch, sParamVisible, DateTime.Now, _
SecuityManager.CurrentUser.U_LogonName, _
DR.qRepID)
MsgBox("The " & DR.RepDesc & " is Updated.", MsgBoxStyle.Information, "Update")
flag = False
Else
If Not (String.IsNullOrEmpty(CmbRptID.Text) Or _
String.IsNullOrEmpty(TxtEditReportDes.Text) Or _
String.IsNullOrEmpty(TxtEditReportPath.Text) Or _
String.IsNullOrEmpty(sCtlType) Or _
String.IsNullOrEmpty(sDefValue) Or _
String.IsNullOrEmpty(sParamVisible) Or _
String.IsNullOrEmpty(sSubSearch) Or _
String.IsNullOrEmpty(sParamName) Or _
String.IsNullOrEmpty(sCaption)) Then
sRptPath = Trim(TxtEditReportPath.Text)
sRptDescription = Trim(TxtEditReportDes.Text)
sRptID = Trim(CmbRptID.Text)
DT = New RS_RadarReport.dsSDFGeneral.aaAAARepWizSdfDataTable
DT = RiskkServices.RadarReportService.GetReportWizardRecord(sRptID)
If DT.Count <> 0 Then
MsgBox("The " & sRptDescription & " is exist in database.", MsgBoxStyle.Critical, "error")
'RiskkServices.RadarReportService.UpdateReportWizardRecord(sCaption, sCtlType, sDefValue, sParamName, _
' sSubSearch, sParamVisible, DateTime.Now, _
' SecuityManager.CurrentUser.U_LogonName, _
' DR.qRepID)
Else
RiskkServices.RadarReportService.InsertReportWizardRecord(sRptID, sRptDescription, _
sCaption, sCtlType, sDefValue, sParamName, sRptPath, sSubSearch, _
sParamVisible, DateTime.Now, SecuityManager.CurrentUser.U_LogonName)
MsgBox("The " & sRptDescription & " is Inserted.", MsgBoxStyle.Information, "Insert")
BtnSave.Enabled = False
End If
Else
MsgBox("Please Enter the necessary information.")
End If
End If
End Sub
'''
''' Enable User to select the Report file and add a record to the Database
''' Author: Omid Aghili
''' Starting Date: 8/2/2010
'''
'''
'''
Private Sub BtnNew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnNew.Click
BtnEditReportPath.Visible = True
BtnEditReportPath.Text = ""
TxtEditReportPath.Text = ""
TxtEditReportDes.Properties.ReadOnly = False
TxtEditReportDes.Text = ""
CmbRptID.Text = ""
LblUpdateBy.Text = ""
LblUpdateDate.Text = ""
LblUpdateTime.Text = ""
If DTForArray IsNot Nothing Then
DTForArray.Clear()
End If
Initial()
BtnSave.Enabled = False
End Sub
Private Sub BtnEditReportPath_ButtonClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraEditors.Controls.ButtonPressedEventArgs) Handles BtnEditReportPath.ButtonClick
If OpenFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
BtnEditReportPath.Text = OpenFileDialog1.SafeFileName
TxtEditReportPath.Text = OpenFileDialog1.SafeFileName
GetParamName()
'CmbRptID.Text = ""
'TxtEditReportDes.Text = ""
BtnSave.Enabled = True
End If
End Sub
'''
''' Convert the information in Datatable to the String in order to save to the DataBase
''' Author: Omid Aghili
''' Starting Date: 8/2/2010
'''
'''
'''
Private Sub TableToString()
sCaption = ""
sCtlType = ""
sDefValue = ""
sParamName = ""
sParamVisible = ""
sSubSearch = ""
For i As Integer = 0 To DTForArray.Rows.Count - 1
If IsDBNull(DTForArray.Rows(i).Item(sArrayFields(1))) Then
sCaption += "|"
Else
sCaption += Trim(DTForArray.Rows(i).Item(sArrayFields(1))) + "|"
End If
If IsDBNull(DTForArray.Rows(i).Item(sArrayFields(2))) Then
sCtlType += "|"
Else
sCtlType += Trim(DTForArray.Rows(i).Item(sArrayFields(2))) + "|"
End If
If IsDBNull(DTForArray.Rows(i).Item(sArrayFields(3))) Then
sDefValue += "|"
Else
sDefValue += Trim(DTForArray.Rows(i).Item(sArrayFields(3))) + "|"
End If
If IsDBNull(DTForArray.Rows(i).Item(sArrayFields(4))) Then
sSubSearch += "|"
Else
sSubSearch += Trim(DTForArray.Rows(i).Item(sArrayFields(4))) + "|"
End If
If IsDBNull(DTForArray.Rows(i).Item(sArrayFields(5))) Then
sParamVisible += "False" & "|"
Else
sParamVisible += Trim(DTForArray.Rows(i).Item(sArrayFields(5))) + "|"
End If
If IsDBNull(DTForArray.Rows(i).Item(sArrayFields(0))) Then
sParamName += "|"
Else
sParamName += Trim(DTForArray.Rows(i).Item(sArrayFields(0))) + "|"
End If
'sCaption += Trim(DTForArray.Rows(i).Item(sArrayFields(1))) + "|"
'sCtlType += Trim(DTForArray.Rows(i).Item(sArrayFields(2))) + "|"
'sDefValue += Trim(DTForArray.Rows(i).Item(sArrayFields(3))) + "|"
'sParamName += Trim(DTForArray.Rows(i).Item(sArrayFields(0))) + "|"
'sParamVisible += Trim(DTForArray.Rows(i).Item(sArrayFields(5))) + "|"
'sSubSearch += Trim(DTForArray.Rows(i).Item(sArrayFields(4))) + "|"
Next
sCaption = sCaption.Remove(sCaption.LastIndexOf(CChar("|")))
sCtlType = sCtlType.Remove(sCtlType.LastIndexOf(CChar("|")))
sDefValue = sDefValue.Remove(sDefValue.LastIndexOf(CChar("|")))
sParamName = sParamName.Remove(sParamName.LastIndexOf(CChar("|")))
sParamVisible = sParamVisible.Remove(sParamVisible.LastIndexOf(CChar("|")))
sSubSearch = sSubSearch.Remove(sSubSearch.LastIndexOf(CChar("|")))
End Sub
'''
''' Get the Parameter filed after selecting the Report File by the User.
''' Author: Omid Aghili
''' Starting Date: 8/2/2010
'''
'''
'''
Private Sub GetParamName()
Dim reportDocument As New ReportDocument
'Dim path As String = "\\192.168.0.3\R&D FoldeR\Report\" & BtnEditReportPath.Text
Dim path As String = "C:\Report\" & BtnEditReportPath.Text
Dim parameterField As ParameterField
DSForArray = New DataSet
DTForArray = New DataTable
If File.Exists(path) Then
reportDocument.Load(path)
Else
Throw New Exception("Erorr! The Report Not Exists.")
End If
For i As Integer = 0 To sArrayFields.Count - 1
DTForArray.Columns.Add(sArrayFields(i))
DTForArray.Columns(sArrayFields(i)).DataType = Type.GetType("System.String")
Next
DTForArray.Columns(sArrayFields(5)).DataType = Type.GetType("System.Boolean")
For Each parameterField In reportDocument.ParameterFields
DRForArray = DTForArray.NewRow
DRForArray.Item(sArrayFields(0)) = parameterField.Name
DRForArray.Item(sArrayFields(1)) = parameterField.Name
DTForArray.Rows.Add(DRForArray)
Next
DSForArray.Tables.Add(DTForArray)
GridMain.DataSource = DSForArray.Tables(0)
End Sub
'''
''' Get The Report List
'''
''' Pass In - Report ID
''' Pass In - Top String
'''
''' Omid Aghili - 10/2/2010 Created
Private Sub LoadRepWizardLookUp(ByVal qRepID As String, ByVal v_strTop As String)
Try
Dim DT As New RS_RadarReport.dsSDFGeneral.paaAAARepWizLookUpDataTable
DT = RiskkServices.RadarReportService.GetRepWizardLookUp(qRepID, v_strTop)
If DT.Rows.Count > 0 Then
CmbRptID.Properties.DataSource = Nothing
CmbRptID.Properties.Columns.Clear()
CmbRptID.Properties.Columns.Add( _
New DevExpress.XtraEditors.Controls.LookUpColumnInfo( _
"qRepID", 225, "Report ID"))
CmbRptID.Properties.Columns.Add( _
New DevExpress.XtraEditors.Controls.LookUpColumnInfo( _
"RepDesc", 225, "Report Description"))
CmbRptID.Properties.DisplayMember = "qRepID"
CmbRptID.Properties.ValueMember = "RepDesc"
CmbRptID.Properties.DataSource = DT
End If
Catch ex As Exception
Dim rethrow As Boolean = ExceptionPolicy.HandleException(ex, "PresentationPolicy")
If rethrow Then
Throw
End If
End Try
End Sub
Private Sub CmbRptID_ButtonPressed(ByVal sender As System.Object, ByVal e As DevExpress.XtraEditors.Controls.ButtonPressedEventArgs) Handles CmbRptID.ButtonPressed
Try
'CmbRptID.Text = ""
'TxtEditReportDes.Text = ""
If e.Button.Kind = DevExpress.XtraEditors.Controls.ButtonPredefines.Ellipsis Then
LoadRepWizardLookUp("%%", "")
CmbRptID.ShowPopup()
End If
BtnEditReportPath.Visible = False
Catch ex As Exception
Dim rethrow As Boolean = ExceptionPolicy.HandleException(ex, "PresentationPolicy")
If rethrow Then
Throw
End If
End Try
End Sub
Private Sub CmbRptID_ProcessNewValue(ByVal sender As System.Object, ByVal e As DevExpress.XtraEditors.Controls.ProcessNewValueEventArgs) Handles CmbRptID.ProcessNewValue
Try
If BtnEditReportPath.Visible = True Then
CmbRptID.SetMyValue(CmbRptID.Text)
Else
If CmbRptID.Text <> Nothing Then
LoadRepWizardLookUp(CmbRptID.Text, "TOP")
CmbRptID.ShowPopup()
End If
End If
Catch ex As Exception
Dim rethrow As Boolean = ExceptionPolicy.HandleException(ex, "PresentationPolicy")
If rethrow Then
Throw
End If
End Try
End Sub
Private Sub CmbRptID_EditValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmbRptID.EditValueChanged
If BtnEditReportPath.Visible = False Then
GetReportWizardRecord(Trim(CmbRptID.Text))
BtnEditReportPath.Visible = True
TxtEditReportDes.Text = sRptDescription
LbSubTitle.Text = sRptDescription
TxtEditReportPath.Text = sRptPath
BtnEditReportPath.Text = sRptPath
LblUpdateDate.Text = DR.KeyInDate.ToLongDateString
LblUpdateTime.Text = DR.KeyInDate.ToLongTimeString
LblUpdateBy.Text = DR.KeyInBy
Initial()
ArrayToTable()
BtnSave.Enabled = True
End If
End Sub
Private Sub GridMain_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GridMain.Click
End Sub
Private Sub TxtEditReportDes_EditValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TxtEditReportDes.EditValueChanged
End Sub
End Class ... |