• Jueves 2 de Mayo de 2024, 15:52

Autor Tema:  Mini gestor moviles (práctica sobre clases)  (Leído 1207 veces)

revolta

  • Nuevo Miembro
  • *
  • Mensajes: 1
    • Ver Perfil
Mini gestor moviles (práctica sobre clases)
« en: Martes 30 de Noviembre de 2010, 16:38 »
0
Aqui va el código q me han pedido.

 C&P de la clase:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace dllmovil
{
    [Serializable]
    public  class movil
    {
        private int codigo;
        private string marca;
        private string modelo;
        private int anofabricacion;
        private bool mp3;
        private bool fotos;
        private bool video;
        private bool bluetooth;
        private bool gprs;
        private bool videollamada;
        private string imagen;

        public movil()
        {    }
    public movil(int cod, string marc, string mod, int anofab, bool mp, bool fot, bool vid, bool blue, bool gp, bool vidll,string ima)
        {
            codigo = cod;
            marca = marc;
            modelo = mod;
            anofabricacion = anofab;
            mp3 = mp;
            fotos = fot;
            video = vid;
            bluetooth = blue;
            gprs = gp;
            videollamada = vidll;
            imagen = ima;
        }
    public int Codigo
    {
        set { codigo = value; }
        get { return this.codigo; }
    }
    public string Marca
    {
        set { marca = value; }
        get { return this.marca; }
            }
        public string Modelo
        {
            set { modelo = value; }
            get {return this.modelo;}
        }
        public int Anofabricacion
        {
            set { anofabricacion = value; }
            get { return this.anofabricacion; }
        }
        public bool Mp3
        {
            set { mp3=value ;}
            get { return this.mp3; }
        }
        public bool Fotos
        {
            set { fotos = value; }
            get { return this.fotos; }
        }
        public bool Video
        {
            set { video = value; }
            get { return this.video; }
        }
        public bool Bluetooth
        {
            set { bluetooth  = value; }
            get { return this.bluetooth ; }
        }
        public bool Gprs
        {
            set { gprs = value; }
            get { return this.gprs; }
        }
        public bool Videollamada
        {
            set { videollamada = value; }
            get { return this.videollamada ; }
        }
        public string Imagen
        {
            set { imagen = value; }
            get { return this.imagen; }
        }

C&P del formBase:

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;
using dllmovil;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;


namespace formmovil
{
    public partial class FormBase : Form
    {
        public static List <movil> moviles = new List<movil>();
        public static bool administrador;
        public static string control;
        public static string nombre;
        public static string marca;
        public static string mascara;
       
        public FormBase()
        {
         
            InitializeComponent();
             


        }
        public void cargarlista()
        {
            lista lista1 = new lista();
            lista1.MdiParent = obtenerFormPpal();
            lista1.Show();
            lista1.WindowState = FormWindowState.Maximized;

        }
        public void cargarinfo()
        {
           
            info info1 = new info();
            info1.MdiParent = obtenerFormPpal ();
            info1.Show();
            info1.WindowState = FormWindowState.Maximized;

        }
 public void cargarbusqueda()
        {
            busqueda  busqueda1 = new busqueda ();
            busqueda1.MdiParent = obtenerFormPpal();
            busqueda1.Show();
            busqueda1.WindowState = FormWindowState.Maximized;

        }
        public PrincipalAdministrador  obtenerFormPpal()
        {
            FormCollection actuales = Application.OpenForms;
            PrincipalAdministrador  miform1 = new PrincipalAdministrador ();
            foreach (Form f in actuales)
            {
                if (f is PrincipalAdministrador )
                {
                    miform1 = (PrincipalAdministrador )f;

                }
            }
            return miform1;
        }
         




             
        public void guardarmovil()
        {
            try
            {

                IFormatter formatter = new BinaryFormatter();
                FileStream fs = new FileStream("./basedatos.dat", FileMode.Create);
                formatter.Serialize(fs, moviles);
                fs.Close();
            }
            catch
            {
                MessageBox.Show ("Error al guardar los datos");
            }

        }
        public void cargarmovil()
        {
            try
            {

                IFormatter formatter = new BinaryFormatter();
                FileStream fs = new FileStream("./basedatos.dat", FileMode.OpenOrCreate);

                moviles = (List<dllmovil.movil>)formatter.Deserialize(fs);
            }
            catch
            {
                MessageBox.Show("Error al cargar los datos");
            }

        }
        public string mascaracheckbox(bool b1, bool b2, bool b3, bool b4, bool b5, bool b6)
        {
            string Mascara = "";
            if (b1)
            {
                Mascara += "1";
            }
            else
            {
                Mascara += "0";
            }
            if (b2)
            {
                Mascara += "1";
            }
            else
            {
                Mascara += "0";
            }
            if (b3)
            {
                Mascara += "1";
            }
            else
            {
                Mascara += "0";
            }
            if (b4)
            {
                Mascara += "1";
            }
            else
            {
                Mascara += "0";
            }
            if (b5)
            {
                Mascara += "1";
            }
            else
            {
                Mascara += "0";
            }
            if (b6)
            {
                Mascara += "1";
            }
            else
            {
                Mascara += "0";
            }
            return Mascara;
        }
    }
}
El mensaje contiene 1 archivo adjunto. Debes ingresar o registrarte para poder verlo y descargarlo.

m0skit0

  • Miembro de PLATA
  • *****
  • Mensajes: 2337
  • Nacionalidad: ma
    • Ver Perfil
    • http://fr33kk0mpu73r.blogspot.com/
Re: Mini gestor moviles (práctica sobre clases)
« Respuesta #1 en: Miércoles 1 de Diciembre de 2010, 09:43 »
0
Por favor, usa las etiquetas de código, que así no hay quien ni le dé ganas de leerlo.