Akshaya arumugam

Akshaya arumugam

  • NA
  • 116
  • 38.8k

Convert code from vb6.net to c#?

Feb 8 2018 2:23 AM
Can anyone help me to convert this code in C#?
 
code:
Dim rsChart As ADODB.RecordSet
Dim ArrData() As Variant
Dim strsql As String
Dim strtemp As String
Dim strHtWtValue As String
Dim intHtCount As Integer
Dim intWtCount As Integer
Dim intRecCount As Integer
Dim intcol As Integer
Dim introw As Integer
Dim intCount As Integer
On Error GoTo ErrHandler
'Don't change the order of the columns
strsql = " select query"
Call SetRecordSetProperties(rsChart) ' this record set used to find out test ordered to a specific patient
rsChart.Open strsql, gObjDbCon ' test information of pat
rsChart.ActiveConnection = Nothing
If rsChart.RecordCount < 2 Then
Set rsChart = Nothing
Call MessageBox(, "Details not sufficient to display in graphical view.", vbOKOnly, InformationImage, Me.Caption, , 1)
OptHtWtGraphView.Value = vbUnchecked
optVitalSignsGridView.Value = True
Exit Sub
End If
Call MakeVisibleGraphControl(True)
If Not rsChart.EOF Then
'Store the recordcount
intRecCount = rsChart.RecordCount
'Set the Legend property of the chart to True
MSCVitalSigns.ShowLegend = True
'An array is used as the DataSource of the graph as we are assigning the Array to the ChartData property of the graph
'Redim the array based on the recordcout. If the recordcount is 5, then the array will be arrData(4,1)
'So the array {arrData(4,1)} will hold 5 rows and 2 columns (Date and Amount) as the array index starts from 0
ReDim ArrData(intRecCount - 1, 2)
MSCVitalSigns.FootnoteText = "Height-Weight Vs Visit Graph"
'Set the default Chart Type to 2D Line Type
MSCVitalSigns.ChartType = VtChChartType2dLine
'hiding the first series from user
MSCVitalSigns.Plot.SeriesCollection.Item(1).ShowLine = False
MSCVitalSigns.Plot.SeriesCollection.Item(1).SeriesMarker.Show = False
intHtCount = 0
intWtCount = 0
'Fill the array by looping through the recordset
For intcol = 0 To 2
rsChart.MoveFirst
For introw = 0 To intRecCount - 1
If intcol = 0 Then
strHtWtValue = rsChart(intcol) & ""
ElseIf intcol = 1 Then
If rsChart("HeightUnits") & "" = "" Or IsNumeric(rsChart(intcol) & "") = False Then
strHtWtValue = GetHeightInCm(rsChart(intcol) & "")
Else
strHtWtValue = GetHeightRespectToUnits(rsChart(intcol) & "", rsChart("HeightUnits") & "")
End If
If strHtWtValue <> "" Then
intHtCount = intHtCount + 1
End If
ElseIf intcol = 2 Then
If rsChart("HeightUnits") & "" = "" Or IsNumeric(rsChart(intcol) & "") = False Then
strHtWtValue = GetOnlyNumericValue(GetWeightRespectToUnits(rsChart(intcol) & "", "lbs"))
Else
strHtWtValue = GetOnlyNumericValue(GetWeightRespectToUnits(rsChart(intcol) & "", rsChart("WtUnits") & ""))
End If
If strHtWtValue <> "" Then
intWtCount = intWtCount + 1
End If
End If
If strHtWtValue = "" Then
If strtemp <> "" Then
ArrData(introw, intcol) = strtemp
Else
ArrData(introw, intcol) = strHtWtValue
End If
Else
ArrData(introw, intcol) = strHtWtValue
End If
If strHtWtValue <> "" Then
strtemp = strHtWtValue
End If
rsChart.MoveNext
Next introw
strtemp = ""
Next intcol
If intHtCount < 2 And intWtCount < 2 Then
Set rsChart = Nothing
Call MakeVisibleGraphControl(False)
Call MessageBox(, "Details not sufficient to display in graphical view.", vbOKOnly, InformationImage, Me.Caption, , 1)
optVitalSignsGridView.Value = False
Exit Sub
End If
'After filling the array with the data from the recordset, set the chartData property of the graph to the array
'This will display the graph
MSCVitalSigns.ChartData = ArrData
MSCVitalSigns.Plot.SeriesCollection(1).Position.Excluded = True
MSCVitalSigns.Plot.SeriesCollection.Item(1).ShowLine = False
MSCVitalSigns.Plot.SeriesCollection.Item(1).SeriesMarker.Show = False
MSCVitalSigns.Plot.SeriesCollection(2).Pen.Style = VtPenStyleSolid
MSCVitalSigns.Plot.SeriesCollection(3).Pen.Style = VtPenStyleSolid
'Add titles to the axes.
'X-Axis will be Height-Weight and Y-Axis will be Visit No
With MSCVitalSigns.Plot
.Axis(MSChart20Lib.VtChAxisId.VtChAxisIdX).AxisTitle.Text = "Visit --->"
.Axis(MSChart20Lib.VtChAxisId.VtChAxisIdY).AxisTitle.Text = "Height - Weight --->"
End With
If MSCVitalSigns.RowCount > 1 Then
rsChart.MoveFirst
For intCount = 1 To MSCVitalSigns.RowCount
MSCVitalSigns.Row = intCount
MSCVitalSigns.RowLabel = rsChart("VisitDate")
rsChart.MoveNext
Next
End If
If MSCVitalSigns.ColumnCount > 1 Then
MSCVitalSigns.Column = 2
MSCVitalSigns.ColumnLabel = "Height(Inches)"
End If
If MSCVitalSigns.ColumnCount > 2 Then
MSCVitalSigns.Column = 3
MSCVitalSigns.ColumnLabel = "Weight(Lbs)"
End If
End If
'Close the recordset object and destroy the instance
rsChart.Close
Set rsChart = Nothing
Exit Sub
ErrHandler:
Set rsChart = Nothing
Call ProcessOnErrors(gObjDbCon, Me.Caption, "DisplayHeightWeightGraph", GetAddErrInfo, True, mstrParentScrId)
optVitalSignsGridView.Value = True
Call MakeVisibleGraphControl(False)
End Sub
 

Answers (1)