Exemple #1
0
        public bool UpdateOrDelete(albumes nuevo, bool update)
        {
            LinqManager db    = new LinqManager();
            var         query = from album in db.albumes where album.cod_album == nuevo.cod_album select album;

            foreach (albumes album in query)
            {
                if (update)
                {
                    album.nombre      = nuevo.nombre;
                    album.año         = nuevo.año;
                    album.descripcion = nuevo.descripcion;
                }
                else
                {
                    album.estado = 'I';
                }
            }
            try
            {
                db.SubmitChanges();
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Exemple #2
0
        public bool Insert(albumes nuevo)
        {
            LinqManager db = new LinqManager();

            db.albumes.InsertOnSubmit(nuevo);
            try
            {
                db.SubmitChanges();
                return(true);
            }
            catch
            {
                return(false);
            }
        }
        protected void btnProcesar_Click(object sender, EventArgs e)
        {
            bool band = false;

            if (Session["mode"] == "N")
            {
                albumes nuevo = new albumes();
                nuevo.nombre      = txtNombre.Text;
                nuevo.año         = Convert.ToInt32(txtAño.Text);
                nuevo.descripcion = txtDescripcion.Text;
                nuevo.estado      = 'A';
                band = nuevo.Insert(nuevo);
            }
            else
            {
                albumes updateObject = new albumes();
                updateObject.cod_album   = Convert.ToInt32(txtCodigo.Text);
                updateObject.nombre      = txtNombre.Text;
                updateObject.año         = Convert.ToInt32(txtAño.Text);
                updateObject.descripcion = txtDescripcion.Text;
                if (Session["mode"] == "M")
                {
                    band = updateObject.UpdateOrDelete(updateObject, true);
                }
                else
                {
                    band = updateObject.UpdateOrDelete(updateObject, false);
                }
            }
            if (band)
            {
                Response.Redirect(Request.RawUrl);
            }
            else
            {
                lblMensaje.Text = "Error en la operacion.";
            }
        }