Example #1
0
        //procedimiento para empezar
        public void Inicio(vista v, modelo m)
        {
            int menu = 0;

            while (menu != 5)
            {
                this.v.PintaMenu();
                menu = Convert.ToInt32(Console.ReadLine());
                switch (menu)
                {
                case 1:
                    //insertar nuevo cliente
                    this.v.Pinta1();
                    cliente nuevo = NuevoCliente();
                    /*porque no this.m*/ modelo.InsertarCliente(@"('" + nuevo.nombre + "','" + nuevo.apellidos + "','" + nuevo.direccion + "','" + nuevo.dni + "','" + nuevo.fecha_alta + "','" + nuevo.fecha_mod + "')");
                    this.v.PintaMenu();
                    break;

                case 2:
                    //modificar cliente
                    this.v.Pinta2();
                    cliente viejo      = modelo.LeerCliente(Convert.ToInt32(Console.ReadLine()));
                    cliente modificado = EditaCliente(viejo);   //leer viejo
                    modelo.ModificarCliente(modificado);
                    this.v.PintaMenu();
                    break;

                case 3:
                    //listado
                    this.v.Pinta3();
                    var Tabla = new ConsoleTable("ID", "NOMBRE", "APELLIDOS", "DIRECCION", "DNI", "FECHA ALTA", "FECHA MOD");
                    Tabla = modelo.CargarListado();
                    Tabla.Write(Format.Alternative);
                    Console.WriteLine("Pulsa cualquier tecla para continuar...");
                    Console.ReadLine();
                    this.v.PintaMenu();
                    break;

                case 4:
                    this.v.Pinta4();
                    modelo.BorrarCliente(Convert.ToInt32(Console.ReadLine()));
                    this.v.PintaMenu();
                    Console.WriteLine("Pulsa cualquier tecla para continuar...");
                    Console.ReadLine();
                    break;

                case 5:
                    //salir
                    break;

                default:
                    Console.WriteLine("Introduce un valor vĂ¡lido");
                    Console.ReadLine();
                    this.v.PintaMenu();
                    break;
                }
            }
        }
Example #2
0
 //constructor y lanzador
 public controlador(vista v, modelo m)
 {
     this.v = v;
     this.m = m;
     Inicio(v, m);
 }