VERSION 5.00 Begin VB.Form Form5 BackColor = &H00C0CEC0& BorderStyle = 4 'Fixed ToolWindow Caption = "Orden de producción robots" ClientHeight = 3615 ClientLeft = 45 ClientTop = 345 ClientWidth = 11250 FillColor = &H0000FFFF& FontTransparent = 0 'False LinkTopic = "Form2" MaxButton = 0 'False MDIChild = -1 'True MinButton = 0 'False ScaleHeight = 3615 ScaleWidth = 11250 ShowInTaskbar = 0 'False Begin VB.CommandButton Command5 BackColor = &H00FFC0C0& Caption = "Generar Listado de Producción" Height = 615 Left = 9720 Style = 1 'Graphical TabIndex = 16 Top = 480 Visible = 0 'False Width = 1095 End Begin VB.CommandButton Command4 Caption = "Eliminar Último Producto" Height = 495 Left = 7320 TabIndex = 15 Top = 1320 Visible = 0 'False Width = 1455 End Begin VB.CommandButton Command3 Caption = "Añadir Producto al Listado" Height = 495 Left = 7320 TabIndex = 9 Top = 600 Width = 1455 End Begin VB.CommandButton Command2 Caption = "Cancelar" Height = 375 Left = 9840 TabIndex = 7 Top = 2640 Width = 855 End Begin VB.CommandButton Command1 BackColor = &H00FFC0C0& Caption = "Generar Listado de Control" Height = 615 Left = 9720 Style = 1 'Graphical TabIndex = 6 Top = 1320 Visible = 0 'False Width = 1095 End Begin VB.TextBox Text3 Height = 285 Left = 3000 TabIndex = 5 Top = 1320 Width = 975 End Begin VB.TextBox Text2 Appearance = 0 'Flat BorderStyle = 0 'None ForeColor = &H00404040& Height = 285 HideSelection = 0 'False Left = 3000 Locked = -1 'True TabIndex = 4 TabStop = 0 'False Top = 960 Width = 3375 End Begin VB.TextBox Text1 Height = 285 Left = 3000 TabIndex = 3 Top = 600 Width = 975 End Begin VB.Label Label11 BackStyle = 0 'Transparent BorderStyle = 1 'Fixed Single Height = 1695 Left = 360 TabIndex = 14 Top = 360 Width = 8895 End Begin VB.Label Label10 Alignment = 2 'Center Appearance = 0 'Flat BackColor = &H00C0FFFF& BackStyle = 0 'Transparent Caption = "LISTADO DE SOLDADURA" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 700 Underline = -1 'True Italic = 0 'False Strikethrough = 0 'False EndProperty ForeColor = &H80000008& Height = 255 Left = 360 TabIndex = 13 Top = 2280 Width = 5775 End Begin VB.Label Label7 Alignment = 2 'Center Appearance = 0 'Flat BackColor = &H80000004& BorderStyle = 1 'Fixed Single ForeColor = &H80000008& Height = 255 Index = 0 Left = 360 TabIndex = 12 Top = 3000 Visible = 0 'False Width = 1215 End Begin VB.Label Label6 Appearance = 0 'Flat BackColor = &H00C0F0FF& BorderStyle = 1 'Fixed Single Caption = "Cantidad" ForeColor = &H80000008& Height = 255 Left = 5040 TabIndex = 11 Top = 2760 Width = 1095 End Begin VB.Label Label5 Alignment = 2 'Center Appearance = 0 'Flat BackColor = &H00C0F0FF& BorderStyle = 1 'Fixed Single Caption = "Descripción" ForeColor = &H80000008& Height = 255 Left = 1560 TabIndex = 10 Top = 2760 Width = 3495 End Begin VB.Label Label4 Alignment = 2 'Center Appearance = 0 'Flat BackColor = &H00C0F0FF& BorderStyle = 1 'Fixed Single Caption = "Producto" ForeColor = &H80000008& Height = 255 Left = 360 TabIndex = 8 Top = 2760 Width = 1215 End Begin VB.Label Label3 BackColor = &H00C0E0FF& Caption = "Cantidad a fabricar" Height = 255 Left = 720 TabIndex = 2 Top = 1320 Width = 1935 End Begin VB.Label Label2 BackColor = &H00C0E0FF& Caption = "Descripción Producto" Height = 255 Left = 720 TabIndex = 1 Top = 960 Width = 1935 End Begin VB.Label Label1 BackColor = &H00C0E0FF& Caption = "Referencia Producto Final" Height = 255 Left = 720 TabIndex = 0 Top = 600 Width = 1935 End End Attribute VB_Name = "Form5" 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 'Public rslistado As ADODB.Recordset Dim indice As Integer Dim altura As Integer Dim aformulario As Integer Private Sub Command1_Click() If Text1.Text = "" Then MsgBox "Por favor, introduzca una referencia válida para el producto", vbExclamation End If If Label7.Count = 1 Then MsgBox "Por favor, añada algun producto al listado", vbExclamation Else gproducto.referencia = Text1.Text gproducto.cantidad = Text3.Text 'PASO DE DATOS A LA BASE DE DATOS ' Por si ya estaba abierta la conexion ... Set conn = Nothing Set rslistado = Nothing ' Crear los objetos Set conn = New ADODB.Connection Set rslistado = New ADODB.Recordset ' Abrir la base con el proveedor correspondiente conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=C:\DBPROSS.mdb" 'Consulta de todos los procesos del listado de producción Dim n As Integer Dim otroarray() As String Dim busqueda As Double Dim ultimo As Integer Dim vselec As String otroarray = listado(2) ultimo = Label7.Count vselec = " PRODUCTO.ID_PRODUCTO, PRODUCTO.DESCRIPCION_PRODUCTO, PIEZA.DESCRIPCION_PIEZA, PIEZA.UNIDADES, PROCESO.DESCRIPCION_PROCESO, PIEZA.MEDIDA1, PIEZA.MEDIDA2, PIEZA.ESPESOR, PIEZA.LONGITUD, PROCESO.TIEMPO FROM PRODUCTO, PIEZA, PROCESO WHERE " For n = 0 To ultimo - 4 busqueda = CDbl(otroarray(n)) vselec = vselec & " PRODUCTO.ID_PRODUCTO = " & busqueda & " AND PRODUCTO.ID_PRODUCTO = PIEZA.ID_PRODUCTO AND PIEZA.ID_PIEZA = PROCESO.ID_PIEZA " If n <> ultimo - 4 Then vselec = vselec & " OR " End If n = n + 2 Next n rslistado.Open " SELECT " & vselec & " ORDER BY PRODUCTO.ID_PRODUCTO, PIEZA.ID_PIEZA, PROCESO.DESCRIPCION_PROCESO, PIEZA.MEDIDA1, PIEZA.MEDIDA2, PIEZA.ESPESOR", conn, adOpenDynamic, adLockBatchOptimistic Dim r As Integer Dim aformulario8 As Integer Dim altura Dim izda izda = 120 altura = 1690 rslistado.MoveFirst aformulario8 = 4000 Form8.Height = aformulario8 r = 1 n = 0 If Form8.Label2.Count <> 1 Then Dim u As Integer Dim bye As Integer bye = Form8.Label2.Count For u = 1 To bye - 1 Unload Form8.Label2(u) Next u End If Do While rslistado.EOF = False Load Form8.Label2(r) Form8.Label2(r).Caption = rslistado(0) Form8.Label2(r).Move izda, altura, 1090 Form8.Label2(r).Visible = True izda = izda + 1085 r = r + 1 Load Form8.Label2(r) Form8.Label2(r).Caption = rslistado(1) Form8.Label2(r).Move izda, altura, 3370 Form8.Label2(r).Visible = True izda = izda + 3360 r = r + 1 Load Form8.Label2(r) Form8.Label2(r).Caption = rslistado(2) Form8.Label2(r).Move izda, altura, 2650 Form8.Label2(r).Visible = True izda = izda + 2615 r = r + 1 Load Form8.Label2(r) Dim cant As Integer otroarray = listado(2) ultimo = Label7.Count For n = 0 To ultimo - 4 busqueda = CDbl(otroarray(n)) If busqueda = rslistado(0) Then cant = rslistado(3) * otroarray(n + 2) End If n = n + 2 Next n Form8.Label2(r).Caption = cant Form8.Label2(r).Move izda, altura, 1345 Form8.Label2(r).Visible = True izda = izda + 1345 r = r + 1 Load Form8.Label2(r) Form8.Label2(r).Caption = rslistado(4) Form8.Label2(r).Move izda, altura, 2290 Form8.Label2(r).Visible = True izda = izda + 2280 r = r + 1 Load Form8.Label2(r) Form8.Label2(r).Caption = rslistado(5) Form8.Label2(r).Move izda, altura, 850 Form8.Label2(r).Visible = True izda = izda + 840 r = r + 1 Load Form8.Label2(r) Form8.Label2(r).Caption = rslistado(6) Form8.Label2(r).Move izda, altura, 850 Form8.Label2(r).Visible = True izda = izda + 840 r = r + 1 Load Form8.Label2(r) Form8.Label2(r).Caption = rslistado(7) Form8.Label2(r).Move izda, altura, 850 Form8.Label2(r).Visible = True izda = izda + 840 r = r + 1 Load Form8.Label2(r) Form8.Label2(r).Caption = rslistado(8) Form8.Label2(r).Move izda, altura, 850 Form8.Label2(r).Visible = True izda = izda + 840 r = r + 1 Load Form8.Label2(r) Form8.Label2(r).Caption = rslistado(9) Form8.Label2(r).Move izda, altura, 855 Form8.Label2(r).Visible = True izda = izda + 850 r = r + 1 izda = 120 aformulario8 = aformulario8 + 240 Form8.Height = aformulario8 altura = altura + 240 rslistado.MoveNext Loop Dim t As Integer For t = 1 To indice - 1 Unload Label7(t) Next t Form2.Visible = False Form8.Visible = True Command1.Visible = False Text1.Text = "" Text3.Text = "" indice = 1 Unload Form2 conn.Close End If End Sub 'Función para pasar los productos y cantidades a un array Private Function listado(mult As Byte) As String() Dim arr() As String, i As Integer Dim ultimo As Integer ultimo = Label7.Count - 1 ReDim arr(0 To ultimo - 1) For i = 0 To ultimo - 1 arr(i) = Label7(i + 1) Next i listado = arr End Function Private Sub Command2_Click() Form5.Visible = False End Sub Private Sub Command3_Click() If Text3.Text = "" Then MsgBox "Por favor, introduzca una una cantidad a fabricar", vbExclamation Else Load Label7(indice) Load Label7(indice + 1) Load Label7(indice + 2) Label7(indice).Move 360, 3000 + altura, 1215 Label7(indice).Caption = Text1.Text Label7(indice + 1).Move 1560, 3000 + altura, 3495 Label7(indice + 1).Caption = Text2.Text Label7(indice + 2).Move 5040, 3000 + altura, 1095 Label7(indice + 2).Caption = Text3.Text Label7(indice).Visible = True Label7(indice + 1).Visible = True Label7(indice + 2).Visible = True indice = indice + 3 altura = altura + 240 aformulario = aformulario + 240 Form5.Height = aformulario Command4.Visible = True End If End Sub Private Sub Command4_Click() indice = indice - 3 Label7(indice).Move 360, 3000 + altura, 1215 Label7(indice).Caption = 0 Label7(indice + 1).Move 1560, 3000 + altura, 3495 Label7(indice + 1).Caption = 0 Label7(indice + 2).Move 5040, 3000 + altura, 1095 Label7(indice + 2).Caption = 0 Label7(indice).Visible = False Label7(indice + 1).Visible = False Label7(indice + 2).Visible = False Unload Label7(indice) Unload Label7(indice + 1) Unload Label7(indice + 2) altura = altura - 240 aformulario = aformulario - 240 Form2.Height = aformulario Command4.Visible = False End Sub Private Sub Command5_Click() If Text1.Text = "" Then MsgBox "Por favor, introduzca una referencia válida para el producto", vbExclamation End If If Label7.Count = 1 Then MsgBox "Por favor, añada algun producto al listado", vbExclamation Else gproducto.referencia = Text1.Text gproducto.cantidad = Text3.Text 'PASO DE DATOS A LA BASE DE DATOS ' Por si ya estaba abierta la conexion ... Set conn = Nothing Set rslistado = Nothing ' Crear los objetos Set conn = New ADODB.Connection Set rslistado = New ADODB.Recordset ' Abrir la base con el proveedor correspondiente conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=C:\DBPROSS.mdb" 'Consulta de todos los procesos del listado de producción Dim n As Integer Dim otroarray() As String Dim busqueda As Double Dim ultimo As Integer Dim vselec As String otroarray = listado(2) ultimo = Label7.Count vselec = " ID_PRODUCTO, DESCRIPCION_PRODUCTO, UDS_UTILLAJE, TIEMPO_ROBOT FROM PRODUCTO WHERE " For n = 0 To ultimo - 4 busqueda = CDbl(otroarray(n)) vselec = vselec & " ID_PRODUCTO = " & busqueda & " " If n <> ultimo - 4 Then vselec = vselec & " OR " End If n = n + 2 Next n rslistado.Open " SELECT " & vselec & " ORDER BY TIEMPO_ROBOT ", conn, adOpenDynamic, adLockBatchOptimistic ' formación del array preorden que contiene los datos de id_producto,descripcion_producto,uds_utillaje,tiempo_robot,cantidad a fabricar Dim preorden() As String Dim i As Integer Dim t As Integer Dim u As Integer otroarray = listado(2) Dim ultimo_pre As Integer ultimo = Label7.Count ultimo_pre = (5 * ((ultimo - 1) / 3)) rslistado.MoveFirst ReDim preorden(0 To ultimo_pre) n = 0 i = 0 For u = 0 To ultimo - 4 preorden(n) = rslistado(0) preorden(n + 1) = rslistado(1) preorden(n + 2) = rslistado(2) preorden(n + 3) = rslistado(3) For t = 0 To ultimo - 4 If otroarray(t) = preorden(n) Then preorden(n + 4) = otroarray(t + 2) End If t = t + 2 Next t rslistado.MoveNext n = n + 5 i = i + 4 u = u + 2 Next u 'Calculo del un array con todos los trabajos,referencia,tiempo Dim tra As Integer Dim pre As Integer Dim r As Integer Dim nro_trabajos1 As Integer Dim nro_trabajos2 As Integer Dim nro_referencias Dim trabajo_array() nro_trabajos1 = 0 nro_trabajos2 = 0 nro_referencias = ultimo_pre / 5 pre = 0 t = 1 tra = 0 ReDim trabajo_array(0 To 10000) For r = 1 To nro_referencias nro_trabajos1 = CInt(preorden(pre + 4) / preorden(pre + 2)) nro_trabajos2 = nro_trabajos2 + nro_trabajos1 For n = 1 To nro_trabajos1 trabajo_array(tra) = t trabajo_array(tra + 1) = preorden(pre) trabajo_array(tra + 2) = preorden(pre + 3) t = t + 1 tra = tra + 3 Next n pre = pre + 5 Next r For n = 0 To 20 MsgBox trabajo_array(n), vbExclamation Next n 'Dim R As Integer 'Dim aformulario16 As Integer 'Dim altura 'Dim izda 'izda = 120 'altura = 1690 'rslistado.MoveFirst 'aformulario16 = 4000 'Form16.Height = aformulario16 'R = 1 'n = 0 'If Form16.Label2.Count <> 1 Then ' Dim u As Integer ' Dim bye As Integer ' bye = Form16.Label2.Count ' For u = 1 To bye - 1 ' Unload Form16.Label2(u) ' Next u 'End If 'Do While rslistado.EOF = False 'Load Form16.Label2(R) 'Form16.Label2(R).Caption = rslistado(0) 'Form16.Label2(R).Move izda, altura, 2290 'Form16.Label2(R).Visible = True 'izda = izda + 2280 'R = R + 1 'Load Form16.Label2(R) 'Form16.Label2(R).Caption = rslistado(1) 'Form16.Label2(R).Move izda, altura, 1090 'Form16.Label2(R).Visible = True 'izda = izda + 1085 'R = R + 1 'Load Form16.Label2(R) 'Form16.Label2(R).Caption = rslistado(2) 'Form16.Label2(R).Move izda, altura, 3370 'Form16.Label2(R).Visible = True 'izda = izda + 3360 'R = R + 1 'Load Form16.Label2(R) 'Form16.Label2(R).Caption = rslistado(3) 'Form16.Label2(R).Move izda, altura, 2650 'Form16.Label2(R).Visible = True 'izda = izda + 2615 'R = R + 1 'Load Form16.Label2(R) 'Dim cant As Integer 'otroarray = listado(2) 'ultimo = Label7.Count 'For n = 0 To ultimo - 4 'busqueda = CDbl(otroarray(n)) ' If busqueda = rslistado(1) Then ' cant = rslistado(4) * otroarray(n + 2) ' End If 'n = n + 2 'Next n 'Form16.Label2(R).Caption = cant 'Form16.Label2(R).Move izda, altura, 1345 'Form16.Label2(R).Visible = True 'izda = izda + 1345 'R = R + 1 'Load Form16.Label2(R) 'Form16.Label2(R).Caption = rslistado(5) 'Form16.Label2(R).Move izda, altura, 850 'Form16.Label2(R).Visible = True 'izda = izda + 840 'R = R + 1 ' Load Form16.Label2(R) ' Form16.Label2(R).Caption = rslistado(6) ' Form16.Label2(R).Move izda, altura, 850 ' Form16.Label2(R).Visible = True ' izda = izda + 840 ' R = R + 1 'Load Form16.Label2(R) 'Form16.Label2(R).Caption = rslistado(7) 'Form16.Label2(R).Move izda, altura, 850 'Form16.Label2(R).Visible = True 'izda = izda + 840 'R = R + 1 'Load Form16.Label2(R) 'Form16.Label2(R).Caption = rslistado(8) 'Form16.Label2(R).Move izda, altura, 850 'Form16.Label2(R).Visible = True 'izda = izda + 840 'R = R + 1 ' Load Form16.Label2(R) ' Form16.Label2(R).Caption = rslistado(9) ' Form16.Label2(R).Move izda, altura, 855 ' Form16.Label2(R).Visible = True ' izda = izda + 850 ' R = R + 1 ' izda = 120 ' aformulario16 = aformulario16 + 240 ' Form16.Height = aformulario16 ' altura = altura + 240 ' rslistado.MoveNext 'Loop Dim h As Integer For h = 1 To indice - 1 Unload Label7(h) Next h Form5.Visible = False Form16.Visible = True Command1.Visible = False Text1.Text = "" Text3.Text = "" indice = 1 Unload Form5 conn.Close End If End Sub Private Sub Form_Load() ' centrar el formulario en la parte superior Move (Screen.Width - Width) \ 2, 1000 indice = 1 aformulario = 4000 altura = 0 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 Command1.Visible = False Command5.Visible = False Else Text2.Text = rsproducto(1) '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 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 número correcto (0 para cancelar)", vbExclamation End If If Cancel = False Then Command1.Visible = True Command5.Visible = True End If End Sub e-REdING. Biblioteca de la Escuela Superior de Ingenieros de Sevilla.


GESTIÓN Y OPTIMIZACIÓN DE LA PRODUCCIÓN EN UNA FÃBRICA DE ESTRUCTURAS METÃLICAS DE SILLERÃA

: Narbona Fernández, Jesús
: Ingeniería Organización
Contenido del proyecto: