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); }
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); }
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)); }
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)); }
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")); }
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")); }
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()); }