Ver Mensaje Individual
  #7 (permalink)  
Antiguo 05/06/2011, 16:14
guillebomtrasmiti
 
Fecha de Ingreso: noviembre-2010
Ubicación: madrid
Mensajes: 478
Antigüedad: 13 años, 5 meses
Puntos: 5
Respuesta: no duplicar numero de factura

ya ... por si alguien lo necesita

Private Sub TextUnd_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextUnd.KeyPress
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''
'con este IF consigo que el punto siempre sea una coma
If e.KeyChar = "."c Then
e.Handled = True
TextUnd.Text += ","
TextUnd.SelectionStart = TextUnd.Text.Length
End If
'con este if convierto la pulsación hacia la tecla enter
If e.KeyChar = Convert.ToChar(Keys.Enter) Then
'compruebo si factura tiene su número y paso el foco a formato compra, si no da mensaje de error

'con este if compruebo que la factura no esté ya en el historico
Dim com As New OleDbCommand
Dim buscar As String = "SELECT * from LineasFacturasHCabecera where NFacturaSRCabecera = '" & TextNFactura.Text & "'"

com = New OleDbCommand(buscar, conexion)

Dim Adapter As OleDbDataAdapter = New OleDbDataAdapter(buscar, conexion)
Dim tabla_temp As DataTable = New DataTable

conexion.Open()
Adapter.Fill(tabla_temp)
If tabla_temp.Rows.Count = 1 Then
MessageBox.Show("Existe el Número de Factura " & TextNFactura.Text & " decida si continuar")
ElseIf tabla_temp.Rows.Count = 0 Then
End If
conexion.Close()

'con este If compruebo si el textbox factura está en blanco o no
If Not String.IsNullOrEmpty(TextNFactura.Text) Then
TextFComp.Focus()
Else
MessageBox.Show("Debe cubrir un número de factura campo obligatorio. ", "Información de Error")
End If
End If