using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication1
{
public partial class FrmEjercicio7 : Form
{
int[,] Matriz;
string[] Nombres;
int R, C;
int M, N;
public FrmEjercicio7()
{
InitializeComponent();
R = C = 0;
M = N = 0;
}
private void button1_Click(object sender, EventArgs e)
{
M = int.Parse(textBox1.Text);
N = int.Parse(textBox2.Text);
Nombres = new string[M];
Matriz = new int[M, N + 1];
textBox1.Enabled = false;
textBox2.Enabled = false;
button1.Enabled = false;
textBox3.Text = (R + 1).ToString();
textBox4.Text = (C + 1).ToString();
textBox5.Focus();
}
private void button2_Click(object sender, EventArgs e)
{
if (R < M && C < N)
{
Matriz[R, C] = int.Parse(textBox5.Text);
Nombres[R] = textBox6.Text;
C++;
textBox6.Enabled = false;
if (C == N)
{
C = 0;
R++;
textBox6.Enabled = true;
textBox6.Clear();
}
if (R != M)
{
textBox3.Text = (R + 1).ToString();
textBox4.Text = (C + 1).ToString();
textBox5.Clear();
textBox5.Focus();
}
else
{
textBox3.Enabled = false;
textBox4.Enabled = false;
textBox5.Enabled = false;
textBox6.Enabled = false;
MessageBox.Show("Todos los datos fueron introducidos");
}
}
}
private void button3_Click(object sender, EventArgs e)
{
int Suma = 0;
listBox1.Items.Add("No. Estacion Responsable Produccion");
for (R = 0; R < M; R++)
{
Suma = 0;
for (C = 0; C < N; C++)
{
Suma += Matriz[R, C];
}
Matriz[R, C] = Suma;
}
for (R = 0; R < M; R++)
{
listBox1.Items.Add((R + 1).ToString() + " " + Nombres[R] + " " + Matriz[R, N].ToString());
}
}
}
}
No hay comentarios:
Publicar un comentario