
using System;
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 frmPractica7 : Form
{
int[,] Matriz;
string[] Nombres;
int R, C;
int M, N;
public frmPractica7()
{
InitializeComponent();
R = C = 0;
M = N = 0;
}
private void button1_Click(object sender, EventArgs e)
{
M = int.Parse(txtestaciones.Text);
N = int.Parse(txtnmeses.Text);
Nombres = new string[M];
Matriz = new int[M, N + 1];
txtestaciones.Enabled = false;
txtnmeses.Enabled = false;
cmdaceptar.Enabled = false;
txtnestacion.Text = (R + 1).ToString();
txtnumeromeses.Text = (C + 1).ToString();
txtproduccion.Focus();
}
private void button2_Click(object sender, EventArgs e)
{
if (R < M && C < N)
{
Matriz[R, C] = int.Parse(txtproduccion.Text);
Nombres[R] = txtresponsable.Text;
C++;
txtresponsable.Enabled = false;
if (C == N)
{
C = 0;
R++;
txtresponsable.Enabled = true;
txtresponsable.Clear();
}
if (R != M)
{
txtnestacion.Text = (R + 1).ToString();
txtnumeromeses.Text = (C + 1).ToString();
txtproduccion.Clear();
txtproduccion.Focus();
}
else
{
txtnestacion.Enabled = false;
txtnumeromeses.Enabled = false;
txtproduccion.Enabled = false;
txtresponsable.Enabled = false;
MessageBox.Show("Todos los datos fueron introducidos");
}
}
}
private void button3_Click(object sender, EventArgs e)
{
int Suma = 0;
lstagregar.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++)
{
lstagregar.Items.Add((R + 1).ToString() + " " + Nombres[R] + " " + Matriz[R, N].ToString());
}
}
private void frmPractica7_Load(object sender, EventArgs e)
{
}
private void cmdSalir_Click(object sender, EventArgs e)
{
Close();
}
}
}
No comments:
Post a Comment