public virtual ActionResult Crear() { try { var entidad = new Ensayo { ENS_Nombre = string.Empty }; PrepararDatos(ref entidad, "Crear"); return PartialView("Edit", entidad); } catch (Exception ex) { logger.Error(string.Format("Mensaje: {0} Trace: {1}", ex.Message, ex.StackTrace)); return new HttpNotFoundWithViewResult("Error"); } }
public virtual JsonResult Crear(Ensayo entidad) { var jsonResponse = new JsonResponse { Success = false }; if (ModelState.IsValid) { try { entidad.UsuarioCreacion = UsuarioActual.IdUsuario.ToString(); entidad.UsuarioModificacion = UsuarioActual.IdUsuario.ToString(); // carga de data temporal 24/01/2013 if (entidad.ENS_NombreIngles == null) entidad.ENS_NombreIngles = ""; if (entidad.ENS_Descripcion == null) entidad.ENS_Descripcion = ""; if (entidad.IDLaboratorio == null || entidad.IDLaboratorio == 0) entidad.IDLaboratorio = 2; // fin carga EnsayoBL.Instancia.Add(entidad); jsonResponse.Success = true; jsonResponse.Message = "Se Proceso con éxito"; } catch (Exception ex) { logger.Error(string.Format("Mensaje: {0} Trace: {1}", ex.Message, ex.StackTrace)); jsonResponse.Message = "Ocurrio un error, por favor intente de nuevo o más tarde."; } } else { jsonResponse.Message = "Por favor ingrese todos los campos requeridos"; } return Json(jsonResponse, JsonRequestBehavior.AllowGet); }
public static Ensayo Load(SqlDataReader reader) { Ensayo item = new Ensayo { Id = Convert.ToInt32(reader["Id"]), CampanaId = Convert.ToInt32(reader["CampanaId"]), Campana = reader["Campana"].ToString(), ProductoId = Convert.ToInt32(reader["ProductoId"]), Producto = reader["Producto"].ToString(), Rinde = Convert.ToDecimal(reader["Rinde"]), Ranking = Convert.ToInt32(reader["Ranking"]), Total = Convert.ToInt32(reader["Total"]) }; if (reader["LugarId"] != DBNull.Value) { item.LugarId = Convert.ToInt32(reader["LugarId"]); } if (reader["CategoriaId"] != DBNull.Value) { item.CategoriaId = Convert.ToInt32(reader["CategoriaId"]); } if (reader["Categoria"] != DBNull.Value) { item.Categoria = reader["Categoria"].ToString(); } if (reader["Provincia"] != DBNull.Value) { item.Provincia = reader["Provincia"].ToString(); } if (reader["Departamento"] != DBNull.Value) { item.Departamento = reader["Departamento"].ToString(); } if (reader["Localidad"] != DBNull.Value) { item.Localidad = reader["Localidad"].ToString(); } if (reader["Fuente"] != DBNull.Value) { item.Fuente = reader["Fuente"].ToString(); } if (reader["Establecimiento"] != DBNull.Value) { item.Establecimiento = reader["Establecimiento"].ToString(); } if (reader["Archivo"] != DBNull.Value) { item.Archivo = reader["Archivo"].ToString(); } if (reader["Observaciones"] != DBNull.Value) { item.Observaciones = reader["Observaciones"].ToString(); } if (reader["FechaSiembra"] != DBNull.Value) { item.FechaSiembra = Convert.ToDateTime(reader["FechaSiembra"]); } if (reader["FechaCosecha"] != DBNull.Value) { item.FechaCosecha = Convert.ToDateTime(reader["FechaCosecha"]); } if (reader["Indice"] != DBNull.Value) { item.Indice = Convert.ToInt32(reader["Indice"]); } return(item); }
private void PrepararDatos(ref Ensayo entidad, string accion) { entidad.Accion = accion; ViewData["idMenu"] = this.IdMenu; entidad.IdMenu = this.IdMenu; entidad.IdModulo = this.IdModulo; entidad.Estados = Utils.EnumToList<TipoEstado>(); }