public ActionResult Motivacion(Motivacion modelo, string strMensaje = "") { if (string.IsNullOrEmpty(modelo.StrObservacion)) { ViewBag.Error = "Debe ingresar una observacion"; return(View(modelo)); } else { var usuario = Session["Usuario"].ToString(); modelo.StrEmail = usuario; var vc = new Clases.VisitasDao(); var res = vc.AddMotivacion(modelo, out _strMensaje); if (res) { ViewBag.mensaje = _strMensaje; return(View(modelo)); } else { ViewBag.Error = _strMensaje; return(View(modelo)); } } }
public bool AddMotivacion(Motivacion modelo, out string strMensaje) { try { var parametros = new List <SqlParameter>() { new SqlParameter("@strEmail", modelo.StrEmail), new SqlParameter("@idTipoVisita", TpVisitas.Motivacion), new SqlParameter("@strDocumento", modelo.StrDocumento), new SqlParameter("@strNombre", modelo.StrNombre), new SqlParameter("@strObservacion", modelo.StrObservacion) }; var mensaje = new SqlParameter("@strMensaje", SqlDbType.VarChar, 100) { Direction = ParameterDirection.Output }; var respuesta = new SqlParameter("@logRespuesta", SqlDbType.Bit) { Direction = ParameterDirection.Output }; var id = new SqlParameter("@numCodigo", SqlDbType.BigInt) { Direction = ParameterDirection.Output }; parametros.Add(mensaje); parametros.Add(respuesta); parametros.Add(id); var res = _datahelper.EjecutarSp <bool>("sp_vtAddVisitasMobil", parametros); if (res) { strMensaje = mensaje.Value.ToString(); return(Convert.ToBoolean(respuesta.Value)); } else { strMensaje = "No hay conexion con el servidor"; return(false); } } catch (Exception ex) { strMensaje = ex.Message; return(false); } }
public Motivacion ConsultaMotivacion(string strUsuario, string strDocumento, out string strMensaje) { try { var parametros = new List <SqlParameter>() { new SqlParameter("@strEmail", strUsuario), new SqlParameter("@strDocumento", strDocumento) }; var dt = _datahelper.EjecutarSp <DataTable>("sp_vtConsultaAsesoraMotivacion", parametros); if (dt != null) { if (dt.Rows.Count > 0) { var xdatos = new Motivacion(); xdatos.StrZona = dt.Rows[0]["strZona"].ToString(); xdatos.StrDocumento = dt.Rows[0]["strIdentificacion"].ToString(); xdatos.StrNombre = dt.Rows[0]["Nombre"].ToString(); xdatos.NumPuntos = Convert.ToInt32(dt.Rows[0]["Puntos"]); xdatos.StrUltimaCampaña = dt.Rows[0]["UltimaCampaña"].ToString(); strMensaje = ""; return(xdatos); } else { strMensaje = "La Asesora no existe o no pertenece a la zona"; return(null); } } else { strMensaje = "No hay conexion con el servidor"; return(null); } } catch (Exception ex) { strMensaje = ex.Message; return(null); } }
//MOTIVOS DE LOS EVENTOS public List <Motivacion> MotivoEventos() { List <Motivacion> motivacion = null; string listita = "USP_LISTAR_MOTIVO_EVENTO"; SqlCommand comando = new SqlCommand(listita, conexion); comando.CommandType = System.Data.CommandType.StoredProcedure; conexion.Open(); SqlDataReader reader = comando.ExecuteReader(); if (reader.HasRows) { motivacion = new List <Motivacion>(); while (reader.Read()) { Motivacion motivaciones = new Motivacion(); motivaciones.COD_MOT = int.Parse(reader["COD_MOT"].ToString()); motivaciones.DES_MOT = reader["DES_MOT"].ToString(); motivacion.Add(motivaciones); } } conexion.Close(); return(motivacion); }