public IHttpActionResult PutPlantillaDetalle(int id, PlantillaDetalle plantillaDetalle)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != plantillaDetalle.PlantillaDetalleID)
            {
                return(BadRequest());
            }

            db.Entry(plantillaDetalle).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PlantillaDetalleExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public IHttpActionResult PostPlantillaDetalle(PlantillaDetalle plantillaDetalle)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            //Encuentra la plantilla ya existente
            if (plantillaDetalle.Plantilla == null)
            {
                plantillaDetalle.Plantilla = null;
            }
            else
            {
                plantillaDetalle.Plantilla = db.Plantillas.Find(plantillaDetalle.Plantilla.PlantillaID);
            }
            //Encuentra la pregunta ya existente
            if (plantillaDetalle.Pregunta == null)
            {
                plantillaDetalle.Pregunta = null;
            }
            else
            {
                plantillaDetalle.Pregunta = db.Preguntas.Find(plantillaDetalle.Pregunta.PreguntaID);
            }
            //Salva
            db.PlantillaDetalles.Add(plantillaDetalle);
            db.SaveChanges();

            return(StatusCode(HttpStatusCode.OK));
            //return CreatedAtRoute("DefaultApi", new { id = plantillaDetalle.PlantillaDetalleID }, plantillaDetalle);
        }
Exemple #3
0
        protected void btnDel_Click(object sender, EventArgs e)
        {
            string msg = "Se ha eliminado correctamente";

            int id = Utilerias.StrToInt(_IDPregunta.Value);

            PlantillaDetalle obj = uow.PlantillaDetalleBusinessLogic.GetByID(id);

            //Se elimina el objeto
            uow.PlantillaDetalleBusinessLogic.Delete(obj);
            uow.SaveChanges();

            if (uow.Errors.Count > 0) //Si hubo errores
            {
                msg = string.Empty;
                foreach (string cad in uow.Errors)
                {
                    msg += cad;
                }

                lblMensajes.Text      = msg;
                lblMensajes.ForeColor = System.Drawing.Color.Red;


                return;
            }

            lblMensajes.Text      = msg;
            lblMensajes.ForeColor = System.Drawing.Color.Black;

            BindGrid();
            divCaptura.Style.Add("display", "none");
            divBtnNuevo.Style.Add("display", "block");
            divMsg.Style.Add("display", "block");
        }
        public IHttpActionResult GetPlantillaDetalle(int id)
        {
            PlantillaDetalle plantillaDetalle = db.PlantillaDetalles.Find(id);

            if (plantillaDetalle == null)
            {
                return(NotFound());
            }

            return(Ok(plantillaDetalle));
        }
        public IHttpActionResult DeletePlantillaDetalle(int id)
        {
            PlantillaDetalle plantillaDetalle = db.PlantillaDetalles.Find(id);

            if (plantillaDetalle == null)
            {
                return(NotFound());
            }

            db.PlantillaDetalles.Remove(plantillaDetalle);
            db.SaveChanges();

            return(Ok(plantillaDetalle));
        }
Exemple #6
0
        protected void imgBtnEdit_Click(object sender, ImageClickEventArgs e)
        {
            GridViewRow row = (GridViewRow)((ImageButton)sender).NamingContainer;

            int id = Utilerias.StrToInt(grid.DataKeys[row.RowIndex].Values["Id"].ToString());

            PlantillaDetalle obj = uow.PlantillaDetalleBusinessLogic.GetByID(id);

            BindControles(obj);

            _IDPregunta.Value = grid.DataKeys[row.RowIndex].Values["Id"].ToString();
            _Accion.Value     = "A"; //Se cambia el estado de la forma a ACTUALIZAR un registro existente

            divCaptura.Style.Add("display", "block");
            divGuardar.Style.Add("display", "block");
            divBtnNuevo.Style.Add("display", "none");
            divMsg.Style.Add("display", "none");
        }
        protected void imgBtnEliminar_Click(object sender, ImageClickEventArgs e)
        {
            //Se busca l ID de la fila seleccionada
            GridViewRow row = (GridViewRow)((ImageButton)sender).NamingContainer;
            string      msg = "Se ha eliminado correctamente";

            int id = Utilerias.StrToInt(grid.DataKeys[row.RowIndex].Value.ToString());

            PlantillaDetalle obj = uow.PlantillaDetalleBusinessLogic.GetByID(id);

            //Se elimina el objeto
            uow.PlantillaDetalleBusinessLogic.Delete(obj);
            uow.SaveChanges();

            if (uow.Errors.Count > 0) //Si hubo errores
            {
                msg = string.Empty;
                foreach (string cad in uow.Errors)
                {
                    msg += cad;
                }

                //MANEJAR EL ERROR
                divMsgError.Style.Add("display", "block");
                divMsgSuccess.Style.Add("display", "none");
                lblMsgError.Text = msg;


                return;
            }

            BindGrid();

            lblMsgSuccess.Text = msg;
            divMsgError.Style.Add("display", "none");
            divMsgSuccess.Style.Add("display", "block");
            divCaptura.Style.Add("display", "none");
            divBtnNuevo.Style.Add("display", "block");
        }
Exemple #8
0
 private void BindControles(PlantillaDetalle obj)
 {
     txtClave.Text    = obj.Clave;
     txtPregunta.Text = obj.Pregunta;
 }
Exemple #9
0
        protected void btnGuardar_Click(object sender, EventArgs e)
        {
            PlantillaDetalle obj;
            string           msg = "Se ha guardado correctamente";

            if (_Accion.Value.Equals("N"))
            {
                obj = new PlantillaDetalle();
            }
            else
            {
                obj = uow.PlantillaDetalleBusinessLogic.GetByID(Utilerias.StrToInt(_IDPregunta.Value));
                msg = "Se ha actualizado correctamente";
            }



            obj.Clave    = txtClave.Text;
            obj.Pregunta = txtPregunta.Text;
            //obj.Orden = 1;

            switch (_Accion.Value)
            {
            case "N":
                //Agregar campos de bitacora
                obj.PlantillaId = Utilerias.StrToInt(_IDPlantilla.Value);

                uow.PlantillaDetalleBusinessLogic.Insert(obj);     //Se guarda el nuevo objeto creado

                break;

            case "A":
                //Agregar campos de bitacora

                uow.PlantillaDetalleBusinessLogic.Update(obj);     //Se actualiza el objeto


                break;
            }

            uow.SaveChanges();

            if (uow.Errors.Count > 0)
            {
                msg = string.Empty;
                foreach (string cad in uow.Errors)
                {
                    msg += cad;
                }

                lblMensajes.Text      = msg;
                lblMensajes.ForeColor = System.Drawing.Color.Red;
                divMsg.Style.Add("display", "block");
                return;
            }

            lblMensajes.Text      = msg;
            lblMensajes.ForeColor = System.Drawing.Color.Black;

            BindGrid();  //Se bindean los datos
            divCaptura.Style.Add("display", "none");
            divGuardar.Style.Add("display", "none");
            divMsg.Style.Add("display", "block");
            divBtnNuevo.Style.Add("display", "block");
        }