miércoles, 24 de marzo de 2010

practica 8 en "Visual"

Practica 8 problema 1
Codigo:
namespace practica_8_problema_1_visual
{
public partial class Form1 : Form
{
double g, litros;
public Form1()
{
InitializeComponent();
listBox1.Items.Add("\tGalones\t\tLitros");
}

private void Form1_Load(object sender, EventArgs e)
{

}

private void button1_Click(object sender, EventArgs e)
{
for (g = 100; g <= 200; g = g + 10)
{
litros = g * 3.875;
listBox1.Items.Add("\t" + g + "\t\t" + litros);
}
}

private void button2_Click(object sender, EventArgs e)
{
listBox1.Items.Clear();
listBox1.Items.Add("\tGalones\t\tLitros");
}

private void button3_Click(object sender, EventArgs e)
{
Close();
}
}
}

Practica 8 problmea 2
Codigo:
namespace parctica_8_problema_2_visual
{
public partial class Form1 : Form
{
int numero;
int contador, mayor, pos;
public Form1()
{
InitializeComponent();
numero = mayor = pos = 0;
contador = 1;
}

private void Form1_Load(object sender, EventArgs e)
{

}

private void button1_Click(object sender, EventArgs e)
{
numero = int.Parse(textBox1.Text);
listBox1.Items.Add(numero);
if (contador < 5)
{
if (numero > mayor)
{
mayor = numero;
pos = contador;
}
}
else
{
if (numero > mayor)
{
mayor = numero;
pos = contador;
}
listBox1.Items.Add("El dato mayor es= " + mayor);
listBox1.Items.Add("Esta en la posicion= " + pos);
}
contador++;
textBox1.Clear();
textBox1.Focus();

}

private void button2_Click(object sender, EventArgs e)
{
listBox1.Items.Clear();
listBox1.Items.Add("Lista de numeros");
mayor = 0;
pos = 0;
contador = 1;


}

private void button3_Click(object sender, EventArgs e)
{
Close();
}

private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{

}
}
}

Practica 8 problema 3
Codigo:
namespace practica_8_problema_3_visual
{
public partial class Form1 : Form
{
hermosillo hermosillo;
guamuchil guamuchil;
tijuana tijuana;
culiacan culiacan;
mexico mexico;
double ttotalpro, ttotaldef, ttotalpor;
public Form1()
{
InitializeComponent();
hermosillo = new hermosillo();
guamuchil = new guamuchil();
tijuana = new tijuana();
culiacan = new culiacan();
mexico = new mexico();
ttotaldef = ttotalpor = ttotalpro = 0;
}

private void button1_Click(object sender, EventArgs e)
{
hermosillo.Show();
}

private void button2_Click(object sender, EventArgs e)
{
guamuchil.Show();
}

private void button3_Click(object sender, EventArgs e)
{
tijuana.Show();
}

private void button4_Click(object sender, EventArgs e)
{
culiacan.Show();
}

private void button5_Click(object sender, EventArgs e)
{
mexico.Show();
}

private void button6_Click(object sender, EventArgs e)
{
ttotalpro = hermosillo.totalpro + guamuchil.totalpro + tijuana.totalpro + culiacan.totalpro + mexico.totalpro;
ttotaldef = hermosillo.totaldef + guamuchil.totaldef + tijuana.totaldef + culiacan.totaldef + mexico.totaldef;
ttotalpor = (((hermosillo.totalpor + guamuchil.totalpor + tijuana.totalpor + culiacan.totalpor + mexico.totalpor) / 100) / 5) * 100;
listBox1.Items.Add(" ");
listBox1.Items.Add(" \"Reporte de Control de Calidad\"");
listBox1.Items.Add(" ");
listBox1.Items.Add(" \tLocalizacion De \t Unidades \t Unidades \t%De Unidades");
listBox1.Items.Add(" \t La Planta \tProducidas \tDefectuosas \t Defectuosas");
listBox1.Items.Add(" \t------------------------------------------------------------------------------------------------------------------------");
listBox1.Items.Add(" \t Hermosillo \t" + hermosillo.totalpro + "\t\t" + hermosillo.totaldef + "\t\t" + hermosillo.totalpor);
listBox1.Items.Add(" \t------------------------------------------------------------------------------------------------------------------------");
listBox1.Items.Add(" \t Guamuchil \t" + guamuchil.totalpro + "\t\t" + guamuchil.totaldef + "\t\t" + guamuchil.totalpor);
listBox1.Items.Add(" \t------------------------------------------------------------------------------------------------------------------------");
listBox1.Items.Add(" \t Tijuana \t" + tijuana.totalpro + "\t\t" + tijuana.totaldef + "\t\t" + tijuana.totalpor);
listBox1.Items.Add(" \t------------------------------------------------------------------------------------------------------------------------");
listBox1.Items.Add(" \t Culiacan \t" + culiacan.totalpro+"\t\t"+culiacan.totaldef+"\t\t"+culiacan.totalpor);
listBox1.Items.Add(" \t------------------------------------------------------------------------------------------------------------------------");
listBox1.Items.Add(" \t México \t"+mexico.totalpro+"\t\t"+mexico.totaldef+"\t\t"+mexico.totalpor);
listBox1.Items.Add(" \t============================================================");
listBox1.Items.Add(" \t Total \t"+ttotalpro+"\t\t"+ttotaldef+"\t\t"+ttotalpor);
}

private void button7_Click(object sender, EventArgs e)
{
listBox1.Items.Clear();

}

private void button8_Click(object sender, EventArgs e)
{
Close();
}
}
}

namespace practica_8_problema_3_visual
{
public partial class hermosillo : Form
{
public double dpro1, dpro2, dpro3, dpro4, dpro5, dpro6, dpro7;
public double ddef1, ddef2, ddef3, ddef4, ddef5, ddef6, ddef7;
public double dpor1, dpor2, dpor3, dpor4, dpor5, dpor6, dpor7;
public double totalpro, totaldef, totalpor;
public hermosillo()
{
InitializeComponent();
dpro1 = dpro2 = dpro3 = dpro4 = dpro5 = dpro6 = dpro7 = ddef1 = 0;
ddef1 = ddef2 = ddef3 = ddef4 = ddef5 = ddef6 = ddef7 = 0;
totalpro = totalpor = totaldef = 0;

}

private void btH1_Click(object sender, EventArgs e)
{
dpro1 = double.Parse(txtdpro1.Text);
dpro2 = double.Parse(txtdpro2.Text);
dpro3 = double.Parse(txtdpro3.Text);
dpro4 = double.Parse(txtdpro4.Text);
dpro5 = double.Parse(txtdpro5.Text);
dpro6 = double.Parse(txtdpro6.Text);
dpro7 = double.Parse(txtdpro7.Text);
ddef1 = double.Parse(txtddef1.Text);
ddef2 = double.Parse(txtddef2.Text);
ddef3 = double.Parse(txtddef3.Text);
ddef4 = double.Parse(txtddef4.Text);
ddef5 = double.Parse(txtddef5.Text);
ddef6 = double.Parse(txtddef6.Text);
ddef7 = double.Parse(txtddef7.Text);
totalpro = dpro1 + dpro2 + dpro3 + dpro4 + dpro5 + dpro6 + dpro7;
totaldef = ddef1 + ddef2 + ddef3 + ddef4 + ddef5 + ddef6 + ddef7;
dpor1 = (ddef1 / dpro1) * 100;
dpor2 = (ddef2 / dpro2) * 100;
dpor3 = (ddef3 / dpro3) * 100;
dpor4 = (ddef4 / dpro4) * 100;
dpor5 = (ddef5 / dpro5) * 100;
dpor6 = (ddef6 / dpro6) * 100;
dpor7 = (ddef7 / dpro7) * 100;
totalpor = (totaldef / totalpro) * 100;
txtpor1.Text = dpor1.ToString();
txtpor2.Text = dpor2.ToString();
txtpor3.Text = dpor3.ToString();
txtpor4.Text = dpor4.ToString();
txtpor5.Text = dpor5.ToString();
txtpor6.Text = dpor6.ToString();
txtpor7.Text = dpor7.ToString();
txttpro.Text = totalpro.ToString();
txttdef.Text = totaldef.ToString();
txtpdef.Text = totalpor.ToString();

}

private void btlimpiar_Click(object sender, EventArgs e)
{
txtdpro1.Clear();
txtdpro2.Clear();
txtdpro3.Clear();
txtdpro4.Clear();
txtdpro5.Clear();
txtdpro6.Clear();
txtdpro7.Clear();
txtddef1.Clear();
txtddef2.Clear();
txtddef3.Clear();
txtddef4.Clear();
txtddef5.Clear();
txtddef6.Clear();
txtddef7.Clear();
txtpor1.Clear();
txtpor2.Clear();
txtpor3.Clear();
txtpor4.Clear();
txtpor5.Clear();
txtpor6.Clear();
txtpor7.Clear();
txttpro.Clear();
txttdef.Clear();
txtpdef.Clear();

}

private void btsalir_Click(object sender, EventArgs e)
{
Close();
}
}
}

Practica 8 problema 4
Codigo:
namespace practica_8_problema_4_visual
{
public partial class Form1 : Form
{
public int lununi, maruni, mieruni, jueuni;
public double lunpro, marpro, mierpro, juepro;
public double lunmat, marmat, miermat, juemat;
public double luncosto, marcosto, miercosto, juecosto;
//total
double totaluni, totalpro, totalmat, totalcosto, costopromedio;
public Form1()
{
InitializeComponent();
lununi = maruni = mieruni = jueuni = 0;
lunpro= marpro= mierpro= juepro=lunmat= marmat= miermat= juemat=0;
luncosto = marcosto = miercosto = juecosto = totaluni = totalpro = totalmat = totalcosto = costopromedio = 0;

}

private void button1_Click(object sender, EventArgs e)
{
lununi =int.Parse(txtlununi.Text);
maruni = int.Parse(txtmaruni.Text);
mieruni = int.Parse(txtmieruni.Text);
jueuni = int.Parse(txtjueuni.Text);
lunpro = double.Parse(txtlunpro.Text);
marpro = double.Parse(txtmarpro.Text);
mierpro = double.Parse(txtmierpro.Text);
juepro = double.Parse(txtjuepro.Text);
lunmat = double.Parse(txtlunmat.Text);
marmat = double.Parse(txtmarmat.Text);
miermat = double.Parse(txtmiermat.Text);
juemat = double.Parse(txtjuemat.Text);
luncosto = (lunpro + lunmat) / lununi;
marcosto = (marpro + marmat) / maruni;
miercosto = (mierpro + miermat) / mieruni;
juecosto = (juepro + juemat) / jueuni;
totaluni = lununi + maruni + mieruni + jueuni;
totalpro = lunpro + marpro + mierpro + juepro;
totalmat = lunmat + marmat + miermat + juemat;
totalcosto = luncosto + marcosto + miercosto + juecosto;
costopromedio = totalcosto / 4;
txtluncosto.Text=luncosto.ToString();
txtmarcosto.Text=marcosto.ToString();
txtmiercosto.Text=miercosto.ToString();
txtjuecosto.Text=juecosto.ToString();
txttotaluni.Text = totaluni.ToString();
txttotalpro.Text = totalpro.ToString();
txttotalmat.Text = totalmat.ToString();
txttotalcosto.Text = totalcosto.ToString();
lbpromedio.Text = ("Costo Unitario Promedio= "+costopromedio);

}

private void button2_Click(object sender, EventArgs e)
{
txtlununi.Clear();
txtlunpro.Clear();
txtlunmat.Clear();
txtluncosto.Clear();
txtmaruni.Clear();
txtmarpro.Clear();
txtmarmat.Clear();
txtmarcosto.Clear();
txtmieruni.Clear();
txtmierpro.Clear();
txtmiermat.Clear();
txtmiercosto.Clear();
txtjueuni.Clear();
txtjuepro.Clear();
txtjuemat.Clear();
txtjuecosto.Clear();
txttotaluni.Clear();
txttotalpro.Clear();
txttotalmat.Clear();
txttotalcosto.Clear();
lbpromedio.Text = " ";

}

private void button3_Click(object sender, EventArgs e)
{
Close();
}
}
}

No hay comentarios:

Publicar un comentario