You are on page 1of 3

PSEUDOCODIGO DEL PROGRAMA

Private Sub CORRIDAS() Try Dim CMDLIMPIA As New SqlCommand("delete from simulacion", CBD) CMDLIMPIA.ExecuteNonQuery() DataGridView2.Rows.Clear() For CLIENTE As Integer = 1 To CInt(Me.TXTCLIENTE.Text) Dim Dim Dim Dim Dim Dim Dim Dim Dim Dim Dim Dim CAJAS As New DataTable EVENTOS As New DataTable SERVICIOS As New DataTable CONT As Decimal = 0 ANTE As Decimal = 0 ANTE2 As Decimal = 0 ANTE3 As Decimal = 0 RAN As Decimal = Rnd() RAN2 As Decimal = Rnd() RAN3 As Decimal = Rnd() CAJAELEJIDA As Integer = 0, LANDACAJA As Decimal = 0, LANDASERVICIO As Decimal = 0 TIEMPOELLEGADA As Decimal = 0, TIEMPOSERVICIO As Decimal = 0, IDEVENTO As Integer

=0 0

Dim PORAUMENTO As Decimal = 0, TIEMPOAUMENTO As Decimal = 0, IDSERVICIO As Integer =

Dim CMD As New SqlCommand("SELECT IDCORRIDA, IDCAJA, (POROCURRENCIA/100)AS POROCURRENCIA, LANDALLEGADA, LANDASERVICIO FROM CORRIDA_CAJAS WHERE IDCORRIDA = (SELECT IDCORRIDA FROM CORRIDA_ENCABEZADO WHERE ESTADO = 'FALSE')", CBD) Dim DR As SqlDataReader = CMD.ExecuteReader CAJAS.Load(DR, LoadOption.OverwriteChanges) For I As Integer = 0 To CAJAS.Rows.Count - 1 If RAN > ANTE And RAN < (ANTE + Convert.ToDecimal(CAJAS.Rows(I).Item("POROCURRENCIA"))) Then CAJAELEJIDA = CAJAS.Rows(I).Item("IDCAJA") : LANDACAJA = CAJAS.Rows(I).Item("LANDALLEGADA") LANDASERVICIO = CAJAS.Rows(I).Item("LANDASERVICIO") Exit For End If ANTE += Convert.ToDecimal(CAJAS.Rows(I).Item("POROCURRENCIA")) Next DR.Close() TIEMPOELLEGADA = POISSON(LANDACAJA) TIEMPOSERVICIO = EXPONENCIAL(LANDASERVICIO) Dim CMD2 As New SqlCommand("SELECT IDCORRIDA, IDEVENTO, (POROCURRENCIA/100)AS POROCURRENCIA, PORAUMENTO FROM CORRIDA_EVENRETRASO WHERE IDCORRIDA = (SELECT IDCORRIDA FROM CORRIDA_ENCABEZADO WHERE ESTADO = 'FALSE')", CBD) Dim DR2 As SqlDataReader = CMD2.ExecuteReader EVENTOS.Load(DR2, LoadOption.OverwriteChanges) For I As Integer = 0 To EVENTOS.Rows.Count - 1 If RAN2 > ANTE2 And RAN2 < (ANTE2 + Convert.ToDecimal(EVENTOS.Rows(I).Item("POROCURRENCIA"))) Then IDEVENTO = EVENTOS.Rows(I).Item("IDEVENTO") : PORAUMENTO = Convert.ToDecimal(EVENTOS.Rows(I).Item("PORAUMENTO")) Exit For End If ANTE2 += Convert.ToDecimal(EVENTOS.Rows(I).Item("POROCURRENCIA")) Next DR2.Close() TIEMPOAUMENTO = (TIEMPOSERVICIO * PORAUMENTO) Dim CMD3 As New SqlCommand("SELECT IDCORRIDA, CODSER,(POROCURRENCIA/100)AS POROCURRENCIA FROM CORRIDA_SERVICIOS WHERE IDCORRIDA = (SELECT IDCORRIDA FROM CORRIDA_ENCABEZADO WHERE ESTADO = 'FALSE')", CBD) Dim DR3 As SqlDataReader = CMD3.ExecuteReader SERVICIOS.Load(DR3, LoadOption.OverwriteChanges) For I As Integer = 0 To SERVICIOS.Rows.Count - 1 If RAN3 > ANTE3 And RAN3 < (ANTE3 + Convert.ToDecimal(SERVICIOS.Rows(I).Item("POROCURRENCIA"))) Then IDSERVICIO = SERVICIOS.Rows(I).Item("CODSER") Exit For End If ANTE3 += Convert.ToDecimal(SERVICIOS.Rows(I).Item("POROCURRENCIA"))

TB.Clear() Dim ENTRE# = 0. ENTRE#.Rows(I).IDEVENTO LEFT JOIN SERVICIOS_BANCARIOS SB ON S. TB.S.S.Clear() EVENTOS. TB.Tables("SIMULACION"). noanten& = 0.Rows.Rows. TB. LoadOption. TB.Load(DR.IsNullOrEmpty(Me.Click Try If String.Rows(I).ENTRE# End If End If Me.Rows.Item("TIEMPOTOTAL")." & TIEMPOAUMENTO & ".Next DR3.Item("DESEVENTO")) = "NO AUTORIZACION" Then noanten& += 1 . ENTRE#.Rows(I).Rows(I). TB.Item("DESCRIPCION").Log(RAN)) POISSON = RET ' [-(1/*LN(RAND)] End Function Private Function EXPONENCIAL(ByVal LAND) As Decimal Dim RAN As Decimal = Rnd() Dim RET As Decimal = 0 RET = ((-1 * LAND) * Math.Log(RAN)) EXPONENCIAL = RET '[-*LN(RAND)] End Function Private Sub cmdsimular_Click(ByVal sender As System. TB. TB.TIEMPOSERVICIO.1 If I > 0 Then ENTRE# = TB. TB.Item("TIEMPOLLEGADA") If ENTRE# < TB.Item("TIEMPOLLEGADA").Item("CLIENTE").CAJA " & _ "FROM SIMULACION S LEFT JOIN dbo.S." & CLIENTE & ".Rows(I).Rows(I .EVENTOS_RETRASO M ON S.Rows(I).Item("CAJA")) ORIGENDATOS.Close() Dim CMDEJECUTA As New SqlCommand("EXEC CREA_SIMULACION " & IDCOR& & ".1).Rows(I . TB. promesp# = 0." & TIEMPOELLEGADA & _ ".Item("TIEMPOSERVICIO").DESCRIPCION.Item("TIEMPOTOTAL").DESEVENTO.TIEMPOLLEGADA.CLIENTE.Rows(I).Rows(I).OverwriteChanges) For I As Integer = 0 To TB.Object.Item("TIEMPOLLEGADA").Item("CLIENTE").TIEMPOSERVICIO + S.Item("CAJA")) If Trim(TB. CBD) CMDEJECUTA.Rows(I). TB.Rows(I).CORRIDAS() ORIGENDATOS.IDMOTIVO = M.Rows(I). promser# = 0.Item("TIEMPOSERVICIO"). TB.Rows(I).S.(S.Rows(I). TB.Tables("SIMULACION").1).1).Rows(I).ExecuteReader Dim TB As New DataTable TB. ESPE#.SB." & TIEMPOSERVICIO & ". promtot# = 0 Dim CMD As New SqlCommand("SELECT S.Rows(I . CBD) Dim DR As SqlDataReader = CMD.Rows(I).Item("TIEMPORETRASO").Rows(I).Add(TB.Item("TIEMPORETRASO").Clear() SERVICIOS.Message) End Try End Sub Private Function POISSON(ByVal LAND) As Decimal Dim RAN As Decimal = Rnd() Dim RET As Decimal = 0 RET = ((-1 / LAND) * Math.TIEMPORETRASO) AS TIEMPOTOTAL. promret# = 0.M." & CAJAELEJIDA.Rows.TIEMPORETRASO.Item("DESCRIPCION").Item("DESEVENTO").Rows(I).Item("TIEMPOTOTAL") Then ESPE# = TB.EventArgs) Handles cmdsimular." & IDEVENTO & ".IDSERVICIO". promlleg# = 0. ByVal e As System.Add(TB.Rows.IDSERVICIO = SB.TXTCLIENTE. ESPE# = 0 Dim anten& = 0. ESPE#.Item("DESEVENTO").Item("TIEMPOTOTAL") .Count .Rows.Clear() Next Catch ex As Exception MsgBox(ex.ExecuteNonQuery() CAJAS.Rows.Text) Then Exit Sub Me. TB." & IDSERVICIO & ".DataGridView2.

Text = Math.Text).ToDecimal(Me.TXTCLIENTE. 4) Me.End If promlleg# += TB.Text = Convert.Rows(I).Round(promtot# / Convert.Text).Text = Math.Text).Round(promesp# / Convert.Text) .TXTCLIENTE.Text = Math. 4) Me. 4) Me.TextBox6.Message) End Try End Sub .ToDecimal(Me.Item("TIEMPOSERVICIO") promret# += TB.Item("TIEMPOLLEGADA") promesp# += ESPE# promser# += TB.TextBox3.Text = noanten& Me.TXTCLIENTE.Tables("SIMULACION"). 4) Me.TXTCLIENTE.TextBox5.TXTCLIENTE.Round(promser# / Convert.Rows(I).Text) Me.Round(promlleg# / Convert.TextBox7.ToDecimal(Me.TextBox1.Rows(I).TextBox8.cmdimprimir.Text = Convert.ToDecimal(Me.ToDecimal(Me.Count > 0 Then Me.ToDecimal(Me.Text = Math.TextBox4.ToDecimal(Me.Text).noanten& Me.TXTCLIENTE.TextBox2.Item("TIEMPOTOTAL") Next Me.Text). 4) If ORIGENDATOS.Enabled = True End If Catch ex As Exception MsgBox(ex.Round(promret# / Convert.Item("TIEMPORETRASO") promtot# += TB.Rows.TXTCLIENTE.Text = Math.Rows(I).