Ver Mensaje Individual
  #3 (permalink)  
Antiguo 14/08/2011, 16:58
guillebomtrasmiti
 
Fecha de Ingreso: noviembre-2010
Ubicación: madrid
Mensajes: 478
Antigüedad: 13 años, 6 meses
Puntos: 5
Respuesta: Update en un textbox

Public Sub restarporcentaje()

Dim adapt As New OleDbDataAdapter
Dim setda As New DataSet
Dim com = conexion.CreateCommand
Dim total As Decimal = 0
Dim totalcelda As Decimal = 0
Dim totalfinal As Decimal = 0
Dim division As Decimal = 0

For Each row As DataGridViewRow In DgTotales.Rows
'carga el textbox total con lo que exista en el grid
Dim s As String = CType(row.Cells(5).Value, String)

If row.Cells(0).Value Is Nothing Then
MessageBox.Show("Estimación Finalizada", "Aviso GesDreamtpos")
ElseIf s = "TARJETA CREDITO" Then
MessageBox.Show("es tarjeta")
Else
'totalcelda = CDec(CDec(total + Val(row.Cells(1).Value) * Val(row.Cells(2).Value)))
' total = CDec(CDec(total + Val(row.Cells(1).Value) * Val(row.Cells(2).Value)) * CDbl(TxtPorcentaje.Text) / 100)
totalcelda = CDec(Val(row.Cells(1).Value) * Val(row.Cells(2).Value))
total = CDec((Val(row.Cells(1).Value) * Val(row.Cells(2).Value)) * CDbl(TxtPorcentaje.Text) / 100)
totalfinal = CDec(CStr(CDec(totalcelda - total)))
division = CDec(totalfinal / Val(row.Cells(1).Value))
Textprueba.Text = CStr(division.ToString("#,##0.00€"))

com.CommandType = CommandType.Text

com.CommandText = "UPDATE IntroduccionDeVentasAhora SET Pts = ('" & Textprueba.Text & "') where Fecha BETWEEN @FI AND @FF"

com.Parameters.AddWithValue("@FI", Fecha1.Value.Date.ToString("dd/MM/yyyy"))
com.Parameters.AddWithValue("@FF", Fecha2.Value.Date.ToString("dd/MM/yyyy"))

adapt.SelectCommand = com

conexion.Open()
' Dim lecto As Decimal
'lecto =
com.ExecuteNonQuery()
'Convert.ToDecimal(CInt(com.ExecuteNonQuery()))
conexion.Close()
End If
Next


nada...no lo consigo, ahora lo que me sucede es que actualizo celda a celda pero luego me cambia todas las celdas por el último resultado, alguna ayuda?