Está en la página 1de 17

Programa de la cosecha de maíz

modificado
Imports System.IO

Public Class Form1

'PROGRAMA DE MAIZ

'PROGRAMADORA: BELTRAN MIRAFUENTES GABRIELA

Dim archivo As System.IO.StreamWriter

Dim linea, rfc As String

Dim neto2, sub_total2, isr2, kilo_des2, kilos_p2, s_kilo_p2, t_neto2, t_kilo_des2, sub_tp2,
suma_imp_imp2 As Double

Private Sub guardar_Click(sender As Object, e As EventArgs) Handles guardar.Click

linea = UCase(producto.Text) & "," & Format(neto2, "00000000.00") & "," & Format(kilos_p2,
"00000000.00") & "," & Format(isr2, "00000000.00")

list.Items.Add(linea)

archivo.WriteLine(linea)

archivo.Flush()

End Sub

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

fe.Text = Date.Now

archivo = My.Computer.FileSystem.OpenTextFileWriter("C:\padron\MAIZ.txt", True)

End Sub

Private Sub salir_Click(sender As Object, e As EventArgs) Handles salir.Click

Close()

Beep()

End

End Sub
Private Sub calculo_Click(sender As Object, e As EventArgs) Handles calculo.Click

If Val(hume.Text) <= 14 Then

kilo_des.Text = 0

t_kilo_des2 = Val(t_kilo_des2) + Val(kilo_des.Text)

t_kilo_des.Text = Format(t_kilo_des2, "kg ##,##0.00 ")

kilos_p2 = Val(kilos.Text)

kilos_p.Text = Format(kilos_p2, "kg ##,##0.00 ")

s_kilo_p2 = Val(s_kilo_p2) + Val(kilos_p2)

s_kilo_p.Text = Format(s_kilo_p2, "kg ##,##0.00 ")

sub_total2 = Math.Round((Val(kilos_p2) * Val(p_tone.Text)) / 1000, 2)

sub_total.Text = Format(sub_total2, "$ ##,##0.00 ")

sub_tp2 = Val(sub_tp2) + Val(sub_total2)

sub_tp.Text = Format(sub_tp2, "$ ##,##0.00 ")

isr2 = Math.Round(0.012 * Val(sub_total2), 2)

isr.Text = Format(isr2, "$ ##,##0.00 ")

suma_imp_imp2 = Val(suma_imp_imp2) + Val(isr2)

suma_imp_imp.Text = Format(suma_imp_imp2, "$ ##,##0.00 ")

neto2 = Math.Round(Val(sub_total2) - Val(isr2), 2)

neto.Text = Format(neto2, "$ ##,##0.00 ")

t_neto2 = Val(t_neto2) + Val(neto2)

t_neto.Text = Format(t_neto2, "$ ##,##0.00 ")

ElseIf Val(hume.Text) > 14.01 And Val(hume.Text) <= 16 Then

kilo_des2 = Math.Round(Val(kilos.Text) * 0.03, 2)

kilo_des.Text = Format(kilo_des2, "kg ##,##0.00 ")

t_kilo_des2 = Val(t_kilo_des2) + Val(kilo_des2)

t_kilo_des.Text = Format(t_kilo_des2, "kg ##,##0.00 ")


kilos_p2 = Val(kilos.Text) - Val(kilo_des2)

kilos_p.Text = Format(kilos_p2, "kg ##,##0.00 ")

s_kilo_p2 = Val(s_kilo_p2) + Val(kilos_p2)

s_kilo_p.Text = Format(s_kilo_p2, "kg ##,##0.00 ")

sub_total2 = Math.Round((Val(kilos_p2) * Val(p_tone.Text)) / 1000, 2)

sub_total.Text = Format(sub_total2, "$ ##,##0.00 ")

sub_tp2 = Val(sub_tp2) + Val(sub_total2)

sub_tp.Text = Format(sub_tp2, "$ ##,##0.00 ")

isr2 = Math.Round(0.012 * Val(sub_total2), 2)

isr.Text = Format(isr2, "$ ##,##0.00 ")

suma_imp_imp2 = Val(suma_imp_imp2) + Val(isr2)

suma_imp_imp.Text = Format(suma_imp_imp2, "$ ##,##0.00 ")

neto2 = Math.Round(Val(sub_total2) - Val(isr2), 2)

neto.Text = Format(neto2, "$ ##,##0.00 ")

t_neto2 = Val(t_neto2) + Val(neto2)

t_neto.Text = Format(t_neto2, "$ ##,##0.00 ")

End If

If Val(hume.Text) > 16.01 And Val(hume.Text) <= 18 Then

kilo_des2 = Math.Round(Val(kilos.Text) * 0.05, 2)

kilo_des.Text = Format(kilo_des2, "kg ##,##0.00 ")

t_kilo_des2 = Val(t_kilo_des2) + Val(kilo_des2)

t_kilo_des.Text = Format(t_kilo_des2, "kg ##,##0.00 ")

kilos_p2 = Val(kilos.Text) - Val(kilo_des2)

kilos_p.Text = Format(kilos_p2, "kg ##,##0.00 ")

s_kilo_p2 = Val(s_kilo_p2) + Val(kilos_p2)

s_kilo_p.Text = Format(s_kilo_p2, "kg ##,##0.00 ")

sub_total2 = Math.Round((Val(kilos_p2) * Val(p_tone.Text)) / 1000, 2)

sub_total.Text = Format(sub_total2, "$ ##,##0.00 ")

sub_tp2 = Val(sub_tp2) + Val(sub_total2)


sub_tp.Text = Format(sub_tp2, "$ ##,##0.00 ")

isr2 = Math.Round(0.012 * Val(sub_total2), 2)

isr.Text = Format(isr2, "$ ##,##0.00 ")

suma_imp_imp2 = Val(suma_imp_imp2) + Val(isr2)

suma_imp_imp.Text = Format(suma_imp_imp2, "$ ##,##0.00 ")

neto2 = Math.Round(Val(sub_total2) - Val(isr2), 2)

neto.Text = Format(neto2, "$ ##,##0.00 ")

t_neto2 = Val(t_neto2) + Val(neto2)

t_neto.Text = Format(t_neto2, "$ ##,##0.00 ")

ElseIf Val(hume.Text) > 18.01 Then

kilo_des2 = Math.Round(Val(kilos.Text) * 0.07, 2)

kilo_des.Text = Format(kilo_des2, "kg ##,##0.00 ")

t_kilo_des2 = Val(t_kilo_des2) + Val(kilo_des2)

t_kilo_des.Text = Format(t_kilo_des2, "kg ##,##0.00 ")

kilos_p2 = Val(kilos.Text) - Val(kilo_des2)

kilos_p.Text = Format(kilos_p2, "kg ##,##0.00 ")

s_kilo_p2 = Val(s_kilo_p2) + Val(kilos_p2)

s_kilo_p.Text = Format(s_kilo_p2, "kg ##,##0.00 ")

sub_total2 = Math.Round((Val(kilos_p2) * Val(p_tone.Text)) / 1000, 2)

sub_total.Text = Format(sub_total2, "$ ##,##0.00 ")

sub_tp2 = Val(sub_tp2) + Val(sub_total2)

sub_tp.Text = Format(sub_tp2, "$ ##,##0.00 ")

isr2 = Math.Round(0.012 * Val(sub_total2), 2)

isr.Text = Format(isr2, "$ ##,##0.00 ")

suma_imp_imp2 = Val(suma_imp_imp2) + Val(isr2)

suma_imp_imp.Text = Format(suma_imp_imp2, "$ ##,##0.00 ")

neto2 = Math.Round(Val(sub_total2) - Val(isr2), 2)

neto.Text = Format(neto2, "$ ##,##0.00 ")

t_neto2 = Val(t_neto2) + Val(neto2)


t_neto.Text = Format(t_neto2, "$ ##,##0.00 ")

End If

End Sub

Private Sub limpiar_Click(sender As Object, e As EventArgs) Handles limpiar.Click

borrar()

End Sub

Private Sub borrar()

clave.Text = ""

clave.Focus()

producto.Text = ""

kilos.Text = ""

hume.Text = ""

kilo_des.Text = ""

kilos_p.Text = ""

sub_total.Text = ""

isr.Text = ""

neto.Text = ""

End Sub

End Class
Programa para leer el archivo txt
Imports System.IO

Public Class Form1

Dim linea As String

Dim datos() As String

Dim rfc4, nombre_productor As String

Dim kilos_pagados, importe_neto, isr, rfc3 As Double

Dim mes As Integer

Dim cadena, dia, mes2, año As String

Private Sub Button1_Click_1(sender As Object, e As EventArgs) Handles Button1.Click

Dim objReader As New StreamReader("C:\padron\MAIZ.txt")

If Len(rfc.Text) = 12 Or Len(rfc.Text) = 13 Then


rfc4 = UCase(rfc.Text)

Do

linea = objReader.ReadLine()

datos = Split(linea, ",")

If datos(0) = rfc4 Then

nombre_productor = datos(1)

importe_neto = importe_neto + datos(2)

kilos_pagados = kilos_pagados + datos(3)

isr = isr + datos(4)

End If

nombre.Text = nombre_productor

money.Text = Format(importe_neto, "$###,##0.00")

pago_letra.Text = UCase(EnLetras(Math.Round(importe_neto, 2)))

Loop Until linea = ""

grid.Rows.Clear()

grid.Rows.Add(nombre_productor, importe_neto, kilos_pagados, isr)

End If

objReader.Close()

End Sub

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles pago.Click

borrar()

End Sub

Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click

Close()

Beep()

End

End Sub
Private Sub generar_Click(sender As Object, e As EventArgs) Handles generar.Click

dia = Val(dia_fecha.Text)

mes = Val(mes_fecha.Text)

If mes = "01" Then

mes2 = "Enero "

ElseIf mes = "02" Then

mes2 = "Febrero "

ElseIf mes = "03" Then

mes2 = "Marzo"

ElseIf mes = "04" Then

mes2 = "Abril "

ElseIf mes = "05" Then

mes2 = "Mayo"

ElseIf mes = "06" Then

mes2 = "Junio"

ElseIf mes = "07" Then

mes2 = "Julio "

ElseIf mes = "08" Then

mes2 = "Agosto "

ElseIf mes = "09" Then

mes2 = "Septiembre "

ElseIf mes = "10" Then

mes2 = "Octubre "

ElseIf mes = "11" Then

mes2 = "Noviembre "

ElseIf mes = "12" Then

mes2 = "Diciembre "

End If

año = Val(año_fecha.Text)

cadena = dia & " de " & mes2 & " del " & año
fecha.Text = cadena

End Sub

Private Sub borrar()

pago.Text = ""

pago_letra.Text = ""

nombre.Text = ""

rfc.Text = ""

fecha.Text = ""

kilos_pagados = 0

importe_neto = 0

isr = 0

End Sub

Public Function EnLetras(numero As String) As String

Dim b, paso As Integer

Dim expresion, entero, deci, flag As String

flag = "N"

For paso = 1 To Len(numero)

If Mid(numero, paso, 1) = "." Then

flag = "S"

Else

If flag = "N" Then

entero = entero + Mid(numero, paso, 1) 'Extae la parte entera del numero

Else

deci = deci + Mid(numero, paso, 1) 'Extrae la parte decimal del numero

End If

End If

Next paso

If Len(deci) = 1 Then

deci = deci & "0"


End If

flag = "N"

If Val(numero) >= -999999999 And Val(numero) <= 999999999 Then 'si el numero esta dentro
de 0 a 999.999.999

For paso = Len(entero) To 1 Step -1

b = Len(entero) - (paso - 1)

Select Case paso

Case 3, 6, 9

Select Case Mid(entero, b, 1)

Case "1"

If Mid(entero, b + 1, 1) = "0" And Mid(entero, b + 2, 1) = "0" Then

expresion = expresion & "cien "

Else

expresion = expresion & "ciento "

End If

Case "2"

expresion = expresion & "doscientos "

Case "3"

expresion = expresion & "trescientos "

Case "4"

expresion = expresion & "cuatrocientos "

Case "5"

expresion = expresion & "quinientos "

Case "6"

expresion = expresion & "seiscientos "

Case "7"

expresion = expresion & "setecientos "

Case "8"

expresion = expresion & "ochocientos "

Case "9"
expresion = expresion & "novecientos "

End Select

Case 2, 5, 8

Select Case Mid(entero, b, 1)

Case "1"

If Mid(entero, b + 1, 1) = "0" Then

flag = "S"

expresion = expresion & "diez "

End If

If Mid(entero, b + 1, 1) = "1" Then

flag = "S"

expresion = expresion & "once "

End If

If Mid(entero, b + 1, 1) = "2" Then

flag = "S"

expresion = expresion & "doce "

End If

If Mid(entero, b + 1, 1) = "3" Then

flag = "S"

expresion = expresion & "trece "

End If

If Mid(entero, b + 1, 1) = "4" Then

flag = "S"

expresion = expresion & "catorce "

End If

If Mid(entero, b + 1, 1) = "5" Then

flag = "S"

expresion = expresion & "quince "

End If

If Mid(entero, b + 1, 1) > "5" Then


flag = "N"

expresion = expresion & "dieci"

End If

Case "2"

If Mid(entero, b + 1, 1) = "0" Then

expresion = expresion & "veinte "

flag = "S"

Else

expresion = expresion & "veinti"

flag = "N"

End If

Case "3"

If Mid(entero, b + 1, 1) = "0" Then

expresion = expresion & "treinta "

flag = "S"

Else

expresion = expresion & "treinta y "

flag = "N"

End If

Case "4"

If Mid(entero, b + 1, 1) = "0" Then

expresion = expresion & "cuarenta "

flag = "S"

Else

expresion = expresion & "cuarenta y "

flag = "N"

End If

Case "5"

If Mid(entero, b + 1, 1) = "0" Then

expresion = expresion & "cincuenta "


flag = "S"

Else

expresion = expresion & "cincuenta y "

flag = "N"

End If

Case "6"

If Mid(entero, b + 1, 1) = "0" Then

expresion = expresion & "sesenta "

flag = "S"

Else

expresion = expresion & "sesenta y "

flag = "N"

End If

Case "7"

If Mid(entero, b + 1, 1) = "0" Then

expresion = expresion & "setenta "

flag = "S"

Else

expresion = expresion & "setenta y "

flag = "N"

End If

Case "8"

If Mid(entero, b + 1, 1) = "0" Then

expresion = expresion & "ochenta "

flag = "S"

Else

expresion = expresion & "ochenta y "

flag = "N"

End If

Case "9"
If Mid(entero, b + 1, 1) = "0" Then

expresion = expresion & "noventa "

flag = "S"

Else

expresion = expresion & "noventa y "

flag = "N"

End If

End Select

Case 1, 4, 7

Select Case Mid(entero, b, 1)

Case "1"

If flag = "N" Then

If paso = 1 Then

expresion = expresion & "uno "

Else

expresion = expresion & "un "

End If

End If

Case "2"

If flag = "N" Then

expresion = expresion & "dos "

End If

Case "3"

If flag = "N" Then

expresion = expresion & "tres "

End If

Case "4"

If flag = "N" Then

expresion = expresion & "cuatro "

End If
Case "5"

If flag = "N" Then

expresion = expresion & "cinco "

End If

Case "6"

If flag = "N" Then

expresion = expresion & "seis "

End If

Case "7"

If flag = "N" Then

expresion = expresion & "siete "

End If

Case "8"

If flag = "N" Then

expresion = expresion & "ocho "

End If

Case "9"

If flag = "N" Then

expresion = expresion & "nueve "

End If

End Select

End Select

If paso = 4 Then

If Mid(entero, 6, 1) <> "0" Or Mid(entero, 5, 1) <> "0" Or Mid(entero, 4, 1) <> "0" Or


(Mid(entero, 6, 1) = "0" And Mid(entero, 5, 1) = "0" And Mid(entero, 4, 1) = "0" And Len(entero) <=
6) Then

expresion = expresion & "mil "

End If

End If

If paso = 7 Then

If Len(entero) = 7 And Mid(entero, 1, 1) = "1" Then


expresion = expresion & "millón "

Else

expresion = expresion & "millones "

End If

End If

Next paso

If deci <> "" Then

If Mid(entero, 1, 1) = "-" Then 'si el numero es negativo

EnLetras = "menos " & expresion & "con " & deci ' & "/100"

Else

EnLetras = expresion & "con " & deci ' & "/100"

End If

Else

If Mid(entero, 1, 1) = "-" Then 'si el numero es negativo

EnLetras = "menos " & expresion

Else

EnLetras = expresion

End If

End If

Else 'si el numero a convertir esta fuera del rango superior e inferior

EnLetras = ""

End If

End Function

End Class

También podría gustarte