
Buscar en un case dependiendo del codigo ingresado por el usuario
Publicado por Jessica (1 intervención) el 08/09/2014 00:33:46
ayuda veran tengo un ejercico que el usuario ingresa los datos de un producto en el primer case1: pero no se km hacer que en el segundo busque por el codigo que ingresa el usuario y le muestre lo que ingreso dependiendo del codigo del producto
EL PRIMER CASE LO QUE HACE ES INGRESAR LOS DATOS DE 3 PRODUCTOS
EL QUE ME URGE ES EL SEGUNDO CASE2:
QUE TIENE QUE BUSCA DEPENDIENDO DE QUE CODIGO INGRESA EL USUARIO Y MOSTRAR LOS DATOS DEL PRODUCTO CON ESE CODIGO!
EL PRIMER CASE LO QUE HACE ES INGRESAR LOS DATOS DE 3 PRODUCTOS
EL QUE ME URGE ES EL SEGUNDO CASE2:
QUE TIENE QUE BUSCA DEPENDIENDO DE QUE CODIGO INGRESA EL USUARIO Y MOSTRAR LOS DATOS DEL PRODUCTO CON ESE CODIGO!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
struct Almacen {
public int codigo;
public string nombre;
public string fech_elb;
public double prec_comp;
public double prec_vent;
public int cant;
public string fech_ven;
}
public static void Main(string[] args) {
Console.WriteLine("INGRESO DE PRODUCTOS!");
const int limite=3;
Almacen[] prodct = new Almacen[limite];
int encont;
int op, anio, mes, dia;
double ganc;
do { Console.Clear();
Console.SetCursorPosition(1,3);
Console.WriteLine("-------MENU-------");
Console.WriteLine("1.- Ingrese el producto");
Console.WriteLine("2.- Buscar el producto");
Console.WriteLine("3.- Modificar el Producto");
Console.WriteLine("4.- Mostrar todos los productos");
Console.WriteLine("5.- .......SALIR.......");
Console.SetCursorPosition(1,10);
Console.WriteLine("****ESCOJA UNA OPCION****");
op = Convert.ToInt16(Console.ReadLine());
switch(op){
case 1://Ingresar los productos
for(int i=0;i<3;i++){
prodct[i].codigo=i+1; Console.WriteLine();
Console.WriteLine("Codigo:{0}",prodct[i].codigo);
Console.Write("Nombre:"); prodct[i].nombre=Console.ReadLine();
Console.WriteLine("Nombre del Producto:{0}",prodct[i].nombre);
// Fecha de elaboracion
Console.WriteLine("fech/elab:");
Console.Write("Ing.año:"); anio=Convert.ToInt16(Console.ReadLine());
Console.Write("Ing.mes:"); mes=Convert.ToInt16(Console.ReadLine());
Console.Write("Ing.dia:"); dia=Convert.ToInt16(Console.ReadLine());
string fech_elb;
DateTime fe = new DateTime(anio, mes, dia);
Console.WriteLine(String.Format("({0})",fe));
fech_elb = fe.ToShortDateString();
fe=fe.AddDays(30);
//Precio Compra
Console.Write("VAL_UNI:");prodct[i].prec_comp=Convert.ToDouble(Console.ReadLine());
//Precio Venta + 30%
Console.WriteLine("Calculo/Prec_Venta:"); prodct[i].prec_vent=((prodct[i].prec_comp*30)/100);
ganc=(prodct[i].prec_comp+prodct[i].prec_vent);
Console.WriteLine("P.V.P:{0}",ganc);
//Ingreso de Cantidad Productos
Console.WriteLine("El Numero/Productos:"); prodct[i].cant=Convert.ToInt16(Console.ReadLine());
// Fecha de Vencimiento
Console.WriteLine(String.Format("({0})",fe));}
break;
case 2: // Buscar un Producto
Console.Write("Ingrese el codigo a buscar:");encont=Convert.ToInt16(Console.ReadLine());
for(int i=0;i<3;i++){
if (encont==prodct[i].codigo){
Console.WriteLine("Nombre del Producto:{0}",prodct[i].nombre);}
else{Console.WriteLine("Error");}}
break;
/*/fecha de elaboracion
DateTime fe = new DateTime(anio, mes, dia);
Console.WriteLine(String.Format("({0})",fe));
fech_elb = fe.ToShortDateString();
Valora esta pregunta


0