Datagridview doesnt show data in rows - vb.net

I am currently working on project in which i have to display IP Configuration to user in VB.Net Application.
I am using DataGridView to display IP Config to user.
But problem is Datagridview doesnt display anything in its row at all.
Image for proof
Here is the code
Public Sub MT_Validate_Msg(ByRef lbData() As Byte)
Dim lsAddr(3) As String
Dim lsMAC(5) As String
Dim lstConfig As TCP_SER_Config
If lbData.Length >= 256 Then
'Check Header Footer and Response Size
If lbData(0) = Asc("$") And lbData(1) = Asc("#") _
And lbData(254) = Asc("<") And lbData(255) = Asc(">") _
And lbData(2) = UDP_RESPONSE_SIZE And lbData(3) = 0 Then
gnDevice_Search_Count += 1
'MsgBox("Response Received")
lsAddr(0) = lbData(7).ToString
lsAddr(1) = lbData(9).ToString
lsAddr(2) = lbData(11).ToString
lsAddr(3) = lbData(13).ToString
lstConfig.IP = String.Join(".", lsAddr)
lsAddr(0) = lbData(15).ToString
lsAddr(1) = lbData(17).ToString
lsAddr(2) = lbData(19).ToString
lsAddr(3) = lbData(21).ToString
lstConfig.Subnet = String.Join(".", lsAddr)
lsAddr(0) = lbData(23).ToString
lsAddr(1) = lbData(25).ToString
lsAddr(2) = lbData(27).ToString
lsAddr(3) = lbData(29).ToString
lstConfig.Gateway = String.Join(".", lsAddr)
lstConfig.Alive_Time = lbData(31)
lsMAC(0) = Hex(lbData(33)).ToString
lsMAC(1) = Hex(lbData(34)).ToString
lsMAC(2) = Hex(lbData(35)).ToString
lsMAC(3) = Hex(lbData(36)).ToString
lsMAC(4) = Hex(lbData(37)).ToString
lsMAC(5) = Hex(lbData(38)).ToString
lstConfig.MAC = String.Join("-", lsMAC)
MT_FillGrid(lstConfig)
End If
End If
End Sub
Public Sub MT_FillGrid(ByRef lstTCPConfig As TCP_SER_Config)
Dim row As String() = New String() {gnDevice_Search_Count.ToString, lstTCPConfig.IP, lstTCPConfig.Subnet, _
lstTCPConfig.Gateway, lstTCPConfig.Alive_Time.ToString, lstTCPConfig.MAC}
GridDev_List.Rows.Add(row)
row = New String() {"1", "192.168.0.100", "255.255.255.0", "255.255.255.255", "60", "22-0B-3C-2D-00-01"}
GridDev_List.Rows.Add(row)
End Sub
Expecting a result like this, Where i am going wrong in code ?

Related

Insert into table without LOOP in VB.NET

I have
For Each itemSN As SellingDetailSNCustomer In item.listSN
Dim newItem As New TR_Selling_Customer_Product_SN
newItem.FK_Selling_Detail_Customer_ID = oNew.PK_Selling_Customer_Detail_ID
newItem.SN = itemSN.SNProduct
newItem.CreatedDate = Now.ToString("yyyy-MM-dd")
newItem.CreatedBy = "system"
newItem.LastUpdateDate = Now.ToString("yyyy-MM-dd")
newItem.LastUpdateBy = "system"
newItem.Active = True
objdb.Entry(newItem).State = Entity.EntityState.Added
Dim obUpdateBookedSN As MS_Product_Serial_Number = (From x In objdb.Product_Serial_Number Where x.FK_Product_ID = item.FK_Product_ID And x.Serial_Number = itemSN.SNProduct Select x).FirstOrDefault
If obUpdateBookedSN IsNot Nothing Then
obUpdateBookedSN.Booked_Serial_Number = True
obUpdateBookedSN.LastUpdateDate = Now.ToString("yyyy-MM-dd")
obUpdateBookedSN.LastUpdateBy = "system"
objdb.Entry(obUpdateBookedSN).State = Entity.EntityState.Modified
End If
Next
objdb.SaveChanges()
When I have more than thousand serial number, this looping become very slow processing time.
I want to changes this code without looping.
How do I figure that out?

Populate a structure

I have a structure containing 47 fields.I also have a string that contains "|" delimited value . I want to populate the structure with the values in the string. The only solution that I can think of is below.However this involves hardcoding. Is there a better way to achieve the same via a loop or anything else
Dim lobjStructData As New SUB_PNDGORDR_QRY_RESP
Dim lstrarrStream As String() = pstrStream.Split(CChar("|"))
lobjStructData.ClientId = CType(lstrarrStream(0), Char())
lobjStructData.PortfolioId = CShort(lstrarrStream(1))
lobjStructData.Currency = CType(lstrarrStream(2), Char())
lobjStructData.ProductId = CType(lstrarrStream(3), Char())
lobjStructData.InstrumentClass = CShort(lstrarrStream(4))
lobjStructData.OrderSymbol = CType(lstrarrStream(5), Char())
lobjStructData.Qty = CDbl(lstrarrStream(6))
lobjStructData.QtyRemaining = CDbl(lstrarrStream(7))
lobjStructData.OrderPrice = CDbl(lstrarrStream(8))
lobjStructData.TriggerPrice = CDbl(lstrarrStream(9))
lobjStructData.Remarks = CType(lstrarrStream(10), Char())
lobjStructData.QtyDiscRem = CDbl(lstrarrStream(11))
lobjStructData.OrderDateTime = CInt(lstrarrStream(12))
lobjStructData.IntOrderNo = CDbl(lstrarrStream(13))
lobjStructData.OrderStat = CType(lstrarrStream(14), Char())
lobjStructData.DiscQty = CDbl(lstrarrStream(15))
lobjStructData.SerialNo = CInt(lstrarrStream(16))
lobjStructData.OpenCloseFlg = CInt(lstrarrStream(17))
lobjStructData.InstrumentId = CInt(lstrarrStream(18))
lobjStructData.ContractSeriesId = CInt(lstrarrStream(19))
lobjStructData.InstrumentType = CShort(lstrarrStream(20))
lobjStructData.BuySellInd = CShort(lstrarrStream(21))
lobjStructData.MinFillQty = CDbl(lstrarrStream(22))
lobjStructData.ExchId = CInt(lstrarrStream(23))
lobjStructData.OrderTyp = CShort(lstrarrStream(24))
lobjStructData.ValidityCond = CDbl(lstrarrStream(25))
lobjStructData.ExchTrdNo = CType(lstrarrStream(26), Char())
lobjStructData.IntTranscode = CShort(lstrarrStream(27))
lobjStructData.ValidityAttr = CInt(lstrarrStream(28))
lobjStructData.BosRefId = CInt(lstrarrStream(29))
lobjStructData.OriginatorId = CType(lstrarrStream(30), Char())
lobjStructData.Commision = CDbl(lstrarrStream(31))
lobjStructData.SolicitedFlg = CType(lstrarrStream(32), Char())
lobjStructData.OrderFamily = CType(lstrarrStream(33), Char())
lobjStructData.ReceiptTime = CInt(lstrarrStream(34))
lobjStructData.ExchShortSellFlag = CType(lstrarrStream(35), Char())
lobjStructData.cSourceFlag = CChar(lstrarrStream(36))
lobjStructData.extnno = CInt(lstrarrStream(37))
lobjStructData.sReceiptMode = CType(lstrarrStream(38), Char())
lobjStructData.sErrorMsg = CType(lstrarrStream(39), Char())
lobjStructData.cCoverUncover = CChar(lstrarrStream(40))
lobjStructData.fATOrderNo = CDbl(lstrarrStream(41))
lobjStructData.iQtyCond = CShort(lstrarrStream(42))
lobjStructData.iReserve2 = CChar(lstrarrStream(43))
lobjStructData.fInternalRefId = CDbl(lstrarrStream(44))
Well, you have a few redundancies here:
the data type you convert to (which is probably the same as the data type of the field),
the position in the array (which is the same as the order in which you write the statement),
the name of the result variable,
the name of the stream.
Let's try to get rid of them. We will remove (1) with method overloads, (2) with an auto-incremented position variable, (3) with a shorter variable name and (4) by extracting the conversion code into a method.
The following code is untested, but the idea should be obvious:
Public Function ParseStream(pstrStream As String) As SUB_PNDGORDR_QRY_RESP
Dim p As New Parser(pstrStream)
Dim r As New SUB_PNDGORDR_QRY_RESP()
With r
p.ParseField(.ClientId)
p.ParseField(.PortfolioId)
p.ParseField(.Currency)
...
End With
Return r
End Function
Private Class Parser
Public Sub New(pstrStream As String)
Me.lstrarrStream = pstrStream.Split("|"c)
End Sub
Private pos As Integer = 0
Private lstrarrStream As String()
Public Sub ParseField(ByRef field As Char())
field = CType(lstrarrStream(pos), Char())
pos += 1
End Sub
Public Sub ParseField(ByRef field As Short)
field = CShort(lstrarrStream(pos))
pos += 1
End Sub
... other ParseField overloads...
End Class

TransformPDFFields option not working in CreateEnvelopeFromTemplatesAndForms using SOAP API

I am trying to create envelop using CreateEnvelopeFromTemplatesAndForms to make the pdf form fields editable. I am gettting unspecified_error. I have also tried removing the document from composite template and adding the document in the inline template envelop. In this case it creates and sends the envelop but does not make the fields editable. See my code below
'compositeTemplate
Dim envInfo As New EnvelopeInformation
With envInfo
.AccountId = c.AccountID
.Subject = subject
.EmailBlurb = emailBlurb
End With
Dim template As New CompositeTemplate
'recipients
Dim recipients As New List(Of Recipient)
For iRecip As Integer = 1 To packet.Recipients.Count
Dim recipient As New Recipient
Dim customfields As New List(Of String)
With packet.Recipients(iRecip - 1)
recipient.Email = .Email
recipient.SignerName = .Name
recipient.UserName = .Name
recipient.ID = .ID
recipient.RoutingOrder = .RoutingOrder
recipient.RoutingOrderSpecified = True
recipient.RequireIDLookup = .RequireIDLookup
recipient.RequireIDLookupSpecified = True
recipient.AccessCode = .AccessCode
recipient.AddAccessCodeToEmail = False
recipient.AddAccessCodeToEmailSpecified = True
recipient.DefaultRecipient = .DefaultRecipient
recipient.DefaultRecipientSpecified = .IsDefaultRecipientSpecified
If (Not String.IsNullOrEmpty(.CaptiveInfoClientUserId)) Then
recipient.CaptiveInfo = New RecipientCaptiveInfo()
recipient.CaptiveInfo.ClientUserId = .CaptiveInfoClientUserId
End If
customfields.Add(String.Format("SignerRole={0}", .Role))
End With
'add customfields list to recipient customfields
recipient.CustomFields = customfields.ToArray
recipients.Add(recipient)
Next
Dim inlineTemplate As New InlineTemplate
inlineTemplate.Sequence = 1
inlineTemplate.Envelope = New Envelope
inlineTemplate.Envelope.AccountId = c.AccountID
With inlineTemplate.Envelope
.Notification = New APIService.Notification
Dim exp As New APIService.Expirations
With exp
.ExpireEnabled = _envelopeExpirationEnabled
If _envelopeExpirationEnabled Then
.ExpireAfter = _envelopeExpirationDays
If _envelopeExpirationWarningEnabled Then
.ExpireWarn = _envelopeExpirationWarningDaysLeft
End If
End If
End With
.Notification.Expirations = exp
End With
Dim tabs As New List(Of Tab)
'add documents
Dim documents As New List(Of Document)
Dim matchBoxes As New List(Of MatchBox)
For iDoc As Integer = 1 To packet.Forms.Count
Dim theForm As Objects.Form = packet.Forms(iDoc - 1)
theForm.ID = iDoc
Dim document As New Document
document.Name = theForm.FilePath
document.PDFBytes = theForm.FileBytes
document.ID = theForm.ID
document.TransformPdfFields = True
'add tabs - this will be based on metadata defined in the database for the attached forms
For Each oTab As Objects.Tab In theForm.Tabs
Dim tab As New Tab
If Not String.IsNullOrEmpty(oTab.AnchorText) AndAlso oTab.TabType <> TabTypeCode.Custom Then
Dim aTab As New AnchorTab
aTab.AnchorTabString = oTab.AnchorText
tab.AnchorTabItem = aTab
ElseIf oTab.TabType = TabTypeCode.Custom Then
tab.TabLabel = oTab.AnchorText
End If
With tab
.DocumentID = document.ID
.RecipientID = oTab.Recipient.ID
.Type = oTab.TabType
.PageNumber = oTab.PageNumber
.XPosition = oTab.XPosition
.YPosition = oTab.YPosition
If .Type = TabTypeCode.InitialHere Then
.ScaleValueSpecified = True
.ScaleValue = 0.53
End If
End With
tabs.Add(tab)
Next
documents.Add(document)
Next
inlineTemplate.Envelope.Recipients = recipients.ToArray
inlineTemplate.Envelope.Tabs = tabs.ToArray
template.InlineTemplates = New InlineTemplate() {inlineTemplate}
template.Document = New Document
template.Document.ID = 1
template.Document.Name = "TemplateDoc"
template.Document.PDFBytes = documents(0).PDFBytes
template.Document.TransformPdfFields = True
template.Document.FileExtension = "pdf"
Dim _apiProxy As APIServiceSoap = CreateApiProxy(c)
Dim envStatus As EnvelopeStatus = _apiProxy.CreateEnvelopeFromTemplatesAndForms(envInfo, New CompositeTemplate() {template}, True)
Any assistance would be greatly appreciated.
Thanks,
Pulak
The best way to debug such issues (which are sometimes bugs on the DocuSign server side) is to inspect your raw (XML based) SOAP request that you are sending over the wire. If I were you I would include it here in your question as it's much easier to diagnose when we can see the request as opposed to the code that creates the request.
With that said, are setting the tab's Locked property to false so that it's editable? You'll also need to set CustomTabLockedSpecified property to true for this to take affect.
Basically, in your tab definition code try something like this:
With tab
.DocumentID = document.ID
.RecipientID = oTab.Recipient.ID
.Type = oTab.TabType
...
.CustomTabLockedSpecified = True
.CustomTabLocked = False

SAP B1 - Option Button- 'Unable to cast object System.String to type SAPbouiCOM.Item' Error

I am writing a vb.net code in Visual Studio for an add on in SAP B1. Right now, I want to choose an option button and according to what the user chose, I want to take this value and send it to another function in another class. This action I want to make it right after the user press the OK button, so I am trying to do this in an event.
The code that I wrote for creating the options buttons:
Dim optBtn As SAPbouiCOM.OptionBtn
'Dim oFrm As SAPbouiCOM.Form
Dim oUserdatasource As SAPbouiCOM.UserDataSource
oUserdatasource = oform2.DataSources.UserDataSources.Add("BD_resDS", SAPbouiCOM.BoDataType.dt_SHORT_TEXT, 1)
'Option 1
oItem = oform2.Items.Add("BD_rbRes", SAPbouiCOM.BoFormItemTypes.it_OPTION_BUTTON)
oItem.Left = 155
oItem.Top = 10
oItem.Height = 16
oItem.Width = 55
optBtn = oItem.Specific
optBtn.Caption = "Cheque"
optBtn.DataBind.SetBound(True, , "BD_resDS")
'Option 2
oItem = oform2.Items.Add("BD_rbPost", SAPbouiCOM.BoFormItemTypes.it_OPTION_BUTTON)
oItem.Left = 220
oItem.Top = 10
oItem.Height = 16
oItem.Width = 55
optBtn = oItem.Specific
optBtn.Caption = "Cash"
oItem.Visible = True
optBtn = oItem.Specific
optBtn.GroupWith("BD_rbRes")
optBtn.DataBind.SetBound(True, , "BD_resDS")
'Option 3
oItem = oform2.Items.Add("BD_rbPost2", SAPbouiCOM.BoFormItemTypes.it_OPTION_BUTTON)
oItem.Left = 280
oItem.Top = 10
oItem.Height = 16
oItem.Width = 75
optBtn = oItem.Specific
optBtn.Caption = "Credit Card"
oItem.Visible = True
optBtn = oItem.Specific
optBtn.GroupWith("BD_rbPost")
The code that I wrote in the event is this :
Public Sub SBO_Application_ItemEvent(ByVal FormUID As String, ByRef pVal As SAPbouiCOM.ItemEvent, ByRef BubbleEvent As Boolean) Handles SBO_Application.ItemEvent
Try
Dim fInv As SAPbouiCOM.Form
Dim omethod As SAPbouiCOM.Item
Dim opaymeth As SAPbouiCOM.OptionBtn
Dim paymeth As String
'If pVal.ItemUID = "1" And pVal.EventType = SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED And pVal.BeforeAction = True And pVal.ActionSuccess = False And pVal.FormUID = "60006" Then
'End If
'Events of the Blanket Agreement form
If (FormUID = "Choose") Then
If (pVal.BeforeAction = False) Then
' Click on Add Row
If (pVal.ItemUID = "1") And (pVal.EventType = SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED) Then
fInv = SBO_Application.Forms.Item(FormUID)
omethod = fInv.DataSources.UserDataSources.Item("BD_resDS").ValueEx
opaymeth = omethod.Specific
paymeth = opaymeth.Value.ToString()
SBO_Application.MessageBox(paymeth)
If paymeth <> "" And paymeth <> Nothing Then
Dim paym As New payment(SBO_Application, oCompany)
paym.pay(paymeth)
End If
End If
End If
End If
Catch ex As Exception
'SBO_Application.MessageBox(er.Message)
SBO_Application.MessageBox(ex.Message)
End Try
End Sub
Now, the error that I got in SAP B1 is:
Unable to cast object 'System.String' to type 'SAPbouiCOM.Item'
You have declared
Dim omethod As SAPbouiCOM.Item
and assigning it to the string value
omethod = fInv.DataSources.UserDataSources.Item("BD_resDS").ValueEx
Declare string variable and assign value to it like
Dim tmpval as string =""
tmpval = fInv.DataSources.UserDataSources.Item("BD_resDS").ValueEx
try this
omethod = fInv.DataSources.UserDataSources.Item("BD_resDS").ValueEx
.ValueEx seems to return a String, so I guess you just need to remove it
omethod = fInv.DataSources.UserDataSources.Item("BD_resDS")
Another fine example why you should always turn Option Strict ON ;)

Datagrid on VB.net auto complete the other column?

I have a datagrid and I have imported it to my project under vb.net language, and the database is MS access...
any way in this datagrid one table call
"Employees"
ID - Name - Nationality - Job title
and what I want is when I write the ID number of the Employee, all the other details automatically comes upon to his ID number.
I found near answer I made it by my self ...
But it shown the result in combobox not text box :'(
Dim dgvc1 As New DataGridViewComboBoxColumn()
Dim index1 As Integer = DataGridView1.Columns.IndexOf(DataGridView1.Columns("code"))
Dim index11 As Integer = DataGridView1.Columns.IndexOf(DataGridView1.Columns("nu"))
Dim index111 As Integer = DataGridView1.Columns.IndexOf(DataGridView1.Columns("aaa"))
Dim dgvc11 As New DataGridViewComboBoxColumn()
dgvc1.Name = "Code Meaning"
dgvc1.DataPropertyName = "nu"
dgvc1.ValueMember = "nu"
dgvc1.DisplayMember = "code"
dgvc1.DataSource = CodesTableAdapter.GetData()
dgvc1.SortMode = DataGridViewColumnSortMode.Automatic
If DataGridView1.Columns.Contains(dgvc1) = False Then
DataGridView1.Columns.Insert(index1, dgvc1)
Else
End If
dgvc1.ReadOnly = True
dgvc1.Width = 250
dgvc11.Name = "meaning total"
dgvc11.DataPropertyName = "nu"
dgvc11.ValueMember = "nu"
dgvc11.DisplayMember = "aaa"
dgvc11.DataSource = CodesTableAdapter.GetData()
dgvc11.SortMode = DataGridViewColumnSortMode.Automatic
If DataGridView1.Columns.Contains(dgvc11) = False Then
DataGridView1.Columns.Insert(index111, dgvc11)
Else
End If
dgvc11.ReadOnly = True
dgvc11.Width = 250
dgvc11.DefaultCellStyle.BackColor = Color.White
dgvc11.DefaultCellStyle.ForeColor = Color.Black