lunes, 27 de abril de 2009

Practica 8 "vendedores" (visual)


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
int numero,I, i = 0,x;
string nombre;
double total;
Vendedor[] compania = new Vendedor[25];
public Form1()
{
InitializeComponent();
Vendedor vx = new Vendedor(numero, nombre, total);
}
private void button1_Click(object sender, EventArgs e)
{
numero = int.Parse(textBox1.Text);
if (compania[numero-1]!=null)
{
MessageBox.Show("ESTE EMPLEADO YA FUE REGISTRADO");
}
if (numero >= 1 && numero <= 3 && compania[numero-1]==null)
{
nombre = (textBox2.Text);

total = double.Parse(textBox3.Text);
Vendedor vx = new Vendedor(numero, nombre, total);
compania[numero - 1] = vx;
i++;
}
if (numero <> 4)
{
MessageBox.Show("NO EXISTE NUMERO DE VENDEDOR");
}
if (i==3)
{
MessageBox.Show("LISTA LLENA");
listBox1.Items.Clear();
listBox2.Items.Clear();
listBox3.Items.Clear();
for (I = 0; I < 25; I++)
{
if (compania[I] != null)
{
listBox1.Items.Add(compania[I].no_vend);
listBox2.Items.Add(compania[I].nombre);
listBox3.Items.Add(compania[I].totalventa);
}
}
textBox1.Enabled = false;
textBox2.Enabled = false;
textBox3.Enabled = false;
}
textBox1.Clear();
textBox2.Clear();
textBox3.Clear();
textBox1.Focus();
}
private void button2_Click(object sender, EventArgs e)
{
listBox1.Items.Clear();
listBox2.Items.Clear();
listBox3.Items.Clear();
for (I = 0; I < 25; I++)
{
if (compania[I] != null)
{
listBox1.Items.Add(compania[I].no_vend);
listBox2.Items.Add(compania[I].nombre);
listBox3.Items.Add(compania[I].totalventa);
}
}
}
}
}

Practica 8 "Vendedores" (consola)


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int sigue=1,numero,i=0;
string nombre;
double total;
Vendedor[] compania = new Vendedor[25];
do
{
x:
Console.Write("Numero de vendedor:");
numero = int.Parse(Console.ReadLine());
if (numero <> 3)
{
Console.WriteLine("NO EXISTE NUMERO DE VENDEDOR");
Console.Write("Presione 1 para continuar / presione 0 para terminar");
sigue = int.Parse(Console.ReadLine());
}
if (numero >= 1 && numero <= 3)
{
if (compania[numero - 1] != null)
{
Console.WriteLine("Este empleado ya a llenado sus datos");
goto x;
}
Console.Write("Nombre de vendedor:");
nombre = Console.ReadLine();
Console.Write("monto de venta:");
total = double.Parse(Console.ReadLine());
Vendedor vx = new Vendedor(numero, nombre, total);
compania[numero - 1] = vx;
Console.Write("Presione 1 para continuar / presione 0 para terminar:");
sigue = int.Parse(Console.ReadLine());
i++;
}
}
while (sigue == 1&&i<3);
Console.WriteLine(" No de vendedor: Nombre de vendedor: Total de venta:");
int I;
for (I=0;I<25;I++)
{
if (compania[I]!=null)
{
Console.WriteLine (" \t {0} \t\t {1} \t\t\t\t {2}", compania[I].no_vend,compania[I].nombre,compania[I].totalventa);
}
}
Console.ReadLine();
}
}
}