Foros del Web » Programación para mayores de 30 ;) » .NET »

Update en un textbox

Estas en el tema de Update en un textbox en el foro de .NET en Foros del Web. HOLA AMIGOS, ESPERO ME PODAIS AYUDAR?¿?, TENGO ESTO Dim adapt As New OleDbDataAdapter Dim setda As New DataSet Dim com = conexion.CreateCommand com.CommandType = CommandType.Text ...
  #1 (permalink)  
Antiguo 14/08/2011, 12:12
 
Fecha de Ingreso: noviembre-2010
Ubicación: madrid
Mensajes: 478
Antigüedad: 13 años, 5 meses
Puntos: 5
Pregunta Update en un textbox

HOLA AMIGOS, ESPERO ME PODAIS AYUDAR?¿?, TENGO ESTO

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

com.CommandType = CommandType.Text
com.CommandText = "UPDATE IntroduccionDeVentasAhora SET Pts =ROUND (Pts *(" & TxtPorcentaje.Text & "/100),2) where NombreFormaPago <> ('TARJETA CREDITO') and Fecha BETWEEN @FI AND @FF"
' com.CommandText = "UPDATE IntroduccionDeVentasAhora SET Pts =ROUND (Pts *(" & TxtPorcentaje.Text & "/100),2) 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"))
'com.Parameters.AddWithValue("@id", (DgTotales..Cells(1).Value))

adapt.SelectCommand = com
conexion.Open()
Convert.ToDecimal(CInt(com.ExecuteNonQuery()))
conexion.Close()

FUNCIONA DE VICIO...LO DEJO POR SI ALGUIÉN LO QUIERE USAR, PERO MI PREGUNTA ES...COMO PUEDO HACER PARA NO EJECUTARLO ... QUE SIMPLEMENTE EL RESULTADO LO PONGA EN UN TEXTBOX PERO QUE NO MODIFIQUE NADA DE NADA...QUE TODO QUEDE COMO ESTABA ANTES DE EJECUTARLO?
  #2 (permalink)  
Antiguo 14/08/2011, 13:57
 
Fecha de Ingreso: noviembre-2010
Ubicación: madrid
Mensajes: 478
Antigüedad: 13 años, 5 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
  #3 (permalink)  
Antiguo 14/08/2011, 16:58
 
Fecha de Ingreso: noviembre-2010
Ubicación: madrid
Mensajes: 478
Antigüedad: 13 años, 5 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?
  #4 (permalink)  
Antiguo 14/08/2011, 17:02
Avatar de dwaks  
Fecha de Ingreso: agosto-2002
Ubicación: Panamá
Mensajes: 962
Antigüedad: 21 años, 9 meses
Puntos: 15
Respuesta: Update en un textbox

La verdad vi 3 veces lo que pusiste y no entiendo nada de nada que quieres en verdad. Si no quieres que los queries se ejecuten quita esta línea:

Convert.ToDecimal(CInt(com.ExecuteNonQuery()))

De allí ni idea que es lo que en verdad haces o quieres hacer.
  #5 (permalink)  
Antiguo 14/08/2011, 17:26
 
Fecha de Ingreso: noviembre-2010
Ubicación: madrid
Mensajes: 478
Antigüedad: 13 años, 5 meses
Puntos: 5
Respuesta: Update en un textbox

ahora me dice que no coinciden los datos en la expresion de criterios...en IDCOMANDA...PORQ UEEEEE


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 Single

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€"))
Textprueba.Text = CStr(CSng(division))

com.CommandType = CommandType.Text
com.CommandText = "UPDATE IntroduccionDeVentasAhora SET Pts = ('" & Textprueba.Text & "') Where IdComanda = @valor and 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"))
com.Parameters.AddWithValue("@valor", DgTotales.CurrentRow.Cells(11).Value.ToString)

adapt.SelectCommand = com

conexion.Open()

com.ExecuteNonQuery()

conexion.Close()

End If
Next
  #6 (permalink)  
Antiguo 14/08/2011, 17:27
 
Fecha de Ingreso: noviembre-2010
Ubicación: madrid
Mensajes: 478
Antigüedad: 13 años, 5 meses
Puntos: 5
Respuesta: Update en un textbox

FACIL necesito que en la celda Pts se cargue la cantidad de un textbox..pero el problema es que con el for lo va haciendo bien..pero al terminar cambia todas las filas por el último importe del textbox y no fija cada importe en su row...que quiero poner que se guie por idcomanda..pero me manda el error anterior
  #7 (permalink)  
Antiguo 14/08/2011, 17:31
 
Fecha de Ingreso: noviembre-2010
Ubicación: madrid
Mensajes: 478
Antigüedad: 13 años, 5 meses
Puntos: 5
Respuesta: Update en un textbox

com.CommandType = CommandType.Text
com.CommandText = "UPDATE IntroduccionDeVentasAhora SET Pts = ('" & Textprueba.Text & "') Where IdComanda = @valor and 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"))
com.Parameters.AddWithValue("@valor", DgTotales.CurrentRow.Cells(11).Value.ToString)

ahí necesito que me ayudeis por favor
  #8 (permalink)  
Antiguo 14/08/2011, 17:39
 
Fecha de Ingreso: noviembre-2010
Ubicación: madrid
Mensajes: 478
Antigüedad: 13 años, 5 meses
Puntos: 5
Respuesta: Update en un textbox

arreglado

a = CInt((Val(row.Cells(11).Value)))
Textpruebafinal.Text = CStr(a)

com.CommandType = CommandType.Text
com.CommandText = "UPDATE IntroduccionDeVentasAhora SET Pts = ('" & Textprueba.Text & "') Where IdComanda = (" & a & ") and 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()

com.ExecuteNonQuery()

conexion.Close()

Etiquetas: bd, textbox, update
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 12:43.