Sei sulla pagina 1di 2

PRACTICA DE C SHARP

FORMULARIOS

Disear el siguiente formulario:

Declarar como variables globales:


int cantidad = 0;
int maximo = 0;
int minimo = 1000;
int suma = 0;

Control: button1 Evento: Click


//Botn Ejecutar
private void button1_Click(object sender, EventArgs e)
{ // textBox1 es la caja de texto de cantidad de notas
if (textBox1.Text != "")
{

textBox1.Enabled = false;
textBox2.Enabled = false;
//textBox2 es la caja de texto de Nro. Nota
textBox2.Text = "1";

}
else
{
MessageBox.Show("No ha ingresado la nota");
textBox1.Focus();
}
}
Control: button2 Evento: Click
//Botn Adicionar
private void button2_Click(object sender, EventArgs e)
{
cantidad = Convert.ToInt32(textBox1.Text);
if (textBox3.Text != "")
{// textBox3 es la caja de texto de Nota
if (Convert.ToInt32(textBox3.Text) >= 1 && Convert.ToInt32(textBox3.Text) <= 20)
{
listBox1.Items.Add(textBox3.Text);
if (maximo < Convert.ToInt32(textBox3.Text))
{
maximo = Convert.ToInt32(textBox3.Text);
}
if (minimo > Convert.ToInt32(textBox3.Text))
{
minimo = Convert.ToInt32(textBox3.Text);
}
suma = suma + Convert.ToInt32(textBox3.Text);
// textBox4 es la caja de texto de Maxima Nota
textBox4.Text = maximo.ToString();
// textBox5 es la caja de texto de Minima Nota
textBox5.Text = minimo.ToString();
// textBox6 es la caja de texto de Promedio
textBox6.Text = (suma / Convert.ToInt32(textBox1.Text)).ToString();
if (Convert.ToInt32(textBox2.Text) < cantidad)
{
textBox2.Text = (Convert.ToInt32(textBox2.Text) + 1).ToString();
textBox3.Clear();
textBox3.Select();
}
else
{
textBox3.Enabled = false;
button4.Enabled = false;
}
}
else
{
MessageBox.Show("fuera de rango");
textBox3.Clear();
textBox3.Select();
}
}
else
{
MessageBox.Show("falta ingresar la nota");
textBox3.Select();
} }

Potrebbero piacerti anche