コード例 #1
0
        public List <UserOperative_Entity> returnCredentials()
        {
            List <UserOperative_Entity> list = new List <UserOperative_Entity>();

            try
            {
                sqlConnection.Open();
                sqlCommand             = new SqlCommand("return_credentials_operative", sqlConnection);
                sqlCommand.CommandType = CommandType.StoredProcedure;

                SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();

                while (sqlDataReader.Read())
                {
                    UserOperative_Entity userOperative = new UserOperative_Entity();
                    userOperative.id_user_operative = Convert.ToInt32(sqlDataReader["Identificador"]);
                    userOperative.name_operative    = sqlDataReader["Nombre"].ToString();
                    userOperative.job      = sqlDataReader["Puesto"].ToString();
                    userOperative.email    = sqlDataReader["Email"].ToString();
                    userOperative.celphone = sqlDataReader["Celular"].ToString();
                    userOperative.password = sqlDataReader["Password"].ToString();

                    list.Add(userOperative);
                }

                sqlConnection.Close();
            }
            catch (Exception e)
            {
                throw;
            }

            return(list);
        }
コード例 #2
0
        public ActionResult UpdatePassword(String password, String password2)
        {
            UserOperative_Entity userOperativeEntity = new UserOperative_Entity();

            userOperativeEntity.id_user_operative = Convert.ToInt32(Session["operative"]);

            string script = "";

            if (password.Equals(password2))
            {
                userOperativeEntity.password = password;

                if (userOperative.updatePassword(userOperativeEntity))
                {
                    script = "<script>" +
                             "alert('Las contraseña se actualizo. Debes iniciar Sesión');" +
                             "window.location.href = '/Auth/Login'; " +
                             "</script>";
                }
            }
            else
            {
                script = "<script>" +
                         "alert('Las contraseñas no coinciden');" +
                         "window.location.href = '/Index/HomeOperative'; " +
                         "</script>";
            }

            return(Content(script));
        }
コード例 #3
0
        public UserOperative_Entity searchOperativeById(int id)
        {
            UserOperative_Entity userOperative = new UserOperative_Entity();

            try
            {
                sqlConnection.Open();
                sqlCommand             = new SqlCommand("returnOperativeById", sqlConnection);
                sqlCommand.CommandType = CommandType.StoredProcedure;

                SqlParameter id_parameter = new SqlParameter();
                id_parameter.ParameterName = "@idOperative";
                id_parameter.SqlDbType     = SqlDbType.Int;
                id_parameter.Value         = id;

                sqlCommand.Parameters.Add(id_parameter);

                SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
                sqlDataReader.Read();

                if (sqlDataReader.HasRows)
                {
                    userOperative.id_user_operative = Convert.ToInt32(sqlDataReader["Identificador"]);
                    userOperative.name_operative    = sqlDataReader["Nombre"].ToString();
                    userOperative.job      = sqlDataReader["Puesto"].ToString();
                    userOperative.email    = sqlDataReader["Email"].ToString();
                    userOperative.celphone = sqlDataReader["Celular"].ToString();
                    userOperative.password = sqlDataReader["Password"].ToString();
                }

                sqlConnection.Close();
            }
            catch (Exception)
            {
                throw;
            }

            return(userOperative);
        }
コード例 #4
0
        public List <UserOperative_Entity> searchOperators(int id)
        {
            List <UserOperative_Entity> list = new List <UserOperative_Entity>();

            try
            {
                sqlConnection.Open();
                sqlCommand             = new SqlCommand("search_user_operative", sqlConnection);
                sqlCommand.CommandType = CommandType.StoredProcedure;

                SqlParameter id_parameter = new SqlParameter();
                id_parameter.ParameterName = "@idAdminServices";
                id_parameter.SqlDbType     = SqlDbType.Int;
                id_parameter.Value         = id;

                sqlCommand.Parameters.Add(id_parameter);
                SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();

                while (sqlDataReader.Read())
                {
                    UserOperative_Entity operative = new UserOperative_Entity();
                    operative.id_user_operative = Convert.ToInt32(sqlDataReader["Identificador"]);
                    operative.name_operative    = sqlDataReader["Nombre"].ToString();
                    operative.job      = sqlDataReader["Puesto"].ToString();
                    operative.celphone = sqlDataReader["Celular"].ToString();
                    operative.email    = sqlDataReader["Email"].ToString();

                    list.Add(operative);
                }

                sqlConnection.Close();
            }
            catch (Exception e)
            {
                throw;
            }

            return(list);
        }
コード例 #5
0
        public bool updatePassword(UserOperative_Entity userOperative)
        {
            bool response = false;

            try
            {
                sqlConnection.Open();
                sqlCommand             = new SqlCommand("update_pass_operative", sqlConnection);
                sqlCommand.CommandType = CommandType.StoredProcedure;

                SqlParameter id_parameter = new SqlParameter();
                id_parameter.ParameterName = "@idOperative";
                id_parameter.SqlDbType     = SqlDbType.Int;
                id_parameter.Value         = userOperative.id_user_operative;

                SqlParameter p_password = new SqlParameter();
                p_password.ParameterName = "@Password";
                p_password.SqlDbType     = SqlDbType.VarChar;
                p_password.Size          = 20;
                p_password.Value         = userOperative.password;

                sqlCommand.Parameters.Add(id_parameter);
                sqlCommand.Parameters.Add(p_password);

                sqlCommand.ExecuteNonQuery();

                response = true;

                sqlConnection.Close();
            }
            catch (Exception e)
            {
                throw;
            }

            return(response);
        }
コード例 #6
0
 public bool updatePassword(UserOperative_Entity userOperative)
 {
     return(operative_Data.updatePassword(userOperative));
 }