
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication3
{
public partial class Form1 : Form
{
double peso,total=0;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
textBox2.Enabled = true;
textBox2.Focus();
}
private void button2_Click(object sender, EventArgs e)
{
double limite,excedida;
textBox2.Focus();
limite = double.Parse(textBox1.Text);
peso = double.Parse(textBox2.Text);
textBox2.Clear();
total = total + peso;
textBox3.Text = total.ToString();
if (total > limite)
{
excedida = total - limite;
label5.Visible = true;
label4.Visible = true;
label6.Visible = true;
textBox4.Visible = true;
textBox4.Text = excedida.ToString();
}
if (peso == 0)
{
label7.Visible = true;
textBox2.Enabled = false;
}
}
private void button3_Click(object sender, EventArgs e)
{
total = 0;
peso = 0;
label5.Visible = false;
label6.Visible = false;
textBox4.Visible = false;
label7.Visible = false;
textBox2.Enabled = true;
textBox1.Clear();
textBox3.Clear();
textBox2.Enabled = false;
textBox1.Focus();
}
private void button4_Click(object sender, EventArgs e)
{
Close();
}
}
}
No hay comentarios:
Publicar un comentario