Skip to Content
0
Former Member
Feb 05, 2015 at 06:39 AM

matrix focus problem when assigning value to a cell using vb.net

58 Views

Hi Guys,
Everytime i pressed the tab button in Itemcode,Quantity,price,Discrate1...DiscRate5 columns, the CURSOR is focusing in the DiscAmt's and DiscNet's.. its like the cursor is moving in every cell becouse of auto computation... what i want is when i press the tab key,the cursor will not move in the column that updating.

heres my code.

If (((pVal.FormType = "139") Or (pVal.FormType = "142")) And (pVal.ItemUID = "38") And _

(pVal.EventType = SAPbouiCOM.BoEventTypes.et_KEY_DOWN)) Then

'SO

If (pVal.FormType = "139") Then

oForm = SBO_Application.Forms.GetForm(139, 0)

End If

'PO

If (pVal.FormType = "142") Then

oForm = SBO_Application.Forms.GetForm(142, 0)

End If

oMatrix = oForm.Items.Item("38").Specific

If ((pVal.ColUID = "1") Or (pVal.ColUID = "14") Or pVal.ColUID = "11" Or pVal.ColUID = "U_DiscRate1" Or pVal.ColUID = "U_DiscRate2" Or _

pVal.ColUID = "U_DiscRate3" Or pVal.ColUID = "U_DiscRate4" Or pVal.ColUID = "U_DiscRate5") And _

(pVal.BeforeAction = False) And (pVal.CharPressed = "9") Then

'---loop the matrix and get the row selected

For i As Integer = 1 To oMatrix.VisualRowCount

If i = pVal.Row Then

Dim itemcode As String = oMatrix.Columns.Item("1").Cells.Item(i).Specific.value.ToString

If (itemcode = "" Or itemcode.Length = 0) Then

Exit Sub

End If

Dim Quantity As Integer = oMatrix.Columns.Item("11").Cells.Item(i).Specific.value.ToString

Dim Price As Decimal = oMatrix.Columns.Item("14").Cells.Item(i).Specific.value.ToString

Dim Total As Decimal = Quantity * Price

Dim DiscRate1 As Decimal = oMatrix.Columns.Item("U_DiscRate1").Cells.Item(i).Specific.value.ToString

Dim DiscAmt1 As Decimal

Dim DiscNet1 As Decimal

If (DiscRate1 > 0) Then

DiscAmt1 = DiscRate1 * Total

DiscNet1 = Total - DiscAmt1

oMatrix.Columns.Item("U_DiscAmt1").Cells.Item(i).Specific.value = DiscAmt1

oMatrix.Columns.Item("U_NetAmt1").Cells.Item(i).Specific.value = DiscNet1

Else

DiscAmt1 = 0

DiscNet1 = 0

oMatrix.Columns.Item("U_DiscAmt1").Cells.Item(i).Specific.value = DiscAmt1

oMatrix.Columns.Item("U_NetAmt1").Cells.Item(i).Specific.value = DiscNet1

End If

Dim DiscRate2 As Decimal = oMatrix.Columns.Item("U_DiscRate2").Cells.Item(i).Specific.value.ToString

Dim DiscAmt2 As Decimal

Dim DiscNet2 As Decimal

If (DiscRate2 > 0 And DiscRate1 > 0) Then

DiscAmt2 = DiscNet1 * DiscRate2

DiscNet2 = DiscNet1 - DiscAmt2

oMatrix.Columns.Item("U_DiscAmt2").Cells.Item(i).Specific.value = DiscAmt2

oMatrix.Columns.Item("U_DiscNet2").Cells.Item(i).Specific.value = DiscNet2

Else

DiscAmt2 = 0

DiscNet2 = 0

oMatrix.Columns.Item("U_DiscAmt2").Cells.Item(i).Specific.value = DiscAmt2

oMatrix.Columns.Item("U_DiscNet2").Cells.Item(i).Specific.value = DiscNet2

End If

Dim DiscRate3 As Decimal = oMatrix.Columns.Item("U_DiscRate3").Cells.Item(i).Specific.value.ToString

Dim DiscAmt3 As Decimal

Dim DiscNet3 As Decimal

If (DiscRate3 > 0 And DiscRate1 > 0 And DiscRate2 > 0) Then

DiscAmt3 = DiscNet2 * DiscRate3

DiscNet3 = DiscNet2 - DiscAmt3

oMatrix.Columns.Item("U_DiscAmt3").Cells.Item(i).Specific.value = DiscAmt3

oMatrix.Columns.Item("U_DiscNet3").Cells.Item(i).Specific.value = DiscNet3

Else

DiscAmt3 = 0

DiscNet3 = 0

oMatrix.Columns.Item("U_DiscAmt3").Cells.Item(i).Specific.value = DiscAmt3

oMatrix.Columns.Item("U_DiscNet3").Cells.Item(i).Specific.value = DiscNet3

End If

Dim DiscRate4 As Decimal = oMatrix.Columns.Item("U_DiscRate4").Cells.Item(i).Specific.value.ToString

Dim DiscAmt4 As Decimal

Dim DiscNet4 As Decimal

If (DiscRate4 > 0 And DiscRate1 > 0 And DiscRate2 > 0 And DiscRate3 > 0) Then

DiscAmt4 = DiscNet3 * DiscRate4

DiscNet4 = DiscNet3 - DiscAmt4

oMatrix.Columns.Item("U_DiscAmt4").Cells.Item(i).Specific.value = DiscAmt4

oMatrix.Columns.Item("U_DiscNet4").Cells.Item(i).Specific.value = DiscNet4

Else

DiscAmt4 = 0

DiscNet4 = 0

oMatrix.Columns.Item("U_DiscAmt4").Cells.Item(i).Specific.value = DiscAmt4

oMatrix.Columns.Item("U_DiscNet4").Cells.Item(i).Specific.value = DiscNet4

End If

Dim DiscRate5 As Decimal = oMatrix.Columns.Item("U_DiscRate5").Cells.Item(i).Specific.value.ToString

Dim DiscAmt5 As Decimal

Dim DiscNet5 As Decimal

If (DiscRate5 > 0 And DiscRate4 > 0 And DiscRate1 > 0 And DiscRate2 > 0 And DiscRate3 > 0) Then

DiscAmt5 = DiscNet4 * DiscRate5

DiscNet5 = DiscNet4 - DiscAmt5

oMatrix.Columns.Item("U_DiscAmt5").Cells.Item(i).Specific.value = DiscAmt5

oMatrix.Columns.Item("U_DiscNet5").Cells.Item(i).Specific.value = DiscNet5

Else

DiscAmt5 = 0

DiscNet5 = 0

oMatrix.Columns.Item("U_DiscAmt5").Cells.Item(i).Specific.value = DiscAmt5

oMatrix.Columns.Item("U_DiscNet5").Cells.Item(i).Specific.value = DiscNet5

End If

' oForm.Items.Item("24").Specific.value = TotalDiscRate

Exit For

End If

Next

'---loop the matrix and get the row selected

'---total discRates

Dim TotalDiscRate As Double = 0.0

For i As Integer = 1 To oMatrix.VisualRowCount

Dim ItemCode As String = oMatrix.Columns.Item("1").Cells.Item(i).Specific.value.ToString

If (ItemCode.Length > 0) Then

Dim Rate1 As Decimal = oMatrix.Columns.Item("U_DiscAmt1").Cells.Item(i).Specific.value.ToString

Dim Rate2 As Decimal = oMatrix.Columns.Item("U_DiscAmt2").Cells.Item(i).Specific.value.ToString

Dim Rate3 As Decimal = oMatrix.Columns.Item("U_DiscAmt3").Cells.Item(i).Specific.value.ToString

Dim Rate4 As Decimal = oMatrix.Columns.Item("U_DiscAmt4").Cells.Item(i).Specific.value.ToString

Dim Rate5 As Decimal = oMatrix.Columns.Item("U_DiscAmt5").Cells.Item(i).Specific.value.ToString

TotalDiscRate += Rate1 + Rate2 + Rate3 + Rate4 + Rate5

oForm.Items.Item("42").Specific.value = TotalDiscRate

End If

Next

'---total discRates

End If

End If

End Sub