Esempio n. 1
0
        public eProcesador Guardar(DSDataContext dcOri)
        {
            try
            {
                DSDataContext dc   = dcOri;
                eProcesador   fila = new eProcesador();
                fila.modelo = this.modelo;

                if (this.id == 0)
                {
                    dc.eProcesadors.InsertOnSubmit(fila);
                }
                else
                {
                    var res = from x in dc.eProcesadors where x.id == this.id select x;
                    if (res.Count() > 0)
                    {
                        fila        = res.First();
                        fila.modelo = this.modelo;
                    }
                    else
                    {
                        throw new Exception("Id no encontrado en Procesadores");
                    }
                }
                return(fila);
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 2
0
 public computadora()
 {
     this.estaEncendida = false;
     this.marca         = (eMarca)0;
     this.peso          = 0;
     this.procesador    = (eProcesador)0;
 }
Esempio n. 3
0
        public void Guardar()
        {
            DSDataContext dc   = new DSDataContext(Conexion.DarStrConexion());
            eProcesador   fila = new eProcesador();

            if (this.id != 0) //detectamos que es uno nuevo
            {
                var res = from x in dc.eProcesadors where x.id == this.id select x;
                if (res.Count() > 0)
                {
                    fila = res.First();
                }
                else //no lo encontramos.. mostramos error
                {
                    throw new Exception("Id no encontrado en Procesadores");
                }
            }


            fila.modelo     = modelo;
            fila.frecuencia = frecuencia;
            fila.nroNucleos = nroNucleos;
            fkMarca         = this.Marca.Id;

            if (this.Marca.Id == 0)
            {
                fila.eMarca = this.Marca.Guardar(dc);
            }
            else
            {
                fila.idMarca = fkMarca;
            }

            fkGraficos = this.Graficos.Id;

            if (this.Graficos.Id == 0)
            {
                fila.eGraficos = this.Graficos.Guardar(dc);
            }
            else
            {
                fila.idGraficos = fkGraficos;
            }

            if (this.id == 0)
            {
                dc.eProcesadors.InsertOnSubmit(fila);
            }

            dc.SubmitChanges();
            this.id = fila.id;
        }