Ver Mensaje Individual
  #1 (permalink)  
Antiguo 22/08/2011, 11:39
guillebomtrasmiti
 
Fecha de Ingreso: noviembre-2010
Ubicación: madrid
Mensajes: 478
Antigüedad: 13 años, 5 meses
Puntos: 5
Pregunta volver en el grid dónde ya estabas

hola amigos...tengo un ligero problemilla, tengo un grid...cuando el usuario realiza un cambio el da a un btón que pone MODIFICAR...pero ahí viene el problemilla, yo realizo el guardado de los nuevos datos y recargo el grid con la función general que tengo y eso claro hace que el usuario vuelva a estar al principio del grid...necesitaba que tanto al eliminar como al modificar...se recargara la información pero le dejara en el mismo sito dónde estaba...por ejemplo si estaba en la lína 3 siga en ahí...

os envío como lo hago...gracias.

Public Sub modificar()

'Try
Dim adapt As New OleDbDataAdapter
Dim setda As New DataSet
Dim com = conexion.CreateCommand

com.CommandType = CommandType.Text

com.CommandText = "UPDATE Productos SET NomProducto='" + TbNombreProd.Text + "',NomFamilia='" + ComboFamilia.Text + "',NUnidades='" + TbUnidades.Text + "',Merma='" + TbMerma.Text + "',NomProveedor='" + ComboProveedor.Text + "',TieneReceta='" + TextReceta.Text + "',FormatoCompra='" + TbFormatoCompra.Text + "',PrecioCoste='" + TbCosteUnidad.Text + "',CostePromedio='" + TbCostePromedio.Text + "',PVPPromedio='" + TbPromedioPVP.Text + "',RefProveedor1='" + TBRef1.Text + "',RefProveedor2='" + TbRef2.Text + "',RefProveedor3='" + TbRef3.Text + "',IvaVenta='" + ComboIvaVenta.Text + "',CosteUnidad='" + TbCosteUnidad.Text + "',Imagen='" + TbRutaImagen.Text + "',StockA='" + TbAlamacen.Text + "',Stock1='" + TbM1.Text + "',Stock2='" + TbM2.Text + "',Stock3='" + TbM3.Text + "',Stock4='" + TbM4.Text + "',Stock5='" + TbM5.Text + "',Stock6='" + TbM6.Text + "',Stock7='" + TbM7.Text + "',Stock8='" + TbM8.Text + "',Stock9='" + TbM9.Text + "',Stock10='" + TbM9.Text + "',NoEstimar='" + TbNoestimar.Text + "',NoVerEnInformes='" + TbNoInv.Text + "',Min1='" + TextMin1.Text + "',Min2='" + TextMin2.Text + "',Min3='" + TextMin3.Text + "',Min4='" + TextMin4.Text + "',Min5='" + TextMin5.Text + "',Min6='" + TextMin6.Text + "',Min7='" + TextMin7.Text + "',Min8='" + TextMin8.Text + "',Min9='" + TextMin9.Text + "',Min10='" + TextMin10.Text + "',MinA='" + TextMinA.Text + "' where Plu = @Id"
'

com.Parameters.AddWithValue("@Id", (DataGridView1.CurrentRow.Cells(0).Value))

adapt.SelectCommand = com
adapt.Fill(setda, "Productos")
' Catch ex As Exception
' MessageBox.Show(ex.Message)
'End Try

End Sub
y luego
el el btón

Private Sub BModificar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BModificar.Click
modificar()
cargagridFichasProd()
End Sub
Public Sub cargagridFichasProd()
Dim adapt As New OleDbDataAdapter
Dim setda As New DataSet
Dim com = conexion.CreateCommand

Try
com.CommandType = CommandType.Text
com.CommandText = "Select Plu,NomProducto,NomFamilia,NUnidades,Merma,Formato Compra,PrecioCoste,StockA,Stock1,Stock2,Stock3,Sto ck4,Stock5,Stock6,Stock7,Stock8,Stock9,Stock10,Min 1,Min2,Min3,Min4,Min5,Min6,Min7,Min8,Min9,Min10,Mi nA,NomTpv,TipoIva,CodBarras,NFamilia,NProveedor,No mProveedor,TieneReceta,PrecioVenta,Tarifa1,Tarifa2 ,Tarifa3,Tarifa4,Tarifa5,Tarifa6,Tarifa7,Tarifa8,T arifa9,Tarifa10,Tarifa11,Tarifa12,Tarifa13,Tarifa1 4,Tarifa15,Tarifa16,CostePromedio,PvpPromedio,RefP roveedor1,RefProveedor2,RefProveedor3,IvaVenta,Cos teUnidad,Imagen,ProductoAsociadoCompra,AlmacenUnid ades,NTipoProductoInv,NoEstimar,PluGestion From Productos order by Plu ASC"

adapt.SelectCommand = com
adapt.Fill(setda, "Productos")


'aquí cargo el datasource y el datamenber del datagrid
DataGridView1.DataSource = setda
DataGridView1.DataMember = "Productos"
DataGridView1.Refresh()
Catch
MessageBox.Show("Compruebe sus datos", "Aviso GesDreamtPos")
End Try