public static int EditarNotificacionUsuario(int IdUsuario, Clases.PerfilNotificacion perfilNotificacion, int id_perfil_notificacion)

        {
            int validar = 0;

            SqlConnection conec = new SqlConnection(AlmaTest);

            try

            {
                conec.Open();



                SqlCommand comando = new SqlCommand("EXEC EditarNotificacionUsuario @IDUSUARIO, @id_perfil_notificacion, @commodity, @frecuencia, @variacion_sup_temp, @variacion_inf_temp;", conec);

                comando.Parameters.Add("@IDUSUARIO", SqlDbType.Int).Value = IdUsuario;

                comando.Parameters.Add("@id_perfil_notificacion", SqlDbType.Int).Value = id_perfil_notificacion;



                comando.Parameters.Add("@commodity", SqlDbType.VarChar, 80).Value = perfilNotificacion.commodity;

                comando.Parameters.Add("@frecuencia", SqlDbType.VarChar, 80).Value = perfilNotificacion.frecuencia;

                comando.Parameters.Add("@variacion_sup_temp", SqlDbType.Float).Value = perfilNotificacion.variacion_sup_temp;

                comando.Parameters.Add("@variacion_inf_temp", SqlDbType.Float).Value = perfilNotificacion.variacion_inf_temp;



                SqlDataReader lectura = comando.ExecuteReader();



                while (lectura.Read())

                {
                    if (lectura["VALIDAR"] != DBNull.Value)

                    {
                        validar = Convert.ToInt32(lectura["VALIDAR"].ToString());

                        //validado = Convert.ToInt32(lectura["VALIDADO"].ToString());
                    }
                }



                conec.Close();
            }

            catch (Exception ex)

            {
                throw ex;
            }

            finally

            {
                conec.Close();
            }



            return(validar);
        }
        public static Clases.PerfilNotificacion ObtenerDatosNotificacion(int IdPerfilNotificacion)

        {
            Clases.PerfilNotificacion notificacion = new Clases.PerfilNotificacion();

            SqlConnection conec = new SqlConnection(AlmaTest);

            try

            {
                conec.Open();



                SqlCommand comando = new SqlCommand("EXEC ConsultarPerfilNotificacion @IdPerfilNotificacion;", conec);

                comando.Parameters.Add("@IdPerfilNotificacion", SqlDbType.Int).Value = IdPerfilNotificacion;



                SqlDataReader lectura = comando.ExecuteReader();



                while (lectura.Read())

                {
                    if (lectura["ID_PERFIL_NOTIFICACION"] != DBNull.Value)

                    {
                        notificacion.idPerfilNotificacion = IdPerfilNotificacion;



                        notificacion.commodity = lectura["COMMODITY"].ToString();

                        notificacion.idCommodity = Convert.ToInt32(lectura["ID_COMMODITY"]);



                        notificacion.activo = lectura["ACTIVO"].ToString();

                        if (notificacion.activo == "ON")
                        {
                            notificacion.activoTrue = true;
                        }

                        else
                        {
                            notificacion.activoTrue = false;
                        }



                        notificacion.idFrecuencia = Convert.ToInt32(lectura["ID_FRECUENCIA_ENVIO"]);

                        notificacion.frecuencia = lectura["FRECUENCIA_ENVIO"].ToString();



                        notificacion.variacion_sup_temp = float.Parse(lectura["VARIACION_SUP_TEMP"].ToString());

                        notificacion.variacion_inf_temp = float.Parse(lectura["VARIACION_INF_TEMP"].ToString());
                    }
                }



                conec.Close();
            }

            catch (Exception ex)

            {
                throw ex;
            }

            finally

            {
                conec.Close();
            }



            return(notificacion);
        }
        public static int InsertarNotificacionUsuario(int IdUsuario, Clases.PerfilNotificacion perfilNotificacion)

        {
            Clases.ReturnIngreso retorno = new Clases.ReturnIngreso();

            retorno.validar = 0;

            //int validado = 0;



            int IdPerfilNotificacion = 0;

            SqlConnection conec = new SqlConnection(AlmaTest);

            try

            {
                conec.Open();



                SqlCommand comando = new SqlCommand("EXEC InsertarNotificacionUsuario @IDUSUARIO, @commodity, @frecuencia, @variacion_sup_temp, @variacion_inf_temp;", conec);

                comando.Parameters.Add("@IDUSUARIO", SqlDbType.Int).Value = IdUsuario;



                //comando.Parameters.Add("@nombrePerfil", SqlDbType.VarChar, 100).Value = perfilNotificacion.nombrePerfil;

                comando.Parameters.Add("@commodity", SqlDbType.VarChar, 80).Value = perfilNotificacion.commodity;

                //comando.Parameters.Add("@id_setpoint", SqlDbType.Int).Value = perfilNotificacion.idSetpoint;



                comando.Parameters.Add("@frecuencia", SqlDbType.VarChar, 80).Value = perfilNotificacion.frecuencia;

                comando.Parameters.Add("@variacion_sup_temp", SqlDbType.Float).Value = perfilNotificacion.variacion_sup_temp;

                comando.Parameters.Add("@variacion_inf_temp", SqlDbType.Float).Value = perfilNotificacion.variacion_inf_temp;



                /*comando.Parameters.Add("@limite_inf_co2", SqlDbType.Int).Value = perfilNotificacion.limite_inf_co2;
                 *
                 * comando.Parameters.Add("@limite_sup_co2", SqlDbType.Int).Value = perfilNotificacion.limite_sup_co2;
                 *
                 * comando.Parameters.Add("@limite_inf_temp", SqlDbType.Int).Value = perfilNotificacion.limite_inf_temp;
                 *
                 * comando.Parameters.Add("@limite_sup_temp", SqlDbType.Int).Value = perfilNotificacion.limite_sup_temp;
                 *
                 */

                SqlDataReader lectura = comando.ExecuteReader();



                while (lectura.Read())

                {
                    if (lectura["ID_PERFIL_NOTIFICACION"] != DBNull.Value)

                    {
                        IdPerfilNotificacion = Convert.ToInt32(lectura["ID_PERFIL_NOTIFICACION"].ToString());

                        //validado = Convert.ToInt32(lectura["VALIDADO"].ToString());
                    }
                }



                conec.Close();
            }

            catch (Exception ex)

            {
                throw ex;
            }

            finally

            {
                conec.Close();
            }



            //retorno.idPerfilNotificacion = IdPerfilNotificacion;

            //retorno.validar = validado;



            return(IdPerfilNotificacion);
        }