You are on page 1of 2

Try

Dim s1 As String
s1 =
DG_articulos.Rows(DG_articulos.CurrentRow.Index).Cells(1).Value
s1 = Mid(s1, InStr(s1, " ") + 1, Len(s1))
s1 = Mid(s1, 1, InStr(s1, " ") - 1)

Dim llena_CAT As New SqlCommand("SELECT TOP 1 C.Name FROM
Category AS C, Department AS D WHERE C.DepartmentID = D.ID AND D.Name =
'" & DG_articulos.Rows(DG_articulos.CurrentRow.Index).Cells(11).Value &
"' AND C.Name LIKE '" & s1 & "%' ORDER BY C.Name ASC", conexion_hq)

'----
Dim DG_virtual As New DataGridViewComboBoxCell

Dim consultar_depto As New SqlCommand("SELECT ID FROM
Department WHERE Name LIKE'" &
DG_articulos.Rows(DG_articulos.CurrentRow.Index).Cells(11).Value & "'",
conexion_hq)
Dim id_depto As Integer = consultar_depto.ExecuteScalar

Dim llena_catX As New SqlClient.SqlDataAdapter("SELECT
Name FROM Category WHERE DepartmentID = " & id_depto & " ORDER BY Name",
conexion_hq)
Dim datos_cat As New DataSet
llena_catX.Fill(datos_cat)

DG_virtual.DataSource = datos_cat.Tables(0)
DG_virtual.DisplayMember =
datos_cat.Tables(0).Columns(0).Caption.ToString

DG_articulos.Item(12, DG_articulos.CurrentRow.Index) =
DG_virtual
'----

DG_articulos.Rows(DG_articulos.CurrentRow.Index).Cells(12).Value =
llena_CAT.ExecuteScalar

'codigo mayoreo________________
If
DG_articulos.Rows(DG_articulos.CurrentRow.Index).Cells(8).Value <> 0 Then
Try
Dim s1x As String
s1x =
DG_articulos.Rows(DG_articulos.CurrentRow.Index).Cells(1).Value
s1x = Mid(s1x, 1, InStr(s1x, " ") - 1)
Dim llena_mayore As New SqlCommand("SELECT
(CATEGORIA + ' [' + BINLOCATION + ']') as Cat FROM cat_mayorista WHERE
Departamento = '" & departament & "' AND CATEGORIA LIKE '%" & s1x & "%'",
conexion_hq)


DG_articulos.Rows(DG_articulos.CurrentRow.Index).Cells(13).Value =
llena_mayore.ExecuteScalar
Catch err As Exception
'MsgBox(ex.Message)
End Try
End If
Catch ex As Exception
'MsgBox(ex.Message)
End Try
Else
If
DG_articulos.Rows(DG_articulos.CurrentRow.Index).Cells(8).Value = 0 Then

DG_articulos.Rows(DG_articulos.CurrentRow.Index).Cells(13).Value =
Nothing
End If
End If
End If
End If

You might also like