Пример #1
0
        public static string createItemPlanilla(ItemPlanilla item)
        {
            string mensaje = string.Empty;

            try
            {
                NpgsqlConnection cnn;
                cnn = new NpgsqlConnection(connectionString);
                cnn.Open();

                NpgsqlCommand command;
                string        sql, Output = string.Empty;

                sql = $"insert into dbo.itemplanilla(idtipoitem, idsubunidad, titulo, descripcion, puntajemaximo, fechaevaluacion, idinstitucion)" +
                      $"values ({item.TipoItemID}, {item.SubUnidadID}, '{item.Titulo}', '{item.Descripcion}', {item.PuntajeMaximo}, TO_DATE('{item.FechaEvaluacionString}', 'DD/MM/YYYY'),{item.InstitucionID})";

                command = new NpgsqlCommand(sql, cnn);
                command.ExecuteNonQuery();
                mensaje = "OK";
                command.Dispose(); cnn.Close();
            }
            catch (Exception e)
            {
                mensaje = "Ha ocurrido un error al insertar el item.";
            }

            return(mensaje);
        }
Пример #2
0
        public static string updateItemPlanilla(ItemPlanilla item)
        {
            string mensaje = string.Empty;

            try
            {
                NpgsqlConnection cnn;
                cnn = new NpgsqlConnection(connectionString);
                cnn.Open();

                NpgsqlCommand command;
                string        sql, Output = string.Empty;

                sql = $"update dbo.itemplanilla set idtipoitem = {item.TipoItemID}, idsubunidad = {item.SubUnidadID}, " +
                      $"titulo = '{item.Titulo}', descripcion = '{item.Descripcion}', puntajemaximo = {item.PuntajeMaximo}, " +
                      $"fechaevaluacion = TO_DATE('{item.FechaEvaluacionString}', 'DD/MM/YYYY'), idinstitucion = {item.InstitucionID}" +
                      $"where id = {item.ID}";

                command = new NpgsqlCommand(sql, cnn);
                command.ExecuteNonQuery();
                mensaje = "OK";
                command.Dispose(); cnn.Close();
            }

            catch (Exception e)
            {
                mensaje = "Ha ocurrido un error al editar la item.";
            }

            return(mensaje);
        }
Пример #3
0
        public ActionResult Eliminar(string id)
        {
            var longid = Convert.ToInt64(id);
            List <ItemPlanilla> items = (List <ItemPlanilla>)Session["items"];
            ItemPlanilla        item  = items.Where(x => x.ID == longid).SingleOrDefault();

            return(View(item));
        }
Пример #4
0
        public ActionResult Editar(string id)
        {
            var longid = Convert.ToInt64(id);
            List <ItemPlanilla> items = (List <ItemPlanilla>)Session["items"];
            ItemPlanilla        item  = items.Where(x => x.ID == longid).SingleOrDefault();

            ViewBag.tipositem   = ObtenerTiposItemSelect(item.TipoItemID.ToString());
            ViewBag.subunidades = ObtenerSubUnidadesSelect(item.SubUnidadID.ToString());

            return(View(item));
        }
Пример #5
0
        public ActionResult Eliminar(ItemPlanilla item)
        {
            var mensaje = ItemPlanillaRepository.deleteItemPlanilla(item.ID);

            if (mensaje == "OK")
            {
                ViewBag.mensaje = "La unidad se eliminó exitosamente.";
            }
            else
            {
                ViewBag.error = mensaje;
            }

            return(RedirectToAction("Index"));
        }
Пример #6
0
        public ActionResult Editar(ItemPlanilla unidad)
        {
            unidad.InstitucionID = Convert.ToInt64(HttpContext.Session["institucion"].ToString());
            var mensaje = ItemPlanillaRepository.updateItemPlanilla(unidad);

            if (mensaje == "OK")
            {
                ViewBag.mensaje = "La carga se editó exitosamente.";
            }
            else
            {
                ViewBag.error = mensaje;
            }

            return(RedirectToAction("Index"));
        }
Пример #7
0
        public ActionResult Crear(ItemPlanilla unidad)
        {
            unidad.InstitucionID = Convert.ToInt64(HttpContext.Session["institucion"].ToString());
            var mensaje = ItemPlanillaRepository.createItemPlanilla(unidad);

            if (mensaje == "OK")
            {
                ViewBag.mensaje = "La carga se realizó exitosamente.";
            }
            else
            {
                ViewBag.error = mensaje;
            }

            ViewBag.tipositem   = ObtenerTiposItemSelect("0");
            ViewBag.subunidades = ObtenerSubUnidadesSelect("0");

            return(View());
        }