Ver Mensaje Individual
  #2 (permalink)  
Antiguo 14/08/2011, 13:57
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

vale he decidido hacer esto que pongo aquí, pero el problema además de que sigue cambiando la base de datos es que cuando hay mas de 50 registros en el grid se hace ETERNOOO


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

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(5).Value Is Nothing Then
MessageBox.Show("Estimación Finalizada", "Aviso GesDreamtpos")
ElseIf s = "TARJETA CREDITO" Then

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)
totalfinal = CDec(CStr(CDec(totalcelda - total)))
Textprueba.Text = CStr(totalfinal.ToString("#,##0.00€"))

com.CommandType = CommandType.Text

com.CommandText = "UPDATE IntroduccionDeVentasAhora SET Pts = ('" & Textprueba.Text & "') where NombreFormaPago <> ('TARJETA CREDITO') and 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()
Convert.ToDecimal(CInt(com.ExecuteNonQuery()))
conexion.Close()
End If
Next