VERSION 5.00 Begin VB.Form Form3 BackColor = &H00C0CEC0& BorderStyle = 4 'Fixed ToolWindow Caption = " Modificación Producto" ClientHeight = 2700 ClientLeft = 45 ClientTop = 345 ClientWidth = 4995 LinkTopic = "Form4" MaxButton = 0 'False MDIChild = -1 'True MinButton = 0 'False ScaleHeight = 2700 ScaleWidth = 4995 ShowInTaskbar = 0 'False Begin VB.TextBox Text3 Height = 285 Left = 2760 TabIndex = 2 Top = 1200 Width = 615 End Begin VB.CommandButton Command2 Caption = "Cancelar" Height = 375 Left = 960 Style = 1 'Graphical TabIndex = 6 Top = 1920 Width = 1335 End Begin VB.TextBox Text2 Appearance = 0 'Flat BorderStyle = 0 'None Height = 285 Left = 2760 TabIndex = 1 Top = 720 Width = 1815 End Begin VB.TextBox Text1 Height = 285 Left = 2760 MaxLength = 7 TabIndex = 0 Top = 240 Width = 1815 End Begin VB.CommandButton Command1 Caption = "Siguiente" Height = 375 Left = 2760 Style = 1 'Graphical TabIndex = 4 Top = 1920 Width = 1335 End Begin VB.Label Label3 Alignment = 2 'Center BackColor = &H00C0E0FF& Caption = "Unidades por utillaje Robot" Height = 255 Left = 360 TabIndex = 7 Top = 1200 Width = 1935 End Begin VB.Label Label2 Alignment = 2 'Center BackColor = &H00C0E0FF& Caption = "Descripción Producto" Height = 255 Left = 360 TabIndex = 3 Top = 720 Width = 1935 End Begin VB.Label Label1 Alignment = 2 'Center BackColor = &H00C0E0FF& Caption = "Referencia Producto" Height = 255 Left = 360 TabIndex = 5 Top = 240 Width = 1935 End End Attribute VB_Name = "Form3" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Private conn As New ADODB.Connection Private rsproducto As ADODB.Recordset Private rsiproducto As ADODB.Recordset Private Sub Command1_Click() 'PASO DE DATOS A LA BASE DE DATOS ' Por si ya estaba abierta la conexion ... Set conn = Nothing Set rsproducto = Nothing Set rsiproducto = Nothing ' Crear los objetos Set conn = New ADODB.Connection Set rsproducto = New ADODB.Recordset Set rsiproducto = New ADODB.Recordset ' Abrir la base con el proveedor correspondiente conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=C:\DBPROSS.mdb" ' Ver si la referencia ya existe en la base de datos BDProSS If Text1.Text = "" Then MsgBox "Por favor, introduzca una referencia válida para el producto", vbExclamation ElseIf Text3.Text = "" Then MsgBox "Por favor, indique las unidades por utillaje", vbExclamation Else 'paso de contenido a variables globales gproducto.referencia = Text1.Text gproducto.descripcion = Text2.Text gproducto.udsutillaje = Text3.Text 'insertar modificaciones en la tabla producto rsiproducto.Open "UPDATE PRODUCTO SET DESCRIPCION_PRODUCTO ='" & gproducto.descripcion & "' , UDS_UTILLAJE = " & gproducto.udsutillaje & " WHERE ID_PRODUCTO = " & gproducto.referencia & " ", conn, adOpenDynamic, adLockOptimistic 'rsiproducto.Close 'Consulta de todos los procesos/piezas de la referencia a modificar Dim n As Integer Dim otroarray() As String Dim busqueda As Double Dim ultimo As Integer Dim vselec As String vselec = " PIEZA.ID_PIEZA, PIEZA.DESCRIPCION_PIEZA, PIEZA.UNIDADES, PROCESO.ID_PROCESO, PIEZA.MEDIDA1, PIEZA.MEDIDA2, PIEZA.ESPESOR, PIEZA.LONGITUD,PROCESO.DESCRIPCION_PROCESO, PROCESO.TIEMPO FROM PRODUCTO, PIEZA, PROCESO WHERE " vselec = vselec & " PRODUCTO.ID_PRODUCTO = " & gproducto.referencia & " AND PRODUCTO.ID_PRODUCTO = PIEZA.ID_PRODUCTO AND PIEZA.ID_PIEZA = PROCESO.ID_PIEZA " rsproducto.Open " SELECT " & vselec & " ORDER BY PIEZA.ID_PIEZA, PIEZA.MEDIDA1, PIEZA.MEDIDA2, PIEZA.ESPESOR", conn, adOpenDynamic, adLockBatchOptimistic Dim R As Integer Dim aformulario6 As Integer Dim altura Dim izda izda = 120 altura = 1690 rsproducto.MoveFirst aformulario6 = 4000 Form6.Height = aformulario6 R = 1 n = 0 If Form6.Text1.Count <> 1 Then Dim u As Integer Dim bye As Integer bye = Form6.Text1.Count For u = 1 To bye - 1 Unload Form6.Text1(u) Next u End If Do While rsproducto.EOF = False Load Form6.Text1(R) Form6.Text1(R).Text = rsproducto(0) Form6.Text1(R).Move izda, altura, 3000 Form6.Text1(R).Visible = False 'izda = izda + 3000 R = R + 1 Load Form6.Text1(R) Form6.Text1(R).Text = rsproducto(1) Form6.Text1(R).Move izda, altura, 3000 Form6.Text1(R).Visible = True izda = izda + 3000 R = R + 1 Load Form6.Text1(R) Form6.Text1(R).Text = rsproducto(2) Form6.Text1(R).Move izda, altura, 840 Form6.Text1(R).Visible = True izda = izda + 840 R = R + 1 Load Form6.Text1(R) Form6.Text1(R).Text = rsproducto(3) Form6.Text1(R).Move izda, altura, 3000 Form6.Text1(R).Visible = False 'izda = izda + 3000 R = R + 1 Load Form6.Text1(R) Form6.Text1(R).Text = rsproducto(4) Form6.Text1(R).Move izda, altura, 840 Form6.Text1(R).Visible = True izda = izda + 840 R = R + 1 Load Form6.Text1(R) Form6.Text1(R).Text = rsproducto(5) Form6.Text1(R).Move izda, altura, 840 Form6.Text1(R).Visible = True izda = izda + 840 R = R + 1 Load Form6.Text1(R) Form6.Text1(R).Text = rsproducto(6) Form6.Text1(R).Move izda, altura, 840 Form6.Text1(R).Visible = True izda = izda + 840 R = R + 1 Load Form6.Text1(R) Form6.Text1(R).Text = rsproducto(7) Form6.Text1(R).Move izda, altura, 840 Form6.Text1(R).Visible = True izda = izda + 840 R = R + 1 Load Form6.Text1(R) Form6.Text1(R).Text = rsproducto(8) Form6.Text1(R).Move izda, altura, 1920 Form6.Text1(R).Visible = True Form6.Text1(R).Locked = True Form6.Text1(R).BackColor = &HE0FFFF izda = izda + 1920 R = R + 1 Load Form6.Text1(R) Form6.Text1(R).Text = rsproducto(9) Form6.Text1(R).Move izda, altura, 840 Form6.Text1(R).Visible = True izda = izda + 840 R = R + 1 'Load Form6.Text1(R) 'Form6.Text1(R).Text = rsproducto(10) 'Form6.Text1(R).Move izda, altura, 3000 'Form6.Text1(R).Visible = True 'izda = izda + 3000 'R = R + 1 'Load Form6.Text1(R) 'Form6.Text1(R).Text = rsproducto(11) 'Form6.Text1(R).Move izda, altura, 3000 'Form6.Text1(R).Visible = True 'izda = izda + 3000 'R = R + 1 izda = 120 aformulario6 = aformulario6 + 240 Form6.Height = aformulario6 Form6.Label8.Move 120, altura + 400, 4000 altura = altura + 240 rsproducto.MoveNext Loop Dim final As Integer final = R For R = 1 To final - 20 If Form6.Text1(R) = Form6.Text1(R + 10) Then Form6.Text1(R).Locked = True Form6.Text1(R + 1).Locked = True Form6.Text1(R + 2).Locked = True Form6.Text1(R + 3).Locked = True Form6.Text1(R + 4).Locked = True Form6.Text1(R + 5).Locked = True Form6.Text1(R + 6).Locked = True Form6.Text1(R + 7).Locked = True Form6.Text1(R + 8).Locked = True Form6.Text1(R).BackColor = &HE0FFFF Form6.Text1(R + 1).BackColor = &HE0FFFF Form6.Text1(R + 2).BackColor = &HE0FFFF Form6.Text1(R + 3).BackColor = &HE0FFFF Form6.Text1(R + 4).BackColor = &HE0FFFF Form6.Text1(R + 5).BackColor = &HE0FFFF Form6.Text1(R + 6).BackColor = &HE0FFFF Form6.Text1(R + 7).BackColor = &HE0FFFF Form6.Text1(R + 8).BackColor = &HE0FFFF End If R = R + 9 Next R 'Dim t As Integer 'For t = 1 To indice - 1 ' Unload Label7(t) 'Next t Form3.Visible = False Form6.Visible = True Command1.Visible = False Text1.Text = "" Text3.Text = "" 'indice = 1 Unload Form3 conn.Close End If 'conn.Close End Sub Private Sub Command2_Click() Form3.Visible = False End Sub Private Sub Form_Load() ' centrar el formulario en la parte superior Move (Screen.Width - Width) \ 2, 1500 End Sub Private Sub Text1_LostFocus() ' Por si ya estaba abierta la conexion ... Set conn = Nothing Set rsproducto = Nothing ' Crear los objetos Set conn = New ADODB.Connection Set rsproducto = New ADODB.Recordset ' Abrir la base con el proveedor correspondiente conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=C:\DBPROSS.mdb" If Text1.Text <> "" Then ' Ver si la referencia ya existe en la base de datos BDProSS rsproducto.Open "SELECT * FROM PRODUCTO WHERE ID_PRODUCTO = " & Text1.Text & "", conn, adOpenDynamic, adLockOptimistic If rsproducto.EOF = True Then MsgBox "No existe ningún Producto Final con la referencia introducida", vbExclamation Text1.Text = "" Text1.SetFocus Else Text2.Text = rsproducto(1) Text3.Text = rsproducto(2) 'cerrar la conexion conn.Close End If End If End Sub Private Sub Text1_Validate(Cancel As Boolean) If Not IsNumeric(Text1.Text) Then Cancel = True ElseIf CDbl(Text1.Text) < 0 Then Cancel = True End If If Cancel Then MsgBox "Por favor, escriba una referencia válida (0 para cancelar)", vbExclamation End If End Sub Private Sub Text3_Validate(Cancel As Boolean) If Not IsNumeric(Text3.Text) Then Cancel = True ElseIf CDbl(Text3.Text) < 0 Then Cancel = True End If If Cancel Then MsgBox "Por favor, escriba un dato correcto(0 para cancelar)", vbExclamation End If End Sub