Thursday, October 30, 2008

Practica 5 Visual





using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Practica5_visual
{
public partial class frmPractica5visual : Form
{
public frmPractica5visual()
{
InitializeComponent();
}
int NumA = 0, NumC = 0, R = 0, C = 0;
int Suma = 0,b=0;
string[] Nombres;
int[,] Calificaciones;
double[] Promedio;

private void cmdCapturar_Click(object sender, EventArgs e)
{





if (R < NumA)
{
if (b == 0)
{
Nombres[R] = txtNombre.Text;
lstNombres.Items.Add(Nombres[R].ToString());
txtNombre.Enabled = false;
b = 1;
}
if (C < NumC)
{
txtCalificaciones.Enabled = true;
Calificaciones[R, C] = System.Int16.Parse(txtCalificaciones.Text);
txtNota.Text=txtNota.Text.ToString()+Calificaciones[R,C].ToString()+"\t";
txtCalificaciones.Clear();
txtCalificaciones.Focus();
C++;

if (C == NumC)
{
txtNota.Text = txtNota.Text + "\r\n";
txtNombre.Enabled = true;
txtNombre.Clear();
txtNombre.Focus();
R++;
b = 0;
C = 0;
}

}

}



if (R == NumA)
{
txtNombre.Enabled = false;
txtCalificaciones.Enabled = false;
for (R = 0; R < NumA; R++)
{

Suma = 0;
for (C = 0; C < NumC; C++)
{
Suma = Suma + Calificaciones[R, C];

}
Promedio[R] = Suma / NumC;
lstPromedio.Items.Add(Promedio[R].ToString());
}

}

}





private void cmdLimpiar_Click(object sender, EventArgs e)
{
txtCalificaciones.Clear();
txtNombre.Clear();
txtNumA.Enabled = true;
txtNumC.Enabled = true;
lstNombres.Items.Clear();
lstPromedio.Items.Clear();
txtNota.Clear();
txtNumA.Clear();
txtNumC.Clear();
txtNumA.Focus();
}

private void cmdCap_Click(object sender, EventArgs e)
{
NumA = System.Int16.Parse(txtNumA.Text);
NumC = System.Int16.Parse(txtNumC.Text);
txtNumA.Enabled = false;
txtNumC.Enabled = false;

Nombres = new string[NumA];
Calificaciones = new int[NumA, NumC];
Promedio = new double[NumA];
}

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

private void frmPractica5_Load(object sender, EventArgs e)
{

}




}
}

No comments: