Example #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["Usuario"] == null)
            {
                Response.Write("<script>window.alert('Debes estar registrado para poder acceder');</script>");
                Response.Redirect("../Pages/Home.aspx");
            }
            else
            {
                ClienteEN cli = new ClienteEN();
                cli = cli.sacarCliente(Session["Usuario"].ToString());
                CestaEN cesta = new CestaEN();
                cesta.SacarCesta(cli.nifCliente);
                DataTable tabla = new DataTable();
                tabla.Columns.Add("Matricula");
                tabla.Columns.Add("Imagen");
                tabla.Columns.Add("Marca");
                tabla.Columns.Add("Modelo");
                tabla.Columns.Add("Precio");
                precio.Text = "Precio total: " + cesta.Precio + " €";
                for (int i = 0; i < cesta.Coches.Count; i++)
                {
                    DataRow row = tabla.NewRow();
                    row["Matricula"] = cesta.Coches[i].Matricula;
                    row["Imagen"]    = cesta.Coches[i].Imagen;
                    row["Marca"]     = cesta.Coches[i].Marca;
                    row["Modelo"]    = cesta.Coches[i].Modelo;
                    row["Precio"]    = cesta.Coches[i].Precio;
                    tabla.Rows.Add(row);
                }

                ListProducts.DataSource = tabla;
                ListProducts.DataBind();
            }
        }
Example #2
0
        public int Crear(CestaEN cesta)
        {
            try
            {
                SessionInitializeTransaction();

                session.Save(cesta);
                SessionCommit();
            }

            catch (Exception ex) {
                SessionRollBack();
                if (ex is InariPlaysGenNHibernate.Exceptions.ModelException)
                {
                    throw ex;
                }
                throw new InariPlaysGenNHibernate.Exceptions.DataLayerException("Error in CestaCAD.", ex);
            }


            finally
            {
                SessionClose();
            }

            return(cesta.Iden);
        }
Example #3
0
        public void Borrar(int Iden)
        {
            try
            {
                SessionInitializeTransaction();
                CestaEN cestaEN = (CestaEN)session.Load(typeof(CestaEN), Iden);
                session.Delete(cestaEN);
                SessionCommit();
            }

            catch (Exception ex) {
                SessionRollBack();
                if (ex is InariPlaysGenNHibernate.Exceptions.ModelException)
                {
                    throw ex;
                }
                throw new InariPlaysGenNHibernate.Exceptions.DataLayerException("Error in CestaCAD.", ex);
            }


            finally
            {
                SessionClose();
            }
        }
Example #4
0
// Modify default (Update all attributes of the class)

        public void ModifyDefault(CestaEN cesta)
        {
            try
            {
                SessionInitializeTransaction();
                CestaEN cestaEN = (CestaEN)session.Load(typeof(CestaEN), cesta.Id);


                session.Update(cestaEN);
                SessionCommit();
            }

            catch (Exception ex) {
                SessionRollBack();
                if (ex is OSIRISGenNHibernate.Exceptions.ModelException)
                {
                    throw ex;
                }
                throw new OSIRISGenNHibernate.Exceptions.DataLayerException("Error in CestaCAD.", ex);
            }


            finally
            {
                SessionClose();
            }
        }
Example #5
0
        //Saca una cesta de la BD y la devuelve
        public CestaEN SacarCesta(string id)
        {
            CestaEN       cesta   = new CestaEN(id);;
            string        comando = "select * from Cesta where idCliente = '" + id + "'";
            SqlConnection con     = new SqlConnection(conexion);

            try
            {
                con.Open();
                SqlCommand    c  = new SqlCommand(comando, con);
                SqlDataReader dr = c.ExecuteReader();
                if (dr.Read())
                {
                    cesta.Precio = double.Parse(dr[1].ToString());
                    cesta.Coches = SacarCoches(id);
                }
                dr.Close();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            con.Close();
            return(cesta);
        }
Example #6
0
        public void Destroy(int id
                            )
        {
            try
            {
                SessionInitializeTransaction();
                CestaEN cestaEN = (CestaEN)session.Load(typeof(CestaEN), id);
                session.Delete(cestaEN);
                SessionCommit();
            }

            catch (Exception ex) {
                SessionRollBack();
                if (ex is CervezUAGenNHibernate.Exceptions.ModelException)
                {
                    throw ex;
                }
                throw new CervezUAGenNHibernate.Exceptions.DataLayerException("Error in CestaCAD.", ex);
            }


            finally
            {
                SessionClose();
            }
        }
Example #7
0
        public int New_(CestaEN cesta)
        {
            try
            {
                SessionInitializeTransaction();
                if (cesta.Usuario != null)
                {
                    // Argumento OID y no colección.
                    cesta.Usuario = (CervezUAGenNHibernate.EN.CervezUA.UsuarioEN)session.Load(typeof(CervezUAGenNHibernate.EN.CervezUA.UsuarioEN), cesta.Usuario.NUsuario);

                    cesta.Usuario.Cesta
                        = cesta;
                }

                session.Save(cesta);
                SessionCommit();
            }

            catch (Exception ex) {
                SessionRollBack();
                if (ex is CervezUAGenNHibernate.Exceptions.ModelException)
                {
                    throw ex;
                }
                throw new CervezUAGenNHibernate.Exceptions.DataLayerException("Error in CestaCAD.", ex);
            }


            finally
            {
                SessionClose();
            }

            return(cesta.Id);
        }
Example #8
0
        public CestaEN ReadOIDDefault(int Iden)
        {
            CestaEN cestaEN = null;

            try
            {
                SessionInitializeTransaction();
                cestaEN = (CestaEN)session.Get(typeof(CestaEN), Iden);
                SessionCommit();
            }

            catch (Exception ex) {
                SessionRollBack();
                if (ex is InariPlaysGenNHibernate.Exceptions.ModelException)
                {
                    throw ex;
                }
                throw new InariPlaysGenNHibernate.Exceptions.DataLayerException("Error in CestaCAD.", ex);
            }


            finally
            {
                SessionClose();
            }

            return(cestaEN);
        }
Example #9
0
        public CestaEN ReadOID(int id
                               )
        {
            CestaEN cestaEN = null;

            cestaEN = _ICestaCAD.ReadOID(id);
            return(cestaEN);
        }
Example #10
0
        //Actualiza la cesta en la BD
        public bool Actualizar(CestaEN cesta)
        {
            bool update = false;

            if (Borrar(cesta))
            {
                update = Insertar(cesta);
            }
            return(update);
        }
Example #11
0
        public void Modify(int p_Cesta_OID)
        {
            CestaEN cestaEN = null;

            //Initialized CestaEN
            cestaEN    = new CestaEN();
            cestaEN.Id = p_Cesta_OID;
            //Call to CestaCAD

            _ICestaCAD.Modify(cestaEN);
        }
Example #12
0
        public int New_()
        {
            CestaEN cestaEN = null;
            int     oid;

            //Initialized CestaEN
            cestaEN = new CestaEN();
            //Call to CestaCAD

            oid = _ICestaCAD.New_(cestaEN);
            return(oid);
        }
Example #13
0
        protected void Delete_Click(object sender, EventArgs e)
        {
            ClienteEN cli = new ClienteEN();

            cli = cli.sacarCliente(Session["Usuario"].ToString());
            CocheEN coche = new CocheEN();

            coche.SacarCoche(((ImageButton)sender).CommandArgument);
            CestaEN cesta = new CestaEN();

            cesta.SacarCesta(cli.nifCliente);
            cesta.DeleteCoche(coche);
            cesta.Actualizar();
        }
Example #14
0
        public int Crear(int p_Iden, Nullable <DateTime> p_fecha)
        {
            CestaEN cestaEN = null;
            int     oid;

            //Initialized CestaEN
            cestaEN      = new CestaEN();
            cestaEN.Iden = p_Iden;

            cestaEN.Fecha = p_fecha;

            //Call to CestaCAD

            oid = _ICestaCAD.Crear(cestaEN);
            return(oid);
        }
Example #15
0
        public int Crear(int p_Iden, Nullable <DateTime> p_fecha, System.Collections.Generic.IList <string> p_productos)
        {
            CestaEN cestaEN = null;
            int     oid;

            //Initialized CestaEN
            cestaEN      = new CestaEN();
            cestaEN.Iden = p_Iden;

            cestaEN.Fecha = p_fecha;

            cestaEN.Productos = p_productos;

            //Call to CestaCAD

            oid = _ICestaCAD.Crear(cestaEN);
            return(oid);
        }
Example #16
0
        //Borra la cesta
        public bool Borrar(CestaEN cesta)
        {
            bool          delete  = false;
            string        comando = "delete from Cesta where idCliente = '" + cesta.IdCliente + "'; delete from CochesCesta where Id = '" + cesta.IdCliente + "'";
            SqlConnection con     = new SqlConnection(conexion);

            try
            {
                con.Open();
                SqlCommand cmd = new SqlCommand(comando, con);
                cmd.ExecuteNonQuery();

                delete = true;
            }
            catch (Exception e)
            {
            }
            con.Close();
            return(delete);
        }
Example #17
0
        public int New_(string p_usuario)
        {
            CestaEN cestaEN = null;
            int     oid;

            //Initialized CestaEN
            cestaEN = new CestaEN();

            if (p_usuario != null)
            {
                // El argumento p_usuario -> Property usuario es oid = false
                // Lista de oids id
                cestaEN.Usuario          = new CervezUAGenNHibernate.EN.CervezUA.UsuarioEN();
                cestaEN.Usuario.NUsuario = p_usuario;
            }

            //Call to CestaCAD

            oid = _ICestaCAD.New_(cestaEN);
            return(oid);
        }
Example #18
0
        //Inserta una Cesta por si no está en la BD
        public bool Insertar(CestaEN cesta)
        {
            bool          insert  = false;
            string        comando = "Insert into Cesta values ('" + cesta.IdCliente + "', '" + cesta.Precio + "')";
            SqlConnection con     = new SqlConnection(conexion);

            try
            {
                con.Open();
                SqlCommand cmd = new SqlCommand(comando, con);
                cmd.ExecuteNonQuery();

                for (int i = 0; i < cesta.Coches.Count; i++)
                {
                    InsertarCoche(cesta.IdCliente, cesta.Coches[i].Matricula);
                }
                insert = true;
            }
            catch (Exception e)
            {
            }
            con.Close();
            return(insert);
        }
Example #19
0
 public LineaPedidoCAD(CestaEN cesta, PedidoEN pedido)
 {
     this.cesta  = cesta;
     this.pedido = pedido;
 }
Example #20
0
 public PedidoCAD(ClienteEN cliente, CestaEN cesta)
 {
     this.cliente = cliente;
     this.cesta   = cesta;
 }
Example #21
0
 public CestaCAD(CestaEN cesta)
 {
     this.cesta = cesta;
 }